|
whiskerBox legend problem |
Posted by Georg Erlacher on Aug-22-2013 16:51 |
|
Hallo,
I have made a whiskerBox similar to that in http://www.advsofteng.com/doc/cdperl.htm#boxwhisker.htm and need to add a legend.
I would like to see a sample of a single whiskerBox (like an Icon) with some text to the right (max / 90% / median / 10% / min), like in the attached screenshot.
I can produce a legend, but it does not look like I want.
Here the code snippet (perl)
# Add a WhiskerLayer
my $wb = $chart->addBoxWhiskerLayer($arg->{-t}->{t_mon_m0u},
$arg->{-t}->{t_mon_m0l},
$arg->{-t}->{t_mon_m0x},
$arg->{-t}->{t_mon_m0n},
$arg->{-t}->{t_mon_m0m},
$self->{"-gd_color_wiskerBox_fill_$subType"},
$self->{"-gd_color_wiskerBox_line_$subType"},
$self->{"-gd_color_wiskerBox_outline_$subType"},
);
my $dataset = $wb->getDataSet(0);
$dataset->setDataName("this is not the kind of legend I want to see ...");
my $lb = $chart->addLegend(130, 120, 0, "arialbd.ttf", 10);
$lb->setAlignment($perlchartdir::TopCenter);
$lb->setBackground($perlchartdir::Transparent);
The code works, but the result is not what I want, see wb_bad_legend.png
With the following code, I tried to add a legend which is closer to what I want, here the code snippet:
my $blayer = $chart->addLineLayer2();
$blayer->addDataSet([()], 0x00ffffff, " ") ->setDataSymbol2("./custom_box_symbol.png");
my $legendBox = $chart->addLegend( 60,46, "", $self->{-gd_font}, 10);
# results in wb_good_legend.png
The problem is that it is a lot of manual work always to create custom_box_symbol.png (with photoshop or gimp or similar) for differnt colors and sizes, so is there a better way to do this in chartDirecor directly?
thanks a lot for any help, Georg Erlacher
|
Re: whiskerBox legend problem |
Posted by Peter Kwan on Aug-23-2013 01:27 |
|
Hi Georg,
Instead of using a legend box, you may consider to add it as custom textboxes and lines. It
is like:
$c->addLine($leftX, $topY, $leftX + $iconWidth, $topY, $topWhiskerColor);
$c->addLine($leftX, $topY + $iconHeight, $leftX + $iconWidth, $topY + $iconHeight,
$bottomWhiskerColor);
#The box symbol - created as an empty text box
my $t = $c->addText($leftX, $topY + iconHeigth * 0.25, "");
$t->setBackground($boxFillColor, $boxEdgeColor);
$t->setSize($iconWidth, $iconHeight * 0.5);
.........
In total, it should need 4 lines (for the top, bottom, middle whiskers and the vertical line)
and 6 text boxes (for the box symbol, and the 5 text labels).
Hope this can help.
Regards
Peter Kwan |
Re: whiskerBox legend problem |
Posted by Georg Erlacher on Aug-26-2013 22:49 |
|
Thanks a lot, works great! |
|