I have a JSON in the following format [{"usage_idle": 99.49824385418651, "time": "2017-06-12T10:15:20Z"}, {"usage_idle": 99.59798994937717, "time": "2017-06-12T10:15:20Z"}]
How can I plot a time series graph with this using highchart? I am using python in the backend.
答案 0 :(得分:1)
将数据格式映射到下面的highcharts点选项的示例:
const json = [
{"usage_idle": 99.49824385418651, "time": "2017-06-12T10:15:20Z"},
{"usage_idle": 99.59798994937717, "time": "2017-06-12T10:15:21Z"}
]
const options = {
xAxis: { type: 'datetime' },
yAxis: { type: 'logarithmic' },
series: [{
data: json.map((o) => ({ x: Date.parse(o.time), y: o.usage_idle })),
type: 'column'
}]
}
const chart = Highcharts.chart('container', options)