<%@ 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", 1499020200000L); map.put("y", new Double[] {4.0, 6.0, 8.0, 9.0, 7.0}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1499106600000L); map.put("y", new Double[] {5.0, 6.0, 7.0, 8.0, 6.5}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1499193000000L); map.put("y", new Double[] {4.0, 5.0, 7.0, 8.0, 6.5}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1499279400000L); map.put("y", new Double[] {3.0, 5.0, 6.0, 9.0, 5.5}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1499365800000L); map.put("y", new Double[] {6.0, 8.0, 10.0, 11.0, 8.5}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1499452200000L); map.put("y", new Double[] {5.0, 7.0, 9.0, 12.0, 7.5}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1499538600000L); map.put("y", new Double[] {4.0, 6.0, 8.0, 9.0, 7.0}); 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: "Daily Sleep Statistics" }, subtitles: [{ text: "Age Group 12 - 20" }], axisX: { valueFormatString: "DDD" }, axisY: { title: "Sleep Time (in Hours)", includeZero: true }, data: [{ type: "boxAndWhisker", color: "#000", upperBoxColor: "#FFFFFF", lowerBoxColor: "#757575", xValueFormatString: "DDDD", yValueFormatString: "#,##0.# Hours", 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>