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:Interfaces.EstadisticaConocioGui.java
/** * Creates new form EstadisticaConocioGui *//*from w w w. ja v a2 s . c o m*/ public EstadisticaConocioGui(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); abrirBase(); LazyList<Socio> socios = Socio.findAll(); Iterator<Socio> it = socios.iterator(); Socio s; String nosConocio; Boolean activo; Integer[] nosConocioSuma = { 0, 0, 0, 0, 0, 0 }; LinkedList<Pair<Integer, Integer>> actividadesRealizan = new LinkedList<>(); LazyList<Arancel> aranceles = Arancel.findAll(); Iterator<Arancel> itArancel = aranceles.iterator(); while (itArancel.hasNext()) { Pair<Integer, Integer> par = new Pair<>(itArancel.next().getInteger("id"), 0); actividadesRealizan.add(par); } while (it.hasNext()) { s = it.next(); nosConocio = s.getString("NOSCONOCIOPOR"); activo = s.getBoolean("ACTIVO"); switch (nosConocio) { case "NO ESPECIFICA": nosConocioSuma[0]++; break; case "VIO EL GIMNASIO": nosConocioSuma[1]++; break; case "POR RADIO": nosConocioSuma[2]++; break; case "POR TV": nosConocioSuma[3]++; break; case "REDES SOCIALES": nosConocioSuma[4]++; break; case "UN AMIGO/A": nosConocioSuma[5]++; break; } if (activo) { LazyList<Socioarancel> arancelesSocio = Socioarancel.where("id_socio = ?", s.getId()); Iterator<Socioarancel> itAr = arancelesSocio.iterator(); while (itAr.hasNext()) { Socioarancel ar = itAr.next(); boolean sume = false; int i = 0; while (i < actividadesRealizan.size() && !sume) { if (actividadesRealizan.get(i).first() == ar.getInteger("id_arancel")) { Pair<Integer, Integer> aux = new Pair<>(actividadesRealizan.get(i).first(), actividadesRealizan.get(i).second() + 1); actividadesRealizan.remove(i); actividadesRealizan.add(i, aux); sume = true; } i++; } } } } DefaultCategoryDataset datasetConocio = new DefaultCategoryDataset(); datasetConocio.setValue(nosConocioSuma[0], "nos conocieron", "NO ESPECIFICA"); datasetConocio.setValue(nosConocioSuma[1], "nos conocieron", "VIO EL GIMNASIO"); datasetConocio.setValue(nosConocioSuma[2], "nos conocieron", "POR RADIO"); datasetConocio.setValue(nosConocioSuma[3], "nos conocieron", "POR TV"); datasetConocio.setValue(nosConocioSuma[4], "nos conocieron", "REDES SOCIALES"); datasetConocio.setValue(nosConocioSuma[5], "nos conocieron", "UN AMIGO/A"); JFreeChart chart = ChartFactory.createBarChart3D("Estadisticas por donde nos conocieron", "donde", "cantidad de personas", datasetConocio, PlotOrientation.VERTICAL, true, true, false); // Creacin del panel con el grfico ChartPanel panelGrafico = new ChartPanel(chart); pnlConocio.add(panelGrafico); DefaultCategoryDataset datasetAct = new DefaultCategoryDataset(); for (int i = 0; i < actividadesRealizan.size(); i++) { String nombreAct = Arancel.findById(actividadesRealizan.get(i).first()).getString("nombre"); datasetAct.setValue(actividadesRealizan.get(i).second(), "actividad", nombreAct); } JFreeChart chartAct = ChartFactory.createBarChart3D("Estadisticas que actividad realizan", "actividad", "cantidad de personas", datasetAct, PlotOrientation.VERTICAL, true, true, false); // Creacin del panel con el grfico ChartPanel panelGraficoAc = new ChartPanel(chartAct); pnlAct.add(panelGraficoAc); }
From source file:org.wsm.database.tools.editor.ui.GraphPane.java
public JFreeChart getChart(String chartType) { if (CHART_TYPE_BAR_3D.equals(chartType)) return ChartFactory.createBarChart3D("Load Test Results", "Thread Id", "Time taken in Seconds", dcd, PlotOrientation.VERTICAL, true, true, true); else if (CHART_TYPE_LINE_3D.equals(chartType)) return ChartFactory.createLineChart3D("Load Test Results", "Thread Id", "Time taken in Seconds", dcd, PlotOrientation.VERTICAL, true, true, true); else/* w ww .j a va 2 s. c om*/ return null; }
From source file:UserInterface.FinanceRole.DonationsReceivedJPanel.java
private void generateDonationAnalysis() { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (Organization objDonorOrganization : objWorldEnterprise.getObjOrganizationDirectory() .getOrganizationList()) {//from w w w . jav a2 s . com if (objDonorOrganization instanceof DonorOrganization) { for (Person objPerson : objDonorOrganization.getObjPersonDirectory().getPersonList()) { BigDecimal totalAmount = new BigDecimal(0); for (Transaction objTransaction : objPerson.getObjDonorTransactionDirectory() .getTransactionList()) { totalAmount = totalAmount.add(objTransaction.getTransactionBDAmount()); } dataSet.setValue(totalAmount, "Donation", objPerson.getPersonFirstName()); } } } JFreeChart chart = ChartFactory.createBarChart3D("Overview of entire donation", "Donor Name", "Total donation in USD $", dataSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.black); ChartPanel myChart = new ChartPanel(chart); donationJPanel.setLayout(new java.awt.BorderLayout()); donationJPanel.add(myChart, BorderLayout.CENTER); donationJPanel.validate(); }
From source file:edu.indiana.htrc.visual.HTRCBarChartDrawer.java
@Override public File draw() { System.out.println("draw bar!!!!!!!!!!!!!"); DefaultCategoryDataset bar_dataset = new DefaultCategoryDataset(); /*dataset.setValue(6, "Profit", "Jane"); dataset.setValue(7, "Profit", "Tom"); dataset.setValue(8, "Profit", "Jill"); dataset.setValue(5, "Profit", "John"); dataset.setValue(12, "Profit", "Fred");*/ Set<String> key_set = input_map.keySet(); Iterator<String> iter = key_set.iterator(); while (iter.hasNext()) { String key = iter.next(); int value = input_map.get(key); bar_dataset.setValue(value, dataset_label, key); }/*from w ww . ja v a 2 s .c om*/ JFreeChart chart = null; if (is3D) { chart = ChartFactory.createBarChart3D(chart_name, x_axis_label, y_axis_label, bar_dataset, PlotOrientation.VERTICAL, true, true, false); } else { chart = ChartFactory.createBarChart(chart_name, x_axis_label, y_axis_label, bar_dataset, PlotOrientation.VERTICAL, true, true, false); } CategoryPlot p = chart.getCategoryPlot(); /* NumberAxis rangeAxis = (NumberAxis) p.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());*/ BarRenderer renderer = (BarRenderer) p.getRenderer(); DecimalFormat decimalformat1 = new DecimalFormat("##"); StandardCategoryItemLabelGenerator label_generator = new StandardCategoryItemLabelGenerator("{2}", decimalformat1); renderer.setItemLabelGenerator(label_generator); final ItemLabelPosition pos = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0/* -Math.PI / 2.0*/ ); renderer.setPositiveItemLabelPosition(pos); final CategoryAxis domainAxis = p.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); renderer.setMaximumBarWidth(.15); renderer.setItemLabelsVisible(true); chart.getCategoryPlot().setRenderer(renderer); File img = new File("../webapps/HTRC-UI-AuditAnalyzer/images/" + System.currentTimeMillis() + ".jpg"); try { ChartUtilities.saveChartAsJPEG(img, chart, 1400, 600); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } return img; }
From source file:org.karndo.graphs.CustomChartFactory.java
/** * Creates a chart of the selected PiracyEvent data graphed by vessel * type. Presently uses a very basic method of graphing this data by * using the static CreateBarChart3D method available in class * org.jfree.chart.ChartFactory. //from ww w . j a v a 2 s .c om * * @param data the selected PiracyEvent data to graph. * @return A JFreeChart object representing a graph of the selected * PiracyEvent data against vessel type. */ public JFreeChart createHistogramVesselType(LinkedList<PiracyEvent> data) { //the data to plot DefaultCategoryDataset dataset = new DefaultCategoryDataset(); LinkedHashMap<String, MutableInt> freqs_cats = new LinkedHashMap<String, MutableInt>(); for (PiracyEvent ev : data) { if (!freqs_cats.containsKey(ev.getVesselType())) { freqs_cats.put(ev.getVesselType(), new MutableInt(1)); } else { freqs_cats.get(ev.getVesselType()).increment(); } } Iterator itr = freqs_cats.keySet().iterator(); while (itr.hasNext()) { String category = (String) itr.next(); Integer i1 = freqs_cats.get(category).getValue(); dataset.addValue(i1, "Piracy Incidents", category); } JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by vessel type", "Vessel Type", "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChart3DDemo2.java
/** * Creates a chart.//from w w w. j a va2s . com * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(1.0f); // left align the category labels... CategoryAxis axis = plot.getDomainAxis(); CategoryLabelPositions p = axis.getCategoryLabelPositions(); CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, 0.0, CategoryLabelWidthType.RANGE, 0.30f); axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left)); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); setCategorySummary(dataset); return chart; }
From source file:grafici.StatisticheBarChart3D.java
/** * Creates a sample chart.//from ww w . j av a 2 s . c om * * @param dataset * the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset, Table results, int variabile1, int variabile2, int valore) { // create the chart... JFreeChart chart = ChartFactory.createBarChart3D(titolo, // chart // title results.getColumn(variabile2).getText().toUpperCase(), // domain axis label results.getColumn(valore).getText().toUpperCase(), // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); final CategoryPlot plot = chart.getCategoryPlot(); final CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0)); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setItemLabelsVisible(true); final BarRenderer r = (BarRenderer) renderer; return chart; }
From source file:org.jfree.chart.demo.BarChart3DDemo3.java
/** * Creates a chart./* ww w. j a v a 2 s.c o m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart3D("3D Bar Chart Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = chart.getCategoryPlot(); final CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0)); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setItemLabelsVisible(true); final BarRenderer r = (BarRenderer) renderer; r.setMaxBarWidth(0.05); return chart; }
From source file:j2se.jfreechart.barchart.BarChart3DDemo3.java
/** * Creates a chart.//from www . java 2 s .c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart3D("3D Bar Chart Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = chart.getCategoryPlot(); final CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0)); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setItemLabelsVisible(true); final BarRenderer r = (BarRenderer) renderer; r.setMaximumBarWidth(0.05); return chart; }
From source file:edu.ku.brc.af.tasks.subpane.BarChartPane.java
public synchronized void allResultsBack(final QueryResultsContainerIFace qrc) { // create a dataset... String cat = ""; //$NON-NLS-1$ DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object> list = handler.getDataObjects(); for (int i = 0; i < list.size(); i++) { Object descObj = list.get(i++); Object valObj = list.get(i); dataset.addValue(getInt(valObj), getString(descObj), cat); }// w w w . j ava2 s . c o m list.clear(); // create the chart... JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title xAxisTitle, // domain axis label yAxisTitle, // range axis label dataset, // data isVertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, true, // include legend true, // tooltips? false // URLs? ); // create and display a frame... ChartPanel panel = new ChartPanel(chart, true, true, true, true, true); panel.setMaximumSize(new Dimension(100, 100)); panel.setPreferredSize(new Dimension(100, 100)); //chart.getCategoryPlot().setRenderer(new CustomColorBarChartRenderer()); addCompletedComp(panel); }