Mix between Interval and Layered Bar Chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
CAU
Posts: 1
Joined: Mon May 02, 2011 3:52 pm
antibot: No, of course not.

Mix between Interval and Layered Bar Chart

Post by CAU » Tue May 10, 2011 1:37 pm

Hello,
I spent quite a long time trying to create a chart which mix Interval Bar Chart and Layered Bar Chart.
I would like to use an IntervalCategoryDataset with a LayeredBarRenderer but it doesn't work (my interval bars on the chart always start at 0).

For the moment, I use an IntervalCategoryDataset and the IntervalBarRenderer like the following image. But I would like just one bar which groups the bars for one category.

Image

Is there any solution to use the layeredRenderer with an intervalCategoryDataSet ?

thanks

bmiras
Posts: 2
Joined: Tue Jun 23, 2015 1:00 pm
antibot: No, of course not.

Re: Mix between Interval and Layered Bar Chart

Post by bmiras » Tue Jun 23, 2015 1:04 pm

Hello,

I know that this post is quite old, but I've got exactly the same need than CAU.
Does anyone has a fresh answer for this question?

thank you,

bmiras
Posts: 2
Joined: Tue Jun 23, 2015 1:00 pm
antibot: No, of course not.

Re: Mix between Interval and Layered Bar Chart

Post by bmiras » Thu Jun 25, 2015 8:40 am

I answer to my own question, since it may be useful for another errant. I managed to do a mix between a LayeredBarRenderer and an IntervalBarRenderer. I wrote a subclass of IntervalBarRenderer and redefined/override the methods

Code: Select all

protected void drawInterval(Graphics2D g2,
                                CategoryItemRendererState state,
                                Rectangle2D dataArea,
                                CategoryPlot plot,
                                CategoryAxis domainAxis,
                                ValueAxis rangeAxis,
                                IntervalCategoryDataset dataset,
                                int row,
                                int column)
and

Code: Select all

    protected void calculateBarWidth(CategoryPlot plot,
                                     Rectangle2D dataArea,
                                     int rendererIndex,
                                     CategoryItemRendererState state) 
in order to superpose the interval bars.
Ones who want to see what to write in these methods, can upload the jfreechart source code for LayeredBarRenderer and IntervalBarRenderer and try do a mix of these two classes.

Locked