【问题标题】:ng2-chart: Smallest values in bar chart is invisibleng2-chart:条形图中的最小值不可见
【发布时间】:2021-11-06 15:55:53
【问题描述】:

数据集有值 10 和 50000,它不能在图表的 2006 列中显示值为 10 的条形图,因为它是图表比例最小的。谁能帮我展示一下?

public barChartOptions: ChartOptions = {
    responsive: true,
    scales: { //you're missing this
      yAxes: [{
         scaleLabel: {
            display: true,
            labelString: 'Frequency Rate'
         },
         ticks: { // and this
            callback: function(value, index, values) {
             return value/1000 + 'k';
          }
        }
      }]
   }
  };
  public barChartLabels: Label[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
  public barChartType: ChartType = 'bar';
  public barChartLegend = true;
  public barChartPlugins = [];

  public barChartData: ChartDataSets[] = [
    
    { data: [6500, 5900, 8000, 8100, 5600, 5500, 4000], label: 'Series A' },
    { data: [10, 4800, 4000, 1900, 8600, 2700, 50000], label: 'Series B' }
  ];

You can see Chart in this image

您可以在此处查看完整代码: a link!

【问题讨论】:

    标签: angular typescript ng2-charts


    【解决方案1】:

    10 is 0.02% of 50000

    在您分享的图片中,50 000 列的高度为 210 像素,并且

    0.02% of 210 is 0.042 px

    所以它的高度小于一个像素,这就是它不在列中呈现的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-02-06
      • 2019-07-13
      • 1970-01-01
      • 1970-01-01
      • 2021-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多