<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.google.gson.Gson"%>
<%@ page import="com.google.gson.JsonObject"%>
<%
Gson gsonObj = new Gson();
Map<Object,Object> map = null;
List<Map<Object,Object>> list = new ArrayList<Map<Object,Object>>();
map = new HashMap<Object,Object>(); map.put("label", "2008–09"); map.put("y", 209.7); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2009–10"); map.put("y", 198.3); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2010–11"); map.put("y", 206.1); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2011–12"); map.put("y", 224.8); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2012–13"); map.put("y", 238.2); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2013–14"); map.put("y", 271.6); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2014–15"); map.put("y", 290.2); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2015–16"); map.put("y", 319); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2016–17"); map.put("y", 332.9); list.add(map);
String dataPoints1 = gsonObj.toJson(list);
list = new ArrayList<Map<Object,Object>>();
map = new HashMap<Object,Object>(); map.put("label", "2008–09"); map.put("y", 136.4); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2009–10"); map.put("y", 135); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2010–11"); map.put("y", 143.3); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2011–12"); map.put("y", 162.6); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2012–13"); map.put("y", 173.1); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2013–14"); map.put("y", 206.6); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2014–15"); map.put("y", 225.2); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2015–16"); map.put("y", 254); list.add(map);
map = new HashMap<Object,Object>(); map.put("label", "2016–17"); map.put("y", 267.9); list.add(map);
String dataPoints2 = gsonObj.toJson(list);
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
window.onload = function() {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "dark1",
title: {
text: "Australian Thermal Coal Production and Exports"
},
axisY: {
title: "in million tonnes",
includeZero: true
},
toolTip: {
shared: true
},
legend: {
cursor: "pointer",
itemclick: toggleDataSeries
},
data: [{
type: "column",
name: "Production",
yValueFormatString: "#0.0# million tonnes",
showInLegend: true,
dataPoints: <%out.print(dataPoints1);%>
}, {
type: "column",
name: "Exports",
yValueFormatString: "#0.## million tonnes",
showInLegend: true,
dataPoints: <%out.print(dataPoints2);%>
}]
});
chart.render();
function toggleDataSeries(e) {
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
}
else {
e.dataSeries.visible = true;
}
chart.render();
}
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
</body>
</html>