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
Empty line segments not displayed in d3.svg.line. #2061
Comments
This is probably a bug (and I don’t think we’d need a new API to fix it). One simple fix is to patch this code in svg/line.js: function segment() {
segments.push("M", interpolate(projection(points), tension) || "z");
} This causes d3.svg.line to use "z" for empty segments, producing a zero-length line, rather than a bare "M" command which draws nothing. This is probably the right fix, although perhaps not the optimal one. But this fix would still require you to use stroke-linecap: round or stroke-linecap: square, and the dots would still be pretty small (dependent on the stroke-width). You might consider rendering each data point explicitly, say as circles on top of the line, so that you have more control over how they are displayed. |
Sounds reasonable. |
A workaround for the time-being: line.interpolate(function(points) { return points.length > 1 ? points.join("L") : points + "z"; }); |
Fixes #2061. A line segment with a single point is now rendered as "M2,3Z" rather than "M2,3", such that if there is an associated stroke-linecap, it is displayed correctly.
Fix staged in #2591 for 3.5.7. |
I can't get a line chart to display single points. In SVG it get's rendered as a dot when I move the pen to a point and then do a line to with the same coordinates (at least with a linecap different than "butt"). I noticed that d3.svg.line just creates the moves of the pen. Is this intentional?
I provided an example: http://jsfiddle.net/ntdwa4dv/1/
The text was updated successfully, but these errors were encountered: