In a servlet I send ArrayList on JSP page and try to insert ArrayList into JavaScript(Highcharts), but I don't have any idea how to do it.
This code below is the code that take ArrayList from servlet on JSP page.
<c:forEach items="${elecMeterRecordList}" var="el" >
${el.electricity_meter_record_unit}
</c:forEach>
And the code below is Javascript(highcharts) that I want to display ArrayList that sent from servlet.
<script type="text/javascript">
$(function() {
$('#container').highcharts(
{
chart : {
type : 'line'
},
title : {
text : 'Monthly Average Temperature'
},
subtitle : {
text : 'Source: WorldClimate.com'
},
xAxis : {
categories : [ 'Jan', 'Feb', 'Mar',
'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov',
'Dec' ]
},
yAxis : {
title : {
text : 'Temperature (°C)'
}
},
plotOptions : {
line : {
dataLabels : {
enabled : true
},
enableMouseTracking : false
}
},
series : [
{
name : 'Water',
data : [ 7.02, 6.91, 9.53,
14.54, 18.41, 21.54,
25.21, 26.54, 23.35,
18.23, 13.91, 9.26 ]
},
{
name : 'Electricity',
data : [ 3.49, 4.25, 5.67,
8.35, 11.59, 15.26,
17.20, 16.63, 14.32,
10.35, 6.56, 4.08 ]
} ]
});
});
</script>
The code here, I want to replace these data with the ArrayList.
data : [ 3.49, 4.25, 5.67,
8.35, 11.59, 15.26,
17.20, 16.63, 14.32,
10.35, 6.56, 4.08 ]