我在创建包含一些嵌套在数组中的数据的图表时遇到问题。
索引.html
<div id="chartDiv" style="width: 100%; height: 400px;"></div>
捆绑.js
HTTP_GET_REQUEST.onreadystatechange = function () {
// OF TJE HTTP_REQUEST IS DONE FETCHING ITS DATA THEN PARSE JSON AND OUTPUT TO INDEX.HTML
if (HTTP_GET_REQUEST.readyState === 4) {
URL = URL.toString();
var JSON_RESPONSE = JSON.parse(HTTP_GET_REQUEST.responseText);
var JSON_TIMESTAMP_DATA = JSON_RESPONSE["chart"]["result"][0]["timestamp"];
var JSON_CLOSE_DATA = JSON_RESPONSE["chart"]["result"][0]["indicators"]["quote"][0]['close'];
var JSON_HIGH_DATA = JSON_RESPONSE["chart"]["result"][0]["indicators"]["quote"][0]['high'];
var JSON_LOW_DATA = JSON_RESPONSE["chart"]["result"][0]["indicators"]["quote"][0]['low'];
var JSON_OPEN_DATA = JSON_RESPONSE["chart"]["result"][0]["indicators"]["quote"][0]['open'];
var JSON_VOL_DATA = JSON_RESPONSE["chart"]["result"][0]["indicators"]["quote"][0]['volume'];
var JOINED_DATA = [
JSON_TIMESTAMP_DATA,
JSON_CLOSE_DATA,
JSON_HIGH_DATA,
JSON_LOW_DATA,
JSON_OPEN_DATA,
JSON_VOL_DATA
]
var points = [];
points.push({x:JSON_TIMESTAMP_DATA, y:JSON_CLOSE_DATA})
JSON_RESPONSE = JSON_RESPONSE;
console.log(points[0])
const divChart = document.getElementById("chartDiv")
const newChart = new JSC.Chart("chartDiv", {
type: 'line',
// Pass Points to Series
series: [{
name: 'Close Price',
points: points[0]
}],
xAxis_scale_type: "time"
});
};
};
我收到了一些警告,我无法让图表映射我的 X 值数组:TIMESTAMP_DATA 和 Y 值:CLOSE_DATA
如果我换行 -
从:
series: [{
name: 'Close Price',
points: points[0]
}],
至:
series: [{
name: 'Close Price',
points: points[0]['x']
}],
我不知道如何解决这个问题。