Prakhar1Ojha opened a new pull request, #21836:
URL: https://github.com/apache/echarts/pull/21836

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] 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
   
   - close #17561
   
   ## 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
   
   - [x] 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
   
   - [x] 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)


-- 
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]

Reply via email to