<%@ 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", 1104517800000L); map.put("y", 345.29); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1136053800000L); map.put("y", 360.89); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1167589800000L); map.put("y", 372.54); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1199125800000L); map.put("y", 373.66); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1230748200000L); map.put("y", 361.83); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1262284200000L); map.put("y", 377.01); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1293820200000L); map.put("y", 391.18); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1325356200000L); map.put("y", 362.41); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1356978600000L); map.put("y", 398.85); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1388514600000L); map.put("y", 437.04); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1420050600000L); map.put("y", 437.33); 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", animationEnabled: true, title: { text: "Wholesale Price of Tiger Prawn in Phillipines" }, subtitles: [{ text: "2005 to 2015" }], axisY: { title: "Price per Kilogram (in piso)", prefix: "₱" }, data: [{ type: "stepArea", xValueType: "dateTime", xValueFormatString: "YYYY", 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>