Chart.js axes label font size

前端 未结 5 1165
天命终不由人
天命终不由人 2021-02-01 01:20

In chart.js how can I set the set the font size for just the x axis labels without touching global config?

I\'ve already tried setting the \'scaleFontSize\' option my op

相关标签:
5条回答
  • 2021-02-01 01:57

    Try to see if this will work

    {
      ...
      scales: {
        xAxes: [{
          fontSize: 40
          ...
        }]
       }
    }
    

    It doesn't look like scaleFontSize is a valid property.

    0 讨论(0)
  • 2021-02-01 02:00

    Try this

    Chart.defaults.global.defaultFontSize = 8;
    
    0 讨论(0)
  • 2021-02-01 02:02

    Try this simple solution:

    myChart.options.scales.yAxes[0].ticks.fontSize = 40 ;
    
    myChart.update();
    
    0 讨论(0)
  • 2021-02-01 02:10

    The fontSize attribute is actually in scales.xAxes.ticks and not in scales.xAxes as you thought.

    So you just have to edit the attribute like this :

    var options = {
        scales: {
            yAxes: [{
                ticks: {
                    fontSize: 40
                }
            }]
        }
    }
    


    You can see a fully working example in this jsFiddle and here is its result :

    0 讨论(0)
  • 2021-02-01 02:10

    Try this is working

         options: {
            scales: {
               xAxes: [{
                       ticks: {
                        fontSize: 10
                       }
                      }]
                    }
                 }

    0 讨论(0)
提交回复
热议问题