PROT-5 template for the histogram servlet (still not working )
authorNatasha Sherstneva <n.shertneva@gmail.com>
Mon, 18 Nov 2013 21:24:54 +0000 (21:24 +0000)
committerNatasha Sherstneva <n.shertneva@gmail.com>
Mon, 18 Nov 2013 21:24:54 +0000 (21:24 +0000)
website/HistogramaExecutionTime.jsp [new file with mode: 0644]

diff --git a/website/HistogramaExecutionTime.jsp b/website/HistogramaExecutionTime.jsp
new file mode 100644 (file)
index 0000000..91607fe
--- /dev/null
@@ -0,0 +1,60 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ page import="java.awt.*" %>
+<%@ page import="java.io.*" %>
+<%@ page import="java.util.Random" %>
+<%@ page import="org.jfree.chart.ChartFactory" %>
+<%@ page import="org.jfree.chart.ChartPanel" %>
+<%@ page import="org.jfree.chart.JFreeChart" %>
+<%@ page import="org.jfree.chart.ChartUtilities" %>
+<%@ page import="org.jfree.data.statistics.HistogramDataset" %>
+<%@ page import="org.jfree.data.statistics.HistogramType" %>
+<%@ page import="org.jfree.chart.plot.PlotOrientation;" %>
+
+<%
+double[] val = new double[10];
+%>
+<c:forEach items="${result}" var="res" varStatus="loop">
+<c:choose>
+       <c:when test="${loop.last}">
+               <c:forEach items="${res.timeTotalExec}" var="total">
+                               ${total}
+                               <c:set var="sum" value="${total}" />
+                       </c:forEach>
+       </c:when>
+</c:choose>
+</c:forEach>
+
+<%
+double[] value = new double[10];
+out.println("{sum}");
+for (int i=1; i < 10; i++) {
+       value[i] = i;
+    int number = 5;
+       HistogramDataset dataset = new HistogramDataset();
+       dataset.setType(HistogramType.RELATIVE_FREQUENCY);
+       dataset.addSeries("Histogram",value,number);
+       String plotTitle = "Histogram"; 
+       String xaxis = "number";
+       String yaxis = "value"; 
+       PlotOrientation orientation = PlotOrientation.VERTICAL; 
+       boolean show = false; 
+       boolean toolTips = false;
+       boolean urls = false; 
+       JFreeChart chart = ChartFactory.createHistogram( plotTitle, xaxis, yaxis, 
+         dataset, orientation, show, toolTips, urls);
+       int width = 800;
+       int height = 500; 
+ try {
+       File file1=new File("histogram2.jpg");
+       ChartUtilities.saveChartAsJPEG(file1, chart, width, height);
+ } catch (IOException e) {}
+}
+
+%>
+
+<html>
+<body>
+<IMG SRC="histogram.PNG" WIDTH="800" HEIGHT="500" BORDER="0" USEMAP="#chart">
+</body>
+</html> 
\ No newline at end of file