List of usage examples for org.jfree.data.category DefaultCategoryDataset DefaultCategoryDataset
public DefaultCategoryDataset()
From source file:user.Query.java
private CategoryDataset getCategoryDataset(ResultSet resultSet, String value, String second_value) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); try {//from w w w. ja v a 2 s .c om while (resultSet.next()) { dataset.addValue(Double.parseDouble(resultSet.getString(value)), value, resultSet.getString(second_value)); } } catch (SQLException ex) { } return dataset; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.ExecutionDashboard.java
private void init() { setCaption(TRANSLATOR.translate("execution.dash")); setHeight(100, Unit.PERCENTAGE);/* ww w . ja va 2 s . c o m*/ setWidth(100, Unit.PERCENTAGE); //Gather stats DefaultCategoryDataset dataset = new DefaultCategoryDataset(); extractions.forEach((e) -> { ExecutionStats es = new ExecutionStats(e); es.stats.entrySet().forEach((entry) -> { //This is for the whole execution ExecutionResultServer.getResults().forEach((er) -> { if (e.getTestCase() == null || e.getTestCase().getName().equals(entry.getKey())) { dataset.addValue(new Double(entry.getValue().get(er.getResultName())), entry.getKey(), Lookup.getDefault().lookup(InternationalizationProvider.class) .translate(er.getResultName())); } }); }); }); //Build bar graph JFreeChart chart = ChartFactory.createBarChart(TRANSLATOR.translate("execution.progress"), // chart title TRANSLATOR.translate("test.case"), TRANSLATOR.translate("general.amount"), dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); setContent(new JFreeChartWrapper(chart)); }
From source file:playground.yu.utils.charts.StackedBarChart.java
public StackedBarChart(String title, String categoryAxisLabel, String valueLabel, PlotOrientation plotOrientation) { super(title, categoryAxisLabel, valueLabel); dataset = new DefaultCategoryDataset(); chart = createChart(title, categoryAxisLabel, valueLabel, dataset, plotOrientation); }
From source file:org.karndo.graphs.CustomChartFactory.java
/** * Creates a chart of the selected PiracyEvent data graphed by day-of-the- * week. Presently uses a very basic method of graphing this data by * using the static CreateBarChart3D method available in class * org.jfree.chart.ChartFactory. * //from w ww . ja v a 2s . c om * * @param data the selected PiracyEvent data to graph. * @return A JFreeChart object representing a graph of the selected * PiracyEvent data against days of the Calendar week. */ public JFreeChart createPiracyHistogramDayOfWeek(LinkedList<PiracyEvent> data) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Integer[] freqs = new Integer[DAYS_OF_THE_WEEK.length]; Calendar cal = Calendar.getInstance(); //set up the frequencies array for (int i = 0; i < freqs.length; i++) { freqs[i] = 0; } for (PiracyEvent ev : data) { cal.setTime(ev.getDate()); freqs[cal.get(Calendar.DAY_OF_WEEK) - 1]++; } //add the frequencies to a dataset for plotting for (int i = 0; i < freqs.length; i++) { dataset.addValue(freqs[i], "Piracy Incidents", DAYS_OF_THE_WEEK[i]); } JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by days of the week", "Day of the Week", "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false); return chart; }
From source file:org.openmrs.module.vcttrac.web.view.chart.VCTCreateBarChartView.java
/** * Auto generated method comment/*ww w . j a va2 s .c o m*/ * * @return */ private static CategoryDataset createDataset() { Date curDate = new Date(); VCTModuleService vms = Context.getService(VCTModuleService.class); // create the dataset... DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Date yesterday = new Date(curDate.getTime() - (VCTTracConstant.ONE_DAY_IN_MILLISECONDS * 1)); double value = vms.getNumberOfClientByDateOfRegistration(yesterday); dataset.addValue(value, "todayVsYesterday", VCTTracUtil.getMessage("vcttrac.graph.statistic.yesterday", null)); // + " (" // + value + ")"); Date today = new Date(curDate.getTime()); double value1 = vms.getNumberOfClientByDateOfRegistration(today); dataset.addValue(value1, "todayVsYesterday", VCTTracUtil.getMessage("vcttrac.graph.statistic.today", null)); // + " (" // + value1 + ")"); return dataset; }
From source file:com.indicator_engine.graphgenerator.cewolf.PageViewCountData.java
/** * Produces some random data./*from w ww . j a va2s. c o m*/ */ public Object produceDataset(Map params) throws DatasetProduceException { log.debug("producing data."); DefaultCategoryDataset dataset = new DefaultCategoryDataset() { /** * @see java.lang.Object#finalize() */ protected void finalize() throws Throwable { super.finalize(); log.debug(this + " finalized."); } }; for (int series = 0; series < seriesNames.length; series++) { int lastY = (int) (Math.random() * 1000 + 1000); for (int i = 0; i < categories.length; i++) { final int y = lastY + (int) (Math.random() * 200 - 100); lastY = y; dataset.addValue(y, seriesNames[series], categories[i]); } } return dataset; }
From source file:org.miloss.fgsms.services.rs.impl.reports.ws.InvocationsByDataCollector.java
/** * {@inheritDoc}/* w w w . j a v a 2s . 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 { int itemcount = 0; Connection con = Utility.getPerformanceDBConnection(); try { PreparedStatement cmd = null; ResultSet rs = null; DefaultCategoryDataset set = new DefaultCategoryDataset(); JFreeChart chart = null; if (!UserIdentityUtil.hasGlobalAdministratorRole(currentuser, "THROUGHPUT_BY_HOSTING_SERVER", classification, ctx)) { data.append("<h2>Access for " + GetDisplayName() + " was denied for non-global admin users</h2>"); return; } data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>"); data.append("This represents Data Collector Service utilization.<br />"); data.append("<table class=\"table table-hover\"><tr><th>Host</th><th>Invocations</th></tr>"); List<String> dcs = new ArrayList<String>(); try { //was select distinct monitorsource from RawData; cmd = con.prepareStatement("select monitorsource from rawdata group by monitorsource;"); rs = cmd.executeQuery(); while (rs.next()) { dcs.add(rs.getString(1)); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } try { itemcount = dcs.size(); for (int i = 0; i < dcs.size(); i++) { data.append("<tr><td>").append(Utility.encodeHTML(dcs.get(i))).append("</td><td>"); int success = 0; try { cmd = con.prepareStatement( "select count(*) from RawData where monitorsource=? and UTCdatetime > ? and UTCdatetime < ?;"); cmd.setString(1, dcs.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); if (rs.next()) { success = rs.getInt(1); } } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } data.append("<td>").append(success + "").append("</td></tr>"); set.addValue(success, dcs.get(i), dcs.get(i)); } } catch (Exception ex) { log.log(Level.ERROR, "Error generating chart information.", ex); } chart = org.jfree.chart.ChartFactory.createBarChart(GetDisplayName(), "Monitoring Servers", "", set, PlotOrientation.HORIZONTAL, true, false, false); data.append("</table>"); try { ChartUtilities.saveChartAsPNG(new File( path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart, 1500, pixelHeightCalc(itemcount)); } 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:sernet.gs.ui.rcp.main.bsi.views.chart.MaturityWithOutISASpiderChart.java
@Override protected Object createSpiderDataset() throws CommandException { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); MassnahmenWithOutISASummaryHome dao = new MassnahmenWithOutISASummaryHome(); Map<String, Double> items2 = dao.getControlMaxGroups(elmt); Set<Entry<String, Double>> entrySet2 = items2.entrySet(); for (Entry<String, Double> entry : sort(entrySet2)) { dataset.addValue(entry.getValue(), Messages.MaturitySpiderChart_1, entry.getKey()); }/* ww w . jav a2s . c o m*/ Map<String, Double> items4 = dao.getControlGoal2Groups(elmt); Set<Entry<String, Double>> entrySet4 = items4.entrySet(); for (Entry<String, Double> entry : sort(entrySet4)) { dataset.addValue(entry.getValue(), Messages.MaturitySpiderChart_2, entry.getKey()); } Map<String, Double> items3 = dao.getControlGoal1Groups(elmt); Set<Entry<String, Double>> entrySet3 = items3.entrySet(); for (Entry<String, Double> entry : sort(entrySet3)) { dataset.addValue(entry.getValue(), Messages.MaturitySpiderChart_3, entry.getKey()); } Map<String, Double> items1 = dao.getControlGroups(elmt); Set<Entry<String, Double>> entrySet = items1.entrySet(); for (Entry<String, Double> entry : sort(entrySet)) { dataset.addValue(entry.getValue(), Messages.MaturitySpiderChart_4, entry.getKey()); } return dataset; }
From source file:bc.ui.swing.charts.BarChart.java
public void setModel(BarVisualModel model) { this.model = model; dataset = new DefaultCategoryDataset(); for (String a : model.getAlgorithms()) { for (Entry<String, Double> v : model.getValues(a).entrySet()) { dataset.addValue(v.getValue(), a, v.getKey()); }/*from www . ja v a2 s . co m*/ } removeAll(); chartPanel = new ChartPanel(generateView()); add(chartPanel, BorderLayout.CENTER); }
From source file:com.itemanalysis.jmetrik.graph.barchart.BarChartPanel.java
public void updateDataset(TwoWayTable table) { String groupingName = ""; try {//w ww. j a va 2 s . c om boolean showFreq = command.getSelectOneOption("yaxis").isValueSelected("freq"); if (command.getFreeOption("groupvar").hasValue()) { groupingName = command.getFreeOption("groupvar").getString(); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Iterator<Comparable<?>> rowIter = table.rowValuesIterator(); Iterator<Comparable<?>> colIter = null; Comparable<?> r = null; Comparable<?> c = null; while (rowIter.hasNext()) { r = rowIter.next(); colIter = table.colValuesIterator(); while (colIter.hasNext()) { c = colIter.next(); if (showFreq) { dataset.addValue(table.getCount(r, c), r.toString(), c.toString()); } else { dataset.addValue(table.getCount(r, c) / table.getFreqSum(), (groupingName + " " + r.toString()), c.toString()); } } } CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDataset(dataset); } catch (IllegalArgumentException ex) { logger.fatal(ex.getMessage(), ex); this.firePropertyChange("error", "", "Error - Check log for details."); } }