选项不会加载到chart.js中

acruukt9  于 2022-11-06  发布在  Chart.js
关注(0)|答案(1)|浏览(189)

由于某种原因,我的所有选项都不会显示在图表中。我自己也找不到错误。图表的代码是以下代码的一个片段:https://codepen.io/sietssoo/pen/oNqGpXq如果有人能找到这个错误,你就是我的英雄。

  1. //Making chart
  2. var ctx = document.getElementById('myChart').getContext('2d');
  3. var chart = new Chart(ctx, {
  4. type: 'bar',
  5. data: getChartData(),
  6. options: {
  7. legend: {display: true},
  8. responsive: true,
  9. tooltips: {
  10. mode: 'index',
  11. intersect: false,
  12. callbacks: {
  13. label: function (tooltipItem, data) {
  14. return data.datasets[tooltipItem.datasetIndex].label + '€ ' + tooltipItem.yLabel;
  15. }
  16. }
  17. },
  18. scales: {
  19. x: [{
  20. stacked: true,
  21. scaleLabel: {
  22. isplay: true,
  23. labelString: 'Jaar'
  24. }
  25. }],
  26. y: [{
  27. stacked: true,
  28. scaleLabel: {display: true},
  29. ticks: {
  30. callback: function (value) {
  31. return '€' + value;
  32. }
  33. }
  34. }]
  35. }
  36. }
  37. });
jum4pzuy

jum4pzuy1#

这是因为您在V3中使用的是V2语法。
图例和工具提示配置已移至options.plugins.legendoptions.plugins.tooltip命名空间,秤不再是数组,所有秤都是它们自己的对象。
有关所有更改和详细解释,您可以阅读migration guide

相关问题