displaying values at the top of each bar---Bar Chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ranyeng
Posts: 13
Joined: Fri May 22, 2009 6:53 am

displaying values at the top of each bar---Bar Chart

Post by ranyeng » Tue May 26, 2009 7:13 am

I have a simple bar chart.. Part of the code is as follows:



final JFreeChart chart = ChartFactory.createBarChart(
"Bar Chart Demo 3", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
false, // include legend
true,
false
);

chart.setBackgroundPaint(Color.lightGray);

After drawing the chart I want to display the values for each corresponding bar at the top of the bar.

Please can you help me....


Thanks
Ranjan Yengkhom

ranyeng
Posts: 13
Joined: Fri May 22, 2009 6:53 am

Re: displaying values at the top of each bar---Bar Chart

Post by ranyeng » Tue May 26, 2009 10:55 am

I got it...... I have to add


renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator());
renderer.setSeriesItemLabelsVisible(1, true);
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseSeriesVisible(true);
chart.getCategoryPlot().setRenderer(renderer);

Locked