[Chartjs]-Chartjs Customize Scale Numbers

2👍

You can keep track of the minimum value and set the label to $ if the value passed into the scaleLabel function is the minimum value.

Your code should look something like this :

var min = Infinity;
var myBarChart = new Chart(ctx).Bar(data, {
    scaleLabel: function(e) {
        if (Number(e.value) < min)
            min = Number(e.value);
        return (Number(e.value) === min) ? '$' : e.value;
    },
});

If you actually know your minimum value, you could just check for that instead.


See also this Fiddle!

Leave a comment