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.eevolution.form.CRP.java
/** * create Chart using the data set and UOM * @param dataset/*w w w . j a v a 2 s . co m*/ * @param title * @param uom * @return JFreeChart */ protected JFreeChart createChart(CategoryDataset dataset, String title, MUOM uom) { JFreeChart chart = ChartFactory.createBarChart3D(title, " ", " ", dataset, PlotOrientation.VERTICAL, true, true, false); if (uom == null || uom.isHour()) { chart = ChartFactory.createBarChart3D(title, Msg.translate(Env.getCtx(), "Days"), // X-Axis label Msg.translate(Env.getCtx(), "Hours"), // Y-Axis label dataset, // Dataset PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); } else { chart = ChartFactory.createBarChart3D(title, Msg.translate(Env.getCtx(), "Days"), // X-Axis label Msg.translate(Env.getCtx(), "Kilo"), // Y-Axis label dataset, // Dataset PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); } return chart; }
From source file:org.squale.squaleweb.util.graph.BarMaker.java
/** * @return le diagramme JFreeChart/*from www . j av a2 s . c o m*/ */ protected JFreeChart getChart() { JFreeChart retChart = super.getChart(); if (null == retChart) { retChart = ChartFactory.createBarChart3D(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = retChart.getCategoryPlot(); // Les valeurs sont des entiers final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // On effectue une rotation de 90 pour afficher le titre des abscisses la verticale CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0)); super.setChart(retChart); } return retChart; }
From source file:org.posterita.core.BarChart.java
public JFreeChart createChart() throws OperationException { if (dataset == null) { throw new OperationException("Cannot create Bar chart: cause -> dataset empty!"); }//from w w w . jav a 2 s . com switch (type) { case BARCHART_FLAT: chart = ChartFactory.createBarChart(title, xLabel, yLabel, dataset, orientation, showLegend, showTooltip, true); break; case BARCHART_3D: chart = ChartFactory.createBarChart3D(title, xLabel, yLabel, dataset, orientation, showLegend, showTooltip, true); break; default: throw new OperationException( "Invalid barchart type! Can only be BarChart.BARCHART_FLAT or BarChart.BARCHART_3D"); } //setting subtitle if (subtitle != null) { TextTitle title = new TextTitle(subtitle); chart.addSubtitle(title); } CategoryPlot plot = chart.getCategoryPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); //setting tickUnits if (integerTickUnits) axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barRender = (BarRenderer) plot.getRenderer(); barRender.setMaximumBarWidth(maximumBarWidth); //displaying labels if (showLabels) { CategoryItemRenderer itemRender = plot.getRenderer(); itemRender.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); itemRender.setItemLabelsVisible(true); } return chart; }
From source file:br.senac.tads.pi3.ghosts.locarsys.dao.Relatorios.java
public static void relatoriosVendas() throws SQLException, ClassNotFoundException { String query = "SELECT FL.NOME_FILIAL, COUNT(FL.NOME_FILIAL) AS QUANTIDADE FROM FILIAL FL " + "INNER JOIN FUNCIONARIO FUNC ON FUNC.ID_FILIAL = FL.ID_FILIAL " + "INNER JOIN ALUGUEL AL ON AL.ID_FUNCIONARIO = FUNC.ID_FUNCIONARIO " + "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 ww w. j a v a2 s . co m JFreeChart grafico = ChartFactory.createBarChart3D("Relatrio de Aluguis", "Filiais", "Separadas por filiais", ds, PlotOrientation.VERTICAL, true, true, false); try (OutputStream arquivo = new FileOutputStream("ImagensLoCarSys\\vendas.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\\vendas.png")) { try (OutputStream arquivo = new FileOutputStream( "C:\\Users\\temp.cas\\Documents\\NetBeansProjects\\LoCarSys\\target\\LoCarSys-1.0-SNAPSHOT\\ImagensLoCarSys\\vendas.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:graficos.GraficoBarras.java
private static JFreeChart crearGrafico(CategoryDataset cjto_datos) { JFreeChart grafico = ChartFactory.createBarChart3D("Distribucin de Recursos", // Ttulo "Unidad de tiempo", // Ttulo eje x "Recurso", // Ttulo eje y cjto_datos, // Datos PlotOrientation.VERTICAL, // Orientacin true, // Incluir leyenda true, // Incluir tooltips false // Incluir URLs );//w w w .j av a 2 s .c om grafico.setBackgroundPaint(new Color(240, 240, 240)); grafico.getPlot().zoom(0.0); CategoryPlot ploter = (CategoryPlot) grafico.getPlot(); NumberAxis3D rangeAxis = (NumberAxis3D) ploter.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis3D.createIntegerTickUnits()); BarRenderer3D renderer = (BarRenderer3D) ploter.getRenderer(); renderer.setDrawBarOutline(false); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setItemMargin(0.0); CategoryAxis domainAxis = ploter.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.0)); return grafico; }
From source file:wtw.ui.GetChartAction.java
@Override public String execute() throws Exception { Object start = ActionContext.getContext().getSession().get("start"); Object end = ActionContext.getContext().getSession().get("end"); if (start != null && end != null) { startdate = (String) start; enddate = (String) end;/*from w w w .ja v a2 s . c o m*/ } if (start == null || end == null) { all = 6; mobile = 1; web = 1; software = 1; design = 1; data = 1; other = 1; } else { Date date2; Date date; DateFormat formater = new SimpleDateFormat("yyyy-MM-dd"); date = (Date) formater.parse(startdate); date2 = (Date) formater.parse(enddate); all = projectManager.getCountProjectInMonth(date, date2); mobile = projectManager.getCountProjectInMonthAndCategory(date, date2, " Mobile"); web = projectManager.getCountProjectInMonthAndCategory(date, date2, " Website"); software = projectManager.getCountProjectInMonthAndCategory(date, date2, " Software"); design = projectManager.getCountProjectInMonthAndCategory(date, date2, " Design"); data = projectManager.getCountProjectInMonthAndCategory(date, date2, " Data Entry"); other = projectManager.getCountProjectInMonthAndCategory(date, date2, " Other"); } DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); dataSet.setValue(all, "Population", "Total"); dataSet.setValue(mobile, "Population", "Mobile"); dataSet.setValue(web, "Population", "Website"); dataSet.setValue(software, "Population", "Software"); dataSet.setValue(data, "Population", "Data Entry"); dataSet.setValue(design, "Population", "Design"); dataSet.setValue(other, "Population", "Other"); chart = ChartFactory.createBarChart3D("Report Quantity Project By Category", "Project Category", "Quantity of Project", dataSet, PlotOrientation.VERTICAL, false, true, false); return SUCCESS; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.BarChartExpression.java
public JFreeChart computeCategoryChart(final CategoryDataset categoryDataset) { final PlotOrientation orientation = computePlotOrientation(); final JFreeChart chart; if (isThreeD()) { if (isStacked()) { chart = ChartFactory.createStackedBarChart3D(computeTitle(), getCategoryAxisLabel(), getValueAxisLabel(), categoryDataset, orientation, isShowLegend(), false, false); } else {/*w ww. java 2 s . com*/ chart = ChartFactory.createBarChart3D(computeTitle(), getCategoryAxisLabel(), getValueAxisLabel(), categoryDataset, orientation, isShowLegend(), false, false); } chart.getCategoryPlot().setDomainAxis(new FormattedCategoryAxis3D(getCategoryAxisLabel(), getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale())); } else { if (isStacked()) { chart = ChartFactory.createStackedBarChart(computeTitle(), getCategoryAxisLabel(), getValueAxisLabel(), categoryDataset, orientation, isShowLegend(), false, false); } else { chart = ChartFactory.createBarChart(computeTitle(), getCategoryAxisLabel(), getValueAxisLabel(), categoryDataset, orientation, isShowLegend(), false, false); } chart.getCategoryPlot().setDomainAxis(new FormattedCategoryAxis(getCategoryAxisLabel(), getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale())); } final CategoryPlot plot = (CategoryPlot) chart.getPlot(); configureLogarithmicAxis(plot); return chart; }
From source file:net.nosleep.superanalyzer.analysis.views.WordView.java
public void createChart() { _chart = ChartFactory.createBarChart3D(Misc.getString("SONG_WORDS"), // chart title Misc.getString("WORD"), // domain axis label Misc.getString("SONG_COUNT"), // range axis label _dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? );/*from w w w. j a va 2 s .c o m*/ _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("SONG_WORDS_TOOLTIP"))); CategoryPlot plot = (CategoryPlot) _chart.getPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(_chart); Misc.formatChart(plot); CategoryItemRenderer renderer = plot.getRenderer(); BarRenderer3D barRenderer = (BarRenderer3D) renderer; barRenderer.setWallPaint(Color.white); barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:WeeklyReport.Sections.Bookings.java
private JFreeChart bookingsByTradelaneChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Map<Double, Map<String, String>> map = new CargoQuoteType().bookingsByTradeLane(); map.entrySet().stream().forEach((mapEntry) -> { Map<String, String> m1 = mapEntry.getValue(); m1.entrySet().stream().forEach((pair) -> { dataset.setValue(mapEntry.getKey(), pair.getKey(), pair.getValue()); });/*from w w w . j av a2s . c om*/ }); JFreeChart barChart = ChartFactory.createBarChart3D("Bookings by Trade Lane", "Company", "Cubic Meters", dataset, PlotOrientation.VERTICAL, true, true, false); barChart.setBackgroundPaint(Color.WHITE); CategoryPlot categoryPlot = barChart.getCategoryPlot(); CategoryAxis domainAxis = categoryPlot.getDomainAxis(); BarRenderer br = (BarRenderer) categoryPlot.getRenderer(); if (map.values().stream().mapToInt((list) -> list.size()).count() > 2) { domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); } categoryPlot.setBackgroundPaint(Color.WHITE); categoryPlot.setRangeGridlinePaint(Color.BLACK); return barChart; }
From source file:Visao.Relatorio.GraficoPerCapta.java
public void plotarGrafico(String chartTitle, ArrayList<Double> indices) { barChart = ChartFactory.createBarChart3D(chartTitle, "Estado", "?ndice de Reclamao", createDataset(indices), PlotOrientation.VERTICAL, true, true, false); barChart.setBackgroundPaint(Color.WHITE); CategoryPlot p = barChart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartPanel panel = new ChartPanel(barChart); panel.setVisible(true);/*from ww w . j a v a 2s . c om*/ panel.setSize(screenSize.width - 210, screenSize.height - 140); this.add(panel); }