CJstate opened a new pull request, #21806:
URL: https://github.com/apache/echarts/pull/21806
## Why is this change needed?
A `markPoint` data item positioned by a plain `coord` array (no statistic
`type`, no explicit `value` field) reaches the label formatter with
`params.value === undefined`, so `{c}` renders as `undefined`. This is most
visible with a **time base axis**, where users naturally write `coord:
['2024-01-02', 200]` and expect the marker label to show the value at that
point. close #20410
## Root cause
`dataTransform` only assigns `item.value` for statistic types
(`max`/`min`/`average`/`median`). For a plain coord item, the marker's
`SeriesData` stores the raw option object `{coord: [...]}`, and
`MarkerModel.getDataParams` builds `params.value` via `retrieveRawValue(mpData,
idx)` without a dimension — which returns the raw option object's `value`
field, i.e. `undefined`. The `type: 'max'` path works because line 143 forces
`item.value = coordInfo[1]`.
## What does this PR do?
In `dataTransform` (`src/component/marker/markerHelper.ts`), when the coord
branch finishes and `item.value == null`:
1. Resolve base/value axes via the existing `getAxisInfo`.
2. Parse the base-dimension coord through
`axisInfo.baseAxis.scale.parse(...)` — this is what makes a time axis work,
where `coord[0]` is a date string that must become a timestamp before lookup.
3. Find the nearest host-series datum with
`seriesModel.indicesOfNearest(...)` and copy its value-dimension value into
`item.value`.
The marker label and tooltip then carry the actual data value at that coord,
consistent with what `type: 'max'` already produces. `markLine` and `markArea`
share `dataTransform`, so coord-only items there get the same benefit.
## How is it tested?
New unit test `test/ut/spec/component/marker/markPointCoord.test.ts`:
- `formatter_params_carry_the_value_for_a_coord_markPoint_on_a_time_axis` —
captures the formatter params for the exact issue repro (time axis, coord-only
item) and asserts `params.value` is defined. **Fails on master, passes with
this fix.**
- `defaultedLabel_dims_carry_the_value_for_coord_markPoint` — guards the
default-label dim path.
Full local suite: `npx jest --config test/ut/jest.config.cjs` → **27 suites
/ 196 tests passed**, no regressions. `npm run checktype` reports no errors in
the touched files.
## What cannot be tested locally?
The sandbox cannot run the full browser rendering pipeline (`npm run dev`
visual cases), but the change only touches data-transform logic that the Jest
suite covers.
close #20410
--
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]