简体   繁体   中英

Options won't load in chart.js

For some reason al my options will not be shown in the chart. Can't find the error myself. The code of the chart is a snippet from this code: https://codepen.io/sietssoo/pen/oNqGpXq If anyone could find the error, you would be my hero.

  //Making chart
  var ctx = document.getElementById('myChart').getContext('2d');
  var chart = new Chart(ctx, {
    type: 'bar',
    data: getChartData(),
    options: {
      legend: {display: true},
      responsive: true,
      tooltips: {
        mode: 'index',
        intersect: false,
        callbacks: {
          label: function (tooltipItem, data) {
            return data.datasets[tooltipItem.datasetIndex].label + '€ ' + tooltipItem.yLabel;
          }
        }
      },
      scales: {
        x: [{
          stacked: true,
          scaleLabel: {
            isplay: true,
            labelString: 'Jaar'
          }
        }],
        y: [{
          stacked: true,
          scaleLabel: {display: true},
          ticks: {
            callback: function (value) {
              return '€' + value;
            }
          }
        }]
      }
    }
  });

That is because you are using V2 syntax in V3.

the legend and tooltip config have been moved to the options.plugins.legend and options.plugins.tooltip namespace, the scales are not arrays anymore all scales are their own object.

For all the changes and detailed explanation you can read the migration guide

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM