<%@ 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("label", "Order Accuracy"); map.put("y", 96); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Packaging"); map.put("y", 70); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Quantity"); map.put("y", 87); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Quality"); map.put("y", 92); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Delivery"); map.put("y", 72); list.add(map); String dataPoints1 = gsonObj.toJson(list); list = new ArrayList<Map<Object,Object>>(); map = new HashMap<Object,Object>(); map.put("label", "Order Accuracy"); map.put("y", new Integer[] {93,98}); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Packaging"); map.put("y", new Integer[] {67,73}); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Quantity"); map.put("y", new Integer[] {83,91}); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Quality"); map.put("y", new Integer[] {89,95}); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Delivery"); map.put("y", new Integer[] {68,75}); list.add(map); String dataPoints2 = 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, title:{ text: "Quality of Service - Survey" }, axisY:{ title: "Response Values", includeZero: true }, toolTip: { shared: true }, data: [{ type: "column", name: "Avg. Score", toolTipContent: "<b>{label}</b> <br> <span style=\"color:#4F81BC\">{name}</span>: {y}", dataPoints: <%out.print(dataPoints1);%> }, { type: "error", name: "Variability Range", toolTipContent: "<span style=\"color:#C0504E\">{name}</span>: {y[0]} - {y[1]}", dataPoints: <%out.print(dataPoints2);%> }] }); 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>