List of usage examples for org.jfree.data.category DefaultCategoryDataset DefaultCategoryDataset
public DefaultCategoryDataset()
From source file:view.HistogramFloat.java
public HistogramFloat(String applicationTitle, String TituloGrafico, List<StringFloat> Lista) { super(applicationTitle); String legenda = Lista.get(Lista.size() - 1).getDescricao(); DefaultCategoryDataset DatasetGrafico = new DefaultCategoryDataset(); int i;/*ww w. j a v a 2 s .c o m*/ for (i = 0; i < Lista.size() - 1; i++) { DatasetGrafico.addValue(Lista.get(i).getValor(), legenda, Lista.get(i).getDescricao()); } //JFreeChart grafico = ChartFactory.createBarChart(TituloGrafico, "Legends", "Value of Quality Index using "+legenda, DatasetGrafico); JFreeChart grafico = ChartFactory.createLineChart(TituloGrafico, "Number of Clusters", "Index of Quality", DatasetGrafico, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = grafico.getCategoryPlot(); LineAndShapeRenderer renderer = new LineAndShapeRenderer(); plot.setRenderer(renderer); //createBarChart(TituloGrafico, "Legends", "Value of Quality Index using "+legenda, DatasetGrafico); this.add(new ChartPanel(grafico)); this.pack(); }
From source file:jasmine.imaging.shapes.RadiusChart.java
public RadiusChart(Vector<Double> values) { super();/* w w w.ja va 2 s. c o m*/ DefaultCategoryDataset series = new DefaultCategoryDataset(); for (int i = 0; i < values.size(); i++) { series.addValue(values.elementAt(i), "row1", String.valueOf(i)); } setTitle("Radius Change"); chart = new JLabel(); getContentPane().add(chart); setSize(320, 240); setVisible(true); myChart = ChartFactory.createLineChart(null, null, null, series, PlotOrientation.VERTICAL, false, false, false); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { if (myChart != null) updateChart(); } }); }
From source file:graficos.GenerarGraficoInventario.java
public void crear() { try {//from w ww . j av a 2s . co m Dba db = new Dba(pathdb); db.conectar(); String sql = "select Nombre, CantidadDisponibles, CantidadEnUso from Activos"; db.prepare(sql); db.query.execute(); ResultSet rs = db.query.getResultSet(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); while (rs.next()) { int total = rs.getInt(2) + rs.getInt(3); dataset.setValue(total, "Cantidad", rs.getString(1)); } JFreeChart chart = ChartFactory.createBarChart3D("Inventario de Activos del Hotel", "Activo", "Cantidad", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); // Get the Plot object for a bar graph p.setBackgroundPaint(Color.black); ((BarRenderer) p.getRenderer()).setBarPainter(new StandardBarPainter()); BarRenderer r = (BarRenderer) chart.getCategoryPlot().getRenderer(); r.setSeriesPaint(0, Color.BLUE); try { ChartUtilities.saveChartAsJPEG(new File(path), chart, 500, 300); } catch (Exception ee) { System.err.println(ee.toString()); System.err.println("Problem occurred creating chart."); } db.desconectar(); } catch (Exception e) { } }
From source file:JavaBean.BeanGraficaPersonal.java
public String muestraGrafica(String matricula) { // List<TareaAlumno> lista=dameDatos(matricula); // if(lista!=null) // {//w ww . j av a 2 s. c o m DefaultCategoryDataset Datos = new DefaultCategoryDataset(); int i; // for(i=0;i<lista.size();i++) // { // // } JFreeChart Grafica; Datos.addValue(1, "Negocio 1", "Lunes"); Datos.addValue(2, "Negocio 1", "Martes"); Datos.addValue(3, "Negocio 1", "Mircoles"); Datos.addValue(4, "Negocio 1", "Jueves"); Datos.addValue(5, "Negocio 1", "Viernes"); Datos.addValue(6, "Negocio 1", "Sbado"); Datos.addValue(7, "Negocio 1", "Domingo"); Grafica = ChartFactory.createBarChart("Visitas diarias", "Das", "Visitas", Datos, PlotOrientation.HORIZONTAL, true, true, false); ChartPanel Panel = new ChartPanel(Grafica); JFrame Ventana = new JFrame("JFreeChart"); Ventana.getContentPane().add(Panel); Ventana.pack(); Ventana.setVisible(true); Ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); return "VistaDeSeleccionGrafica"; // } // else // { // String msj="No hay datos"; // FacesMessage mensaje=new FacesMessage(FacesMessage.SEVERITY_ERROR,msj,""); // FacesContext.getCurrentInstance().addMessage(null, mensaje); // return "VistaDeSeleccionGrafica"; // } }
From source file:de.tuberlin.dima.flinkhandson.utils.SingleSeriesBarChart.java
public SingleSeriesBarChart(String title, String xLabel, String yLabel, Color barColor, Map<String, Double> result) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Map.Entry<String, Double> e : result.entrySet()) { dataset.addValue(e.getValue(), "", e.getKey()); }//from w ww .ja v a 2 s . co m JFreeChart chart = ChartFactory.createBarChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setBackgroundPaint(Color.WHITE); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setSeriesPaint(0, barColor); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(1024, 768)); getContentPane().add(chartPanel); pack(); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:com.sjsu.uidesign.ExecStatus.java
public ExecStatus() { super();//from w w w . jav a2s.c o m super.setTitle("Task Execution Status"); super.setSize(500, 500); super.setResizable(true); super.setLocationRelativeTo(null); JLabel usageImage = new JLabel(); //usageImage.setIcon(new ImageIcon("Pie_3.png")); //usageImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sjsu/uidesign/Bar_4.png"))); // NOI18N //add(usageImage); DefaultCategoryDataset barChartData = new DefaultCategoryDataset(); barChartData.setValue(6, "Cache Cleanup", "Cache Cleanup"); barChartData.setValue(8, "Antivirus Scan", "Antivirus Scan"); barChartData.setValue(7, "Empty Recycle Bin", "Empty Recycle Bin"); JFreeChart barChart = ChartFactory.createBarChart("Task Execution Status", "Task Name", "Status", createDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot barChar = barChart.getCategoryPlot(); barChar.setRangeGridlinePaint(Color.ORANGE); ChartPanel barPanel = new ChartPanel(barChart); JPanel panelChart = new JPanel(); panelChart.removeAll(); panelChart.add(barPanel, BorderLayout.CENTER); panelChart.validate(); add(panelChart); }
From source file:com.opendoorlogistics.components.barchart.BarchartPanel.java
@Override protected JFreeChart createChart(ODLTableReadOnly table, int[] rowFilter) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if (rowFilter != null) { for (int row : rowFilter) { createRowData(table, dataset, row); }//from www . j a v a2 s.c om } else { int n = table.getRowCount(); for (int row = 0; row < n; row++) { createRowData(table, dataset, row); } } // create the chart... JFreeChart chart = ChartFactory.createBarChart( Strings.isEmpty(config.getTitle()) ? null : config.getTitle(), // chart title config.getXLabel(), // domain axis label config.getYLabel(), // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set the background color for the chart... chart.setBackgroundPaint(Color.WHITE); // don't show legend for just one series if (((BarchartConfig) config).getSeriesNames().size() <= 1) { chart.removeLegend(); } return chart; }
From source file:be.pendragon.j2s.seventhcontinent.plot.jfreechart.JFreeChartPlotter.java
@Override public void plot(Statistics[] stats, String[] seriesNames, String title, File outputFile) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int series = 0; series < stats.length; series++) { for (int pct = 1; pct <= 100; pct++) { double pctValue = stats[series].getPercentile(pct); // # of stars if (series > 0) { pctValue = pctValue - stats[series - 1].getPercentile(pct); // deltas are stackables }//from w w w .j a v a 2 s. c o m dataset.addValue(pctValue, seriesNames[series], new Integer(pct)); } } final JFreeChart barChart = ChartFactory.createStackedBarChart(title, "%", "# stars", dataset); try { ChartUtilities.saveChartAsJPEG(outputFile, barChart, width, height); } catch (IOException ex) { // LOG.log(Level.SEVERE, "Plotting chart to file", ex); throw new RuntimeException("Plotting with JFreeChart chart to file", ex); } }
From source file:kata3.HistogramDisplay.java
private DefaultCategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (String key : histo.keySet()) { dataset.addValue(histo.get(key), "", key); }/* ww w. j a v a 2 s . c om*/ return dataset; }
From source file:charts.TiposErrorChart.java
private DefaultCategoryDataset createDataset(JTable table) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int row = 0; row < table.getRowCount(); row++) { String name = (String) table.getValueAt(row, 0); int quantity = (int) table.getValueAt(row, 1); resultadosExcell += "\n" + name + ":" + quantity; sumatoriaCantidad += quantity;/*from w ww . j av a 2 s . c o m*/ dataset.setValue(quantity, name, ""); } return dataset; }