Show values on top of bars in chart.js

后端 未结 7 1110
自闭症患者
自闭症患者 2020-12-04 13:34

Please refer this Fiddle : https://jsfiddle.net/4mxhogmd/1/

I am working on chart.js If you see in fiddle, you will notice that value which is top on bar is not pro

相关标签:
7条回答
  • 2020-12-04 14:08

    The fastest way I found to do this was to use this plugin: https://github.com/chartjs/chartjs-plugin-datalabels

    Labels can be added to your charts simply by importing the plugin to the js file e.g.:

    import 'chartjs-plugin-datalabels'
    

    And if you want to apply it values on top (globally), simply set these options in your code:

    Chart.defaults.global.plugins.datalabels.anchor = 'end';
    Chart.defaults.global.plugins.datalabels.align = 'end';
    

    More options can be found here: https://chartjs-plugin-datalabels.netlify.com/options.html

    0 讨论(0)
提交回复
热议问题