-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
当y为类目轴且series的data为二维数组时,tooltip里的formatter回调的params[0].name属性不显示 #2822
Labels
Comments
谢谢反馈,是 bug |
function createNameList(result, data) {
var nameList = [];
if (result && result.categoryAxisModel) {
// FIXME Two category axis
var categories = result.categoryAxisModel.getCategories();
if (categories) {
var dataLen = data.length;
// Ordered data is given explicitly like
// [[3, 0.2], [1, 0.3], [2, 0.15]]
// or given scatter data,
// pick the category
if (zrUtil.isArray(data[0]) && data[0].length > 1) {
nameList = [];
for (var i = 0; i < dataLen; i++) {
nameList[i] = categories[data[i][0]];
}
}
else {
nameList = categories.slice(0);
}
}
}
return nameList;
} 源码18400行获取nameList的代码中,series出现二维数组时会默认将categories[data[i][0]];设置为name。当类目轴为x轴时data[i][0]表示的是x轴的类目,不会出现问题,但是类目轴为y轴时data[i][0]表示的是值,data[i][1]才表示的是类目,所以此时categories[data[i][0]]作为name取出来会有问题。 if (zrUtil.isArray(data[0]) && data[0].length > 1) {
nameList = [];
for (var i = 0; i < dataLen; i++) {
nameList[i] = categories[data[i][0]];
}
} 判断删掉,但是这样的话series就必须是按顺序排列的,出现离散数据的时候数据会乱。 我想正确方法应该是通过判断类目轴来确定data[i][0]或data[i][1],但是我不会js啊。先就这么办吧。。 |
我提的issue居然有人看!太感动了! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题简述 (One-line summary)
当y为类目轴且series的data为二维数组时,tooltip里的formatter回调的params[0].name属性不显示
版本及环境 (Version & Environment)
当y为类目轴且series的data为二维数组时,tooltip里的formatter回调的params[0].name属性不显示
![image](https://cloud.githubusercontent.com/assets/12960117/13771464/0a0874e2-eac9-11e5-9e6f-cdaaac6bacd5.png)
如果series的data为一维数组的时候,这个name可以正常显示
ECharts配置项 (ECharts option)
在x轴为类目轴的时候formatter的回调name属性能正常显示
![image](https://cloud.githubusercontent.com/assets/12960117/13771403/77fad91e-eac8-11e5-8a78-79cc72690de1.png)
ECharts配置项 (ECharts option)
The text was updated successfully, but these errors were encountered: