Colors highcharts:悬停时更改饼图切片的颜色
当饼图的一部分悬停在上方时,我希望它更改为指定的悬停颜色,然后在鼠标离开该部分后更改回其原始颜色 此处的文档()使以下内容看起来似乎可以工作,但我没有任何运气:Colors highcharts:悬停时更改饼图切片的颜色,colors,highcharts,hover,Colors,Highcharts,Hover,当饼图的一部分悬停在上方时,我希望它更改为指定的悬停颜色,然后在鼠标离开该部分后更改回其原始颜色 此处的文档()使以下内容看起来似乎可以工作,但我没有任何运气: 我找到了这个解决方案,但它要求所有切片的颜色都相同。有没有一种方法可以让一张多色的图表在悬停状态下改变颜色 看起来您需要以下选项: series: { states: { hover: { enabled: false }
我找到了这个解决方案,但它要求所有切片的颜色都相同。有没有一种方法可以让一张多色的图表在悬停状态下改变颜色 看起来您需要以下选项:
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);
}
}
},
}
完美!这回答了我原来的问题,但是。。。你知道为什么同样的方法不适用于条形图吗?悬停时该部分确实会更改,但如果将其悬停多次,则不会返回到原始颜色更改
this.options.oldColor=this.color代码>到this.options.oldColor=this.graphic.fill代码>
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);
}
}
},
}