ng2-charts数据标签上的千位分隔符

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

在这个例子中 http://embed.plnkr.co/7fGsiuRjcF0M0Ffeoml2/

If I Change data to: 
    data: [2000, 3000, 4000, 8000, 12000, 12850]

Is it possible put thousand sepator on dataset label ? 
Like this : 
5,000
10,000
15,000
angular charts label
1个回答
0
投票

我找到了 !我需要在xAxes属性上使用回调函数。像这样:

barChartOptions = {
  scaleShowVerticalLines: false,
  responsive: true,
  scales: {
    yAxes: [{
      ticks: {
        fontSize: 13,
        fontStyle: 'normal',
      }
    }],
    xAxes: [{
      ticks: {
          callback: (dataLabel, index)=> {                  
            let decimalPipe = new DecimalPipe('pt-BR');
            return decimalPipe.transform(dataLabel, '1.0-0');
          }
      }
    }]
  },
  ...

谢谢 !

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