I am trying to show a simple graph using Highcharts. It was working pretty well, but at one point for unknown reasons my line just stopped showing up. The screen seems empty and the points are only visible when mouse hovers over them.
我试图使用Highcharts显示一个简单的图形。它工作得很好,但有一点因为未知原因我的线路刚刚停止出现。屏幕显示为空,只有当鼠标悬停在屏幕上时才能看到这些点。
I added a dummy series to check and this is how it looks now:
我添加了一个虚拟系列来检查,这就是它现在的样子:
The code producing the graph is:
生成图表的代码是:
$(function () {
$.get('data/data.txt', function (data) {
// Preparing data
var formatted = []
var lines = data.split('\n');
$.each(lines, function (lineNo, line) {
var items = line.split('-');
formatted.push(
[
Date.UTC(
items[1],
items[2],
items[3],
items[4],
items[5],
items[6]),
parseInt(items[0])
]
);
});
console.log(formatted)
// Data prepared, now display it
$('#container').highcharts({
xAxis: {
type: 'datetime'
},
series: [
{
data: formatted,
name: "Prize pool"
},
{
name: 'Tokyo',
data: [[1433620800000,7.0], [1433620822000,6.9], [1433620824000,9.5], [1433620826000,14.5], [1433620828000,18.2]]
},
]
});
})
});
The data received is correctly formatted, as seen on the screenshot. It has the same structure and very similar values as the 'Tokyo' series. However, only the latter is visible. Changing line widths or colors did nothing. There is no other customization of the graph. What is going on here?
收到的数据格式正确,如屏幕截图所示。它具有与“东京”系列相同的结构和非常相似的值。但是,只有后者是可见的。改变线宽或颜色什么也没做。没有其他图表自定义。这里发生了什么?
Also the last point of the "hidden" series is completely ignored and never shown.
此外,“隐藏”系列的最后一点完全被忽略,从未显示过。
(视频供参考)
1 个解决方案
#1
Turns out that the graph cannot handle empty data well - in the part where I prepare data to be shown there has to be a handling of empty line (which may occur at the end of the file), and if there is such a line, just ignore it.
事实证明,图形无法很好地处理空数据 - 在我准备显示数据的部分必须处理空行(可能出现在文件的末尾),如果有这样的行,只是忽略它。
#1
Turns out that the graph cannot handle empty data well - in the part where I prepare data to be shown there has to be a handling of empty line (which may occur at the end of the file), and if there is such a line, just ignore it.
事实证明,图形无法很好地处理空数据 - 在我准备显示数据的部分必须处理空行(可能出现在文件的末尾),如果有这样的行,只是忽略它。