List of usage examples for org.jfree.chart ChartFactory createBarChart
public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
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); }/*www .jav a2 s . co m*/ } 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:br.unicamp.cst.motivational.MotivationalMonitor.java
@Override public synchronized void run() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createBarChart(getTitle(), getEntity(), "Value", dataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); chart.setBackgroundPaint(Color.lightGray); ChartFrame frame = new ChartFrame(getTitle(), chart); frame.pack();/*from w w w .ja va2 s . c om*/ frame.setVisible(true); while (true) { ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>(); tempCodeletsList.addAll(this.getListOfMotivationalEntities()); synchronized (tempCodeletsList) { for (Codelet co : tempCodeletsList) { dataset.addValue(co.getActivation(), co.getName(), "activation"); } try { Thread.currentThread().sleep(getRefreshPeriod()); } catch (InterruptedException e) { e.printStackTrace(); } } } }
From source file:com.jeco.ui.view.GraficoPeso.java
public void drawGrafico(Ovino ovino) { if (ovino == null) { ovino = new Ovino(); ovino.setCodigo("00"); }/*from w w w .j a v a 2 s . c om*/ DefaultCategoryDataset ds = new DefaultCategoryDataset(); for (Pesagem pesagem : ovino.getHistoricoPesos()) { ds.addValue(pesagem.getPeso(), "Peso", pesagem.getData()); } //cria o grafico.. JFreeChart data = ChartFactory.createBarChart("", "Data", "Peso do Ovino " + ovino.getCodigo(), ds, PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(data); this.chartPanel = chartPanel; chartPanel.setPreferredSize(new java.awt.Dimension(378, 260)); this.setBackground(new java.awt.Color(255, 255, 255)); this.remove(chartPanel); this.repaint(); this.add(chartPanel); chartPanel.setBackground(new java.awt.Color(255, 255, 255)); this.repaint(); }
From source file:org.jfree.chart.demo.MinMaxCategoryPlotDemo1.java
public static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Min/Max Category Plot", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setRangePannable(true); MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer(); minmaxcategoryrenderer.setDrawLines(false); categoryplot.setRenderer(minmaxcategoryrenderer); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:com.awesheet.models.charts.BarChart.java
@Override public boolean generateImageData() { // Create the dataset. DefaultCategoryDataset dataset = createDataset(); if (dataset == null) { return false; }/* w ww . jav a 2 s . c om*/ // Create the chart. JFreeChart barChart = ChartFactory.createBarChart(title, nameX, nameY, dataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot plot = barChart.getCategoryPlot(); ((BarRenderer) plot.getRenderer()).setBarPainter(new StandardBarPainter()); // Generate the image. try { imageData = ChartUtilities.encodeAsPNG(barChart.createBufferedImage(720, 480)); } catch (IOException e) { return false; } return true; }
From source file:com.crunchify.jsp.servlet.BarServlet.java
public JFreeChart getChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(15, "1", "451"); dataset.addValue(12, "1", "851"); dataset.addValue(10, "2", "362"); dataset.addValue(5, "2", "142"); JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 3", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation false, // include legend true, false);/* ww w .j a v a 2s . c o m*/ chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); renderer.setItemLabelsVisible(true); ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0); renderer.setPositiveItemLabelPosition(p); plot.setRenderer(renderer); // change the margin at the top of the range axis... ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:algo.PlotBar.java
public PlotBar(String applicationTitle, String chartTitle) throws FileNotFoundException, IOException { super(applicationTitle); JFreeChart barChart = ChartFactory.createBarChart(chartTitle, "Algorithms", "Execution Time(ms)", createDataset(), PlotOrientation.VERTICAL, true, true, false); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); ChartPanel chartPanel = new ChartPanel(barChart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 420)); setContentPane(chartPanel);/* w w w. j a va2 s.c o m*/ }
From source file:com.rapidminer.gui.plotter.charts.BarChart2DPlotter.java
public JFreeChart createChart(CategoryDataset categoryDataSet, String groupByName, String valueName, boolean createLegend) { JFreeChart chart = ChartFactory.createBarChart(null, // chart title groupByName, // domain axis label valueName, // range axis label categoryDataSet, // data PlotOrientation.VERTICAL, // orientation ((createLegend) && (groupByName != null)), // include legend if group by column is set true, // tooltips false // URLs );// www .j av a 2s . c o m // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(230, 230, 230)); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set up paints for series if (groupByName == null) { BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, SwingTools.LIGHT_BLUE); renderer.setSeriesPaint(1, SwingTools.LIGHT_YELLOW); } // domain axis labels CategoryAxis domainAxis = plot.getDomainAxis(); if (groupByName == null) { domainAxis.setTickLabelsVisible(true); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); } else { domainAxis.setTickLabelsVisible(false); } return chart; }
From source file:Reportes.BarChart.java
public ChartPanel reporteAportesVentas(DefaultCategoryDataset data) { JFreeChart chart = ChartFactory.createBarChart("Reporte de aporte por sede", "Sedes", "Aporte", data, PlotOrientation.VERTICAL, true, true, true); CategoryPlot categoryP = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) categoryP.getRenderer(); renderer.setMaximumBarWidth(0.35);// w ww . j av a2 s . c o m Color color = new Color(67, 165, 208); renderer.setSeriesPaint(0, color); ChartPanel panel = new ChartPanel(chart, true, true, true, false, false); panel.setSize(ancho, alto); return panel; }
From source file:JavaBean.BeanGraficaPersonal.java
public String muestraGrafica(String matricula) { // List<TareaAlumno> lista=dameDatos(matricula); // if(lista!=null) // {/*from ww w. ja v a 2 s. c om*/ 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"; // } }