I am reading data and loading in two dimensional array using following code by initializing 2d array (series)
where series is structure like as follows (highchart series)
series: [{ name: '' data: [] }]
Manual code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type='text/css'>
</style>
<script type='text/javascript'>
$(function () {
var options = {
chart :{
type: 'polygon',
renderTo: 'container',
},
title: {
text: 'Height vs Weight'
},
yAxis: {
title: false,
gridLineWidth:0,
lineWidth:0,
labels:{
enabled: false
}
},
series: [{},{}]
};
$.getJSON('data.json', function(data) {
options.series[0].data = data[0];
options.series[1].data = data[1];
var chart = new Highcharts.Chart(options);
})
});
</script>
</head>
<body>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
</body>
But i want to initialize dynamic array so that i can insert arrays(data[i]) dynamically.
data.json
[
[
[
153,
42
],
[
149,
46
],
[
149,
55
],
[
152,
60
]
],
[
[
253,
142
],
[
349,
146
],
[
349,
155
],
[
352,
160
]
]
]
dynamic code:
series: [[]]
$.getJSON('data.json', function(data) {
for (i=0; i<data.length(); i++) {
series[i].data = data[i];
}
})
above code does not seem to be working. Pls help me how can i solve my problem.