Skip to content
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

fix(line): fix visual gradient when coords are between two stops. #15938

Merged
merged 2 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/chart/line/LineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ function clipColorStops(colorStops: ColorStop[], maxSize: number): ColorStop[] {
if (prevInRangeColorStop) {
newColorStops.push(lerpStop(prevInRangeColorStop, stop, maxSize));
}
else if (prevOutOfRangeColorStop) { // If there are two stops and coord range is between these two stops
newColorStops.push(
lerpStop(prevOutOfRangeColorStop, stop, 0),
lerpStop(prevOutOfRangeColorStop, stop, maxSize)
);
}
// All following stop will be out of range. So just ignore them.
break;
}
Expand Down Expand Up @@ -313,7 +319,7 @@ function getVisualGradient(
: (outerColors[0] ? outerColors[0] : colorStops[0].color);
}

const tinyExtent = 0; // Arbitrary value: 10px
const tinyExtent = 10; // Arbitrary value: 10px
const minCoord = colorStopsInRange[0].coord - tinyExtent;
const maxCoord = colorStopsInRange[inRangeStopLen - 1].coord + tinyExtent;
const coordSpan = maxCoord - minCoord;
Expand Down
41 changes: 41 additions & 0 deletions test/line-visual2.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.