-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
marker #731
marker #731
Conversation
A gotcha with this approach: the markers aren’t necessarily drawn at the xy location given by the data. For example, with the step curve, the markers are drawn where the curve steps between points: With the basis curve, the markers are drawn on the endpoints of the Bézier segments, rather than the on control points of the spline: On the other hand, using markers is very convenient for getting the markers to orient with the path. And you probably don’t need markers with the step curve, and you probably don’t mind that the dots don’t align with the basis curve. And you can always render dots separately if you want them to be on the data points. Anyway I think this is convenient enough that we probably want this feature, but we probably want to mention these limitations in the documentation. |
I reverted support for markers on rule. Rules lack orientation, so you can’t control which way the arrow points. We could add an additional option to control rule orientation, but I think the utility is small enough for markers on rules that we don’t need it. It was cute that you could draw a little arrow on the axis, though. |
e0a245f
to
ce10d20
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really neat!
I've added some documentation, and a suggestion.
I wonder if we must check what a custom marker returns—either verify that it is a svg:marker, or at least that it is not nullish? I've documented it as a MUST, but if we accepted nullish values it would allow to not return a marker for some colors. Currently one has to return an empty svg:marker—which is probably fine too.
}, | ||
marks: [ | ||
Plot.ruleY([0]), | ||
Plot.lineY(data, {x: "date", y: "deaths", stroke: "cause", marker: "arrow"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we must check what a custom marker returns—either verify that it is a svg:marker, or at least that it is not nullish? I've documented it as a MUST, but if we accepted nullish values it would allow to not return a marker for some colors. Currently one has to return an empty svg:marker—which is probably fine too.
We could maybe add this in the future, but I don’t think we need to do it now. I would add it if it’s frequently needed (for convenience), or is a frequent source of errors (for debugging). For now I think implementing a custom marker function is a relative “power user” feature, similar to a custom mark implementation, so it can have sharper edges than the more commonly-used APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this version feels more natural
I find the natural curve tends to be a little… loosey-goosey, like where it dips below y = 0; catmull-rom tends to do better, and monotone-x makes a hard guarantee. Think I’ll just keep it simple for now though.
Fixes #628. Allows a marker to be applied to the line and link marks. The marker can be specified as one of the built-in types, or a custom marker function that takes the line’s stroke color and returns an SVG marker element. Here are some examples of the built-in markers with line:
arrow:

circle (a.k.a. circle-fill):

circle-stroke:
