这是我找到的API引用:https://api.highcharts.com/highcharts/legend.title.style.fontWeight
默认情况下,标题的fontWeight
设置为bold
。我尝试将其设置为normal
或lighter
。两者都不会产生编译错误,但都不起作用。
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>
要设置legend
的样式,请使用itemStyle
- https://api.highcharts.com/highcharts/legend
堆栈片段
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>