简体   繁体   中英

increase the label size of a line chart in chart.js

I am unable to change the font of my labels. As you can see below I have a label that says "# of votes" and another label that says "# of points" . I want to make the size bigger for them. So i even added the following:

 label: {
          fontSize: 50
        },

But I have had no luck

MY JS CODE

var options = {
  type: 'line',
  data: {
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [
        {
          label: '# of Votes',
          data: [12, 19, 3, 5, 2, 3],
        borderWidth: 1,
        backgroundColor: 'rgba(255, 0, 15, 0.54)'
        },  
            {
                label: '# of Points',
                data: [7, 11, 5, 8, 3, 7],
                borderWidth: 1
            }
        ]
  },
  options: {
  label: {
      fontSize: 50
    },
    scales: {
        yAxes: [{
        ticks: {
                    reverse: false
        }
      }]
    }
  }
}

var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);

MY FIDDLE

Try something like this (in my project works fine) :

options: {
    legend: {
        labels: {
            fontSize: 50
        }
    },
//rest of options

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM