Version
5.2.2
Link to Minimal Reproduction
No response
Steps to Reproduce
chart.getZr().on('click', (params) => {
const pointInPixel = [params.offsetX, params.offsetY];
const yIndex = chart.convertFromPixel(
{
seriesIndex: 0
},
pointInPixel
)[1];
const yData = options.yAxis.data[yIndex];
console.log(yIndex, options);
});
Current Behavior
yIndex 打印出来是小数,并不是索引
Expected Behavior
期望 yIndex 打印出来是索引值
Environment
- OS:
- Browser:chrome
- Framework:
Any additional comments?
No response
3条答案
按热度按时间cmssoen21#
@snowyang2021 It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗
TRANSLATED
TITLE
[Bug] The index after convertfromPixel is inaccurate and decimal
BODY
Version
5.2.2
Link to Minimal Reproduction
No response
Steps to Reproduce
chart.getZr().on('click', (params) => {
Current Behavior
yIndex is printed as a decimal, not an index
Expected Behavior
Expect yIndex to print out the index value
Environment
Any additional comments?
No response
a7qyws3x2#
converFromPixel 返回的是数据并不是索引,是否是小数取决于 y 轴数据类型
q3qa4bjr3#
我看官方文档上写的叫刻度值。“[300, 900] 表示该点 x 轴上对应刻度值 300,y 轴上对应刻度值 900”。刻度值是什么意思?如果yAxis是category类型的,那刻度值怎么和索引值对应上呢? https://echarts.apache.org/examples/zh/editor.html?c=bar-rich-text