Chart.js 2.0 Formatting Y Axis with Currency and Thousands Separator

前端 未结 3 1915
悲哀的现实
悲哀的现实 2021-02-14 02:40

I am having problems with formatting my chart axis and I am not able to find an example for the updated version 2.0.

How can I (for example) make 2000000 to €2.000.000?<

3条回答
  •  旧时难觅i
    2021-02-14 02:45

    Instead a new function you can use a native javascript NumberFormat

            yAxes: [{
          ticks: {
            beginAtZero: true,
            callback: function(value, index, values) {
                    return '€ ' + Intl.NumberFormat().format((value/1000)) + 'K';
                }
          }
        }]
            //2000000 => € 2,000K
    

提交回复
热议问题