highcharts correct json input
Posted
by
Linus
on Stack Overflow
See other posts from Stack Overflow
or by Linus
Published on 2012-04-13T04:32:39Z
Indexed on
2012/04/13
5:28 UTC
Read the original article
Hit count: 496
JSON
|highcharts
i am trying to do a basic column chart. i have looked the examples but not sure why i do not see any graph (lines). I can see the title and subtitle appear an no javascript errors in firebug. any help please
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column',
events: {
load: requestData
}
},
title: {
text: 'Some title'
},
subtitle: {
text: 'subtitle'
},
xAxis: {
categories: [],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'y-Axis',
align: 'high'
}
},
tooltip: {
formatter: function() {
return ''+
this.series.name +': '+ this.y +' ';
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series:[]
});
});
function requestData() {
$.ajax({
url: 'test.json',
success: function(data) {
options.series[0].push(data);
chart.redraw();
},
cache: false
});
}
});
my json input file is below
[
{
name: 'name1',
y: [32.6,16.6,1.5]
}, {
name: 'name2',
y: [6.7,0.2,0.6]
}, {
name: 'name3',
y: [1,3.7,0.7]
}, {
name: 'name4',
y: [20.3,8.8,9.5]
},{
name: 'name5',
y: [21.5,10,7.2]
}, {
name: 'name6',
y: [1.4,1.8,3.7]
}, {
name: 'name7',
y: [8.1,0,0]
}, {
name: 'name8',
y: [28.9,8.9,6.6]
}
]
© Stack Overflow or respective owner