7

I got a chart from Chart JS library. Screenshot

var ctx = document.getElementById("myChart");
    var data = {
    labels: ["HTML", "CSS", "JavaScript", "jQuery", "Bootstrap", "Gulp", "PHP", 'SQL', 'Git'],
    datasets: [
        {
            defaultFontColor: 'red',
            backgroundColor: "rgba(0,255,255,.4)",
            borderColor: "rgba(0,255,255,.4)",
            pointBackgroundColor: "red",
            pointBorderColor: "#fff",
            lineTension: 0,
            pointHoverBackgroundColor: "#fff",
            pointHoverBorderColor: "rgba(179,181,198,1)",
            data: [95, 99, 60, 91, 36, 95, 40, 95, 95]
            }
        ]
    };
    var myRadarChart = new Chart(ctx, {
      type: 'radar',
      data: data,
      options: {
        responsive: true,
        scale: {
            reverse: false,
            ticks: {
                // defaultFontSize: true
            }
        }
      }
    });

I need to change font styles for underlined labels. I've dug over documentation and i tried all what i could. Even global font settings didn't change label styles, though it worked for the rest of other text. Have you met such a problem? Thanks.

Alex
  • 73
  • 1
  • 1
  • 7

2 Answers2

13

It's well hidden, but you can find this under "Point Label Options"

http://www.chartjs.org/docs/#scales-radial-linear-scale

here is a example: https://jsfiddle.net/qvrt01jp/1/

options: {
    scale: {
        pointLabels :{
           fontStyle: "bold",
        }
    }
}

global should also work if set it like this:

Chart.defaults.global.defaultFontStyle = 'italic'
Tom Glover
  • 2,996
  • 23
  • 23
  • By the way, global default styles don't change pointLabels so far. Try yourself. But it doesn't matter now) Thanks again – Alex Feb 19 '17 at 07:42
-1

To give an update for v3.5.1:

Like this for font weights:

Chart.defaults.font.weight = '600';

Or if you want to do it inside the options object:

options: {
    plugins: {
        legend: {
            labels: {
                font: {
                    style: 'italic',
                    weight: '600',
                }
            }
        }
    }
}

Documentation with more info: https://www.chartjs.org/docs/latest/general/fonts.html

Donaldini
  • 96
  • 6