首页 文章

highcharts:在悬停时更改饼图切片的颜色

提问于
浏览
3

当一片饼图悬停在我想要更改为指定的悬停颜色时,然后在鼠标离开该切片后再更改回原始颜色 .

这里的文档(http://api.highcharts.com/highcharts#plotOptions.series.marker.states.hover)使得它看起来像以下工作,但我没有任何运气:

http://jsfiddle.net/pixeloco/ztJkb/3/

plotOptions: {
   series: {
      marker: {
        states: {
          hover: {
            fillColor: 'black'
          }
        }
      }
   }
},

我找到了这个解决方案http://jsfiddle.net/r6p7E/6/,但它要求所有切片都是相同的颜色 . 有没有办法让多色图表的切片在悬停时改变颜色?

1 回答

  • 11

    看起来你需要这些选项:

    series: {
            states: {
                hover: {
                    enabled: false
                }
            },
            point: {
                events: {
                    mouseOver: function () {
                        this.options.oldColor = this.color;
                        this.graphic.attr("fill", "black");
                    },
                    mouseOut: function () {
                        this.graphic.attr("fill", this.options.oldColor);
                    }
                }
            },
        }
    

    FIDDLE EXAMPLE

相关问题