But that's a 2d chart, not 3d.
And I have setItemLabelsVisisble(true) already, and it makes the labels appear, but not
on top of the bar.
Here's the code for the bar creation:
Code: Select all
try
{
// Create the chart object
JFreeChart chart = ChartFactory.createBarChart3D(
"Number of Databases per Engine", // chart title
"Engine", // domain axis label
"Number of Databases", // range axis label
myCatSet, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(new Color(255, 255, 255));
CategoryPlot plot = chart.getCategoryPlot();
plot.setForegroundAlpha(1);
//plot.setURLGenerator(new StandardCategoryURLGenerator("xy_chart.jsp", "section"));
CategoryAxis categoryAxis = plot.getDomainAxis(); // Lower axis
// Set the rotation angle of the lower labels.
categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4));
categoryAxis.setCategoryMargin(.15); //Set the width between categories
BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
renderer.setItemLabelsVisible(true);
renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER));
renderer.setItemMargin(0); // Distance between each bar in a group.
renderer.setMaxBarWidth(.25); // The max width of the bar
renderer.setSeriesItemURLGenerator(0, new StandardCategoryURLGenerator(
"/redi/modules/pasta/Charts/ViewDbCountByEngine.jsp",
"series",
"engine"));
//******************************************************************
// Set colors
//******************************************************************
//System.out.println("Setting colors");
Paint rediPaint = new Color(65, 65, 200);
//renderer.setOutlinePaint(rediPaint); // Bar outline color
//renderer.setWallPaint(rediPaint); // Left wall of graph color
//renderer.setPaint(rediPaint); // Main Bar color
//******************************************************************
// Write the chart image to the temporary directory
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(chart, 800, 550, info, session);
//System.out.println("Writing Image file");
// Write the image map to the PrintWriter
ChartUtilities.writeImageMap(pw, filename, info);
pw.flush();
//System.out.println("Done");
}
catch (Exception e)
{
System.out.println("Exception - " + e.toString());
e.printStackTrace(System.out);
filename = "public_error_500x300.png";
}