【发布时间】:2020-12-06 16:24:22
【问题描述】:
需要更改高图甜甜圈的背景颜色
预期结果
达到的结果
JS Fiddle Link : https://jsfiddle.net/shantanugade/f5ojh13z/1/
需要帮助!提前致谢!
更新:-我尝试更改背景颜色-
【问题讨论】:
标签: javascript reactjs highcharts next.js
JS Fiddle Link : https://jsfiddle.net/shantanugade/f5ojh13z/1/
需要帮助!提前致谢!
【问题讨论】:
标签: javascript reactjs highcharts next.js
您可以使用Highcharts.SVGRenderer 类添加一个圆圈作为背景:
chart: {
...,
events: {
load: function() {
var center = this.series[0].center;
this.renderer.circle(
center[0],
center[1],
(this.plotHeight - this.spacingBox.y * 2) / 2)
.attr({
fill: 'green'
}).add();
}
}
}
现场演示: https://jsfiddle.net/BlackLabel/oghbp479/
API 参考:
https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#circle
【讨论】:
您可以简单地更改图表对象上的 RGB 值;
chart: {
plotBackgroundColor: null,
plotBorderWidth: 0,
plotShadow: false,
height: 175,
width: 175,
margin: 0,
backgroundColor: 'rgba(250,251,236,1)' //this is the background of the whole chart, so change it to this RGBA value.
},
如果您希望第三个值不是白色而是与背景颜色混合,请更改 plotoptions 上颜色数组的最后一个值
plotOptions: {
pie: {
dataLabels: {
enabled: false,
distance: -10,
style: {
fontWeight: 'bold'
},
backgroundColor: "#fafbec"
},
states: {
hover: {
enabled: false
}
},
borderColor: '',
// center: ['50%', '50%'],
size: '100%',
colors: ['#000000', '#e45456', '#fafbec'], //here the last one is the color of the last line, which in the jsfiddle is white, you have to change it to '#fafbec' which is the hexadecimal equivalent of the 'rgba(250,251,236,1)'
},
series: {
states: {
inactive: {
opacity: 1
}
}
},
},
【讨论】: