<%@ 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", 946665000000L); map.put("y", 70.762); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 978287400000L); map.put("y", 68.707); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1009823400000L); map.put("y", 70.926); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1041359400000L); map.put("y", 69.211); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1072895400000L); map.put("y", 70.806); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1104517800000L); map.put("y", 69.828); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1136053800000L); map.put("y", 71.912); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1167589800000L); map.put("y", 74.006); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1199125800000L); map.put("y", 70.735); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1230748200000L); map.put("y", 74.102); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1262284200000L); map.put("y", 72.569); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1293820200000L); map.put("y", 72.743); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1325356200000L); map.put("y", 72.381); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1356978600000L); map.put("y", 71.406); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1388514600000L); map.put("y", 73.163); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1420050600000L); map.put("y", 74.270); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1451586600000L); map.put("y", 72.525); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1483209000000L); map.put("y", 73.121); list.add(map); String dataPoints = 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", { title: { text: "Nuclear Electricity Net Generation in US, 2000 - 2017" }, axisY: { title: "Net Generation", suffix: "bn kWh" }, data: [{ type: "splineArea", xValueType: "dateTime", xValueFormatString: "YYYY", yValueFormatString: "#,##0.00 billion kWh", dataPoints: <%out.print(dataPoints);%> }] }); 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>