I wrote this javaScript function to produce graphs for inputed csv files. The addresses of the multiple csv files are in graph_data.
The reason I am making this as a loop and not separate is because the number of csv files that are in "graph_data" can vary.
This function seems to work but it one shows the graph of the last csv and not the earlier csv files. If I change how many times the loop runs it produces the other graphs but never all of them together on the same HTML page.
I think Highcharts is overwriting the previous graphs but I don't know how to fix it.
Javascript:
<script type="text/javascript">
var arrayLength = {{graph_data}}.length;
for (var i = 0; i < arrayLength; i++) {
data = ({{graph_data}}[i]);
var container="#container"+i;
$.get(data, function(csv) {
$(container).highcharts({
chart: {
zoomType: 'x',
type: 'column',
renderTo: 'container'+i
},
data: {
csv: csv,
lineDelimiter: "\n"
},
title: {
text: "title"
},
yAxis: {
title: {
text: 'Units'
}
},
plotOptions: {
series: {
marker: {
enabled: false
}
}
}
});
});
}
</script>
HTML:
<div id="container0" style="width:100%; height:1400px;"></div>
<div id="container1" style="width:100%; height:1400px;"></div>