You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to get properties from my data before the plot is created, so I can use them during plot creation.
For simplicity, let's say I want to increase my Y domain so it has 10 extra units on each side. I'm thinking it would look something like the following:
constlineMark=Plot.line(values)const[yDomMin,yDomMax]=lineMark.scale('y').domainconstchart=Plot.plot({y: {domain: [yDomMin-10,yDomMax+10]// for example},marks: [lineMark]})
Right now I'd have to do some math, that I imagine will be redone during plot creation.
Why
I'll describe the use case in particular that has triggered this request, since I might be missing something that could allow me to do it with the current state of the library.
I want to be able to find the distance between my domain in y, and add an extra 10% of domain on each side. Sort of like padding the domain.
The reason is that I feel the line is the beginning of the data when the line starts exactly on the bottom-left corner. Adding the padding makes me feel I can scroll sideways to see previous data. Not sure if it makes sense, but that's the way I see it ¯\_(ツ)_/¯
Current Workaround
The current solution I've found is to use d3.extent, but that's about extra 12.6 kb (gzipped) that I imagine is already bundled with plot.
Additional workarounds that I've tried:
Create another plot as "draft" and get the data I need from there. I went a different way because I feel it's too much to create a brand new plot just for this. The code looked more or less like the following:
constdraftChart=Plot.marks(Plot.line(values)).plot()constyExtent=draftChart.scale('y').domain// the rest of the code would look just as the code using d3.extent
Try to mutate chart.scale('y').domain after plot creation. This didn't change anything. The object property was updated, but I imagine the plot itself was created before the mutation, so it didn't have any effect. Maybe a plot.update() method would be handy here, which could be related to updating in place? #1022.
The text was updated successfully, but these errors were encountered:
Feature Request
I'd like to be able to get properties from my data before the plot is created, so I can use them during plot creation.
For simplicity, let's say I want to increase my Y domain so it has 10 extra units on each side. I'm thinking it would look something like the following:
Right now I'd have to do some math, that I imagine will be redone during plot creation.
Why
I'll describe the use case in particular that has triggered this request, since I might be missing something that could allow me to do it with the current state of the library.
I want to be able to find the distance between my domain in y, and add an extra 10% of domain on each side. Sort of like padding the domain.
The reason is that I feel the line is the beginning of the data when the line starts exactly on the bottom-left corner. Adding the padding makes me feel I can scroll sideways to see previous data. Not sure if it makes sense, but that's the way I see it ¯\_(ツ)_/¯
Current Workaround
The current solution I've found is to use
d3.extent
, but that's about extra 12.6 kb (gzipped) that I imagine is already bundled with plot.Additional workarounds that I've tried:
chart.scale('y').domain
after plot creation. This didn't change anything. The object property was updated, but I imagine the plot itself was created before the mutation, so it didn't have any effect. Maybe aplot.update()
method would be handy here, which could be related to updating in place? #1022.The text was updated successfully, but these errors were encountered: