Chartjs列未按值显示

问题描述 投票:0回答:1

我正在使用以下数据集,

  this.chart = new Chart(
    this.canvasContext,
    {
      type: 'bar',
      data: {
        labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
        datasets: [
          {
            label: "Population (millions)",
            backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
            data: [2478,5267,734,784,433]
          }
        ]
      },
      options: {
        showScale: true,
        maintainAspectRatio: false,
        responsive: true,
        utoutPercentage: 50,
        animation: {
          animateRotate: true,
          duration: 2000,
          animateScale: true
        }
      }
    }
  )

出现所有列。

enter image description here

但是如果我使用data: [600,400,400,900,1100],则图表上不会出现400个值。它们显示为零。为什么?

chart.js
1个回答
0
投票

检查此沙箱:

https://codesandbox.io/s/chartjs-hbjrf

确实有效。可以尝试清除缓存,然后再尝试

© www.soinside.com 2019 - 2024. All rights reserved.