Javascript csv实时数据图表
我的数据显示不正确。 我有这样的数据:“1456135353.000000 | 5424492576222277 | 8156610153681827” “14561353”是指时间 “5424492576222277”表示第一个X “8156610153681827”表示第二个X 这是我的代码:Javascript csv实时数据图表,javascript,csv,highcharts,Javascript,Csv,Highcharts,我的数据显示不正确。 我有这样的数据:“1456135353.000000 | 5424492576222277 | 8156610153681827” “14561353”是指时间 “5424492576222277”表示第一个X “8156610153681827”表示第二个X 这是我的代码: var chart /** * Request data from the server, add it to the graph and set a timeout * to requ
var chart
/**
* Request data from the server, add it to the graph and set a timeout
* to request again
*/
function requestData () {
$.ajax({
url: 'api/chart',
dataType: 'text',
success: function (point) {
var series = chart.series[0].push
// longer than 20
// add the point
chart.series[0].addPoint(point, true)
// call it again after one second
setTimeout(requestData, 1000)
},
cache: false
})
}
$(document).ready(function () {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'line',
events: {
load: requestData
}
},
title: {
text: 'XSnews Graph'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150,
maxZoom: 20 * 1000
},
yAxis: {
gridLineColor: '#197F07',
gridLineWidth: 1,
title: {
text: 'GB',
margin: 80
}
},
series: [{
name: 'Time',
data: []
}]
})
})
我不熟悉海图,所以我不知道我做错了什么。
我需要解析它吗?在添加点之前,需要先解析数据。大概是这样的:
success: function (point) {
var options = point.split("|"),
x = parseFloat(options[0]) * 1000,
y_1 = parseFloat(options[1]),
y_2 = parseFloat(options[2]);
chart.series[0].addPoint([x, y_1], true);
setTimeout(requestData, 1000)'
}
看一下文档,我不清楚期望的结果是什么。这是否意味着两个系列,每个系列在同一时间戳上都有一个y值(x值)?