From 5893ed295d557004618eae6ed28c97ccf568a3e2 Mon Sep 17 00:00:00 2001 From: Natasha Sherstneva Date: Mon, 18 Nov 2013 21:24:54 +0000 Subject: [PATCH] PROT-5 template for the histogram servlet (still not working ) --- website/HistogramaExecutionTime.jsp | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 website/HistogramaExecutionTime.jsp diff --git a/website/HistogramaExecutionTime.jsp b/website/HistogramaExecutionTime.jsp new file mode 100644 index 0000000..91607fe --- /dev/null +++ b/website/HistogramaExecutionTime.jsp @@ -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]; +%> + + + + + ${total} + + + + + + +<% +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) {} +} + +%> + + + + + + \ No newline at end of file -- 1.7.10.2