List of usage examples for org.jfree.data.category DefaultCategoryDataset DefaultCategoryDataset
public DefaultCategoryDataset()
From source file:org.miloss.fgsms.services.rs.impl.reports.os.NetworkIOReport.java
@Override public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files, TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx) throws IOException { Connection con = Utility.getPerformanceDBConnection(); try {/*from ww w .j a v a 2 s . com*/ PreparedStatement cmd = null; ResultSet rs = null; DefaultCategoryDataset set = new DefaultCategoryDataset(); JFreeChart chart = null; data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>"); data.append("This represents the network throughput rates of a machine over time.<br />"); data.append( "<table class=\"table table-hover\"><tr><th>URI</th><th>Average Send Rate</th><th>Average Recieve Rate</th></tr>"); TimeSeriesCollection col = new TimeSeriesCollection(); for (int i = 0; i < urls.size(); i++) { if (!isPolicyTypeOf(urls.get(i), PolicyType.MACHINE)) { continue; } //https://github.com/mil-oss/fgsms/issues/112 if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification, ctx)) { continue; } String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i))); data.append("<tr><td>").append(url).append("</td>"); double average = 0; try { cmd = con.prepareStatement( "select avg(sendkbs) from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); if (rs.next()) { average = rs.getDouble(1); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } data.append("<td>").append(average + "").append("</td>"); average = 0; try { cmd = con.prepareStatement( "select avg(receivekbs) from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); if (rs.next()) { average = rs.getDouble(1); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } data.append("<td>").append(average + "").append("</td></tr>"); //ok now get the raw data.... TimeSeriesContainer tsc = new TimeSeriesContainer(); try { cmd = con.prepareStatement( "select receivekbs, sendkbs, utcdatetime, nicid from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); while (rs.next()) { TimeSeries ts = tsc.Get(url + " " + rs.getString("nicid") + " RX", Millisecond.class); TimeSeries ts2 = tsc.Get(url + " " + rs.getString("nicid") + " TX", Millisecond.class); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(rs.getLong(3)); Millisecond m = new Millisecond(gcal.getTime()); ts.addOrUpdate(m, rs.getLong(1)); ts2.addOrUpdate(m, rs.getLong(2)); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } for (int ik = 0; ik < tsc.data.size(); ik++) { col.addSeries(tsc.data.get(ik)); } } chart = org.jfree.chart.ChartFactory.createTimeSeriesChart(GetDisplayName(), "Timestamp", "Rate", col, true, false, false); data.append("</table>"); try { // if (set.getRowCount() != 0) { ChartUtilities.saveChartAsPNG(new File( path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart, 1500, 400); data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">"); files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"); // } } catch (IOException ex) { log.log(Level.ERROR, "Error saving chart image for request", ex); } } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(con); } }
From source file:org.miloss.fgsms.services.rs.impl.reports.ws.ThroughputByService.java
/** * {@inheritDoc}/*www . j a v a 2 s . c o m*/ */ @Override public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files, TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx) throws IOException { Connection con = Utility.getPerformanceDBConnection(); try { PreparedStatement cmd = null; ResultSet rs = null; DefaultCategoryDataset set = new DefaultCategoryDataset(); JFreeChart chart = null; data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>"); data.append(GetHtmlFormattedHelp() + "<br />"); data.append( "<table class=\"table table-hover\"><tr><th>URL</th><th>Invocations</th><th>Msg/Day</th><th>Msg/Hour</th><th>Msg/Min</th><th>Msg/Sec</th></tr>"); for (int i = 0; i < urls.size(); i++) { if (!isPolicyTypeOf(urls.get(i), PolicyType.TRANSACTIONAL)) { continue; } //https://github.com/mil-oss/fgsms/issues/112 if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification, ctx)) { continue; } String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i))); long count = 0; try { cmd = con.prepareStatement("select count(*) from RawData where URI=? and " + "(UTCdatetime > ?) and (UTCdatetime < ?) ;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); try { if (rs.next()) { count = rs.getLong(1); } } catch (Exception ex) { log.log(Level.DEBUG, null, ex); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } double d = range.getEnd().getTimeInMillis() - range.getStart().getTimeInMillis(); double day = d / 86400000; double hours = d / 3600000; double min = d / 60000; double sec = d / 1000; data.append("<tr><td>").append(url).append("</td><td>"); data.append(count + ""); data.append("</td><td>").append(format.format((double) ((double) count / day))).append("</td><td>") .append(format.format((double) ((double) count / hours))).append("</td><td>") .append(format.format((double) ((double) count / min))).append("</td><td>") .append(format.format((double) ((double) count / sec))).append("</td></tr>"); if (count > 0) { set.addValue((double) ((double) count / day), url, url); } } chart = org.jfree.chart.ChartFactory.createBarChart(GetDisplayName(), "Service URL", "", set, PlotOrientation.HORIZONTAL, true, false, false); data.append("</table>"); try { ChartUtilities.saveChartAsPNG(new File( path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart, 1500, pixelHeightCalc(set.getRowCount())); } catch (IOException ex) { log.log(Level.ERROR, "Error saving chart image for request", ex); } data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">"); files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"); } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(con); } }
From source file:net.sourceforge.subsonic.controller.UserChartController.java
private CategoryDataset createDataset(String type) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); List<User> users = securityService.getAllUsers(); for (User user : users) { double value; if ("stream".equals(type)) { value = user.getBytesStreamed(); } else if ("download".equals(type)) { value = user.getBytesDownloaded(); } else if ("upload".equals(type)) { value = user.getBytesUploaded(); } else if ("total".equals(type)) { value = user.getBytesStreamed() + user.getBytesDownloaded() + user.getBytesUploaded(); } else {/*from www .j ava 2s. co m*/ throw new RuntimeException("Illegal chart type: " + type); } value /= BYTES_PER_MB; dataset.addValue(value, "Series", user.getUsername()); } return dataset; }
From source file:herramientas.Ecualizacion_histograma.java
public void histograma() { JFrame vHist = new JFrame("Histograma"); JFreeChart graf_hist = null;//from w ww .j a v a 2 s . co m DefaultCategoryDataset data = new DefaultCategoryDataset(); for (int i = 0; i < 256; i++) { // if(datos[i] != 0) //Mostrando solo los que son distintos de 0. data.addValue(datos[i], "Histograma frec. abs.", Integer.toString(i)); } graf_hist = ChartFactory.createBarChart("Histograma de frecuencias absolutas", "Nivel RGB", "Nmero de pxeles", data, PlotOrientation.VERTICAL, false, false, false); ChartPanel panel = new ChartPanel(graf_hist); vHist.getContentPane().add(panel); vHist.pack(); vHist.setVisible(true); }
From source file:org.miloss.fgsms.services.rs.impl.reports.ws.InvocationsByConsumerByService.java
/** * {@inheritDoc}//from w w w. j a va 2 s. c om */ @Override public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files, TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx) throws IOException { Connection con = Utility.getPerformanceDBConnection(); try { PreparedStatement cmd = null; ResultSet rs = null; DefaultCategoryDataset set = new DefaultCategoryDataset(); JFreeChart chart = null; data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>"); data.append(GetHtmlFormattedHelp() + "<br />"); data.append( "<table class=\"table table-hover\"><tr><th>Consumer</th><th>URL</th><th>Invocations</th></tr>"); Set<String> consumers = new HashSet<String>(); // for (int i = 0; i < (consumers.size()-1); i++) { for (int k = 0; k < urls.size(); k++) { if (!isPolicyTypeOf(urls.get(k), PolicyType.TRANSACTIONAL)) { continue; } //https://github.com/mil-oss/fgsms/issues/112 if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(k), classification, ctx)) { continue; } String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(k))); consumers.clear(); try { try { cmd = con.prepareStatement( "select consumeridentity from rawdata where uri=? and (UTCdatetime > ?) and (UTCdatetime < ?) group by consumeridentity;"); cmd.setString(1, urls.get(k)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); while (rs.next()) { String s = rs.getString(1); if (!Utility.stringIsNullOrEmpty(s)) { String ids[] = s.split(";"); for (int i = 0; i < ids.length; i++) { if (!Utility.stringIsNullOrEmpty(ids[i])) { consumers.add(ids[i]); } } } } } catch (Exception ex) { log.log(Level.WARN, " error querying database forINVOCATIONS_BY_CONSUMER_BY_SERVICE" + urls.get(k), ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } consumers.add("unspecified"); //ok for this service, count the times each consumer as hit it Iterator<String> iterator = consumers.iterator(); while (iterator.hasNext()) { String user = iterator.next(); long count = 0; try { cmd = con.prepareStatement("select count(*) from RawData where URI=? and " + "(UTCdatetime > ?) and (UTCdatetime < ?) and consumeridentity ~* ?;"); cmd.setString(1, urls.get(k)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); cmd.setString(4, user); rs = cmd.executeQuery(); try { if (rs.next()) { count = rs.getLong(1); } } catch (Exception ex) { log.log(Level.WARN, " error querying database forINVOCATIONS_BY_CONSUMER_BY_SERVICE" + urls.get(k), ex); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } if (count > 0) { //cut down on the chatter data.append("<tr><td>").append(url).append("</td><td>").append(Utility.encodeHTML(user)) .append("</td><td>"); data.append(count + ""); data.append("</td></tr>"); set.addValue(count, user, urls.get(k)); } } //this is for anonymous users or for when an identity was not //recorded by the agent long count = 0; try { cmd = con.prepareStatement("select count(*) from RawData where URI=? and " + "(UTCdatetime > ?) and (UTCdatetime < ?) and consumeridentity is null;"); cmd.setString(1, urls.get(k)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); try { if (rs.next()) { count = rs.getLong(1); } } catch (Exception ex) { log.log(Level.WARN, " error querying database forINVOCATIONS_BY_CONSUMER_BY_SERVICE" + urls.get(k), ex); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } if (count > 0) { //cut down on the chatter data.append("<tr><td>").append(url).append("</td><td>(not recorded)</td><td>"); data.append(count + ""); data.append("</td></tr>"); set.addValue(count, "unspecified", url); } } catch (Exception ex) { data.append("0 bytes</td></tr>"); log.log(Level.ERROR, "Error opening or querying the database.", ex); } } // insert query for unspecified chart = org.jfree.chart.ChartFactory.createBarChart(toFriendlyName(get.getType()), "Service URL", "", set, PlotOrientation.HORIZONTAL, true, false, false); data.append("</table>"); chart = org.jfree.chart.ChartFactory.createBarChart(GetDisplayName(), "Service URL", "", set, PlotOrientation.HORIZONTAL, true, false, false); try { int height = pixelHeightCalc(set.getColumnCount()); ChartUtilities.saveChartAsPNG(new File( path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart, 1500, height); } catch (IOException ex) { log.log(Level.ERROR, "Error saving chart image for request", ex); } data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">"); files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"); } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(con); } }
From source file:org.getobjects.samples.HelloChart.Main.java
public CategoryDataset getRevCatDataSet() { // thats like a DB table, a matrix of keys/values DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(15000.0, "revenue", "January"); dataset.addValue(12000.0, "profit", "January"); dataset.addValue(25000.0, "revenue", "February"); dataset.addValue(24000.0, "profit", "February"); dataset.addValue(60000.0, "revenue", "March"); dataset.addValue(55000.0, "profit", "March"); return dataset; }
From source file:com.xpn.xwiki.plugin.charts.plots.CategoryPlotFactory.java
public Plot create(DataSource dataSource, CategoryItemRenderer renderer, ChartParams params) throws GenerateException, DataSourceException { String dataSeries = params.getString(ChartParams.SERIES); CategoryAxis domainAxis = new CategoryAxis(); ValueAxis rangeAxis = new NumberAxis(); ChartCustomizer.customizeCategoryAxis(domainAxis, params, ChartParams.AXIS_DOMAIN_PREFIX); ChartCustomizer.customizeValueAxis(rangeAxis, params, ChartParams.AXIS_RANGE_PREFIX); Class rendererClass = params.getClass(ChartParams.RENDERER); ChartCustomizer.customizeCategoryItemRenderer(renderer, params); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if ("columns".equals(dataSeries)) { for (int row = 0; row < dataSource.getRowCount(); row++) { for (int column = 0; column < dataSource.getColumnCount(); column++) { dataset.addValue(dataSource.getCell(row, column), dataSource.hasHeaderRow() ? dataSource.getHeaderRowValue(column) : ("Category " + (column + 1)), dataSource.hasHeaderColumn() ? dataSource.getHeaderColumnValue(row) : ("Series " + (row + 1))); }// w w w. j a va 2 s. co m } } else if ("rows".equals(dataSeries)) { for (int row = 0; row < dataSource.getRowCount(); row++) { for (int column = 0; column < dataSource.getColumnCount(); column++) { dataset.addValue(dataSource.getCell(row, column), dataSource.hasHeaderColumn() ? dataSource.getHeaderColumnValue(row) : ("Category " + (row + 1)), dataSource.hasHeaderRow() ? dataSource.getHeaderRowValue(column) : ("Series " + (column + 1))); } } } else { throw new GenerateException("Invalid series parameter: " + dataSeries); } return new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); }
From source file:org.miloss.fgsms.services.rs.impl.reports.ws.InvocationsByConsumerByServiceByMethod.java
@Override public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files, TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx) throws IOException { Connection con = Utility.getPerformanceDBConnection(); try {//w w w .ja va2 s .co m PreparedStatement cmd = null; ResultSet rs = null; DefaultCategoryDataset set = new DefaultCategoryDataset(); JFreeChart chart = null; data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>"); data.append(GetHtmlFormattedHelp() + "<br />"); data.append( "<table class=\"table table-hover\"><tr><th>URL</th><th>Consumer</th><th>Method</th><th>Invocations</th></tr>"); Set<String> consumers2 = new HashSet<String>(); List<String> actions = new ArrayList<String>(); for (int k = 0; k < urls.size(); k++) { if (!isPolicyTypeOf(urls.get(k), PolicyType.TRANSACTIONAL)) { continue; } //https://github.com/mil-oss/fgsms/issues/112 if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(k), classification, ctx)) { continue; } String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(k))); consumers2.clear(); actions.clear(); try { actions = getSoapActions(urls.get(k), con); rs = null; for (int k2 = 0; k2 < actions.size(); k2++) { try { consumers2.clear(); cmd = con.prepareStatement( "select consumeridentity from rawdata where uri=? and (UTCdatetime > ?) and (UTCdatetime < ?) and soapaction=? group by consumeridentity;"); cmd.setString(1, urls.get(k)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); cmd.setString(4, actions.get(k2)); rs = cmd.executeQuery(); while (rs.next()) { String s = rs.getString(1); // log.log(Level.WARN, " debug INVOCATIONS_BY_CONSUMER_BY_SERVICE url:" + urls.get(k) + " user: " + s); if (!Utility.stringIsNullOrEmpty(s)) { String ids[] = s.split(";"); for (int i = 0; i < ids.length; i++) { if (!Utility.stringIsNullOrEmpty(ids[i])) { // log.log(Level.WARN, " debug2 INVOCATIONS_BY_CONSUMER_BY_SERVICE url:" + urls.get(k) + " user: " + ids[i]); if (!consumers2.contains(ids[i])) { consumers2.add(ids[i]); } } } } } } catch (Exception ex) { log.log(Level.WARN, " error querying database forINVOCATIONS_BY_CONSUMER_BY_SERVICE" + urls.get(k), ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } consumers2.add("unspecified"); //ok for this service, count the times each consumer as hit it Iterator<String> iterator = consumers2.iterator(); while (iterator.hasNext()) { String u = iterator.next(); long count = 0; try { cmd = con.prepareStatement( "select count(*) from RawData where URI=? and soapaction=? and " + "(UTCdatetime > ?) and (UTCdatetime < ?) and consumeridentity ~* ?;"); cmd.setString(1, urls.get(k)); cmd.setString(2, actions.get(k2)); cmd.setLong(3, range.getStart().getTimeInMillis()); cmd.setLong(4, range.getEnd().getTimeInMillis()); cmd.setString(5, u); rs = cmd.executeQuery(); try { if (rs.next()) { count = rs.getLong(1); } } catch (Exception ex) { log.log(Level.WARN, " error querying database forINVOCATIONS_BY_CONSUMER_BY_SERVICE" + urls.get(k), ex); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } if (count > 0) { //cut down on the noise data.append("<tr><td>").append(url).append("</td><td>") .append(Utility.encodeHTML(u)).append("</td><td>") .append(Utility.encodeHTML(actions.get(k2))).append("</td><td>"); data.append(count + ""); data.append("</td></tr>"); set.addValue(count, u, urls.get(k) + " " + actions.get(k2)); } } long count = 0; try { cmd = con.prepareStatement( "select count(*) from RawData where URI=? and soapaction=? and " + "(UTCdatetime > ?) and (UTCdatetime < ?) and consumeridentity is null;"); cmd.setString(1, urls.get(k)); cmd.setString(2, actions.get(k2)); cmd.setLong(3, range.getStart().getTimeInMillis()); cmd.setLong(4, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); try { if (rs.next()) { count = rs.getLong(1); } } catch (Exception ex) { log.log(Level.WARN, " error querying database forINVOCATIONS_BY_CONSUMER_BY_SERVICE" + urls.get(k), ex); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } if (count > 0) { //cut down on the noise data.append("<tr><td>").append(url).append("</td><td>unspecified</td><td>") .append(Utility.encodeHTML(actions.get(k2))).append("</td><td>"); data.append(count + ""); data.append("</td></tr>"); set.addValue(count, "unspecified", url + " " + actions.get(k2)); } } } catch (Exception ex) { log.log(Level.ERROR, "Error opening or querying the database.", ex); } } // insert query for unspecified chart = org.jfree.chart.ChartFactory.createBarChart(toFriendlyName(get.getType()), "Service URL", "", set, PlotOrientation.HORIZONTAL, true, false, false); data.append("</table>"); chart = org.jfree.chart.ChartFactory.createBarChart(GetDisplayName(), "Service URL", "", set, PlotOrientation.HORIZONTAL, true, false, false); try { ChartUtilities.saveChartAsPNG(new File( path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart, 1500, pixelHeightCalc(set.getColumnCount())); } catch (IOException ex) { log.log(Level.ERROR, "Error saving chart image for request", ex); } data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">"); files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"); } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(con); } }
From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java
/** * @param list//from www .ja v a 2s .co m * @param title * @param xAxisTitle * @param yAxisTitle * @param isVertical * @param width * @param height */ public JFreeChart createLineChart(final List<Object> list, final String title, final String xAxisTitle, final String yAxisTitle, final boolean isVertical, final int width, final int height) { DefaultCategoryDataset catDataSet = new DefaultCategoryDataset(); for (int i = 0; i < list.size(); i++) { Object xVal = list.get(i++); Object yVal = list.get(i); double xv = getDbl(xVal); numMin = Math.min(numMin, xv); numMax = Math.max(numMax, xv); catDataSet.addValue(getDbl(yVal), "X", xVal.toString()); } /*XYDataset dataset = createXYDataSet(list); JFreeChart chart = ChartFactory.createXYLineChart( title, // chart title xAxisTitle, // domain axis label yAxisTitle, // range axis label dataset, // data isVertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, false, // include legend true, // tooltips? false // URLs? ); XYPlot xyplot = chart.getXYPlot(); NumberAxis numberAxis = (NumberAxis) xyplot.getDomainAxis(); numberAxis.setRange(numMin, numMax); //ValueAxis axis = xyplot.getDomainAxis(); //axis = xyplot.getRangeAxis(); //((NumberAxis) axis).setTickUnit(new NumberTickUnit(1)); //axis.setRange(1870,2010);*/ /* JFreeChart jfreechart = ChartFactory.createLineChart3D( title, xAxisTitle, yAxisTitle, catDataSet, PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(new Color(187, 187, 221)); CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryItemRenderer renderer = categoryplot.getRenderer(); renderer.setSeriesPaint(0, new Color(95, 158, 160)); renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); */ JFreeChart jfreechart = ChartFactory.createLineChart(title, xAxisTitle, yAxisTitle, catDataSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setRangeGridlinePaint(Color.DARK_GRAY); categoryplot.setBackgroundPaint(null); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryItemRenderer renderer = categoryplot.getRenderer(); renderer.setSeriesPaint(0, new Color(95, 158, 160)); renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); BasicStroke lineStroke = new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); renderer.setBaseStroke(lineStroke); renderer.setBaseOutlineStroke(lineStroke); renderer.setSeriesStroke(0, lineStroke); //renderer.setOutlineStroke(lineStroke); //renderer.setStroke(lineStroke); return jfreechart; }
From source file:org.squale.squaleweb.util.graph.AuditTimeMaker.java
/** * Constructeur// ww w. j a v a 2s. co m * * @param pTitle le titre * @param pXLabel le label des abscisses * @param pYLabel le label des ordonnes */ public AuditTimeMaker(String pTitle, String pXLabel, String pYLabel) { mTitle = pTitle; mXLabel = pXLabel; mYLabel = pYLabel; mDataSet = new DefaultCategoryDataset(); }