Need advice on customizing XYBarRenderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Commander Salamander
Posts: 21
Joined: Sat Jan 05, 2008 2:14 am

Need advice on customizing XYBarRenderer

Post by Commander Salamander » Wed Oct 22, 2008 6:49 pm

Hello,

I have the developer's guide, and with its assistance I was able to extend XYBarRenderer and override the drawItem() method to suit some of my needs. However, I'm still a bit unsure of the best way to achieve the type of display I require, and I could use some advice.

I have a dynamic plot in which the domain axis is an integer number axis (e.g. 1-1,000,000). Each dataset contains a series of XY values (i.e. not an interval dataset), and I would like to display each XY pair as a bar originating from the Y=0 axis. This much can be accomplished by simply setting my XYPlot renderer to XYBarRenderer. However, I require two additional behaviors:

[1] If multiple XYSeries contain a data point at a given X-value, I need to be able to display the bars side-by-side so they don't occlude each other (or implement a form of stacking that adjusts the paint order so that the bars are painted in order of smallest to largest)

[2] If the user zooms in/out on the x-axis, I would like to adjust the width of the rendered bar (which I'm currently doing with a clumsy override of drawItem()

Any advice on how to approach this would be much appreciated...

Thanks!

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Oct 23, 2008 9:57 am

I think the ClusteredXYBarRenderer will solve your first problem. The second is trickier, because the bar widths are determined by the x-interval coming from the dataset. You can modify drawItem() to determine the bar width more dynamically...but what is the rule you are using to determine the bar width?
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Commander Salamander
Posts: 21
Joined: Sat Jan 05, 2008 2:14 am

Post by Commander Salamander » Fri Oct 24, 2008 5:36 pm

Thanks for the reply David. I will give the ClusteredXYBarRenderer a try.
but what is the rule you are using to determine the bar width?
Because the bars tend to be spaced at roughly increments of 100 along my giant X-axis, I'm scaling them based on the span of the visible x-axis. Anyway, it isn't too important :).

P.S. JFreeChart is terrific... thanks for the great resource!

Locked