<%@ 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("x", 0); map.put("y", 1.293E-03); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 10); map.put("y", 3.982E-04); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 20); map.put("y", 8.269E-05); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 30); map.put("y", 1.554E-05); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 40); map.put("y", 3.148E-06); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 50); map.put("y", 8.280E-07); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 60); map.put("y", 2.328E-07); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 70); map.put("y", 5.761E-08); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 80); map.put("y", 1.296E-08); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 90); map.put("y", 2.702E-09); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 100); map.put("y", 4.535E-10); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 110); map.put("y", 6.809E-11); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 120); map.put("y", 1.604E-11); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 130); map.put("y", 6.210E-12); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 140); map.put("y", 3.143E-12); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 150); map.put("y", 1.825E-12); list.add(map);
String dataPoints1 = gsonObj.toJson(list);
list = new ArrayList<Map<Object,Object>>();
map = new HashMap<Object,Object>(); map.put("x", 0); map.put("y", 272.1); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 10); map.put("y", 214.9); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 20); map.put("y", 206.7); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 30); map.put("y", 216.5); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 40); map.put("y", 250.6); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 50); map.put("y", 258.5); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 60); map.put("y", 238.1); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 70); map.put("y", 221.7); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 80); map.put("y", 210.2); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 90); map.put("y", 189); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 100); map.put("y", 182.3); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 110); map.put("y", 255.4); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 120); map.put("y", 400.2); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 130); map.put("y", 534.3); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 140); map.put("y", 630.4); list.add(map);
map = new HashMap<Object,Object>(); map.put("x", 150); map.put("y", 700.5); 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,
zoomEnabled: true,
theme: "light2",
title: {
text: "Change in Atmospheric Mass Density and Temperature with Altitude"
},
axisX: {
title: "Altitude",
valueFormatString: "#,##0 km"
},
axisY: {
logarithmic: true, //change it to false
title: "Atmospheric Mass Density (g/cm3)",
titleFontColor: "#6D78AD",
lineColor: "#6D78AD",
gridThickness: 0,
lineThickness: 1,
valueFormatString: "0.0#E+0"
},
axisY2: {
title: "Temperature (K)",
titleFontColor: "#51CDA0",
logarithmic: false, //change it to true
lineColor: "#51CDA0",
gridThickness: 0,
lineThickness: 1
},
toolTip: {
shared: true
},
legend: {
verticalAlign: "top",
dockInsidePlotArea: true
},
data: [{
type: "line",
yValueFormatString: "0.0##E+0 g/cm3",
xValueFormatString: "#,##0 km",
showInLegend: true,
name: "Atmospheric Mass Density",
legendText: "{name} (in Log Scale)",
dataPoints: <%out.print(dataPoints1);%>
},
{
type: "line",
yValueFormatString: "###0 K",
xValueFormatString: "#,##0 km",
axisYType: "secondary",
showInLegend: true,
name: "Temperature",
legendText: "{name} (in Linear Scale)",
dataPoints: <%out.print(dataPoints2);%>
}]
});
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>