[Chartjs]-ChartJS v3 custom displayFormats

1๐Ÿ‘

"'Week' W" is a formating string, depending on which adapter you are using 'Week' will be translated to a specific value.

You could check if your adapter support custom strings in the format-string,โ€ฆ
Or you try to modify the label with a callback, like shown here in the documentation: https://www.chartjs.org/docs/latest/axes/labelling.html

Here the relevat code, adapted to fit your code snippet:

...
scales: {
     x: {
         type: 'time',
         time: {
             unit: 'week',
             displayFormats: {
                 week: 'W',
             }
         },
         ticks: {
             // This prepends the "Week" before the label
             callback: function(value, index, ticks) {
                 return '"Week" ' + value;
             }
         }
     }
 }
 ...

Leave a comment