<%@ 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[] {69.23, 69.62, 65.27, 66.73}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1485887400000L); map.put("y", new Double[] {66.45, 72.80, 66.04, 70.93}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1488306600000L); map.put("y", new Double[] {70.97, 72.55, 69.33, 72.08}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1490985000000L); map.put("y", new Double[] {72.08, 75.76, 71.37, 75.18}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1493577000000L); map.put("y", new Double[] {75.08, 79.44, 74.95, 78.59}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1496255400000L); map.put("y", new Double[] {78.63, 80.47, 73.29, 75.68}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1498847400000L); map.put("y", new Double[] {75.83, 80.33, 73.12, 79.98}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1501525800000L); map.put("y", new Double[] {80.25, 81.98, 77.50, 78.07}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1504204200000L); map.put("y", new Double[] {78.30, 81.12, 77.73, 78.13}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1506796200000L); map.put("y", new Double[] {77.90, 89.11, 77.50, 87.30}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1509474600000L); map.put("y", new Double[] {87.07, 100.12, 87.00, 97.23}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512066600000L); map.put("y", new Double[] {97.61, 99.91, 96.13, 98.75}); 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", { theme: "light2", // "light1", "dark1", "dark2" animationEnabled: true, exportEnabled: true, title: { text: "Wal-Mart Stores, Inc. Stock Price - 2017" }, subtitles: [{ text: "Prices in US Dollar" }], axisX: { interval: 1, intervalType: "month", valueFormatString: "MMM" }, axisY: { prefix: "$", title: "Price" }, data: [{ type: "candlestick", xValueType: "dateTime", xValueFormatString: "MMM", yValueFormatString: "$#,##0.00", 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>