自动加入Highcharts JS中缺失的数据空白 [英] Automatically join missing data gaps in Highcharts JS

查看:134
本文介绍了自动加入Highcharts JS中缺失的数据空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在考虑将 Highcharts JS 应用到我的应用程序中,并将月份作为x轴类别。

然而,我在数据上存在空白,并希望图表自动连接空白处。



例如,如果我没有3月份的任何数据,我希望2月和4月用线性连接。



使用highcharts演示,我已编辑这些数据用于说明默认情况下发生了什么:



http ://jsfiddle.net/kf26t/1/

  data:[7.0,10.0,null,14.5, 18.2,21.5,25.2,26.5,23.3,18.3,13.9,9.6] 

正如你所看到的, 2月到4月有一个突破。



我曾考虑过去月份没有来自类别的数据,但是这会给出一个扭曲的结果,因为二月和四月将会如果我要删除4个月,这种不准确的表示方式会被夸大。如果我要删除4个月,这个不准确的表示会被夸大:



http://jsfiddle.net/kf26t/ 2 /

 类别:['Jan','Feb',
'Jul','八月','九月','十月','十一月','十二月']

我可以想到的解决方案是计算几个月之间的平均值,但我不希望显示平均值。



是否有任何内置的填充方式Highchart JS中的差距?如果没有,是否有一个更好的解决方案,我所建议的?






另外,有没有一种分离x基于价值的轴?所以如果没有三月份的月份,二月份和四月份会出现两个月的距离。



当整数是x轴时,这也会很有用。例如,如果我有1,2,10,我不希望这些被均匀地传播。

应该使用这种类型的行为 Highstocks JS 而不是Highcharts JS 。

 数据:[
[Date.UTC(2013,0,1),1],
[Date.UTC(2013,1,1),2],
[Date.UTC(2013,3,1),4],
[Date.UTC(2013,4,1) ,5],
[Date.UTC(2013,5,1),6],
[Date.UTC(2013,6,1),7],
[Date.UTC (2013,7,1),8],
[Date.UTC(2013,8,1),9],
[Date.UTC(2013,9,1),10],
[Date.UTC(2013,10,1),11],
[Date.UTC(2013,11,1),12]
]

现场演示: http://jsfiddle.net/q2kSf/


I'm currently looking to implement Highcharts JS into my application, using months as the x-axis categories.

However, I have gaps in my data, and wish for the chart to automatically connect the gaps.

For example, if I don't have any data for March, I want February and April to connect with a linear line.

Using the highcharts demo, I have edited the data to demonstrate what currently happens by default:

http://jsfiddle.net/kf26t/1/

data: [7.0, 10.0, null, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]

As you can see, there is a break in the line between February and April.

I've considered removing the months with no data from the categories, but then this will give a skewed result as February and April will be an equal distance away from each other as April and May, which won't give an accurate representation.

If I am to remove 4 months, this inaccurate representation is exaggerated:

http://jsfiddle.net/kf26t/2/

categories: ['Jan', 'Feb', 
                    'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

The only solution I can think of is to calculate the average between the months, but I don't wish to display averages.

Is there any built-in way of filling in these gaps in Highchart JS? If not, is there a neater solution to what I have suggested?


Alternatively, is there a way of seperating the x-axis based on value? So if there is no March month, February and April appear the distance of 2 months away.

This would also be useful when integers are the x-axis. For example if I had "1, 2, 10", I wouldn't want these to be evenly spread.

解决方案

For this type of behaviour Highstocks JS should be used instead of Highcharts JS.

data: [
       [Date.UTC(2013,  0, 1), 1],
       [Date.UTC(2013, 1, 1), 2 ],
       [Date.UTC(2013, 3,  1), 4],
       [Date.UTC(2013, 4,  1), 5 ],
       [Date.UTC(2013, 5, 1), 6 ],
       [Date.UTC(2013, 6, 1), 7],
       [Date.UTC(2013,  7,  1), 8],
       [Date.UTC(2013,  8,  1),9],
       [Date.UTC(2013, 9, 1), 10],
       [Date.UTC(2013, 10, 1), 11],
       [Date.UTC(2013, 11, 1), 12]
      ]

Live Demo: http://jsfiddle.net/q2kSf/

这篇关于自动加入Highcharts JS中缺失的数据空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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