高亮显示条形图列颜色在悬停时自动更改回默认颜色 [英] Highchart barchart column color auto change back to default color upon hover
问题描述
我有一些用javascript编写的代码,其中任何小于80的值都会导致条形图的列颜色变为红色。我已经做到了,但似乎有一个错误,而每当我将鼠标悬停在列上时,列颜色会变回默认颜色。
例如红色变成蓝色。
以下是我的代码:
功能(图表){
var max = 80 ;
$ .each(chart.series [ 2 ]。data, function (i,数据){
if (data.y< max){
data.graphic.attr({
fill :' RED'
});
chart.series [ 0 ]。data [i] .graphic.attr({
fill:' RED'
});
悬停:{color:' RED'};
chart.redraw();
}
});
}
我的尝试:
1.试图搜索在线解决方案,但在链接下面是我能得到的最好的。
http://stackoverflow.com/questions/7414287/how-do-you-更改每个类别的颜色 - 高 - 图表 -
.each(chart.series [ 2 ]。data, function (i,data){
if (data.y< max){
data.graphic.attr({
fill:' RED'
});
chart.series [ 0 ]。data [i] .graphic。 attr({
fill:' RED'
});
悬停:{color:' RED'};
chart.redraw();
}
});
}
我的尝试:
1.试图搜索在线解决方案,但在链接下面是我能得到的最好的。
http://stackoverflow.com/questions/7414287/how-do-you-改变最显色的-每个类别中之-highcharts列线图
Hi, I have some codes written in javascript where any value less than 80 will cause the barchart's column color to become red. I have did it but there seems to be a bug whereas the column color change back to default color everytime I hover over the column.
E.g. Red become blue.
Below are my codes:
function (chart) {
var max = 80;
$.each(chart.series[2].data, function (i, data) {
if (data.y < max) {
data.graphic.attr({
fill: 'RED'
});
chart.series[0].data[i].graphic.attr({
fill: 'RED'
});
hover: { color: 'RED' };
chart.redraw();
}
});
}
What I have tried:
1. Tried to search for online solution but below link is the best I can get.
http://stackoverflow.com/questions/7414287/how-do-you-change-the-colour-of-each-category-within-a-highcharts-column-chart
.each(chart.series[2].data, function (i, data) { if (data.y < max) { data.graphic.attr({ fill: 'RED' }); chart.series[0].data[i].graphic.attr({ fill: 'RED' }); hover: { color: 'RED' }; chart.redraw(); } }); }
What I have tried:
1. Tried to search for online solution but below link is the best I can get.
http://stackoverflow.com/questions/7414287/how-do-you-change-the-colour-of-each-category-within-a-highcharts-column-chart
这篇关于高亮显示条形图列颜色在悬停时自动更改回默认颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!