vue.js - Highcharts - 如何动态设置饼图的背景颜色
问题描述
我正在使用以下行根据某些条件更改一些视觉属性
this.$refs.pieChart.chart.series[0].update({ dataLabels: { color: 'blue' }, chart: { backgroundColor: 'yellow' } })
这适用于 dataLabels 部分,但我无法更改 backgroundColor 之一。
我试过这个:
this.$refs.pieChart.chart.series[0].update({ dataLabels: { color: 'blue' }, backgroundColor: 'yellow' })
和这个
this.$refs.pieChart.chart.series[0].update({ backgroundColor: 'yellow' })
没有运气,我在我的代码中搜索了其他任何地方,没有任何东西可以覆盖或设置背景 颜色。
解决方案
您应该更新整个图表配置,而不是系列:
chart.update({
chart: {
backgroundColor: 'red'
}
})
API:https ://api.highcharts.com/highcharts/chart.backgroundColor
API:https ://api.highcharts.com/class-reference/Highcharts.Chart#update
推荐阅读
- swift - Swift 泛型函数类型排序
- python - Groupby 的 Python 最小/最大日期
- javascript - 数组上的 useTransition 返回未定义的数组属性(React Spring)
- spring - 如何为 spring GatewayFilter 测试生成取消的请求?
- excel - 快速/高效的 VBA 代码,用于比较大型数据库(约 9000 行)的 excel 中的两列
- debugging - 我可以阻止 STMCubeIDE 在微控制器复位(调试)时打开启动 .s 文件吗?
- python - 使用 pymssql 连接数据库时遇到问题
- python - Django Docker 问题
- javascript - 使用 jQuery 从动态输入中制作收据
- json - 在列表中选择对象而不将列表转换为 powershell 中的对象