I have a wierd problem going on. When I have 1 dataset on the Bar Chart, I'm getting the number for each item above the bar if it's small, or inside it if it's big. This is great! I love that! But when I have multiple datasets, the bars get printed, but the labels are not presented on the big bars:
Any one knows how to fix that?!
Here is my code:
Code: Select all
if (orientation == null) {
throw new IllegalArgumentException("Null 'orientation' argument.");
}
CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
/* Changes */
categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.9));
categoryAxis.setMaximumCategoryLabelWidthRatio(15.0f);
categoryAxis.setCategoryLabelPositionOffset(1);
/* End changes */
ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
BarRenderer3D renderer = new BarRenderer3D();
renderer.setItemMargin(0);
renderer.setDrawBarOutline(false);
/* Changes */
renderer.setItemLabelsVisible(true);
renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
/* End Changes */
if (urls) {
renderer.setBaseItemURLGenerator(
new StandardCategoryURLGenerator()
);
}
/* Changes */
ItemLabelPosition position1 = new ItemLabelPosition(
dataset.getColumnCount()>20?ItemLabelAnchor.OUTSIDE9:ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_CENTER,
TextAnchor.TOP_CENTER, -1.5708
);
renderer.setPositiveItemLabelPosition(position1);
ItemLabelPosition position2 = new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER,
TextAnchor.TOP_CENTER, -1.5708
);
renderer.setNegativeItemLabelPosition(position2);
/* End Changes */
CategoryPlot plot = new CategoryPlot(
dataset, categoryAxis, valueAxis, renderer
);
plot.setOrientation(orientation);
if (orientation == PlotOrientation.HORIZONTAL) {
// change rendering order to ensure that bar overlapping is the
// right way around
plot.setRowRenderingOrder(SortOrder.DESCENDING);
plot.setColumnRenderingOrder(SortOrder.DESCENDING);
}
plot.setForegroundAlpha(0.75f);
JFreeChart chart = new JFreeChart(
title, JFreeChart.DEFAULT_TITLE_FONT, plot, dataset.getRowCount()>1
);
Iterator<String> itr = subtitle.iterator();
while(itr.hasNext())
chart.addSubtitle(new TextTitle(itr.next()));
return chart;
Tal