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:org.jfree.chart.demo.ImageMapDemo4.java
/** * Starting point for the demo./*from w ww.j a v a2 s .c om*/ * * @param args ignored. */ public static void main(final String[] args) { // create a chart final double[][] data = new double[][] { { 56.0, -12.0, 34.0, 76.0, 56.0, 100.0, 67.0, 45.0 }, { 37.0, 45.0, 67.0, 25.0, 34.0, 34.0, 100.0, 53.0 }, { 43.0, 54.0, 34.0, 34.0, 87.0, 64.0, 73.0, 12.0 } }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data); JFreeChart chart = null; final boolean drilldown = true; if (drilldown) { final CategoryAxis3D categoryAxis = new CategoryAxis3D("Category"); final ValueAxis valueAxis = new NumberAxis3D("Value"); final BarRenderer3D renderer = new BarRenderer3D(); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setItemURLGenerator(new StandardCategoryURLGenerator("bar_chart_detail.jsp")); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { chart = ChartFactory.createBarChart3D("Bar Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); } chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("barchart101.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("barchart101.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"barchart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:common.utility.ChartHelper.java
public static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart3D("Quantity Of Citizens Of Each Area", // chart title "(Include unactived people)", // domain axis label "Quantity", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );//from w w w.java 2s. c o m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.yellow); // Set the background colour of the chart chart.getTitle().setPaint(Color.blue); // Adjust the colour of the title CategoryPlot p = chart.getCategoryPlot(); // Get the Plot object for a bar graph p.setBackgroundPaint(Color.black); // Modify the plot background p.setRangeGridlinePaint(Color.red); return chart; }
From source file:org.jfree.chart.demo.JDBCCategoryChartDemo.java
public JDBCCategoryChartDemo(String s) { super(s);//from ww w . j av a 2s . c o m CategoryDataset categorydataset = readData(); JFreeChart jfreechart = ChartFactory.createBarChart3D("JDBC Category Chart Demo", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.yellow); ChartPanel chartpanel = new ChartPanel(jfreechart); setContentPane(chartpanel); }
From source file:javaapplication2.BarChart3D.java
public BarChart3D(String applicationTitle, String chartTitle) throws ClassNotFoundException, SQLException, IOException { super(applicationTitle); JFreeChart barChart = ChartFactory.createBarChart3D(chartTitle, "Notas", "Porcentagem de votos.", createDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = barChart.getCategoryPlot(); plot.getRangeAxis().setRange(0, 100); ChartPanel chartPanel = new ChartPanel(barChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); setContentPane(chartPanel);//from w w w .j ava2 s. co m this.setExtendedState(BarChart3D.MAXIMIZED_BOTH); //ChartUtilities.saveChartAsJPEG(new File("C:/Users/Public/Pictures/Barchart.jpg"), barChart, 956, 538); }
From source file:br.senac.tads.pi3.ghosts.locarsys.dao.Relatorios.java
public static void relatoriosDisponibilidade() throws SQLException, ClassNotFoundException { String query = "SELECT FL.NOME_FILIAL, COUNT(FL.NOME_FILIAL) AS QUANTIDADE FROM CARRO CA " + "INNER JOIN FILIAL FL ON FL.ID_FILIAL = CA.ID_FILIAL " + "WHERE CA.DISPONIBILIDADE_CARRO = '1' " + "GROUP BY FL.NOME_FILIAL"; Connection conn = Conexoes.obterConexao(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); DefaultCategoryDataset ds = new DefaultCategoryDataset(); while (rs.next()) { ds.addValue(rs.getInt("QUANTIDADE"), "Quantidade", rs.getString("NOME_FILIAL")); }//from w w w . j a va2s.co m /*File fg = new File("C:\\Users\\bruno.lopes.KRONMED\\Documents\\NetBeansProjects\\LoCarSys\\src\\main\\webapp\\ImagensLoCarSys\\disponibilidade.png"); fg.delete();*/ JFreeChart grafico = ChartFactory.createBarChart3D("Relatrio de Disponibilidade", "Filiais", "Separados por filiais", ds, PlotOrientation.VERTICAL, true, true, false); //try (OutputStream arquivo = new FileOutputStream("C:\\Users\\bruno.clopes\\Documents\\NetBeansProjects\\LoCarSys\\target\\LoCarSys-1.0-SNAPSHOT\\ImagensLoCarSys\\disponibilidade.png")) { try (OutputStream arquivo = new FileOutputStream("ImagensLoCarSys\\disponibilidade.png")) { ChartUtilities.writeChartAsPNG(arquivo, grafico, 800, 600); } catch (FileNotFoundException ex) { System.out.println("" + ex.getMessage()); } catch (IOException ex) { System.out.println("" + ex.getMessage()); } //try (OutputStream arquivo = new FileOutputStream("C:\\Users\\bruno.clopes\\Documents\\NetBeansProjects\\LoCarSys\\target\\LoCarSys-1.0-SNAPSHOT\\ImagensLoCarSys\\disponibilidade.png")) { try (OutputStream arquivo = new FileOutputStream( "C:\\Users\\temp.cas\\Documents\\NetBeansProjects\\LoCarSys\\target\\LoCarSys-1.0-SNAPSHOT\\ImagensLoCarSys\\disponibilidade.png")) { ChartUtilities.writeChartAsPNG(arquivo, grafico, 800, 600); } catch (FileNotFoundException ex) { System.out.println("" + ex.getMessage()); } catch (IOException ex) { System.out.println("" + ex.getMessage()); } }
From source file:org.jfree.chart.demo.CylinderChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart3D("Cylinder Chart Demo 1", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); Paint apaint[] = createPaint(); CustomCylinderRenderer customcylinderrenderer = new CustomCylinderRenderer(apaint); customcylinderrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); customcylinderrenderer.setBaseOutlinePaint(Color.gray); customcylinderrenderer.setBaseOutlineStroke(new BasicStroke(0.3F)); customcylinderrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); categoryplot.setRenderer(customcylinderrenderer); return jfreechart; }
From source file:com.ev.gui.views.OverallDiagramView.java
public OverallDiagramView() { OverallConsumption oc = new OverallConsumption(); chart = ChartFactory.createBarChart3D(getLang().getString("Overallview"), getLang().getString("Year"), getLang().getString("Consumption"), oc.generateAllDataset(), PlotOrientation.VERTICAL, true, true, true);//w w w. ja va 2 s .c o m chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_90); chartPanel = new ChartPanel(chart); chart.setBackgroundPaint(chartPanel.getBackground()); add(chartPanel); }
From source file:com.thecoderscorner.groovychart.chart.BarChart3D.java
public JFreeChart createChart() { return ChartFactory.createBarChart3D(getTitle(), getCategoryAxisLabel(), getValueAxisLabel(), (CategoryDataset) getDataset(), getOrientation(), isLegend(), isTooltips(), isUrls()); }
From source file:org.jfree.chart.demo.CylinderChartDemo2.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart3D("Cylinder Chart Demo 2", "Category", "Value", categorydataset, PlotOrientation.HORIZONTAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); Paint apaint[] = createPaint(); CustomCylinderRenderer customcylinderrenderer = new CustomCylinderRenderer(apaint); customcylinderrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); customcylinderrenderer.setBaseOutlinePaint(Color.gray); customcylinderrenderer.setBaseOutlineStroke(new BasicStroke(0.3F)); customcylinderrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); categoryplot.setRenderer(customcylinderrenderer); return jfreechart; }
From source file:com.java.reports.ProvisionalChart.java
@Override public ReportGenerator generateReport() { if (!isReportGenerated) { if (processProvisionalReport()) { chart = ChartFactory.createBarChart3D("Provisional Chart", "EMI Installments", "INR", _datasetProvisional, PlotOrientation.VERTICAL, true, true, false); isReportGenerated = true;// www .j a v a2 s . c o m } else { System.out.println("Report Generation Failed - EMI list is empty.."); } } return this; }