List of usage examples for org.jfree.chart.ui TextAnchor TOP_CENTER
TextAnchor TOP_CENTER
To view the source code for org.jfree.chart.ui TextAnchor TOP_CENTER.
Click Source Link
From source file:org.jfree.chart.ChartFactory.java
/** * Creates a bar chart with a vertical orientation. 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 BarRenderer} as the * renderer./*from www. j ava 2 s.co m*/ * * @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). * @param dataset the dataset for the chart ({@code null} permitted). * * @return A bar chart. */ public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); BarRenderer renderer = new BarRenderer(); ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setDefaultPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setDefaultNegativeItemLabelPosition(position2); renderer.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, plot); currentTheme.apply(chart); return chart; }