<%@ 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", 1483209000000L); map.put("y", new Double[] {88.17, 83.03}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1485887400000L); map.put("y", new Double[] {91.34, 84.16}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1488306600000L); map.put("y", new Double[] {93.98, 85.23}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1490985000000L); map.put("y", new Double[] {89.13, 84.36}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1493577000000L); map.put("y", new Double[] {88.09, 81.64}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1496255400000L); map.put("y", new Double[] {92.65, 81.65}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1498847400000L); map.put("y", new Double[] {94.51, 90.32}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1501525800000L); map.put("y", new Double[] {95.22, 90.16}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1504204200000L); map.put("y", new Double[] {95.88, 88.08}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1506796200000L); map.put("y", new Double[] {102.42, 94.96}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1509474600000L); map.put("y", new Double[] {106.66, 95.95}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512066600000L); map.put("y", new Double[] {108.46, 102.20}); 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: "JPMorgan Stock Price" }, subtitles: [{ text: "High and Low Prices - 2017" }], axisX: { valueFormatString: "MMM", intervalType: "month", interval: 1 }, axisY: { title: "Stock Price (in USD)", prefix: "$" }, data: [{ type: "rangeSplineArea", xValueType: "dateTime", xValueFormatString: "MMMM", yValueFormatString: "$#,##0.00", toolTipContent: "{x}<br><b>High:</b> {y[0]}<br><b>Low:</b> {y[0]}", 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>