如何将缺失数据的高图默认为0 [英] How to make highcharts default to 0 for missing data

查看:111
本文介绍了如何将缺失数据的高图默认为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有1分钟的时间间隔。我想在一个缺少点的图表中显示0。



我找到了xAxis.ordinal,并将其关闭,以显示时间序列的正确间隔。问题是,它直接在点之间划线,而不会为0丢失数据。

解决方案

- 处理数据,用 0 替换 null

  var withNulls = [null,12,23,45,3.44,null,0]; 
var noNulls = withNulls.map(function(item){
return(item === null)?0:item;
});

保存在jsfiddle上的示例: http://jsfiddle.net/7mhMP/


I have a time series at a 1 minute interval. I would like to display that in a chart with missing points as 0.

I've found xAxis.ordinal and turned that off which displays the time series properly spaced out. The issue is that it draws lines between the points directly without going to 0 for the missing data.

解决方案

One way is by pre-processing the data, replacing null with 0:

var withNulls = [null, 12, 23, 45, 3.44, null, 0];
var noNulls = withNulls.map(function (item) {
    return (item === null) ? 0 : item;
});

Example saved on jsfiddle: http://jsfiddle.net/7mhMP/

这篇关于如何将缺失数据的高图默认为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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