并排双条形图与Chart.js 2

时间:2018-02-01 04:09:32

标签: javascript chart.js2

enter image description here

是否可以使用Chart.js(v2)执行此操作?我知道如何做多个轴图表,但到目前为止我见过的所有例子仅限于重叠(例如:线条+条形)或位于同一平面上的堆积条形图。 This is a close example of what I want but not quite right

var canvas = document.getElementById('chart');
new Chart(canvas, {
  type: 'bar',
  data: {
    labels: ['Target', 'Actual'],
    datasets: [{
      label: 'A',
      yAxisID: 'A',
      data: [1400,0]
    }, {
      label: 'B',
      yAxisID: 'B',
      data: [0,0.83]
    }]
  },
  options: {
    scales: {
      yAxes: [{
        id: 'A',
        type: 'linear',
        position: 'left',
      }, {
        id: 'B',
        type: 'linear',
        position: 'right',
        ticks: {
          max: 1,
          min: 0
        }
      }]
    }
  }
});

0 个答案:

没有答案