当我点击这个时,一个部分的Highcharts饼颜色

OOO*_*OOO 2 api jquery highcharts pie-chart

如何修改此代码http://jsfiddle.net/r6p7E/6/以查看每次我选择时使用相同颜色选择的部分?只有当我点击这个时,我希望它是黄色的.

代码:

  $(function () {

            Highcharts.theme = {
            colors: ['#242c4a'],
            chart: {
             width: 350,
                backgroundColor: {
                    linearGradient: [0, 0, 500, 500],
                    stops: [
                        [0, 'rgb(255, 255, 255)'],
                        [1, 'rgb(240, 240, 255)']
                    ]
                }, 
            },

        };

        // Apply the theme
        Highcharts.setOptions(Highcharts.theme);

        // Build the chart
        $('#container').highcharts({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: 'Our Projects'
            },

            plotOptions: {

                pie: {


                    borderColor: '#48588c',
                    borderWidth: 7,
                     slicedOffset: 10,                     
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: false

                    }

                },

                series: {

                point: {
                    events: {
                        select: function() {

                        }
                    }
                }
            }


            },
              series: [{
                type: 'pie',
                name: 'Browser share',
                dashStyle: 'LongDashDotDot',
                data: [
                    ['Firefox',   45.0],
                    ['IE',       26.8],
                    {
                        name: 'Chrome',
                        y: 12.8,
                        sliced: true,
                        selected: true
                    },
                    ['Safari',    8.5],
                    ['Opera',     6.2],
                    ['Others',   0.7]
                ]
            }]
        },

         function(chart) { // on complete


        var renderer = new Highcharts.Renderer(
            $('#container')[0],  50, 50);

        chart.renderer.circle(175, 216, 22).attr({
            fill: '#e7e620',

            'stroke-width': 5,
            zIndex: 3
        }).add();
        }



        );
    });
Run Code Online (Sandbox Code Playgroud)

Jac*_*bit 5

这可能是你真正想要的.但根据你所要求的这个小提琴给你的是:http://jsfiddle.net/r6p7E/8/

您可以将其更改为click事件,而不是mouseOver事件:

point: {
    events: {
        click: function () {
            this.graphic.attr({
                fill: 'yellow'
            });
        }
    }
},
Run Code Online (Sandbox Code Playgroud)

当然,一旦你离开,mouseOut事件会杀死颜色,但我不确定这是否是你想要的,因为你没有提到它.

编辑:这个小提琴保留黄色的颜色,直到它被取消选择(或另一个被选中):http://jsfiddle.net/r6p7E/12/

allowPointSelect: true,
slicedOffset: 0,
point: {
    events: {
        select: function () {
            this.update({color: 'yellow'});
        },
        unselect: function () {
            this.update({color: '#CCCCCC'});
        }
    }
}
Run Code Online (Sandbox Code Playgroud)