JamesGoslings commented on PR #21613:
URL: https://github.com/apache/echarts/pull/21613#issuecomment-4600830430
Thanks for the careful review @Justin-ZS — agreed, fixing it in `LineView`
was treating the symptom. I've pushed a follow-up that addresses all three
points:
**1. Root cause in `PiecewiseModel.getVisualMeta`.** `setStop` now emits the
finite edge of half-infinite intervals into `stops`, in addition to
`outerColors`:
- `[-Infinity, x]` color C → `outerColors[0] = C` and `stops.push({value: x,
color: C})`
- `[x, Infinity]` color C → `outerColors[1] = C` and `stops.push({value: x,
color: C})`
- `[-Infinity, Infinity]` color C → only `outerColors` (no finite edge to
record)
For your example `pieces: [{ lte: 10, color: 'red' }], outOfRange: { color:
'blue' }`, after `Suplement` the iteration walks `[-Infinity, 10]` (red) →
`[10, Infinity]` (blue), so `stops` now ends up as `[{10, red}, {10, blue}]`.
The line correctly renders red ≤ 10 and blue after.
**2. Defensive empty-stop fallback in `LineView` for the truly
fully-infinite case.** Kept it. Updated the comment to say it's specifically
for `[-Infinity, Infinity]` intervals like `pieces: [{ lte: null }]`, since the
half-infinite case is now handled at the source.
**3. Reversal heuristic in `LineView`.** When all stops collapse to one
coord (which is exactly what a single half-infinite piece produces — both stops
are at the same value), `colorStops[0].coord > colorStops[stopLen - 1].coord`
gives no signal. Fall back to `axis.inverse` as the tiebreaker:
```ts
if (stopLen && (
colorStops[0].coord > colorStops[stopLen - 1].coord
|| (colorStops[0].coord === colorStops[stopLen - 1].coord &&
axis.inverse)
)) {
colorStops.reverse();
outerColors.reverse();
}
```
Stops are emitted in value-ascending order by both `PiecewiseModel` and
`ContinuousModel`, so on a non-inverted axis no reversal is correct in the
tied-coord case. On an inverted axis the gradient direction needs to flip,
which `axis.inverse` now picks up.
**Tests.** Three cases now:
- `piecewiseWithNullBoundOnLineSeries`: original crash repro (defensive
path).
- `piecewiseHalfInfiniteEmitsBoundaryStop`: asserts the finite edge of
`{lte: 10}` plus its implicit `(10, Infinity)` outOfRange piece both end up as
stops at value `10`.
- `piecewiseFullInfiniteStillEmitsNoStops`: asserts the fully-infinite case
still produces an empty `stops` array, exercising the defensive fallback.
Full unit suite still green (25 suites, 195 tests). Force-pushed the branch
as a single squashable commit. PTAL when you have a moment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]