user1639485
user1639485

Reputation: 808

Add an Image next to a X-axis label on a JFreeChart's barchart

I have requirement for the barchart which I have created using JFreeChart libraries.

I am illustrating this using an example. Lets say: I have plotted "John", "Mark", "Louis" and "Keith" on the X-axis (Students) and their respective marks on the Y-axis. I am using three different bars for each of the students to show their respective English, Science, and Maths marks.

Lets say, Science weigh the most, hence a student getting highest in Science would get a "Gold-Medal". Highest in "Maths" would fetch a student a "Silver", and highest in English would fetch him a "Bronze"

I want to put a small image (gold, silve or bronze) beside the label of the student who has got the highest marks in each of the subjects. A particular student (obviously) can get all the medals. Can this (or a thing similar to this) be done.

I am using JFreeChart's ChartFactory.createBarChart(...) api for this. I am able to plot the graph correctly but stuck with the above requirement.

Thank you!

Upvotes: 3

Views: 837

Answers (2)

Nagesh Salunke
Nagesh Salunke

Reputation: 1288

It has been a long time this question was asked,

This is what I have done to achieve it.

Drawn a image at  : (x,y) at each Category Entity.
Size of image     :  (width ,height) of CategoryLabel entity.

You can place you image accordingly around the category label.

Preview

enter image description here

Hope it helps.
Cheers :)

Upvotes: 1

trashgod
trashgod

Reputation: 205805

You might look at one of the org.jfree.chart.annotations such as XYDataImageAnnotation, XYDrawableAnnotation or XYImageAnnotation.

Upvotes: 4

Related Questions