如何将Highcharts传奇的标题加粗?

时间:2018-07-22 19:50:30

标签: javascript html5 highcharts

这是我发现的API参考: https://api.highcharts.com/highcharts/legend.title.style.fontWeight

标题的fontWeight默认设置为bold。我尝试将其设置为normallighter。都不会产生编译错误,但是都不会。

legend: {
    title: {
        style: {
            fontWeight: 'lighter',
        }
    }
},

如何更改fontWeight

完整代码:

<!DOCTYPE html>
<html lang="en">

<html>
<head>
    <script src="https://code.highcharts.com/highcharts.js"></script>
</head>

<body>
    <div id="container"></div>
    <script>
        var scoreChart = Highcharts.chart('container', {
            chart: {
                type: 'scatter',
                zoomType: 'xy'
            },
            legend: {
                title: {
                    style: {
                        fontWeight: 'lighter',
                    }
                }
            },

            series: [{
                name: 'score',
                data: [[167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],
                    [170.0, 59.0], [159.1, 47.6],]
            },
            ]
        });
    </script>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

要设置legend的样式,请使用itemStyle

堆栈片段

var scoreChart = Highcharts.chart('container', {
  chart: {
    type: 'scatter',
    zoomType: 'xy'
  },
  legend: {
    itemStyle: {
      fontWeight: 'lighter'
    }
  },
  series: [{
    name: 'score',
    data: [
      [167.5, 59.0],
      [159.5, 49.2],
      [157.0, 63.0],
      [155.8, 53.6],
      [170.0, 59.0],
      [159.1, 47.6],
    ]
  }, ]
});
<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container"></div>