我的目标:我想绘制多个系列的 HighStock 图表。数据由 AJAX 从 data.php 加载。data.php 的输出是一个 JSON 数组
我的问题:我不知道如何从 JSON 数组中获取数据
输出是例如
[[时间戳,value1,value2],[时间戳,value1,value2]]
系列 1 应该是 -> 时间戳和 value1
系列 2 应该是 -> 时间戳和 value2
这是我的代码
// Draw the chart
$(function(){
/* The chart is drawn by getting the specific data from "data.php".
* The configuration settings are transmitted by GET-Method. The output is an JSON-Array. */
$.getJSON('data.php',
function(data) {
chart = new Highcharts.StockChart
({
chart: { renderTo: 'chartcontainer', type: 'line' },
title: { text: 'You see the data of the last hour!' },
xAxis: { type: 'datetime', title: { text: 'time' } },
yAxis: { title: { text: 'unit' } },
series: [{ name: 'series1', data: data },{ name: 'series2', data: data }],
});
});
});
我想我必须改变
series: [{ name: 'series1', data: data },{ name: 'series2', data: data }],
但我不知道在做什么