Skip to content

fix(types): add axis properties to CallbackDataParams. close #17561 - #21836

Open
Prakhar1Ojha wants to merge 2 commits into
apache:masterfrom
Prakhar1Ojha:fix-17561-callback-data-params
Open

Prakhar1Ojha wants to merge 2 commits into
apache:masterfrom
Prakhar1Ojha:fix-17561-callback-data-params

Conversation

@Prakhar1Ojha

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Add axis context properties (axisDim, axisIndex, axisType, axisId, axisValue, axisValueLabel) to the public CallbackDataParams type definition.

Fixed issues

Details

Before: What was the problem?

At runtime, whenever tooltips or formatters are invoked in an axis context (e.g., trigger: 'axis'), ECharts populates axis context properties onto callback parameters (axisDim, axisIndex, axisType, axisId, axisValue, and axisValueLabel in src/component/tooltip/TooltipView.ts:587-595).

However, the public TypeScript interface CallbackDataParams in src/util/types.ts omitted these optional properties. As a consequence, TypeScript users writing custom formatter functions (such as formatter: (params: CallbackDataParams) => ...) experienced compile-time errors: Property 'axisValueLabel' does not exist on type 'CallbackDataParams'.

After: How does it behave after the fixing?

  1. Declares optional axisDim, axisIndex, axisType, axisId, axisValue, and axisValueLabel properties on CallbackDataParams in src/util/types.ts.
  2. Simplifies TooltipCallbackDataParams in src/component/tooltip/TooltipView.ts to directly alias CallbackDataParams.
  3. Adds unit tests in test/ut/spec/util/types.test.ts verifying that axisValue and axisValueLabel can be accessed on CallbackDataParams without compiler or runtime diagnostics.

Document Info

  • This PR doesn't relate to document changes

Misc

Security Checking

  • This PR uses security-sensitive Web APIs.

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

  • test/ut/spec/util/types.test.ts

Merging options

  • Please squash the commits into a single one when merging.

Other information

  • npm run checktype: passed (0 errors)
  • npm run checkheader: passed (0 errors)
  • npm run lint: passed (0 errors, 0 warnings)

@echarts-bot

echarts-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

@TARUNTEjjjj TARUNTEjjjj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted review with independent integration validation on the current head. Details and tested scope are in the inline comment.

Comment thread test/ut/spec/util/types.test.ts Outdated
$vars: ['name', 'value'],
axisDim: 'x',
axisIndex: 0,
axisType: 'categoryAxis',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new declarations work in actual axis-tooltip callbacks too: I checked setOption plus dispatchAction({type: 'showTip', seriesIndex: 0, dataIndex: 1}) for category, value, and time x axes, using a formatter typed with CallbackDataParams. All six axis fields are populated and the value/label types match these declarations.

One useful adjustment to this fixture: the runtime category callback reports axisType: 'xAxis.category', and axisValue is the category string (e.g. 'Monday'), rather than 'categoryAxis' and ordinal index 1. My live cases returned category 'B', numeric 20, and the time-axis timestamp 1704153600000, each with a string label. Using runtime-shaped fixture values—or adding a live callback assertion—would keep the example aligned with the API being exposed.

The existing test and the three-case integration check pass in Jest/jsdom on Node 26.13.0. No browser rendering is claimed. AI-assisted review and local validation with OpenAI Codex.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, @TARUNTEjjjj! I've updated the test fixture to use runtime-shaped values (axisType: 'xAxis.category' and string axisValue: 'Monday'), and added coverage for numeric and timestamp axis values (xAxis.value and xAxis.time). Unit tests and type checking pass cleanly.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the updated head (48f73be) locally:

  • test/ut/spec/util/types.test.ts now aligns with runtime shapes (axisType: 'xAxis.category', axisValue: 'Monday') and covers numeric (xAxis.value) and timestamp (xAxis.time) axes.
  • npm run checktype, npm run lint, npm run checkheader, npm run build:lib, and the Jest UT suite (27 suites / 196 tests, including both CallbackDataParams tests) all pass.
  • Re-checked live echarts.init(..., { renderer: 'svg' }) + dispatchAction({ type: 'showTip', seriesIndex: 0, dataIndex: 1 }) in jsdom (with HTMLCanvasElement.prototype.getContext stubbed for measureText) across category, value, and time x-axes; runtime axisDim, axisIndex, axisType, axisId, axisValue, and axisValueLabel match the updated declarations and test fixtures.

(AI-assisted validation; full browser visual suite was not run.)

…properties

Signed-off-by: Prakhar1Ojha <pjha2737@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CallbackDataParams type doesn't have axisValue, axisValueLabel properties

2 participants