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:org.javarebel.chart.generator.BarChartGenerator.java
@Override public JFreeChart generateChart(ChartData data) { if (data instanceof BarChartData) { CategoryDataset dataset = data.createDataset(); PlotOrientation pltOrd = PlotOrientation.VERTICAL; if ("HORIZONTAL".compareToIgnoreCase(data.getOrientation()) == 0) pltOrd = PlotOrientation.HORIZONTAL; final JFreeChart chart = ChartFactory.createBarChart(data.getTitle(), data.getXaxisLabel(), data.getYaxisLabel(), dataset, pltOrd, true, true, false); super.configureChart(chart, data); return chart; } else// w w w. j a v a 2s.c om throw new IllegalArgumentException(); }
From source file:bc.ui.swing.charts.BarChart.java
private JFreeChart generateView() { JFreeChart ret = ChartFactory.createBarChart(model.getTitle(), model.getDomainAxisLabel(), model.getRangeAxisLabel(), ((DefaultCategoryDataset) dataset), PlotOrientation.VERTICAL, true, true, false);// ww w. j a v a 2 s . c om ret.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) ret.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(new Color(200, 200, 200)); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(new Color(200, 200, 200)); plot.setRangeGridlinesVisible(true); BarRenderer barrenderer = (BarRenderer) plot.getRenderer(); barrenderer.setDrawBarOutline(true); barrenderer.setBarPainter(new StandardBarPainter()); final Color baseColor = new Color(160, 200, 255); final DefaultDrawingSupplier otherColors = new DefaultDrawingSupplier(); plot.setDrawingSupplier(new DefaultDrawingSupplier() { boolean first = true; @Override public Paint getNextPaint() { if (first) { first = false; return baseColor; } return otherColors.getNextPaint(); } }); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setTickMarksVisible(true); return ret; }
From source file:support.TradingVolumeGui.java
private CategoryPlot createChartFrame(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Trading Volume", "Stock", "Volume, USD", dataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Hazelcast Jet Source Builder Sample"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.setVisible(true);/* w w w. ja v a2 s . c o m*/ frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { hzMap.removeEntryListener(entryListenerId); } }); return plot; }
From source file:com.googlecode.logVisualizer.chart.HorizontalIntervallBarChartBuilder.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 CategoryAxis categoryAxis = plot.getDomainAxis(); final LayeredBarRenderer renderer = new LayeredBarRenderer(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.black); setBarShadowVisible(chart, false);/*from ww w . ja va2 s . c o m*/ plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getRangeAxis().setLowerBound(-35); plot.getRangeAxis().setUpperBound(35); renderer.setDrawBarOutline(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.green); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER)); renderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE2, TextAnchor.CENTER)); renderer.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER)); renderer.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.CENTER)); renderer.setItemLabelAnchorOffset(9.0); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{1}, {2}", NumberFormat.getInstance())); plot.setRenderer(renderer); plot.setRowRenderingOrder(SortOrder.DESCENDING); categoryAxis.setCategoryMargin(0.15); categoryAxis.setUpperMargin(0.0175); categoryAxis.setLowerMargin(0.0175); return chart; }
From source file:org.perfrepo.web.controller.reports.testgroup.TestGroupChartBean.java
public void drawChart(OutputStream out, Object data) throws IOException { if (data instanceof ChartData) { ChartData chartData = (ChartData) data; JFreeChart chart = ChartFactory.createBarChart(chartData.getTitle(), "Test", "%", processDataSet(chartData), PlotOrientation.HORIZONTAL, false, true, false); chart.addSubtitle(new TextTitle("Comparison", new Font("Dialog", Font.ITALIC, 10))); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CustomRenderer renderer = new CustomRenderer(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}%", NumberFormat.getInstance())); renderer.setBaseItemLabelsVisible(true); renderer.setDrawBarOutline(false); renderer.setMaximumBarWidth(1d / (chartData.getTests().length + 4.0)); plot.setRenderer(renderer);//from w ww. j a v a 2s . co m CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setCategoryMargin(0.1); categoryAxis.setUpperMargin(0.1); categoryAxis.setLowerMargin(0.1); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.10); BufferedImage buffImg = chart.createBufferedImage(640, chartData.getTests().length * 100 + 100); ImageIO.write(buffImg, "gif", out); } }
From source file:org.jgrasstools.gears.utils.chart.CategoryBoxplot.java
public JFreeChart getChart() { if (chart == null) { createDataset();/* w w w . j av a 2 s . c om*/ chart = ChartFactory.createBarChart(getTitle(), // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis rangeAxis = plot.getDomainAxis(); rangeAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); renderer.setMeanVisible(isMeanVisible); plot.setRenderer(renderer); } return chart; }
From source file:org.jfree.chart.demo.JFreeChartAppletDemo.java
/** * Constructs the demo applet./*from w w w . ja v a2 s .co m*/ */ public JFreeChartAppletDemo() { final JTabbedPane tabs = new JTabbedPane(); final XYDataset data1 = DemoDatasetFactory.createTimeSeriesCollection1(); final JFreeChart chart1 = ChartFactory.createTimeSeriesChart("Time Series", "Date", "Rate", data1, true, true, false); final ChartPanel panel1 = new ChartPanel(chart1, 400, 300, 200, 100, 400, 200, true, false, false, false, true, true); tabs.add("Chart 1", panel1); final CategoryDataset data2 = DemoDatasetFactory.createCategoryDataset(); final JFreeChart chart2 = ChartFactory.createBarChart("Bar Chart", "Categories", "Value", data2, PlotOrientation.HORIZONTAL, true, true, false); final ChartPanel panel2 = new ChartPanel(chart2, 400, 300, 200, 100, 400, 200, true, false, false, false, true, true); tabs.add("Chart 2", panel2); getContentPane().add(tabs); }
From source file:net.sourceforge.jabm.view.BarChart.java
public void afterPropertiesSet() { String name = chartTitle;/* www .j a v a 2s . co m*/ if (name == null) { name = reportVariables.getName(); } // series.initialise(null); JFreeChart chart = ChartFactory.createBarChart(//title, categoryAxisLabel, valueAxisLabel, dataset, orientation, legend, tooltips, urls)( name, // chart title "t", // domain axis label valueAxisLabel, // range axis label this, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips? false // URLs? ); chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(500, 270)); // getContentPane().add(chartPanel); // pack(); // computeVariableNames(); // setTitle("JABM: " + name); // setVisible(true); ((Model) reportVariables).addListener(this); }
From source file:org.deegree.igeo.style.model.Histogram.java
public void update(String title, List<ValueRange<?>> values) { if (values != null) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (ValueRange<?> value : values) { value.getCount();/*from w w w .j a v a 2 s .co m*/ value.getLabel(); dataset.addValue(value.getCount(), "1", value.getLabel()); } JFreeChart chart = ChartFactory.createBarChart(null, get("$MD11052"), get("$MD11053"), dataset, PlotOrientation.VERTICAL, false, true, false); chart.setPadding(new RectangleInsets(10, 10, 10, 10)); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis cAxis = plot.getDomainAxis(); cAxis.setCategoryMargin(0); cAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(1)); if (cf == null) { cf = new ChartPanel(chart); this.add(cf); cf.setVisible(true); } else { cf.setChart(chart); } this.setTitle(title); this.setVisible(true); this.pack(); } }
From source file:org.openmrs.module.vcttrac.web.view.chart.VCTCreateBarChartView.java
/** * @see org.openmrs.module.vcttrac.web.view.chart.AbstractChartView#createChart(java.util.Map, * javax.servlet.http.HttpServletRequest) *///from w w w . j a v a 2s.c om @Override protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) { //JFreeChart chart = null; if (request.getParameter("type").compareTo("todayAndYesterday") == 0) { CategoryDataset dataset = createDataset(); return createChart(dataset, 1); } else if (request.getParameter("type").compareTo("monthInYear") == 0) { CategoryDataset dataset1 = createMonthDataset(); return createChart(dataset1, 2); } else if (request.getParameter("type").compareTo("years") == 0) { CategoryDataset dataset2 = createYearDataset(); return createChart(dataset2, 3); } // OPTIONAL CUSTOMISATION COMPLETED. return ChartFactory.createBarChart(null, null, null, null, PlotOrientation.VERTICAL, true, true, false); }