Changing Weights of Subplots in Combined Plots dynamically

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

Changing Weights of Subplots in Combined Plots dynamically

Postby haibaer » Thu Aug 02, 2007 10:41 am


I'm new to JFreeChart (about 1 week experience); and I got the following Problem: I have a CombinedDomainXYPlot showing 4 Subplots. Each of them has a TimeSeriesCollection. Each of the Collections has N TimeSeries.

Now I want to give to the user the possibility to resize each of the subplots during showing them (and maybe even to show/hide the plots). I've found out in the documentation that there is a setWeight() in the XYPlot class method which can be used to control the size of each subplot relative to the other. But I don't have a glue how this works when the subplots are already added to the combined plot.

Because the resizing did not work for me; I then tried another approach: Instead of changing the weight of the subplot when it is added, I simply remove all the plots and add them with another weigt to the combined plot. This would have the advantage that I can also hide subplots. So I wrote the following test code into an action Listener of a button:
Code: Select all

globalPlot.add(plot1, 2);
globalPlot.add(plot2, 3);
globalPlot.add(plot3, 1);
// omit the 4th because I want to hide it

This works quite well, but now I have the problem, when I now add a new TimeSeries to each of the TimeSeriesCollections (different TimeSeries; I create 4 of them), the renderer seems to "forget" the used Paints so far. So the following repeatable problem exist: (I'll write down my Steps and the action which happens in parantheses after):
1. Create the chart with only the plots in it, every TimeSeriesCollection for each plot is created but contains no time series. The globalPlot will get a simple XYLineAndShapeRenderer to render the plot; the subplots get no extra renderer set.
2. Add a new TimeSeries to each of the TimeSeriesCollections each with (4 red graphs are shown, one in each subplot)
3. Add a new TimeSeries like in step 2 (4 blue graphs are added to the chart)
4. Remove plot4 as described in my code above
5. Add a new TimeSeries like in step 2. But instead of green graphs, there are red graphs added again.

What did I make wrong?

PS: Please excuse my bad English; it's not my native language.
Posts: 1
Joined: Thu Aug 02, 2007 9:55 am

Return to JFreeChart

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 11 guests