Repository navigation
Conversation
A boundary line kept two points for every segment of the filled line, and every fill segment searched all of them three times per draw. With the `segment` option or null gaps that makes each draw quadratic in the number of segments. The boundary is straight, so a line that only moves forward along it needs just the two ends. Lines that turn back and reversed scales keep the existing points.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12380
The boundary line gets two points per line segment, and each fill segment searches all of them three times per draw (once in
_segments, twice throughinterpolate). On the issue's sample (10,430 points, 1,223 segments) that is about 9 million point visits per draw.The boundary is straight, so a line that only moves forward along it needs just the two ends. Lines that turn back and reversed scales keep their existing points and speed.
fill: '-1'andfill: 'stack'follow real lines and aren't sped up here.Using the data and options from the issue's pen:
_boundSegmentpoint visitschart.draw()JS, msMedian [min–max] of 7 alternating fresh processes, headless Chrome 157, software canvas, i7-9700, Windows 11. Not measured in Firefox, which is what the issue used.
Canvas pixels hash the same before and after for 39 chart setups at device pixel ratio 1 and 2: origin, start, end and value fills, above/below, gaps, stepped, tension, stacked,
indexAxis: 'y', reversed axes, unsorted x, decimation and radar.The new spec reads the boundary's point count through a spy on
interpolate, which is an implementation detail, so drop it if you'd rather not have that.