Displaying DataLabel on the Bar Chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Praveen

Displaying DataLabel on the Bar Chart

Post by Praveen » Tue Sep 17, 2002 1:40 pm

Dear sir,

I have developed a Vertical Bar Chart with X-axis with student names and Y-axis with Marks they secured. I displayed Marks for each student like Maths,Physics,Chemistry.

so i got for each student 3 bars. so this is a Clustered graph.

But the problem for me is i want to display two things which i am not able to understand how to display.

1) I want to Display the Value of Bar on the Bar.

eg: if for 1st student gets Maths 75. Then i want 75 to be displayed on the respective bar. Similarly for each bar i want to display the DataValue on respectuve Bar.

2) DataTable.
i want to display the table with the selected data below like:

X ---- student1 student2 student3
Y ---- Maths 80 75 86
Physics 75 66 59
Chemistry 69 79 89

PLease suggest how should i proceed this thing.

Also one more Important doubt.
Can i change the Colors on Bar according my selected colors..


PLease suggest me all possible solutions as soon as possible.

Andreas Schroeder

Re: Displaying DataLabel on the Bar Chart

Post by Andreas Schroeder » Tue Sep 17, 2002 1:52 pm

Dear Praveen,

for the Labels use the setLabelVisible(boolean) method of the CategoryPlot - I assume you use a CategoryBarChart.

For the Colors use the setSeriesPaint(Paint[]) method of the CategoryPlot.

Or if you want a specific color for each student, I think it should be possible with the setCategoriesPaint(Paint[]) method of the AbstractCategoryItemRenderer, in your case extended by the BarRenderer.

if you use the factory methods and allready have the chart, do something
like this:

CategoryPlot plot = chart.getCategoryPlot();
plot.setSeriesPaint(...);

BarRenderer r = (BarRenderer) plot.getRenderer();
r.setCategoriesPaint(...);

For the table - well I don't think JFreeChart supports table creation :-)
That would then depend on the Environment you use.

Hope I was of help

Regards,

Andreas Schroeder

Locked