如何改变凹坑中分组条形图的顺序?

时间:2015-08-26 17:03:14

标签: d3.js graph dimple.js

我有这样的数据,

income  correlation bath_math_count bath_read_count
High    Negative    3   2
High    Not significant 7   12
High    Positive    17  13
Medium  Negative    0   0
Medium  Not significant 2   3
Medium  Positive    9   8
Low Negative    0   1
Low Not significant 6   8
Low Positive    19  16

我的酒窝代码读取,

var svg = dimple.newSvg("#chartContainer", 590, 400);
d3.tsv("generated_data/test.tsv", function (data) {
  var myChart = new dimple.chart(svg, data);
  myChart.setBounds(60, 30, 510, 330);
  myChart.addCategoryAxis("x", ["correlation", "income"]);
  myChart.addMeasureAxis("y", "bath_read_count");
  var s = myChart.addSeries("income", dimple.plot.bar);
  // s.addOrderRule(["Low", "Medium", "High"]);
  myChart.addLegend(65, 10, 510, 20, "right");

看起来像 enter image description here

我希望每个小组从“低”到“高”排列。如果我取消注释上面注释的行,则更改图例的顺序,但不更改条形。 enter image description here 如何解决?

0 个答案:

没有答案