javascript - 当系列值全为 0 时,Highcharts 不会画线

标签 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] },
             ]

});

最佳答案

如果您将 "colors = $.map(colors, apply Gradient);" 行移动到调用 highcharts 之后,它应该可以工作。

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

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

关于javascript - 当系列值全为 0 时,Highcharts 不会画线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20435753/

相关文章:

javascript - 在 Laravel PHP 中创建一个受 WordPress 启发的媒体库

javascript - 如何使用$.ajax读取本地xml文件?

javascript - 检测用户何时离开网页的最佳方法?

jquery - Highchart 渲染器按最小值和最大值

highcharts 数据标签与 plotlines 值重叠

javascript - 如何动态获取对象的嵌套属性?

javascript - jQuery ajax() 函数忽略 Firefox 中的 dataType 参数

javascript - 在 highcharts 系列中传递 3 个值

javascript - 使用 HighCharts 在同一图表中显示多个饼图

highcharts - 仪表 Highcharts : Exterior circle color