lcf8381595's avatar

chartjs add dollar sign to Y coordinate and tooltip

i am using chartjs( http://www.chartjs.org/ ) to set up a chart for month sale amount. so i want the Y coordinate and tooltip of the chart have a dollar sign($) before the amount number.

how can i do that.. I am using version 2, and looks like results i google out are all for version 1. so working working for me.

thanks

0 likes
2 replies
bencekd's avatar

Hi lcf8381595,

for customizing the tooltips you should look into tooltip callbacks, documented here: http://www.chartjs.org/docs/#chart-configuration-tooltip-configuration . Adding a $ sign can be done by using something similar in your callback function:

 window.myBar = new Chart(ctx, {
    options: {
        tooltips: {
            callbacks: {
                label: function(tooltipItems, data) {
                    return "$" + tooltipItems.yLabel.toString();
                }
    ...

By the y coordinate you mean the y-axis?

1 like

Please or to participate in this conversation.