Slackbot
05/16/2023, 9:23 PMMihael Ankerst
05/16/2023, 9:46 PMtan tan
05/16/2023, 10:34 PMconst barPlot = Plot.plot({
x: { },
y: {
// precompute domain here, that's why I asked that original question
domain: custom_domain,
},
marks: [
Plot.barY(dataset, {}),
],
});
tan tan
05/16/2023, 10:35 PMconst barPlot = Plot.plot({}) // without setting domain here
const current_default_domain = barPlot.getDomain()
barPlot.updateDomain([ do some comparison and update according ])
//rendering the plot
tan tan
05/16/2023, 10:37 PMobservable plot
and d3
, so I just have some random idea in my mind based on the doc and typescript hint most likelyMihael Ankerst
05/16/2023, 10:45 PM// cell 1
myYDomain = Plot.plot(// your Plot).scale("y").domain
and another cell to render with the Plot with the same options but initializing the y domain with an adjusted domain based on the default domain you obtain in cell 1tan tan
05/16/2023, 10:48 PMupdate
thing is also because I was using react
, it could be handy if I precompute the plot
and then just do the partial update without rebuilding the entire graph.Mihael Ankerst
05/16/2023, 10:48 PMtan tan
05/16/2023, 10:49 PMtan tan
05/17/2023, 12:21 AMconst draftMarks = Plot.marks(
Plot.barY(dataset, {})
);
const defaultDomain = draftMarks.plot().scale("y")?.domain();
const customDomain = [] // do something based on defaultDomain;
const barPlot = Plot.plot({
x: {},
y: { domain: customDomain },
marks: [draftMarks],
});