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/,但它要求所有切片都是相同的颜色。有没有办法制作一个带有在悬停时改变颜色的切片的多色图表?

4

1 回答 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);
                }
            }
        },
    }

小提琴示例

于 2013-08-27T20:39:55.377 回答