Chartjs-How to manipulate data in react-chartjs-2

1๐Ÿ‘

โœ…

Y-axis can be formatted in the options => scales => yAxis => ticks. There you can format the label with the same style with the tooltip.

    options={ 
      {
        tooltips: {
          callbacks: {
              label: (tooltipItems, data) => {
                  return `${currencyFormatter(tooltipItems.value)}`
              }
          }
        },
        scales:{
          yAxes:[
            {
              ticks: {
                callback: function(label, index, labels) {
                    return `${currencyFormatter(label)}`
                }
              },
            }
          ]
        }
      }
  }

Leave a comment