Histogram

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

Histogram

Post by Eldar Lyn » Tue Jun 25, 2002 7:42 am

Is it possible to simply draw an histogram:

for example, you have thse data: (5,9,2,3,5,4,2,3,4)

and you want to draw a bar which contain the number of value between [1-3], a bar with [4-6] and the last one with [7-9]

-> you obtain a graph with:
*1st bar: 4
*2nd bar: 4
* 3th bar: 1

There is an otpion allowing that?
If yes, is it possible to specify the gap between the data [x-y]

Thanks in advance

David Gilbert

Re: Histogram

Post by David Gilbert » Tue Jun 25, 2002 10:17 am

You can draw a histogram using a VerticalXYBarChart, but there are a few pieces of code missing before this is made easy.

Here is an example of a vertical XY bar chart, showing that even the bar intervals can be irregular:

http://www.object-refinery.com/jfreecha ... art100.png

The missing pieces:

1) The IntervalXYDataset interface has only one implementation at present (TimeSeriesCollection) so for a histogram you need to write your own class that implements this interface.

2) There is a Values interface that could be used to access the sample data you provided. It would be great if there was a utility method that took a Values instance, plus a specification of the intervals required, then generated an IntervalXYDataset that can be used to generate a frequency histogram.

I will work on this at some point, but I have too many other things on right now. My hope is that someone else will contribute some code...

Regards,

DG.

Locked