Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用了green的主题后,图表最左端鼠标hover时tooltip显示数据为undefined #616

Closed
zzmmzz777 opened this issue Aug 26, 2014 · 3 comments

Comments

@zzmmzz777
Copy link

使用了green主题,发现了一个bug:鼠标从图表的最左端hover进来时,在x轴的第一个grid,tooltip的function拿到的参数值中的data为undefined。经过追踪,发现green主题设置了grid的border为0,在执行

subPixelOptimize: function(position, lineWidth) {
    if (lineWidth % 2 == 1) {
        //position += position == Math.ceil(position) ? 0.5 : 0;
        position = Math.floor(position) + 0.5;
    } else {
        position = Math.round(position);
    }
    return position;
}

后postion不变,导致_getNearestDataIndex函数中的:

var curCoord = categoryAxis.getCoordByIndex(dataIndex);
while (curCoord < xEnd) {
    if (curCoord <= x) {
        left = curCoord;
    }
    if (curCoord >= x) {
        break;
    }
    curCoord = categoryAxis.getCoordByIndex(++dataIndex);
    right = curCoord;
}

执行后dataIndex为-2,没有拿到具体的数据。

@kener
Copy link
Contributor

kener commented Aug 28, 2014

什么例子?这还能跟主题有关系?

@zzmmzz777
Copy link
Author

@kener

只是说这个主题中 gird 设置为0后触发了这个 bug:
http://jsfiddle.net/6wtvc53g/

把主题的 gird border 改为1就没问题了。

@kener
Copy link
Contributor

kener commented Aug 28, 2014

赞代码分析,跟主题没关,是个通用计算的bug,thx~

@kener kener closed this as completed in b7ffbbd Aug 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants