<%@ 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", 1512066600000L); map.put("y", new Double[] {1216.15, 1235.00, 1208.00, 1211.65}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512325800000L); map.put("y", new Double[] {1217.00, 1225.09, 1201.80, 1217.50}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512412200000L); map.put("y", new Double[] {1214.50, 1214.50, 1191.34, 1209.90}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512498600000L); map.put("y", new Double[] {1205.90, 1212.00, 1189.00, 1191.25}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512585000000L); map.put("y", new Double[] {1196.00, 1228.44, 1196.00, 1218.40}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512671400000L); map.put("y", new Double[] {1225.00, 1227.00, 1217.69, 1220.34}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512930600000L); map.put("y", new Double[] {1224.00, 1229.00, 1215.25, 1221.84}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513017000000L); map.put("y", new Double[] {1221.19, 1221.50, 1200.50, 1202.90}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513103400000L); map.put("y", new Double[] {1204.50, 1210.00, 1185.00, 1189.25}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513189800000L); map.put("y", new Double[] {1196.50, 1200.00, 1176.09, 1188.80}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513276200000L); map.put("y", new Double[] {1202.00, 1216.25, 1201.00, 1203.55}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513535400000L); map.put("y", new Double[] {1195.00, 1224.00, 1175.00, 1217.90}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513621800000L); map.put("y", new Double[] {1222.00, 1222.00, 1213.34, 1219.90}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513708200000L); map.put("y", new Double[] {1217.19, 1240.44, 1209.00, 1232.50}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513794600000L); map.put("y", new Double[] {1239.00, 1265.00, 1237.00, 1258.80}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1513881000000L); map.put("y", new Double[] {1260.40, 1270.00, 1253.00, 1266.15}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1514226600000L); map.put("y", new Double[] {1266.15, 1275.00, 1257.30, 1269.69}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1514313000000L); map.put("y", new Double[] {1268.90, 1275.94, 1251.30, 1257.84}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1514399400000L); map.put("y", new Double[] {1257.50, 1264.94, 1249.44, 1252.75}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1514485800000L); map.put("y", new Double[] {1262.00, 1270.00, 1247.94, 1258.25}); 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, exportEnabled: true, theme: "light2", title: { text: "Larsen & Toubro Limited Stock Price" }, subtitles: [{ text: "December 2017" }], axisX: { valueFormatString: "D MMM" }, axisY: { title: "Price (in INR)", prefix: "₹" }, data: [{ type: "ohlc", xValueFormatString: "D 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>