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

柱状图changeData传入有序数组。显示无序 #7

Closed
ShighGoing opened this issue Aug 2, 2016 · 4 comments
Closed

柱状图changeData传入有序数组。显示无序 #7

ShighGoing opened this issue Aug 2, 2016 · 4 comments

Comments

@ShighGoing
Copy link

步骤:

  • chart source时传入一有序数组如
    [{ name: 'a', value: 1 }, { name: 'b', value: 2 }, { name: 'c', value: 3 } ]
    显示顺序是a b c
  • changeData时传入有序数组如
    [{ name: 'b', value: 1 }, { name: 'a', value: 2 }, { name: 'c', value: 3 } ]

显示顺序还是 a b c 而我要的顺序是b a c 有解决此问题的配置项或处理方法么

@dxq613
Copy link
Member

dxq613 commented Aug 2, 2016

一般情况下用户想指定分类类型的顺序,你的需求正好相反? 我看了现在的情况,分类的顺序会根据数组的顺序调整,如果你想不改变字符串的顺序,那么可以自己定义列的字符串顺序:

var defs = {
  name: {
   value: ['a','b','c']
  }
}
chart.source(data,defs);

@ShighGoing
Copy link
Author

我想你误解我的意思了。我并不在意分类类型的顺序。我是想按照value值排序显示(事实上已经是排序过的数组,只要按照数组显示即可)。
我的需求是无论是sourceData还是changeData 都按照数组本来的顺序显示

@dxq613
Copy link
Member

dxq613 commented Aug 3, 2016

我试了下,G2现在如果changeData后,分类类型的顺序会根据当前数据集重新排序的。

@xiaxia2017
Copy link

同求该问题,应该有参数可以避免G2自动排序的,之前用的旧版但是不美观;新版切换过来,发现文档太难找了,参数配置变化太大,有的还找不到,不行就只能再切回旧版了

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

3 participants