Histogram Zooming. Constant number of bins.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
dannii
Posts: 12
Joined: Mon Sep 23, 2013 1:26 pm
antibot: No, of course not.

Histogram Zooming. Constant number of bins.

Post by dannii » Tue Dec 10, 2013 11:18 am

Hi,

I'm doing a histogram chart and thinking about what happens when the user zooms the x axis.

I rather like the idea of maintaining a constant number of bins that change range as the user zooms.
So 40 bins would go something like:
40 1 year bins
40 6 month bins
40 1 month bins
40 day bins
etc as the user zooms in.

The user could then pan to see more at that zoom setting.

My first thought was to leave JFreeChart to do the zooming as usual but add a MouseWheelListener that gets the x axis range of the current zoom and then build a new dataset of 40 bins spanning just that range.
So every mouse wheel event would do a plot.setDatset(justCalculatedDataset).

I notice that values falling outside a set of bins would be added to the first/last bins so I would have to have to calculate a subset of the original that exactly spanned the new bins.
This would break panning as the off chart values would not have been plotted.

I did see this http://stackoverflow.com/questions/1062 ... le-zooming where the questioner has overridden the jFreeChart zoom. But the amount of work that must have gone into jFreeCharts zoom code is not something I fancy doing myself.

I would welcome any thoughts on an approach to histogram zooming where the user sees more detail as one bin becomes split into two etc.

Thanks
David

Locked