如何删除render.rect方法的边界半径。我试图添加使用此方法的CSS方法,但未成功。
.css({
borderRadius: 'none'
})
这是我的代码。
Highcharts.chart('container', {
chart: {
type: 'column'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
max: 300
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
}, function (chart) {
let maxPoint = chart.series[0].data.reduce((a, b) => a.y > b.y ? a : b);
for(var i = 0; i <= 10; i++){
var point = chart.series[0].data[i];
let text = chart.renderer.text(
'Hien' + i,
point.plotX + chart.plotLeft + 10,
maxPoint.plotY + chart.plotTop - 10
).attr({
zIndex: 5
}).add();
let box = text.getBBox();
chart.renderer.rect(point.plotX + chart.plotLeft + 5, maxPoint.plotY + chart.plotTop - 25, box.width + 10, box.height + 10, 5)
.attr({
fill: '#FFFFEF',
stroke: 'gray',
'stroke-width': 1,
zIndex: 4
}).css({
borderRadius: 'none'
})
.add();
}
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 300px; width: 400"></div>
.rect()
的语法是:
rect([x] [,y] [,width] [,height] [,r] [,strokeWidth])
第五个参数是边界角半径,因此您只需将其设置为0。
chart.renderer.rect(
point.plotX + chart.plotLeft + 5,
maxPoint.plotY + chart.plotTop - 25,
box.width + 10,
box.height + 10,
0
)...
Highcharts.chart('container', {
chart: {
type: 'column'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
max: 300
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
}, function (chart) {
let maxPoint = chart.series[0].data.reduce((a, b) => a.y > b.y ? a : b);
for(var i = 0; i <= 10; i++){
var point = chart.series[0].data[i];
let text = chart.renderer.text(
'Hien' + i,
point.plotX + chart.plotLeft + 10,
maxPoint.plotY + chart.plotTop - 10
).attr({
zIndex: 5
}).add();
let box = text.getBBox();
chart.renderer.rect(point.plotX + chart.plotLeft + 5, maxPoint.plotY + chart.plotTop - 25, box.width + 10, box.height + 10, 0)
.attr({
fill: '#FFFFEF',
stroke: 'gray',
'stroke-width': 1,
zIndex: 4
})
.add();
}
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 300px; width: 400"></div>