簡體   English   中英

Highcharts - 如何動態設置餅圖的背景顏色

[英]Highcharts - How to set Pie Chart's background color dynamically

我正在使用以下行根據某些條件更改一些視覺屬性

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

演示: https://jsfiddle.net/BlackLabel/p7yg386x/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM