I’m trying to create a custom dynamic histogram type bar graph in Java. I’ve searched a lot but coudn’t find a way to achieve this.
I’m aware of the JFreeChart library but it doesn’t meet my needs. This is what the JFreeChart histogram looks like :
But what I want is a dyanamic Histogram with just X-axis.
This photoshopped image will make it easier to understand.
The JFrame will have fixed boundaries. As you can see, there should be no Y-axis. The bars’ height should adjust automatically based on the values.
Please help me build this! Thanks in advance.
2
Answers
I’d give
JFreeChart
a second look. You can make the range axis invisible and use item labels instead. Absent a legend, overridinggetItemPaint()
can supply arbitrary colors. An alternative approach is shown here.A poor man’s histogram: