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

前端 未结 11 2051
面向向阳花
面向向阳花 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:52

    You can give tooltipTemplate a function, and format the tooltip as you wish:

    tooltipTemplate: function(v) {return someFunction(v.value);}
    multiTooltipTemplate: function(v) {return someOtherFunction(v.value);}
    

    Those given 'v' arguments contain lots of information besides the 'value' property. You can put a 'debugger' inside that function and inspect those yourself.

提交回复
热议问题