javascript Highcharts 在悬停时更改列颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19146049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 14:32:25  来源:igfitidea点击:

Highcharts Change column color on hover

javascriptjqueryhighcharts

提问by TheSharpieOne

It seems like this should be simple, but I cannot figure it out and nothing in the API documentation seems to be working. I want to change the color of a single column when that column is hovered.

看起来这应该很简单,但我无法弄清楚,而且 API 文档中的任何内容似乎都不起作用。我想在该列悬停时更改该列的颜色。

I have tried setting each point in the data to have a hover state with colorFill, but to no avail, i have also tried setting it in plotOptionsin the columnattribute

我尝试将数据中的每个点设置为具有悬停状态colorFill,但无济于事,我也尝试将其设置plotOptionscolumn属性中

Here is a little something to help: http://jsfiddle.net/TheSharpieOne/DMcQ3/

这里有一些帮助:http: //jsfiddle.net/TheSharpieOne/DMcQ3/

Tried this: http://api.highcharts.com/highcharts#series.data.marker.states.hover.fillColor
Tried this: http://api.highcharts.com/highcharts#plotOptions.column.states.hover.marker.fillColor
Both did not work. Not sure what else to do.

试过这个:http: //api.highcharts.com/highcharts#series.data.marker.states.hover.fillColor
试过这个:http: //api.highcharts.com/highcharts#plotOptions.column.states.hover.marker .fillColor
两者都不起作用。不知道还能做什么。

I found this: Highcharts: changing color on hover ranking chartbut it changes the whole series, not just the current point/column.

我发现了这个:Highcharts:改变悬停排名图表上的颜色,但它改变了整个系列,而不仅仅是当前的点/列。

回答by SpaceDog

You were almost there, but you want to set colorand not fillColor(and not on the marker)-- I added this to the chart declaration:

你快到了,但你想设置color而不是fillColor(而不是在标记上)——我将它添加到图表声明中:

plotOptions: {
    column: {
        states: {
            hover: {
                color: '#000000'                                                           
            }
        }
    }
}

And removed the statesstuff from the column data, that seems to work in this fiddle.

states从列数据中删除了这些东西,这似乎在这个fiddle 中有效

And, yes, that's not very clear in the documentation ...

而且,是的,这在文档中不是很清楚......