JavaScript Chart.js - Custom data formatting to display on tooltip

前端 未结 11 1939
面向向阳花
面向向阳花 2020-12-07 20:13

I have looked at various documentation and similar questions on here, but cannot seem to find the particular solution. Apologies if I have missed anything obvious or have re

11条回答
  •  囚心锁ツ
    2020-12-07 20:43

    This works perfectly fine with me. It takes label and format the value.

    options: {
            tooltips: {
                callbacks: {
                    label: function(tooltipItem, data) {
    
                        let label = data.labels[tooltipItem.index];
                        let value = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
                        return ' ' + label + ': ' + value + ' %';
    
                    }
                }
            }
        }
    

提交回复
热议问题