Chart.js - 具有多个数据集的极区

时间:2018-03-07 04:53:15

标签: chart.js

伙计我无法正确地在“数据集”中放置多个数据字段,或者说将极区划分为具有不同数据集的2个或更多个组。使用下面的代码时我会得到这样的视图。

var birdsData = {
    labels: ['A','B','C','D','E','F','G','H','I','J'],
    datasets: [{
        label: '# of Votes',
        data: [1,5,7,2,5,0,0,0,0,0],
        backgroundColor: [
            "rgba(255, 0, 0, 0.8)",
            "rgba(100, 255, 0, 0.8)",
            "rgba(200, 50, 255, 0.8)",
            "rgba(0, 100, 255, 0.8)",
            "rgba(100, 255, 0, 0.8)"
        ],
        hoverBackgroundColor: [
            "#CCC",
            "#CCC",
            "#CCC",
            "#CCC",
            "#CCC"
        ]
  },{
      label: '# of Votes',
    data: [0,0,0,0,0,1,5,7,2,5],
    backgroundColor: [
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)",
      "rgba(120, 120, 120, 0.8)"
    ]
  }]
};

image for reference

有没有正确的方法呢?

0 个答案:

没有答案