无法在Highcharts中断开[null,null]和不规则间隔的折线图

时间:2013-08-06 01:19:48

标签: javascript highcharts

当我在我的JSON数据中包含一个null元素用于Highcharts图表时,它可以很好地搞砸了绘图。以下是针对不规则时间间隔的工作略微修改的Highcharts API演示,我的数据已添加到单个系列中:

http://jsfiddle.net/G2fJT/

        series: [{
            name: 'Winter 2007-2008',
            data: [
                [1375088618000, 23.03],
                [1375088918000, 23.02],
                [1375089218000, 24.03],
                [1375089518000, 25.02],
                [1375089818000, 24.02],
                [1375090118000, 23.02],
                [1375090418000, 23.25],
                [1375090718000, 23.51],
                [1375091018000, 27.02],
                [1375091318000, 28.02],
                [1375091618000, 29.02],
                [1375091918000, 23.02],
                [1375092218000, 23.02],
                [1375092518000, 24.02],
                [1375092818000, 25.02],
                [1375093118000, 26.02],
                [1375093418000, 27.02],
                [1375093718000, 27.02],
                [1375094018000, 26.02]
            ]
        }]

现在,如果我添加一个null元素,这会导致图表中出现空白,因为connectNulls默认为false,我明白了:

http://jsfiddle.net/qpNCP/

        series: [{
            name: 'Winter 2007-2008',
            data: [
                [1375088618000, 23.03],
                [1375088918000, 23.02],
                [1375089218000, 24.03],
                [1375089518000, 25.02],
                [1375089818000, 24.02],
                [1375090118000, 23.02],
                [1375090418000, 23.25],
                [1375090718000, 23.51],
                [1375091018000, 27.02],
                [1375091318000, 28.02],
                [1375091618000, 29.02],
                [null, null],
                [1375091918000, 23.02],
                [1375092218000, 23.02],
                [1375092518000, 24.02],
                [1375092818000, 25.02],
                [1375093118000, 26.02],
                [1375093418000, 27.02],
                [1375093718000, 27.02],
                [1375094018000, 26.02]
            ]
        }]

有没有办法使用null来以一种不规则间隔的方式分解图表?

1 个答案:

答案 0 :(得分:2)

你快到了。试试[1375091618000, null]

Demo