使用ng2图表绘制2个不同的数据集

时间:2019-08-14 11:38:30

标签: angular charts chart.js

我正在使用ng2-charts,我想使用2个不同的数据集绘制折线图,​​如下图所示。一个数据集显示为灰色,另一个数据集显示为红色。

enter image description here

这是我的图表对象

 public chart1 = {
  chartLabels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
    title: 'LINE CHART',
    datasets: [
      {
        data: [1, 2, 3, 4, 5, 6], yAxisID: 'first-y-axis', xAxisID: 'first-x-axis'
      },
    ],
    chartOptions: {
      responsive: true,
      showLines: false,
      scales: {
        yAxes: [{
          id: 'first-y-axis',
          type: 'linear',
          scaleLabel: {
            display: true,
            labelString: 'Fehler',
            fontColor: 'white',
            fontSize: '20',
          },
          gridLines: {
            color: 'white',
            zeroLineColor: 'red'
          },
          ticks: {
            display: true
          }
        }],
        xAxes: [{
          id: 'first-x-axis',
          type: 'linear',
          scaleLabel: {
            display: true,
            labelString: 'Zeit',
            fontColor: 'white',
            fontSize: '20'
          },
          gridLines: {
            color: 'white',
            zeroLineColor: 'red',
          },
          ticks: {
            display: true
          }
        }]
      },
      legend: {
        labels: {
          fontColor: 'white',
          display: false
        }
      }
    },
    chartType: 'line',
  };

您能帮我弄清楚我需要在这里做什么才能使它工作吗?

0 个答案:

没有答案