簡體   English   中英

如何更改highchart圓環圖內圈的背景顏色?

[英]How to change background color of inner circle of highchart doughnut chart?

需要更改 highchart 甜甜圈的背景顏色

預期結果

在此處輸入圖像描述

取得的成果

隨着背景顏色的變化

JS Fiddle Link: https://jsfiddle.net/shantanugade/f5ojh13z/1/

需要幫助! 提前致謝!

更新:-我嘗試更改背景顏色-

添加背景顏色后的結果

您可以簡單地更改圖表 object 上的 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 上 colors 數組上的最后一個值

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
                    }
                }
            },

        },

您可以使用Highcharts.SVGRenderer class 添加一個圓圈作為背景:

    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

https://api.highcharts.com/highcharts/chart.events

暫無
暫無

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

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