<%@ 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", "Brazil"); map.put("y", 104); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "China"); map.put("y", 153); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "India"); map.put("y", 69); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Japan"); map.put("y", 166); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Korea, Rep"); map.put("y", 146); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "Russia"); map.put("y", 61); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "South Africa"); map.put("y", 78); list.add(map); map = new HashMap<Object,Object>(); map.put("label", "United Kingdom"); map.put("y", 135); 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, title: { text: "Deposit Money Banks' Assets to GDP (percent), 2015" }, axisY: { suffix: "%", includeZero: true }, axisX: { title: "Countries" }, data: [{ type: "column", yValueFormatString: "#,##0"%"", 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>