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

问题描述

请看看这个:

  var chart = new Highcharts.Chart({

图:{
renderTo:'container'
},

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

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

});

您会注意到数据中有一个空白值(第二个值)线图显示不正确。



这是一个错误吗?



什么是指定缺失值,所以线图中会出现间隙?即我不希望线条图简单地在点1和点3之间划一条线。



非常感谢您生产出优质的产品!



Tony。

解决方案

您需要将缺少的值更改为null,并指定您想要

  var chart = new Highcharts.Chart({

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

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

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

});

参见以defaultSeriesType:'spline'为例。


please take a look at this:

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.

Is this a bug?

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!

Tony.

解决方案

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

});

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

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

08-29 04:05