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

為{幸葍}努か 提交于 2019-12-10 17:43:57

问题


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!


回答1:


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




回答2:


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

Hope it helps.
Cheers :)



来源:https://stackoverflow.com/questions/12315061/add-an-image-next-to-a-x-axis-label-on-a-jfreecharts-barchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!