xingorg1 commented on issue #16479: URL: https://github.com/apache/echarts/issues/16479#issuecomment-4265876709
> > You should listen to [datazoom](https://echarts.apache.org/en/api.html#events.datazoom) event. > > [@Ovilia](https://github.com/Ovilia) [@pissang](https://github.com/pissang) **求助:** 监听datazoom事件,获取的回调参数start、end,都是百分比值,请问怎么可以更精准的拿到窗口内数轴开始、结束两个端点对应的数据值或者数组下标呢? **现在问题是**,我使用start、end计算后,因为这俩属性值是类似0.643832459的百分比数,导致计算出来的对应x轴的下标可能多1或者少1。比如我的xAxis.data是['一', '二', '三', '四', '五'],datazoom调整handle后窗口显示[ '二', '三', '四'],然后我通过监听事件计算的窗口展示内容可能是['一', '二', '三', '四'] 或者 ['二', '三', '四', '五']。 解决了: ```js myChart.on('datazoom', (params) => { // 获取当前图表配置 const option: any = myChart.getOption(); console.log( option.dataZoom, option.dataZoom[0].startValue, option.dataZoom[0].endValue ) }); ``` -- 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]
