I am new to JS and I am having trouble with feeding my data to Highcharts for visualization.
Say I have a following JSON data
{
"is_error":0,
"keys":[
"count",
"created_date",
"source",
"gender_id",
"type"
],
"error":"",
"values":[
{
"count":3,
"created_date":"2017-08-09",
"source":"",
"gender_id":"",
"type":"Organization"
},
{
"count":1,
"created_date":"2017-08-10",
"source":"",
"gender_id":"",
"type":"Organization"
},
{
"count":2,
"created_date":"2017-08-09",
"source":"",
"gender_id":1,
"type":"Individual"
},
{
"count":1,
"created_date":"2017-08-12",
"source":"",
"gender_id":1,
"type":"Individual"
}
]
}
How would I transform it to a Highcharts series array so that it looks something like this:
series: [{
name: 'Organization',
data: [
[Date.UTC(2017, 08, 09), 3],
[Date.UTC(2017, 08, 10), 1],
]
}, {
name: 'Individual',
data: [
[Date.UTC(2017, 08, 09), 2],
[Date.UTC(2017, 08, 12), 1],
]
}]
In the JSON I have some information which isn't required (source and gender_id).
Here is my example in JSFiddle with full big data set that I want to transform using JS and fit it into a Highchart.
Is there an easy way to do transform a JSON like this to something which can be plugged into a Highchart?
检查这一小提琴并根据您的需要进行更新
series: chartData
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.