Issue in Alignment of 2 charts - Legends

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
vrsarav
Posts: 16
Joined: Mon Nov 09, 2009 4:34 pm
antibot: No, of course not.

Issue in Alignment of 2 charts - Legends

Post by vrsarav » Mon Nov 30, 2009 5:15 pm

Hi,
I have following 2 charts in 2 different chartPanel
1) CombinedDomainXYPlot on the first panel
2)XYPlot on the second panel

I'm displaying both panels combined in a vertical manner, so that it looks like it shares their X Axis. Now I would like to align both charts based on their Y Axis.
I'm trying to use setFixedRangeAxisSpace for both the charts so that both can have the same space.

But the issue is XYPlot responds to the setFixedRangeAxisSpace but there is no effect when it is called for CombinedDomainXYPlot.

Am i missing something here?

I really appreciate any views on this.

Thanks.
Last edited by vrsarav on Wed Dec 16, 2009 11:23 pm, edited 1 time in total.

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: Issue in Alignment of 2 charts

Post by remiohead » Mon Nov 30, 2009 5:36 pm

Looking at the source code, setFixedRangeAxisSpace in CombinedDomainXYPlot just calls the same method in each XYPlot subplot.

So the obvious question would be: are you calling this method before or after you add the subplots to the combined plot?

vrsarav
Posts: 16
Joined: Mon Nov 09, 2009 4:34 pm
antibot: No, of course not.

Re: Issue in Alignment of 2 charts

Post by vrsarav » Mon Nov 30, 2009 5:57 pm

Thanks remiohead for the reply.
I have tried both possible combinations.
I tried calling setFixedRangeAxisSpace for the CombinedDomainXYPlot after adding all subplots.
I tried calling setFixedRangeAxisSpace for the individual subplots and added to CombinedDomainXYPlot

In either case it didn't have any effect.

For now i'm setting a constant value(trial and error method) to XYPlot to align itself to the CombinedDomainXYPlot . But i'm not sure it is going to work for all kind of data.
Ideally i expect to have a common space to be applied to both charts so that i can align for every possible data.

vrsarav
Posts: 16
Joined: Mon Nov 09, 2009 4:34 pm
antibot: No, of course not.

Re: Issue in Alignment of 2 charts

Post by vrsarav » Mon Nov 30, 2009 6:12 pm

To add more info,
I'm displaying both charts using a split pane, using vertical split.

I'm trying to control the alignment of the both charts in the following scenario

As for the tickMarkLabels, it can be dynamic for me. I have an option based on a selection, to display abbreviated labels or descriptive labels in the XYPlot which has a SymbolAxis as it Y-Axis.
So whenever descriptive labels are displayed the XYPlot is gets indented to the right based on the length of the tickMarklabels. During this i would like to have the same indentation for the combinedDomainXYPlot on the top too.

I hope i'm make it clear. I cannot attach image as it is. In case anybody need a screenshot i can work on it to attach here.

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: Issue in Alignment of 2 charts

Post by remiohead » Mon Nov 30, 2009 10:11 pm

Afraid I do not have an answer for you.

I suggest you read the source code for the method calculateAxisSpace() in CombinedDomainXYPlot. It might give you some insight into the problem.

vrsarav
Posts: 16
Joined: Mon Nov 09, 2009 4:34 pm
antibot: No, of course not.

Re: Issue in Alignment of 2 charts

Post by vrsarav » Mon Nov 30, 2009 11:22 pm

Thanks for the suggestion remiohead.
I'm looking into the source code right now. Let me see if i can come up with something.

Anyway thanks for the help.

In the mean time if anyone has any idea, pls let me know. Thanks.

vrsarav
Posts: 16
Joined: Mon Nov 09, 2009 4:34 pm
antibot: No, of course not.

Re: Issue in Alignment of 2 charts - Resolved

Post by vrsarav » Tue Dec 01, 2009 8:45 pm

After analysis, incalculateAxisSpace() method CombinedDomainXYPlot.java doesn't seem to set the fixedRangeAxisSpace from CombinedDomainXYPlot to its subPlots, after having set them to null.

So before calling calculateRangeAxisSpace for each of its subPlots i have set the following
plot.setFixedRangeAxisSpace(getFixedRangeAxisSpace(), false);

It seems to work as of now. i'm not sure where else it's going to break.
But one thing i have analyzed is that, for CombinedDomainXYPlot, setFixedRangeAxisSpace indents 1 pixel extra than the normal XYPlot

For eg. If i set Left value as 100 for CombinedDomainXYPlot FixedRangeAxisSpace, then to align perfectly i had to set 101 for the normal XYPlot. I'm not sure why though. Probable Bug?

Thanks.

vrsarav
Posts: 16
Joined: Mon Nov 09, 2009 4:34 pm
antibot: No, of course not.

Re: Issue in Alignment of 2 charts - Legends

Post by vrsarav » Wed Dec 16, 2009 11:22 pm

New issue regarding the alignment. When the LegendItem is displayed on the left side, the indentation of the chart doesn't seem easy to predict.
My issue, as i have stated earlier,
I need combinedDomainXY chart with legends displayed on the left side in the top panel.
Normal XYPLot without legend in the bottom panel.

When i have the legends displayed on the top, both are perfectly aligned.

As a matter of fact, i would like to know whether i can display the legends in a different panel other than the chartPanel. Is that possible at all?
Displaying the legend in a different panel all together will help in alignment.

Any Suggestions?

Locked