|
Multiple legend boxes possible? |
Posted by M. Koenen on Nov-12-2008 21:07 |
|
Hi,
I'm back with another question. I am setting up a multi-stacked bar chart.
The current legendbox adds all keys from the different stacks into one legend.
Because the keys from the different stacks are different and cannot be compared I want to prevent confusion by having a dedicated legendbox per stack.
I tried something like this, relevant output is attached, because it is based on live data I have removed information which could lead to interpreting the data.
my $legendbox1 = $bargraph->addLegend($width-100,50);
$legendbox1->addKey("TEST", 0xcc33cc);
my $legendbox2 = $bargraph->addLegend($width-500,50);
but all keys appear visually on the location of legendbox2, including the "TEST" which I think would have been added to legendbox1.
What am I doing wrong? Or is it even possible? If possible, how can I tell ChartDirector which keys belong to which box?
Best regards
M. Koenen
|
Re: Multiple legend boxes possible? |
Posted by Peter Kwan on Nov-13-2008 01:56 |
|
Hi M. Koenen,
In ChartDirector, each XYChart object can only have one legend box.
To create a chart with two legend box, you may create an extra chart with just a legend box, then "merge" that chart into your main bar chart.
For example:
my $legendchart = new XYChart(300, 400);
my $legendbox2 = $legendchart->addLegend(0, 0);
.... add keys to $legendbox2 ......
.... after setting up the bar chart, just before outputting the chart, you may
.... merge the two charts
$bargraph->makeChart3()->merge($legendchart->makeChart3(), $width-500, 50, $perlchartdir::TopLeft, 0);
Hope this can help.
Regards
Peter Kwan |
Re: Multiple legend boxes possible? |
Posted by M. Koenen on Nov-13-2008 16:24 |
|
Thanks for the tip, I will be able to check this next Monday. And let you know.
Regards
M. Koenen |
Re: Multiple legend boxes possible? |
Posted by M. Koenen on Nov-18-2008 21:22 |
|
Hi,
I owe you my feedback. I managed it to let it work due to your tip. Result attached.
One last question on this subject: as you might see on the result the 2nd legend is 'on top' of the original picture, thereby not showing up as the original legendbox where you can see the lines from the graph running through.
I want to have both legendboxes 'behave' similar. I tried to play with the transparent flag of the merge function but that also lowers the intensity of the legend box text.
So is there a way to either:
1) enable the transparency of the white part only of legendbox2
or
2) disable the transparency of the original legendbox so that the underlying graph lines are not visible there too.
Best regards
M. Koenen
|
Re: Multiple legend boxes possible? |
Posted by Peter Kwan on Nov-19-2008 01:54 |
|
Hi M. Koenen,
1) enable the transparency of the white part only of legendbox2
If you want to use this method, please set the legend chart background to transparent. For example:
my $legendchart = new XYChart(300, 400, $perlchartdir::Transparent);
2) disable the transparency of the original legendbox so that the underlying graph lines are not visible there too.
If you want to use this method, please set the legend box background color to white. For example:
#white background with black border
$legendbox1->setBackground(0xffffff, 0x000000);
Hope this can help.
Regards
Peter Kwan |
Re: Multiple legend boxes possible? |
Posted by M. Koenen on Nov-19-2008 17:08 |
|
Hi Peter,
Yes it works! It is astonishing that everytime that I think its not possible that you still have a solution
Regards
M. Koenen |
|