Superimpose 2 block chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
MrJack
Posts: 13
Joined: Thu May 18, 2017 3:41 pm
antibot: No, of course not.

Superimpose 2 block chart

Post by MrJack » Thu Jun 29, 2017 8:55 am

Hello !
I'm trying to superimpose 2 chart with different alpha value but only one of them are visible ...
I'm using a XYBlockRenderer and I was wondering if this type of chart enable me to do that.

Is it possible to display 2 chart with this type of renderer ?

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Superimpose 2 block chart

Post by John Matthews » Thu Jun 29, 2017 11:08 am


MrJack
Posts: 13
Joined: Thu May 18, 2017 3:41 pm
antibot: No, of course not.

Re: Superimpose 2 block chart

Post by MrJack » Thu Jun 29, 2017 12:29 pm

But that will set the alpha for every dataset, doesn't it ? Or I have to create 1 plot for each dataset ?

NB : I've already to change the transparency by having a paintScale (custom - with transparency) for each renderer

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Superimpose 2 block chart

Post by John Matthews » Fri Jun 30, 2017 5:16 am

Using setForegroundAlpha() results in draw() applying the AlphaComposite.SRC_OVER rule, using the current alpha, to the graphics context. If you don't setForegroundAlpha(), you get the default value of 1.0f.

You can add more than one dataset and renderer to a single XYPlot.

MrJack
Posts: 13
Joined: Thu May 18, 2017 3:41 pm
antibot: No, of course not.

Re: Superimpose 2 block chart

Post by MrJack » Fri Jun 30, 2017 9:01 am

I've try your solution but it seems that the behavior is the same, the last dataset override the previous dataset ...

My goal is to display every dataset like you can superimpose layer, if you have any idea how to do it I will be glad to try it :)

But for now I've no idea how to do it and I've tried many solution :
* Change the alpha of the paint scale
* Change the alpha of the paint scale => 1 paint scale and 1 renderer by dataset
* Add an Alpha composite (Your solution)

None of them work, but if you think that one solution should work please explain me why and how ;)

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Superimpose 2 block chart

Post by John Matthews » Fri Jun 30, 2017 12:34 pm

The demo HistogramDemo1.java is a good example that uses setForegroundAlpha(). I know a similar approach works with two instances each of SimpleHistogramDataset and XYItemRenderer.

MrJack
Posts: 13
Joined: Thu May 18, 2017 3:41 pm
antibot: No, of course not.

Re: Superimpose 2 block chart

Post by MrJack » Fri Jun 30, 2017 1:04 pm

I see but the result that I'm search for is really to have like 2 pictures (Same size and location) superimpose but being able to see them both by using the alpha.

I would like to have a result like this :
Image

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Superimpose 2 block chart

Post by John Matthews » Sat Jul 01, 2017 1:36 am

This is how HistogramDemo1.java looks:

Image

Locked