admin管理员组文章数量:1291023
The following:
$.get('/api/ajax_prices/' + product +'/', afterEndexPricesLoaded)
Returns a json object
{"aaData": [
[1, "70.1700", "2008-12-29 11:23:00"],
[2, "70.2600", "2008-12-29 16:22:00"],
[3, "70.6500", "2008-12-30 11:30:00"],
[4, "70.8700", "2008-12-30 16:10:00"],
[5, "70.5500", "2009-01-02 11:09:00"],
[6, "70.6400", "2009-01-02 16:15:00"]
]}
I am trying to parse the json string into highchart
This is the code I am trying it with (data = above json string):
function afterPricesLoaded(data, textStatus, xhr) {
var options = {
chart: {
renderTo: 'graph'
},
title: {
text: 'Some text',
style: {
color: '#888888'
}
},
xAxis: {
type: 'datetime'
}
/*
series: [{
data: [
[Date.UTC(2011, 0, 0), 29.9],
[Date.UTC(2012, 0, 0), 71.5],
[Date.UTC(2013, 0, 0), 106.4]
]}
]*/
};
new Highcharts.Chart(options)
}
How can I get the data into highchart series?
Edit
Graphtype =
Example = /
The following:
$.get('/api/ajax_prices/' + product +'/', afterEndexPricesLoaded)
Returns a json object
{"aaData": [
[1, "70.1700", "2008-12-29 11:23:00"],
[2, "70.2600", "2008-12-29 16:22:00"],
[3, "70.6500", "2008-12-30 11:30:00"],
[4, "70.8700", "2008-12-30 16:10:00"],
[5, "70.5500", "2009-01-02 11:09:00"],
[6, "70.6400", "2009-01-02 16:15:00"]
]}
I am trying to parse the json string into highchart
This is the code I am trying it with (data = above json string):
function afterPricesLoaded(data, textStatus, xhr) {
var options = {
chart: {
renderTo: 'graph'
},
title: {
text: 'Some text',
style: {
color: '#888888'
}
},
xAxis: {
type: 'datetime'
}
/*
series: [{
data: [
[Date.UTC(2011, 0, 0), 29.9],
[Date.UTC(2012, 0, 0), 71.5],
[Date.UTC(2013, 0, 0), 106.4]
]}
]*/
};
new Highcharts.Chart(options)
}
How can I get the data into highchart series?
Edit
Graphtype = http://www.highcharts./demo/line-basic
Example = http://jsfiddle/kevink/9q4AT/
- That's a JavaScript object literal, not a JSON string. Which are you actually trying to use? – Matt Ball Commented May 8, 2012 at 13:21
- Why is this tagged as Python? I don't see any Python here. – Gareth Latty Commented May 8, 2012 at 13:23
- My bad, i'm working with python/django. I removed the tags – nelsonvarela Commented May 8, 2012 at 13:25
- which graph type is this? link pls – Zain Khan Commented May 8, 2012 at 13:26
1 Answer
Reset to default 7Is this what you're looking for?
http://jsfiddle/TWF6N/349/
$(function () {
data = {"aaData": [
[1, "70.1700", "2008-12-29 11:23:00"],
[2, "70.2600", "2008-12-29 16:22:00"],
[3, "70.6500", "2008-12-30 11:30:00"],
[4, "70.8700", "2008-12-30 16:10:00"],
[5, "70.5500", "2009-01-02 11:09:00"],
[6, "70.6400", "2009-01-02 16:15:00"]
]};
newData = data.aaData.map( function(row) {
return [ new Date(row[2]).getTime(), parseInt(row[1]) ];
});
console.log(newData);
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {
type: 'datetime'
},
series: [{
data: newData
}]
});
});
本文标签: javascripthow to parse json into highchartsStack Overflow
版权声明:本文标题:javascript - how to parse json into highcharts - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741523475a2383327.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论