当系列值全为0时,Highcharts不会绘制线条

时间:2013-12-07 00:02:01

标签: javascript highcharts

如果使用渐变时数组中的所有值均为0,则Highcharts不会连接折线图系列中的点。

示例代码: http://jsfiddle.net/p2EYM/20/

这似乎与现已结束的问题found here有关。有没有人知道是否有针对此的解决方法?

With gradient applied

Without gradient applied

var colors =  ['#4572A7', 
               '#AA4643', 
               '#89A54E', 
               '#80699B', 
               '#3D96AE', 
               '#DB843D', 
               '#92A8CD', 
               '#A47D7C', 
               '#B5CA92'];

 var applyGradient = function(color) {
     return { radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
            stops: [
                [0, color],
                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')]
            ]
        };
 };

//works if you comment this out.
colors = $.map(colors,  applyGradient);

$('#container').highcharts({
    colors: colors,
    title: {
        text: 'Points with zero value are not connected by line'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May',
                     'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        offset: 0,
    },

    plotOptions: {
        series: {
            connectNulls: true
        }
    },
    yAxis: {
        min: 0,
    },
    series: [{ data: [2, 10, 40, 40, 40, 40, 40, 40, 40, 40, 30, 20] }, 
             { data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
             ]

});

2 个答案:

答案 0 :(得分:0)

如果移动“colors = $ .map(colors,apply Gradient);”行,在调用highcharts后它应该可以工作。

//works if you comment this out.
colors = $.map(colors,  applyGradient);

更新示例:http://jsfiddle.net/jQQF5/

答案 1 :(得分:0)

这是Highcharts的'bug',一般来说,对于SVG,请参阅this