[Chartjs]-How to change axis font in PrimeFaces and Chart.js

3๐Ÿ‘

โœ…

It worked by changing my extender function as follows.

Model:

barModel = new BarChartModel();
barModel.setExtender("skinBar");

Extender function:

function skinBar() {
    Chart.defaults.global.defaultFontFamily = 'Tahoma';
}

reference: https://www.chartjs.org/docs/latest/general/fonts.html

0๐Ÿ‘

If you canโ€™t, or donโ€™t want to use an extender function, you can add this to the bottom of your template (before </body>):

<script>if(typeof Chart!=='undefined'){Chart.defaults.font.family='...'}</script>

It will apply if any charts are visible at the moment the page is rendered. So not perfect, and I suggest to use the extender instead when possible.

Leave a comment