-
Notifications
You must be signed in to change notification settings - Fork 184
Add a "line" marker option #1868
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
Conversation
src/marker.js
Outdated
.attr("stroke-width", 1.5) | ||
.attr("stroke-linecap", "square") | ||
.attr("stroke-linejoin", "square") | ||
.call((marker) => marker.append("line").attr("x1", "0").attr("x2", "0").attr("y1", "-2").attr("y2", "2")) |
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.
y1
& y2
values at -2
and 2
are arbitrary. That was rendering well in my charts.
Let me know if you want to change them 🙂
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.
Made some change to make it configurable
Thanks for sharing! Instead of changing Plot's source code, you can pass a function as a marker. That function can be configurable, to indicate the length of the tick. You might also want to use orient=auto so that it rotates with the curve; see for example: |
Hi @Fil Thanks for the feedback and the link 🙂
My issue was that I didn't know how to make a marker so I had to copy/paste some code from Plot internals (the Finally, I still think it could be a good thing for Plot to have this additional default marker. That's why I submitted this PR. |
It's still not configurable, though I don't know exactly how we'd make it simple to configure. One thing that I would like to change also is the name, because marker "line" does not really evoke this marker that is a small tick across the line (in other words perpendicular to the curve). |
I think the easiest way would be to markerStart: (color, context) => markerLine(4)(color, context)
Agreed. The current name is not ideal. Open to suggestions 🙂 |
Useful to render "error" in bars
Here is a (zoomed) example:

It's my first PR here and I'm, in general, not used to making PRs on JS/TS projects, so please let me know if anything is missing (tests, etc.), I'll add anything missing 🙂
Also, I'm a super newbie with SVG. To make this work, I just copy/pasted the arrow marker and changed it until it was rendering what I wanted. I'm absolutely not sure of what I'm doing here 😅