Custom marks that return Plot objects instead of SVG #1976
-
I sometimes like to use a dashed line to designate y=0, but I only want to add it when the plot contains both pos and neg data on the y-axis, and I cannot hard-code this because the data comes from a database. It is a bit of a hassle to manually extract the y-axis range from the data itself, especially for plots that have multiple marks, or that transform the data such as a stacked I learned from another answer you gave me, that I can make a custom mark, which is really a function that gets various data from the plotting system, including the y-axis range (aka. domain), so I don't have to manually process the data to infer its range. So I essentially have the following:
This gives the following error in the
I tried debugging but the source-file is minified so it is quite hard to read. My guess is that when the plotting-algorithm sees the mark is a function, it assumes it returns an SVG string, but instead it returns a I looked in the source-code and I can see that mark classes have a How can I make this work? Please provide the actual code I would need, as I'm not really a Java-script programmer so it is hard for me to make a solution from just an abstract description. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Again it would be much easier to help if there was a complete example with some (possibly fake) data. Otherwise, I have to make one up, which will or will not match this use case, then create a fix that will or will not work in your situation. It is not a great way of providing support. |
Beta Was this translation helpful? Give feedback.
In this case I would create the svg element directly:
However I reckon that this doesn't give you all the goodies of using a mark. You could also write this: