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:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.BulletGraph.java
public JFreeChart createChart() { logger.debug("IN"); Number value = null;//from w w w . j ava 2 s . c o m if (dataset == null) { logger.debug("The dataset to be represented is null"); value = new Double(0); } else { value = dataset.getValue(); } DefaultCategoryDataset datasetC = new DefaultCategoryDataset(); datasetC.addValue(value, "", ""); // customize a bar chart JFreeChart chart = ChartFactory.createBarChart(null, null, null, datasetC, PlotOrientation.HORIZONTAL, false, false, false); chart.setBorderVisible(false); CategoryPlot plot = chart.getCategoryPlot(); plot.setOutlineVisible(true); plot.setOutlinePaint(Color.BLACK); plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setBackgroundPaint(null); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setAnchorValue(value.doubleValue()); // add the target marker if (target != null) { ValueMarker marker = new ValueMarker(target.doubleValue(), Color.BLACK, new BasicStroke(2.0f)); plot.addRangeMarker(marker, Layer.FOREGROUND); } //sets different marks for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); // add the marks IntervalMarker marker = new IntervalMarker(interval.getMin(), interval.getMax(), interval.getColor()); plot.addRangeMarker(marker, Layer.BACKGROUND); logger.debug("Added new interval to the plot"); } // customize axes CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(false); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setVisible(show_axis); rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 4)); // calculate the upper limit //double upperBound = target * upperFactor; rangeAxis.setRange(new Range(lower, upper)); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // customize renderer BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setMaximumBarWidth(0.18); renderer.setSeriesPaint(0, Color.BLACK); /*BasicStroke d = new BasicStroke(3f,BasicStroke.CAP_ROUND ,BasicStroke.JOIN_ROUND); renderer.setSeriesOutlineStroke(0, d); renderer.setSeriesStroke(0, d); renderer.setStroke(d);*/ return chart; }
From source file:script.imglib.analysis.BarChart.java
static private final JFreeChart createChart(final Collection<? extends Number> data, final String title, final String xLabel, final String yLabel) { DefaultCategoryDataset dcd = new DefaultCategoryDataset(); int k = 1;// w w w . j a va2s .c o m for (final Number value : data) { dcd.addValue(value, "", k++); } boolean legend = false; boolean tooltips = true; boolean urls = false; JFreeChart chart = ChartFactory.createBarChart(title, xLabel, yLabel, dcd, PlotOrientation.VERTICAL, legend, tooltips, urls); setBarTheme(chart); return chart; }
From source file:net.imglib2.script.analysis.BarChart.java
@SuppressWarnings("boxing") static private final JFreeChart createChart(final Collection<? extends Number> data, final String title, final String xLabel, final String yLabel) { DefaultCategoryDataset dcd = new DefaultCategoryDataset(); int k = 1;/*from w ww .jav a 2 s . c o m*/ for (final Number value : data) { dcd.addValue(value, "", k++); } boolean legend = false; boolean tooltips = true; boolean urls = false; JFreeChart chart = ChartFactory.createBarChart(title, xLabel, yLabel, dcd, PlotOrientation.VERTICAL, legend, tooltips, urls); setBarTheme(chart); return chart; }
From source file:org.spantus.exp.segment.draw.DrawLabeledVector.java
public JFreeChart createBarChart(String chartName, String categoriesAxisName) { CategoryDataset dataSet = createCategoryDataset(getCategories()); JFreeChart chart = ChartFactory.createBarChart(chartName, // chart title "Category", // domain axis label "Value", // range axis label dataSet, // data PlotOrientation.HORIZONTAL, // the plot orientation false, // include legend true, false);//from w w w.j a va 2 s. co m chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(2); // change the margin at the top of the range axis... final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setAutoRange(true); return chart; }
From source file:ANNFileDetect.GraphingClass.java
public void drawchartFromInt(Integer[] values) throws IOException { DefaultCategoryDataset ds = new DefaultCategoryDataset(); for (int i = 0; i < values.length; i++) { //double a = (double) i; ds.addValue(i, String.valueOf(i), String.valueOf(values[i])); //ds.addValue((double)i, "Times", values[i]); }//from w w w . ja v a2 s .c o m JFreeChart chart = ChartFactory.createBarChart("chart", "quantity", "value", ds, PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(1200, 700); JPanel jf = new JPanel(); jf.setSize(1300, 800); chartPanel.setVisible(true); chartPanel.setZoomAroundAnchor(true); chartPanel.setDomainZoomable(true); jf.add(chartPanel); JLabel jl = new JLabel("hello!"); jf.add(jl); jf.setVisible(true); jf.repaint(); //jf.setAlwaysOnTop(true); }
From source file:agentlogfileanalyzer.gui.ComparisonFrame.java
/** * Creates a chart frame for comparing a selected classifier to a set of * other classifiers./*from www . java 2 s. co m*/ * * @param firstTitle * the first line of the chart title * @param secondTitle * the second line of the chart title * @param compDataForColumns * the data the will be displayed in the chart */ public ComparisonFrame(String firstTitle, String secondTitle, Vector<ComparisonDataSet> compDataForColumns) { super("Classifier comparison"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < compDataForColumns.size(); i++) { ComparisonDataSet mms = compDataForColumns.get(i); dataset.addValue(mms.getMax(), "max", mms.getColumnName()); dataset.addValue(mms.getMin(), "min", mms.getColumnName()); dataset.addValue(mms.getSelected(), "selected", mms.getColumnName()); } JFreeChart jfreechart = ChartFactory.createBarChart("", // title "", // x-axis title "", // y-axis title dataset, PlotOrientation.VERTICAL, true, true, false); TextTitle subtitle1 = new TextTitle(firstTitle, new Font("SansSerif", Font.BOLD, 12)); TextTitle subtitle2 = new TextTitle(secondTitle, new Font("SansSerif", Font.BOLD, 12)); jfreechart.addSubtitle(0, subtitle1); jfreechart.addSubtitle(1, subtitle2); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer(); categoryplot.setRenderer(minmaxcategoryrenderer); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartpanel); }
From source file:Reportes.BarChart.java
public ChartPanel reporteCantidadVehiculosPorSede(DefaultCategoryDataset data) { JFreeChart chart = ChartFactory.createBarChart("Reporte de cantidad de vehiculos por sede", "Sedes", "Cantidad", data, PlotOrientation.VERTICAL, true, true, true); CategoryPlot categoryP = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) categoryP.getRenderer(); renderer.setMaximumBarWidth(0.35);/*from w ww. j ava2 s .com*/ 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:com.googlecode.logVisualizer.chart.HorizontalBarChartBuilder.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart(getTitle(), xLable, yLable, dataset, PlotOrientation.HORIZONTAL, isIncludeLegend(), true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); final CategoryAxis categoryAxis = plot.getDomainAxis(); final NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); plot.setNoDataMessage("No data available"); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); setBarShadowVisible(chart, false);/*from w w w .j a v a 2 s . c o m*/ renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{1}, {2}", NumberFormat.getInstance())); categoryAxis.setCategoryMargin(0.02); categoryAxis.setUpperMargin(0.02); categoryAxis.setLowerMargin(0.02); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberAxis.setUpperMargin(0.1); return chart; }
From source file:org.no_ip.xeps.jntpplot.Plotter.java
public void chart() { DefaultCategoryDataset statsDataset = new DefaultCategoryDataset(); System.out.println(stats);/* www. j a va 2s . c o m*/ for (List<String> stat : stats) { for (int i = 1; i < statsLabels.size(); i++) { BigDecimal bd = new BigDecimal(stat.get(i)); statsDataset.addValue( //(Number) Long.valueOf(stat.get(i)), bd, (Comparable) statsLabels.get(i), (Comparable) stat.get(0)); } } // Chart bars if instructed to if (chartType == "bar") { JFreeChart barChartObject = ChartFactory.createBarChart(plotLabel, statsLabels.get(0), yLabel, statsDataset, PlotOrientation.VERTICAL, true, true, false); int width = 1280; int height = 1024; File barChart = new File(output); try { ChartUtilities.saveChartAsJPEG(barChart, barChartObject, width, height); } catch (IOException ex) { java.util.logging.Logger.getLogger(Plotter.class.getName()).log(Level.SEVERE, null, ex); logger.error("Failed to output linechart JPEG @ " + output + ": " + ex); } // Default to line charts } else { JFreeChart lineChartObject = ChartFactory.createLineChart(plotLabel, statsLabels.get(0), yLabel, statsDataset, PlotOrientation.VERTICAL, true, true, false); int width = 1280; int height = 1024; File lineChart = new File(output); try { ChartUtilities.saveChartAsJPEG(lineChart, lineChartObject, width, height); } catch (IOException ex) { java.util.logging.Logger.getLogger(Plotter.class.getName()).log(Level.SEVERE, null, ex); logger.error("Failed to output linechart JPEG @ " + output + ": " + ex); } } }
From source file:biblioteca.reportes.ChartCreator.java
public static JFreeChart generateBarChart(DefaultCategoryDataset dataSet, String Titulo, String tituloX, String tituloY) {/* www . ja va2s. c o m*/ JFreeChart chart = ChartFactory.createBarChart(Titulo, tituloX, tituloY, dataSet, PlotOrientation.VERTICAL, false, true, false); return chart; }