Highcharts dataGrouping基于列值的近似列点颜色?

时间:2014-11-18 15:05:34

标签: highcharts highstock

如何根据列值将近似列着色?

1 个答案:

答案 0 :(得分:0)

经过大量挖掘和一些Highcharts支持的消息后,我终于成型了。

在Highcharts完成后回调函数:

}, function(chart) { // on complete

    // Color approximated columns by value
    var series = chart.series[0];
    delete series.pointAttr.hover.fill;
    delete series.pointAttr[''].fill;
    // There are only values 0-5 as integers in this data series
    var colors = { 0: '#fff',  1: '#999', 2: '#777', 3: '#555', 4: '#333' };
    for (var i = 0; i < series.points.length; i++) {
        series.points[i].graphic.attr("fill", colors[ series.points[i].y ] );
    }
});

xAxis在缩放事件后重新着色的事件:

xAxis : [ {
    events: {
        afterSetExtremes: function(event){
            // Color approximated columns by value, again after zoom
            var chart = angular.element('#presence-chart').highcharts();
            var series = chart.series[0];
            delete series.pointAttr.hover.fill;
            delete series.pointAttr[''].fill;
            var colors = { 0: '#fff',  1: '#50117a', 2: '#7631a0', 3: '#c171ed', 4: '#72accf' };
            for (var i = 0; i < series.points.length; i++) {
                series.points[i].graphic.attr("fill", colors[ series.points[i].y ] );
            }
        }
    }
} ],

有人可以在这里填写如何悬停颜色,就好像你注释掉了#34;删除series.pointAttr [&#39;&#39;]。填充;&#34;然后在悬停后,酒吧会留下那种悬停颜色?