混合数字和非数字系列

时间:2016-12-31 16:55:10

标签: javascript chart.js

在Charts.js中,我试图在一个图表中混合非数字和数字系列。我不确定,如果有可能的话,我没有在文件中找到任何明确的陈述。这是我的配置应该IMO工作。 (见https://jsfiddle.net/carnecro/13tfh0gb/

var config = {
  type: 'line',
  data: {
    xLabels: ["00","02","04","06","08","10","12","14","16","18","20","22"],
    yLabels: ['ERR', 'STARTING', 'ON', 'STOPPING', 'OFF'],
    datasets: [{  
        label:  "Motor Status",
        xAxisId: "X",       
        yAxisId: "Y1",
        fill: false,
        borderColor: '#337ab7',
        backgroundColor: '#337ab7',
        steppedLine: true,
        data: ['OFF', 'OFF', 'STARTING', 'ON', 'ON', 'STOPPING', 'OFF']
      },{
        label: "Temperature",
        xAxisId: "X",       
        yAxisId: "Y2",
        fill: false,
        borderColor: '#22dd88',
        backgroundColor: '#22dd88',
        steppedLine: true,
        data: [15,15,18,47,43,27,15]       
    }]
  },
  options: {
    responsive: true,
    tooltips: false,
    scales: {
      xAxes: [{
        id: "X",       
        display: true
      }],
      yAxes: [{
        id: "Y1",
        type: 'category',
        position: 'left',
        display: true,
        scaleLabel: {
          display: true,
          labelString: 'Status'
        },
        ticks: {
          reverse: false
        }
      },{
        id: "Y2",
        min: 0,
        max: 150,
        type: 'linear',
        beginAtZero: true,
        position: 'right',
        display: true,
        scaleLabel: {
          display: true,
          labelString: 'Temp'
        },
        ticks: {
          reverse: false
        }
      }]
    }
  }
});

0 个答案:

没有答案