JFreeChart painting Series Area of negative values

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
hcardoso
Posts: 6
Joined: Wed Nov 13, 2013 5:00 pm
antibot: No, of course not.

JFreeChart painting Series Area of negative values

Post by hcardoso » Wed Nov 27, 2013 4:20 pm

I have one dataset of

Code: Select all

XYSeriesCollection 
and an

Code: Select all

XYAreaChart 
and it is filled first with the positive values and painted with

Code: Select all

for(int i = 0; i< index;i++){
 chart.getXYPlot().getRenderer().setSeriesPaint(i,Color.RED);                           
}
I then proceed to try and paint the negative values the same way. My problem is that when I paint the area JFreeChart paints it using the integral area paint, meaning it goes from the points in my series and paints it to 0. I need it to paint it from my series to the minimumY that i generate.

Is it possible?

Best Regards

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

Re: JFreeChart painting Series Area of negative values

Post by david.gilbert » Wed Nov 27, 2013 5:33 pm

Unfortunately it seems that the renderer is hard-coded to draw the area to the value 0.0:

Code: Select all

double transZero = rangeAxis.valueToJava2D(0.0, dataArea, plot.getRangeAxisEdge());
...so to achieve this you'll need to modify the JFreeChart sources.
David Gilbert
JFreeChart Project Leader

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

hcardoso
Posts: 6
Joined: Wed Nov 13, 2013 5:00 pm
antibot: No, of course not.

Re: JFreeChart painting Series Area of negative values

Post by hcardoso » Wed Nov 27, 2013 6:03 pm

Meaning i have to create a renderer and override the drawItem method? Can you just give me some pointers on how to do it?

Thank you and best regards

hcardoso
Posts: 6
Joined: Wed Nov 13, 2013 5:00 pm
antibot: No, of course not.

Re: JFreeChart painting Series Area of negative values

Post by hcardoso » Wed Nov 27, 2013 6:21 pm

One more thing , i have been looking at XYAreaRenderer2 and it seems to do what i want, i think i might have to change a few things. You think it's worth the effort?

Best regards,

hcardoso
Posts: 6
Joined: Wed Nov 13, 2013 5:00 pm
antibot: No, of course not.

Re: JFreeChart painting Series Area of negative values

Post by hcardoso » Thu Nov 28, 2013 6:52 pm

For those who are interested i did the override on XYAreaRenderer2 drawItem method.

Replaced:

Code: Select all

double transZero = rangeAxis.valueToJava2D( rangeAxis.getLowerBound() , dataArea, plot.getRangeAxisEdge());
Thanks for the help David.

Best regards

Locked