Highcharts-更改明细饼图上的切片颜色

问题描述 投票:3回答:2

我正在尝试更改饼图上的切片点颜色。向下钻取时,无法使用切片上的选择功能更改颜色。颜色始终会变回其父切片的颜色。

例如,当在父图表上单击绿色切片以进行向下钻取时,子图表上单击的任何切片都将变为绿色,即使我试图在plotOptions中设置的select事件中将其更改为黄色。但是,取消选择该颜色将通过单击另一个切片将颜色更改为黄色。

对我来说似乎是个虫子。

       $('#container').highcharts({
            chart: {
                type: 'pie'
            },
            title: {
                text: 'Browser market shares. November, 2013.'
            },
            subtitle: {
                text: 'Click the slices to view versions. Source: netmarketshare.com.'
            },
            plotOptions: {
                series: {
                    allowPointSelect: true,
                    point: {
                        events: {
                          select: function() {
                            this.update({color: 'yellow'});
                          }
                        }
                    },
                    dataLabels: {
                        enabled: true,
                        format: '{point.name}: {point.y:.1f}%'
                    }
                }
            },

            tooltip: {
                headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
                pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
            },

            series: [{
                name: 'Brands',
                colorByPoint: true,
                data: brandsData
            }],
            drilldown: {
                series: drilldownSeries
            }
        });

Here是小提琴。

highcharts pie-chart drilldown
2个回答
1
投票

在当前版本的Highcharts(Highcharts基本版本v7.2.1)中,一切正常。


0
投票

我在这个问题上有点迟了,但这是Highcharts的已知问题。代替使用select事件,而使用selected和unselected事件。这里有一个细微的差别,因为使用select常常不会在单击后立即触发。但是,这两个事件更加可靠。

https://api.highcharts.com/highcharts/plotOptions.pie.point.events.selecthttps://api.highcharts.com/highcharts/plotOptions.pie.point.events.unselect

© www.soinside.com 2019 - 2024. All rights reserved.