List of usage examples for org.jfree.chart.renderer BarRenderer setDrawBarOutline
public void setDrawBarOutline(boolean draw)
From source file:org.jfree.chart.demo.LegendManiaDemo.java
/** * Creates a sample chart./* w w w.j av a 2 s. c o m*/ * * @param dataset * the dataset. * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart(CHART_TITLE, // chart title "Activity", // domain axis label "Rate", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(255, 255, 180)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(BACKGROUND_PAINT); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); final StandardLegend legend = (StandardLegend) chart.getLegend(); legend.setBackgroundPaint(Color.orange); legend.setOutlinePaint(Color.orange); // activate word wrapping when legend is vertical. legend.setPreferredWidth(125); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:hr.restart.util.chart.ChartXYZ.java
/** * Creates a BAR CHART./*from w ww . j a v a 2s .co m*/ * * @param dataset The org.jfree.data.CategoryDataset * @param title The title * @return org.jfree.chart.JFreeChart */ final private JFreeChart createBarChart(final CategoryDataset dataset, String title) { final JFreeChart chart = ChartFactory.createBarChart(title, // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // include legend true, false); chart.setBackgroundPaint(Color.white); //print the subtitles java.util.List subs = getSubtitles(); if (subs != null) { for (int i = 0; i < subs.size(); i++) { chart.addSubtitle(new TextTitle(subs.get(i).toString())); } } // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); //plot.setBackgroundPaint(Color.lightGray); //plot.setDomainGridlinePaint(Color.white); //plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setItemMargin(getItemMargin()); adjustBarRenderer(renderer); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryMargin(getCategoryMargin()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:gui.BarChart.java
/** * Zusammenbauen des Diagrammes./*from w ww . j av a 2 s. c om*/ * * @return diagramm */ private JFreeChart createChart() { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("", // berschrift label_x_axis, // x label label_y_axis, // y label dataset, // datenstze PlotOrientation.VERTICAL, // vertikale balken true, // mit legende true, // mit tooltips false // URLs??? ); // Layoutanpassungen im Folgende: // allg. Hintergrundfarbe chart.setBackgroundPaint(Color.white); // Referenz auf Zeichnung: final CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); // aussehen des eigentlichen diagrammes: plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); // skaleneinteilung: final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.1); // kategorien renderer einstellungen verndern: final CategoryItemRenderer categories = plot.getRenderer(); // casten in bar renderer: final BarRenderer bars = (BarRenderer) categories; // werte im diagramm anzeigen: categories.setLabelGenerator(new StandardCategoryLabelGenerator()); categories.setItemLabelsVisible(true); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER, TextAnchor.CENTER, -Math.PI / 6); categories.setPositiveItemLabelPosition(p); categories.setNegativeItemLabelPosition(p); plot.setRenderer(categories); // farbverlauf der serien 1 und 2 final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, new Color(127, 127, 255), 0.0f, 0.0f, new Color(127, 127, 127)); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, new Color(255, 127, 127), 0.0f, 0.0f, new Color(127, 127, 127)); bars.setSeriesPaint(0, gp0); bars.setSeriesPaint(1, gp1); // keine umrandung der balken bars.setDrawBarOutline(false); // abstand der zahlen vom balken bars.setItemLabelAnchorOffset(13); // x achsenbeschriftung final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }