由网友(清风若过)分享简介:我正在为我的项目使用柱形图.我编写了一个自定义函数,根据 y 值对图表的每个条形进行着色.当我初始化图表时,这工作正常.当我将鼠标悬停在图表上时,条形图的颜色会恢复为默认值,而我的自定义颜色永远不会返回.I am using the column charts for my project. I have writt...
我正在为我的项目使用柱形图.我编写了一个自定义函数,根据 y 值对图表的每个条形进行着色.当我初始化图表时,这工作正常.当我将鼠标悬停在图表上时,条形图的颜色会恢复为默认值,而我的自定义颜色永远不会返回.
I am using the column charts for my project. I have written a custom function that colors each bar of the chart based upon its y value. This works fine when I initialize the chart. As I hover over the chart, the color of the bar goes back to the default and my custom colors never return.
我尝试在悬停时禁用,但这似乎不起作用.即使将鼠标悬停在栏上,我也不希望颜色发生变化.有什么建议吗?
I have tries disabling on hover but that doesn't seem to work. I don't want the color to change even when hovered over the bar. Any suggestions?
推荐答案
你更新颜色的方式不对,使用 point.update()
代替:http://jsfiddle.net/CaPG9/8/
You are updating color in a wrong way, use point.update()
instead: http://jsfiddle.net/CaPG9/8/
$('#container').highcharts({
chart: {
type: 'bar'
},
tooltip: {
valueSuffix: ' millions'
},
series: [{
name: 'Year 1800',
data: [107, 31, 635, 203, 2]
}]
},function(chart){
var max = 200;
$.each(chart.series[0].data,function(i,data){
if(data.y > max)
data.update({
color:'red'
});
});
});
相关推荐
最新文章