TARUNTEjjjj commented on code in PR #21836: URL: https://github.com/apache/echarts/pull/21836#discussion_r4604555177
########## test/ut/spec/util/types.test.ts: ########## @@ -0,0 +1,64 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* 'License'); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +import { CallbackDataParams } from '@/src/util/types'; + +describe('util/types', function () { + describe('CallbackDataParams', function () { + it('should allow accessing axis context properties without type assertions', function () { + const params: CallbackDataParams = { + componentType: 'series', + componentSubType: 'line', + componentIndex: 0, + seriesType: 'line', + seriesIndex: 0, + seriesId: 'series_0', + seriesName: 'Sales', + name: 'Monday', + dataIndex: 1, + data: 120, + value: 120, + $vars: ['name', 'value'], + axisDim: 'x', + axisIndex: 0, + axisType: 'categoryAxis', Review Comment: 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. -- 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]
