[Chartjs]-Chart.js – problems with axes options – what am I doing wrong?

1πŸ‘

βœ…

Here is the code:

var FV201_ctx = document.getElementById('FV201_chart').getContext('2d');
    var FV201_cfg = {
        type: 'line',
        data: {
          labels: FV201_timestamps,
          datasets: [
            {
              label: 'temps',
              data: FV201_temps,
              type: 'line',
              fill: false
            }
          ]
         },
          options: {
            title: {text: 'my chart', display: false},
            scales: {
                xAxes: [{
                    type: 'time',
                    time: {
                        unit: 'second',
                        displayFormats: { second: 'hh:mm:ss' },
                        parser: function(foo) { return moment(foo,'X'); }
                    }
                }],
                yAxes: [{
                  ticks: {
                     suggestedMin: 28.5,
                     suggestedMax: 29,
                     stepSize: 0.1
                  }
              }]
            },
          }
    };
    var FV201_chart = new Chart(FV201_ctx, FV201_cfg);
    FV201_chart.update();
  1. options should not be inside data object.
  2. x and y axes should be array types.

Leave a comment