RXP
RXP

Reputation: 687

Format x axis to show percent with Primefaces/Chartjs ScatterChart

I am creating a scatter chart using Chartjs as part of Primefaces8.0. Both my x and y values are % values. I am able to format the yaxis to show % values using an extender but not the x axis. How do I format the x axis to show percent values. I would like to show the x axis labels as 1.5%, 2%, 2.5% etc.

Thanks!

Upvotes: 0

Views: 356

Answers (1)

RXP
RXP

Reputation: 687

                  scales: {
                 yAxes: [{
                    display: true,
                    scaleLabel: {
                       display: true
                    },
                    ticks: {
                       // add % to y axis label
                       callback: function (value, index, values) {
                           value = value * 100;
                           value = value.toFixed(2);
                           return value + " %";
                       }
                    }
                 }],
                 xAxes: [{
                        ticks: {
                           // add % to x axis label
                           callback: function (value, index, values) {
                               value = value * 100;
                               value = value.toFixed(2);
                               return value + " %";
                           }
                        }
                     }]
              }

Upvotes: -2

Related Questions