Skip to content
Open
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
16 changes: 15 additions & 1 deletion src/chart/line/LineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,14 @@ function getVisualGradient(
const stopLen = colorStops.length;
const outerColors = visualMeta.outerColors.slice();

if (stopLen && colorStops[0].coord > colorStops[stopLen - 1].coord) {
if (stopLen && (
colorStops[0].coord > colorStops[stopLen - 1].coord
// When stops collapse to the same coord (e.g. a piecewise visualMap with
// a single half-infinite piece produces two boundary stops at the same
// value), the coord comparison gives no signal — fall back to the axis
// direction so we still flip on an inverted axis. See #18066.
|| (colorStops[0].coord === colorStops[stopLen - 1].coord && axis.inverse)
)) {
colorStops.reverse();
outerColors.reverse();
}
Expand All @@ -337,6 +344,13 @@ function getVisualGradient(
? (outerColors[1] ? outerColors[1] : colorStops[stopLen - 1].color)
: (outerColors[0] ? outerColors[0] : colorStops[0].color);
}
if (!inRangeStopLen) {
// No color stops at all (e.g. a visualMap piecewise piece producing
// a fully [-Infinity, Infinity] interval, like `pieces: [{ lte: null }]`).
// Fall back to a single outer color or transparent so we don't crash
// on `colorStopsInRange[0].coord` below. See #18066.
return outerColors[0] || outerColors[1] || 'transparent';
}

const tinyExtent = 10; // Arbitrary value: 10px
const minCoord = colorStopsInRange[0].coord - tinyExtent;
Expand Down
20 changes: 18 additions & 2 deletions src/component/visualMap/PiecewiseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,28 @@ class PiecewiseModel extends VisualMapModel<PiecewiseVisualMapOption> {
valueState = visualMapModel.getValueState(representValue);
}
const color = getColorVisual(representValue, valueState);
if (interval[0] === -Infinity) {
const lowInf = interval[0] === -Infinity;
const highInf = interval[1] === Infinity;
if (lowInf) {
outerColors[0] = color;
}
else if (interval[1] === Infinity) {
if (highInf) {
outerColors[1] = color;
}
// Emit the finite edge(s) as stops as well, so consumers know where
// a half-infinite interval ends (e.g. `pieces: [{lte: 10}]` should
// still report a boundary at 10). When the interval is fully infinite
// there is no finite edge to record, so only `outerColors` is set.
// See #18066.
if (lowInf && highInf) {
return;
}
if (lowInf) {
stops.push({value: interval[1], color: color});
}
else if (highInf) {
stops.push({value: interval[0], color: color});
}
else {
stops.push(
{value: interval[0], color: color},
Expand Down
89 changes: 89 additions & 0 deletions test/ut/spec/component/visualMap/setOption.test.ts

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