user626920
user626920

Reputation: 55

chart.js how add euro symbol on each node

i'm using chart.js 3.0 i want to add the euro sybol on each y-axis value. with this code:

const chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
    scales: {
        y: {
            ticks: {
                // Include a dollar sign in the ticks
                callback: function(value, index, ticks) {
                    return '$' + value;
                }
            }
        }
    }
}

});

i add the dollar symbol on each y-axis value, I want to show the euro symbol (€), but if i use this code:

callback: function(value, index, ticks) {
                    return '€' + value;
                }

i get a bad result, i get the symbol ? instead of the € symbol how i can fix it?

enter image description here

Upvotes: 2

Views: 559

Answers (1)

uminder
uminder

Reputation: 26170

Instead of using the Euro symbol, try to use its Unicode as follows.

options: {
  scales: {
    y: {
      ticks: {
        callback: v => v + '\u20AC'
      }
    }
}

Upvotes: 3

Related Questions