How can I display the percentage symbol inside the chartjs?

Viewed 1072

I can already retrieve the correct values for the percentage. How can I display the percentage symbol for each of the values? the codes for the graph:

2 Answers

Tooltips can be modified thus

    <Line
      data={{
<snip>
      options={{
        maintainAspectRatio: false,
        title: {
          display: true,
          text: "Hello",
          fontSize: 20
        },
        plugins: {
          tooltip: {
              callbacks: {
                  label: function(context) {
                      var label = context.dataset.label || '';
                      if (context.parsed.y !== null) {
                          label += ' ' +context.parsed.y + '%';
                      }
                      return label;
                  }
              }
          }
      },
        scales: {
          y: {
            min: 0,
            max: 100,
            ticks: {
              stepSize: 20,
              callback: function (value, index, values) {
                return value + " %";
              }
            }
          }
        },
        legend: {
          labels: {
            fontSize: 25
          }
        }
      }}
    />
Related