jay
jay

Reputation: 1175

chart js put meter square / superscript on y axis

I would like to put meter square (m2) in chart js y axis.

I have the following function :

var floorOptions = {
animation: true,
scaleLabel: 
function(label){return label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' m<sup>2</sup>';}

};

it doesn't work. Can someone please assist? Thx

Upvotes: 2

Views: 1637

Answers (1)

aXul
aXul

Reputation: 77

Try this:

var floorOptions = {
    animation: true,
    scaleLabel: 
    function(label){return label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' m/\u00B2'
;}

Canvas doesn't support HTML tags, but you could use the unicode character for superscript '2'.

link

Upvotes: 3

Related Questions