<%@ 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", 28000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1485887400000L); map.put("y", 28500); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1488306600000L); map.put("y", 23000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1490985000000L); map.put("y", 29000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1493577000000L); map.put("y", 32000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1496255400000L); map.put("y", 35000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1498847400000L); map.put("y", 30000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1501525800000L); map.put("y", 25000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1504204200000L); map.put("y", 28000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1506796200000L); map.put("y", 40000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1509474600000L); map.put("y", 50000); map.put("indexLabel", "High Renewals"); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512066600000L); map.put("y", 38000); list.add(map); String dataPoints1 = gsonObj.toJson(list); list = new ArrayList<Map<Object,Object>>(); map = new HashMap<Object,Object>(); map.put("x", 1483209000000L); map.put("y", 40000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1485887400000L); map.put("y", 41000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1488306600000L); map.put("y", 39000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1490985000000L); map.put("y", 38000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1493577000000L); map.put("y", 45000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1496255400000L); map.put("y", 47000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1498847400000L); map.put("y", 42000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1501525800000L); map.put("y", 43000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1504204200000L); map.put("y", 41000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1506796200000L); map.put("y", 42000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1509474600000L); map.put("y", 45000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512066600000L); map.put("y", 46000); list.add(map); String dataPoints2 = gsonObj.toJson(list); list = new ArrayList<Map<Object,Object>>(); map = new HashMap<Object,Object>(); map.put("x", 1483209000000L); map.put("y", 12000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1485887400000L); map.put("y", 12500); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1488306600000L); map.put("y", 9000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1490985000000L); map.put("y", 13500); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1493577000000L); map.put("y", 13890); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1496255400000L); map.put("y", 18500); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1498847400000L); map.put("y", 16000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1501525800000L); map.put("y", 14500); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1504204200000L); map.put("y", 15880); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1506796200000L); map.put("y", 24000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1509474600000L); map.put("y", 35000); list.add(map); map = new HashMap<Object,Object>(); map.put("x", 1512066600000L); map.put("y", 20000); list.add(map); String dataPoints3 = 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, colorSet: "colorSet2", title: { text: "Monthly Sales" }, axisX: { valueFormatString: "MMMM" }, axisY: { prefix: "$", labelFormatter: addSymbols }, toolTip: { shared: true }, legend: { cursor: "pointer", itemclick: toggleDataSeries, verticalAlign: "top" }, data: [{ type: "column", name: "Actual Sales", showInLegend: true, xValueType: "dateTime", xValueFormatString: "MMMM YYYY", yValueFormatString: "$#,##0", dataPoints: <%out.print(dataPoints1);%> }, { type: "line", name: "Expected Sales", showInLegend: true, xValueType: "dateTime", yValueFormatString: "$#,##0", dataPoints: <%out.print(dataPoints2);%> }, { type: "area", name: "Profit", markerBorderColor: "white", markerBorderThickness: 2, showInLegend: true, xValueType: "dateTime", yValueFormatString: "$#,##0", dataPoints: <%out.print(dataPoints3);%> }] }); chart.render(); function addSymbols(e) { var suffixes = ["", "K", "M", "B"]; var order = Math.max(Math.floor(Math.log(Math.abs(e.value)) / Math.log(1000)), 0); if (order > suffixes.length - 1) order = suffixes.length - 1; var suffix = suffixes[order]; return CanvasJS.formatNumber(e.value / Math.pow(1000, order)) + suffix; } function toggleDataSeries(e) { if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) { e.dataSeries.visible = false; } else { e.dataSeries.visible = true; } e.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>