<%@ 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>>(); int count = 50000; int y = 100; Random rand = new Random(); for(int i = 0; i < count; i++){ y += rand.nextInt(11) - 5; map = new HashMap<Object,Object>(); map.put("x", i); map.put("y", y); 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 limit = 50000; var y = 100; var data = []; var dataSeries = { type: "line" }; var dataPoints = <%out.print(dataPoints);%> dataSeries.dataPoints = dataPoints; data.push(dataSeries); //Better to construct options first and then pass it as a parameter var options = { zoomEnabled: true, animationEnabled: true, title: { text: "Try Zooming - Panning" }, data: data // random data }; var chart = new CanvasJS.Chart("chartContainer", options); var startTime = new Date(); chart.render(); var endTime = new Date(); document.getElementById("timeToRender").innerHTML = "Time to Render: " + (endTime - startTime) + "ms"; } </script> <style> #timeToRender { position:absolute; top: 10px; font-size: 20px; font-weight: bold; background-color: #d85757; padding: 0px 4px; color: #ffffff; } </style> </head> <body> <div id="chartContainer" style="height: 370px; width: 100%;"></div> <span id="timeToRender"></span> <script src="https://cdn.canvasjs.com/canvasjs.min.js"></script> </body> </html>