<%@ 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 Integer[] {30, 39}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1485887400000L); map.put("y", new Integer[] {30, 41}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1488306600000L); map.put("y", new Integer[] {36, 50}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1490985000000L); map.put("y", new Integer[] {39, 57}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1493577000000L); map.put("y", new Integer[] {46, 64}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1496255400000L); map.put("y", new Integer[] {52, 72}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1498847400000L); map.put("y", new Integer[] {55, 79}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1501525800000L); map.put("y", new Integer[] {55, 77}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1504204200000L); map.put("y", new Integer[] {52, 72}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1506796200000L); map.put("y", new Integer[] {45, 59}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1509474600000L); map.put("y", new Integer[] {36, 46}); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512066600000L); map.put("y", new Integer[] {32, 41}); 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, title: { text: "Average High/Low Tempaerature - Geneva, 2017" }, axisY: { includeZero: false, title: "Temperature (°F)", suffix: " °F" }, axisX: { valueFormatString: "MMM" }, data: [{ type: "rangeArea", xValueFormatString: "MMMM", yValueFormatString: "#,##0.## °F", xValueType: "dateTime", toolTipContent: " <span style=\"color:#4F81BC\">{x}</span><br><b>Min:</b> {y[0]}<br><b>Max:</b> {y[1]}", 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>