-
Notifications
You must be signed in to change notification settings - Fork 15
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
Dash mode #13
Comments
Turns out that is an issue of plotly/plotly.js#2946. |
When we have dash length more than a segment length, dash pattern draws inconsistently on segments join. There are two basic approaches to the problem: length-based and global position-based with linked segment offsets. Both of them require re-calculating every segment's length or pattern offset, which is O(n) for dataRange change. Possible approaches to reduce O(n) → O(c):
|
Thanks for taking a close look at this @dy !
Can you try benchmarking this for 1e5 and 1e6 pts? If we only have to compute this on x/y data updates, I'd be ok adding 10-100ms to our |
Wow, that's a really annoying problem! @etpinard @dy I wonder if there's an approximate solution that would work reasonably well for common situations at least - I'm thinking during initial setup (ie In principle "straight-ish" and how long a section needs to be in order to fit many dash patterns depends on the scales, so even that would need to be recalculated as the ranges change... but perhaps we can come up with a heuristic that does a reasonable job. Dash patterns don't make much sense when the curve is very small or jagged anyway, so I'm not too concerned if we start to fail in those cases, as long as the smoother and larger cases work OK. |
Yes, that strategy is somewhat similar to dashadjust property in SVG https://www.w3.org/TR/svg-strokes/#StrokeDashadjustProperty. |
Ah nice find - yes, kind of a hybrid of Not-so-ideal is fine. I think we can accept any solution that gets the general flavor of the dashes correct - ie people will be happy with the outcome as long as the dash ends are perpendicular to the path segment, the pattern doesn't abruptly shift from one segment to the next, and the dash & gap lengths are correct most of the time to within something like 20%. Seems to me the goal of dashes is either to distinguish multiple traces (and match them up with the legend) or to mark a curve or portion of a curve as somehow fuzzier (like an interpolation/extrapolation, confidence bands, that sort of thing), and neither of those cases cares about the precise dash lengths. |
Distance-based dash is more svg-ish but prone to errors on big data, position-based dash is round error proof, but bad on scale.
We can switch that mode by the calculated distance.
Although it seems that we cannot track scale-independent distance.
The text was updated successfully, but these errors were encountered: