List of usage examples for org.jfree.chart.ui Layer FOREGROUND
Layer FOREGROUND
To view the source code for org.jfree.chart.ui Layer FOREGROUND.
Click Source Link
From source file:org.jfree.chart.ChartFactory.java
/** * Creates a waterfall chart. The chart object returned by this method * uses a {@link CategoryPlot} instance as the plot, with a * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and a {@link WaterfallBarRenderer} as the renderer. * * @param title the chart title ({@code null} permitted). * @param categoryAxisLabel the label for the category axis * ({@code null} permitted). * @param valueAxisLabel the label for the value axis ({@code null} * permitted).//from ww w. j av a 2 s . com * @param dataset the dataset for the chart ({@code null} permitted). * * @return A waterfall chart. */ public static JFreeChart createWaterfallChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); categoryAxis.setCategoryMargin(0.0); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); WaterfallBarRenderer renderer = new WaterfallBarRenderer(); // FIXME create a new method for the horizontal version // if (orientation == PlotOrientation.HORIZONTAL) { // ItemLabelPosition position = new ItemLabelPosition( // ItemLabelAnchor.CENTER, TextAnchor.CENTER, // TextAnchor.CENTER, Math.PI / 2.0); // renderer.setBasePositiveItemLabelPosition(position); // renderer.setBaseNegativeItemLabelPosition(position); // } ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 0.0); renderer.setDefaultPositiveItemLabelPosition(position); renderer.setDefaultNegativeItemLabelPosition(position); StandardCategoryToolTipGenerator generator = new StandardCategoryToolTipGenerator(); renderer.setDefaultToolTipGenerator(generator); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.clearRangeMarkers(); Marker baseline = new ValueMarker(0.0); baseline.setPaint(Color.BLACK); plot.addRangeMarker(baseline, Layer.FOREGROUND); JFreeChart chart = new JFreeChart(title, plot); currentTheme.apply(chart); return chart; }