<%@ 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", -315639000000L); map.put("y", 14.93); list.add(map); map = new HashMap<Object,Object>(); map.put("x", -157786200000L); map.put("y", 16.52); list.add(map); map = new HashMap<Object,Object>(); map.put("x", -19800000L); map.put("y", 20.4); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 157746600000L); map.put("y", 17.72); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 315513000000L); map.put("y", 18.24); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 473365800000L); map.put("y", 18.99); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 631132200000L); map.put("y", 15.57); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 788898600000L); map.put("y", 13.88); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 946665000000L); map.put("y", 12.35); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1104517800000L); map.put("y", 10.97); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1262284200000L); map.put("y", 11.59); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1293820200000L); map.put("y", 11.65); 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", { animationEnabled: true, theme: "light2", title: { text: "Energy Production from Crude Oil in US" }, subtitles: [{ text: "1960 to 2011" }], axisY: { suffix: "Q", includeZero: true, title: "in British Thermal Unit" }, data: [{ type: "area", markerSize: 0, xValueType: "dateTime", xValueFormatString: "YYYY", yValueFormatString: "#,##0.00 Quadrillion BTU", 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>