Setting fixed space between boxplot items

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
rashed
Posts: 7
Joined: Thu Nov 12, 2015 6:18 am
antibot: No, of course not.

Setting fixed space between boxplot items

Post by rashed » Tue Feb 02, 2016 4:51 am

Hi All

I need to set fixed space between Boxplot items. I'm using BoxAndWhiskerXYDataset and XYBoxAndWhiskerRenderer, in the renderer I don't see any option to set a fixed distance between Boxplot items. With Scatterplot we can set the space using XYSeries's add method where the 1st parameter is to set the distance, I need something like this. Does anyone have any idea about this? Thanks


--Rashed

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

Re: Setting fixed space between boxplot items

Post by david.gilbert » Tue Feb 02, 2016 9:44 pm

There is a boxWidth attribute in the renderer that lets you set a fixed width for the boxes, but the distance between boxes will depend on the x-value and scale on the x-axis. I don't think there is a good general solution for what you want to do, sorry.
David Gilbert
JFreeChart Project Leader

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

rashed
Posts: 7
Joined: Thu Nov 12, 2015 6:18 am
antibot: No, of course not.

Re: Setting fixed space between boxplot items

Post by rashed » Mon Feb 08, 2016 5:07 pm

Yes, it was not possible straight but I managed to fix the space finally. Investigating drawVerticalItem method of XYBoxAndWhiskerRenderer class I targeted to control the xx value by my logic and it's working nice now, The changes are as follows:

double initX = Constants.DEFAULT_INIT_X_VALUE; // starting x value
double xx = 0;
if (item == 0) {
xx = initX;
// domainAxis.valueToJava2D(x.doubleValue(), dataArea,
// plot.getDomainAxisEdge());
} else {
xx = initX + (item * Constants.X_VALUE_GROW_BY); // dynamically setting space

}

Along with this I'm now controlling XYLineAndShpaRenderer too because my target was to show all rwadata over boxplot, both are working nice. Thanks

Locked