highcharts 折线图中的缺失值导致没有线,只有点 [英] missing value in highcharts line graph results in no line, just points

查看:58
本文介绍了highcharts 折线图中的缺失值导致没有线,只有点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请看这个:

http://jsfiddle.net/2rNzr/

var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        data: [29.9, '', 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]

});

您会注意到数据中有一个空白值(第二个值),这会导致折线图显示不正确.

you'll notice that the data has a blank value in it (the second value), which causes the line graph to display incorrectly.

这是一个错误吗?

指定缺失值以便折线图中会有间隙的正确方法是什么?即我不希望折线图简单地在点 1 和 3 之间画一条线.

What is the correct way of specifying a missing value so there will be a gap in the line graph? i.e. I would NOT want the line graph to simply draw a line between points 1 and 3.

非常感谢您制作了出色的产品!

Many thanks for producing an excellent product!

托尼.

推荐答案

您需要将缺失值更改为 null,并指定您想要一条穿过现有值的线/样条.

You will need to change your missing values to null, and specify that you want a line/spline through the existing values.

var chart = new Highcharts.Chart({

    chart: {
        defaultSeriesType: 'line',
        renderTo: 'container'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        data: [29.9, null, 106.4, 129.2, 144.0, 176.0, null, 148.5, 216.4, 194.1, 95.6, 54.4],
    }]

});

参见 http://jsfiddle.net/xynZT/,以 defaultSeriesType: 'spline' 为例.

see http://jsfiddle.net/xynZT/ with defaultSeriesType: 'spline' as an example.

这篇关于highcharts 折线图中的缺失值导致没有线,只有点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆