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!
Need advice on customizing XYBarRenderer
-
- Posts: 21
- Joined: Sat Jan 05, 2008 2:14 am
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
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
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 21
- Joined: Sat Jan 05, 2008 2:14 am
Thanks for the reply David. I will give the ClusteredXYBarRenderer a try.
.
P.S. JFreeChart is terrific... thanks for the great resource!
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 importantbut what is the rule you are using to determine the bar width?

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