List of usage examples for org.jfree.chart ChartFactory createBarChart3D
public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:com.ouc.cpss.view.EmpSaleChartBuilder.java
private static JFreeChart createJFreeChart(CategoryDataset dataset) { /**/*from w w w . java2 s.c om*/ * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //? JFreeChart jfreeChart = ChartFactory.createBarChart3D("", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); /** * JFreeChart */ jfreeChart.setTitle(new TextTitle("", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); return jfreeChart; }
From source file:de.berlios.statcvs.xml.chart.AbstractBarChart.java
/** * @param filename// ww w. java 2 s. c om * @param title */ public AbstractBarChart(ReportSettings settings, String filename, String title, String domainLabel, String rangeLabel) { super(settings, filename, title); dataset = new DefaultCategoryDataset(); setChart(ChartFactory.createBarChart3D(settings.getProjectName(), // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false)); // urls }
From source file:graficos.GenerarGraficoInventario.java
public void crear() { try {/* w w w. j ava 2 s .com*/ 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:include.picture.MyBarChart.java
/** *? *///www .j a va2 s .c o m public void paint() { try { check(); CategoryDataset dataset = getDataSet(series, category, data); JFreeChart chart = ChartFactory.createBarChart3D(title, axisXLabel, axisYLabel, dataset, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(Color.WHITE); BarRenderer3D renderer = new BarRenderer3D(); CategoryPlot plot = chart.getCategoryPlot(); renderer.setMaxBarWidth(0.01); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelFont(new Font("", Font.PLAIN, 15)); renderer.setItemLabelsVisible(true); renderer.setItemMargin(0.1); plot.setRenderer(renderer); FileOutputStream fos_jpg = null; try { fos_jpg = new FileOutputStream(fileName); ChartUtilities.writeChartAsJPEG(fos_jpg, 1000, chart, width, height, null); } finally { try { fos_jpg.close(); } catch (Exception e) { } } } catch (Exception e) { e.printStackTrace(); } // end of try-catch }
From source file:org.apache.qpid.disttest.charting.chartbuilder.BarChart3DBuilder.java
@Override protected JFreeChart createCategoryChart(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) { JFreeChart chart = ChartFactory.createBarChart3D(title, xAxisTitle, yAxisTitle, (CategoryDataset) dataset, plotOrientation, showLegend, showToolTips, showUrls); return chart; }
From source file:WeeklyReport.Sections.Bookings.java
private JFreeChart bookingsByPODChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Map<Double, Map<String, String>> map = new CargoQuoteType().bookingsByPOD(); map.entrySet().stream().forEach((mapEntry) -> { Map<String, String> m1 = mapEntry.getValue(); m1.entrySet().stream().forEach((pair) -> { dataset.setValue(mapEntry.getKey(), pair.getKey(), pair.getValue()); });/* www. ja v a 2 s . c om*/ }); JFreeChart barChart = ChartFactory.createBarChart3D("Bookings by POD", "Company", "Cubic Meters", dataset, PlotOrientation.HORIZONTAL, true, true, false); barChart.setBackgroundPaint(Color.WHITE); CategoryPlot categoryPlot = barChart.getCategoryPlot(); CategoryAxis domainAxis = categoryPlot.getDomainAxis(); BarRenderer br = (BarRenderer) categoryPlot.getRenderer(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); categoryPlot.setBackgroundPaint(Color.WHITE); categoryPlot.setRangeGridlinePaint(Color.BLACK); return barChart; }
From source file:com.manydesigns.portofino.chart.ChartBar3DGenerator.java
protected JFreeChart createChart(ChartDefinition chartDefinition, CategoryDataset dataset, PlotOrientation plotOrientation) { return ChartFactory.createBarChart3D(chartDefinition.getName(), chartDefinition.getXAxisName(), chartDefinition.getYAxisName(), dataset, plotOrientation, true, true, true); }
From source file:com.ev.gui.views.AnnualDiagramView.java
/** @param energyData Counter values. */ private void init(final CounterOfAYear counter) { final AnnualConsumption ac = new AnnualConsumption(counter); chart = ChartFactory.createBarChart3D(Integer.toString(counter.getYear()), getLang().getString("Month"), getLang().getString("Consumption"), ac.generateYearDatasetForDiagram(), PlotOrientation.VERTICAL, true, true, true);//w ww . j a v a 2 s . com chartPanel = new ChartPanel(chart); chart.setBackgroundPaint(chartPanel.getBackground()); chartPanel.setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT)); add(chartPanel); }
From source file:com.manydesigns.portofino.chart.ChartBar3DLargeGenerator.java
protected JFreeChart createChart(ChartDefinition chartDefinition, CategoryDataset dataset, PlotOrientation plotOrientation) { width = 1000;/*w w w .ja v a 2 s.com*/ height = 600; return ChartFactory.createBarChart3D(chartDefinition.getName(), chartDefinition.getXAxisName(), chartDefinition.getYAxisName(), dataset, plotOrientation, true, true, true); }
From source file:lectorarchivos.MostrarGraficaCSV.java
/** * Creates new form MostrarGraficaCSV//from w ww .j a va 2 s . c om */ public MostrarGraficaCSV(JTable jTableInfoCSV) { initComponents(); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); panel = new JPanel(); getContentPane().add(panel); //Fuente de datos DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //Recorremos la columna del consumo de la tabla for (int i = jTableInfoCSV.getRowCount() - 1; i >= 0; i--) { if (Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()) > 0) dataset.setValue(Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()), "Consumo", jTableInfoCSV.getValueAt(i, 0).toString()); } //Creando el grfico JFreeChart chart = ChartFactory.createBarChart3D("Consumo", "Fecha", "Consumo", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.cyan); chart.getTitle().setPaint(Color.black); chart.setBackgroundPaint(Color.white); chart.removeLegend(); //Cambiar color de barras CategoryPlot plot = (CategoryPlot) chart.getPlot(); BarRenderer barRenderer = (BarRenderer) plot.getRenderer(); barRenderer.setSeriesPaint(0, Color.decode("#5882FA")); // Mostrar Grafico ChartFrame frame = new ChartFrame("CONSUMO", chart); frame.pack(); frame.getChartPanel().setMouseZoomable(false); frame.setVisible(true); panel.add(frame); }