-
Notifications
You must be signed in to change notification settings - Fork 310
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
Step curve could allow NaN x or y for discontinuities. #65
Comments
This might require using a different trick to make the step curve symmetric: var t = x > this._x ? this._t : 1 - this._t; Perhaps something like curve.reverse() which returns a reverse curve to be used as the area’s baseline. If undefined, the curve is used. |
I’ve simplified the step curve in e3b1b0a, but there’s another issue that makes this difficult to implement: if the curve processes partially-defined points, it must use context.moveTo to render a discontinuity for a line, and likewise it must generate discontiguous area segments for an area. It’s probably not possible for the step curve to produce discontiguous area segments internally; that’s primarily the responsibility of the area shape, which buffers the input coordinates so that it can pass the reversed xy coordinates of the baseline to the curve. |
I think you could maybe implement this by first detecting whether x or y was NaN inside the area and line shapes, and treating that as similar to the defined accessor returning falsey. Then, the shape would call curve.lineEnd (or maybe curve.point again?), passing in the partially-defined x and y, before terminating the line segment. That would give the curve the opportunity to draw the terminating tail to a partially-defined value, while keeping the responsibility to generate discontiguous line and area segments with the shape. You’d need to do something similar on curve.lineStart, passing in the last (possibly) partially-defined x and y before the first point in the new segment; this way the stepBefore curve could render a preceding horizontal line before the first defined value. |
From d3/d3#2832: if the y-value is NaN, we can still extend the line using the previous x-value. But we’d have to make sure that it’s symmetric for x and y rather than only supporting undefined y. This would be an alternative to using line.defined and area.defined for missing data.
Presumably we’d only want to extend the previous value for a single data point, however? Like if you get two points in a row with NaN y, you’d want to extend a horizontal line from the previous x to the first x with undefined y, but not the second x.
The text was updated successfully, but these errors were encountered: