使用negativeColor属性悬停的highcharts给出了错误的颜色
我有一个系列,我正在绘制为“column”类型,它可以是负数也可以是正数。我希望正极为绿色,负极为红色,因此我添加了以下函数使用negativeColor属性悬停的highcharts给出了错误的颜色,highcharts,Highcharts,我有一个系列,我正在绘制为“column”类型,它可以是负数也可以是正数。我希望正极为绿色,负极为红色,因此我添加了以下函数 function redrawColumns(chart){ $(chart.series[0].data).each(function(i,e){ if (e.y < 0 ){ e.graphic.attr({fill:'rgba(128,0,0,1)'}); }
function redrawColumns(chart){
$(chart.series[0].data).each(function(i,e){
if (e.y < 0 ){
e.graphic.attr({fill:'rgba(128,0,0,1)'});
}
});
随后以通常的格式声明原始系列
series: [
type: 'column',
name: 'Sentiment',
data: senti,
pointWidth: .3,
//color: 'green',
color: 'rgba(34,139,34,1)',
threshold: 0,
shadow: false,
borderWidth: 0,
我有一个选项,每当我滚动到条形图的任何部分时,它都会显示值,但问题是我滚动到的任何条形图都会变成绿色并保持绿色。我怎样才能确保悬停不会改变颜色(通过任何形式的鼠标移动来保持)。也许我应该移动那个函数?此外,根据数据转储到文本文件,每分钟刷新和打印一次
这是我的马克笔,不要认为这有什么区别
//marker hover option for the sentiment chart
column: {
cursor: 'pointer',
point: {
events: {
click: function () {
location.href = 'https://www.randomsite.com';
}
}
},
states: {
hover: {
enabled: true,
lineWidth: .6,
halo: {
size: 2,
attributes: {
fill: Highcharts.getOptions().colors[2],
'stroke-width': 1,
stroke: Highcharts.getOptions().colors[1]
}
}
}
}
},
您不应该(不必)为负值指定函数
而是使用Highchart的属性来解决问题:
series: [
type: 'column',
color: 'rgba(34,139,34,1)',
negativeColor: 'rgba(128,0,0,1)',
...
参考一下highchart的演示示例
现在我们仍然有悬停颜色的问题。这是
但是这个错误在上一个月就解决了。因此,如果您使用最新版本的Highcharts,它应该可以工作
series: [
type: 'column',
color: 'rgba(34,139,34,1)',
negativeColor: 'rgba(128,0,0,1)',
...