ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Legend
Posted by Greg White on Dec-09-2010 21:49
Attachments:
I have a bar chart with marks (attached), I made another layer so that the labels would not get covered by the mark, this is working well.  Since adding the layer for the labels the legend is showing the ARRAY(0x....).  Can you instruct me on the steps to remove this from the legend?

I am using Chartdirector under Perl.

Thank you.
legend.png

  Re: Legend
Posted by Peter Kwan on Dec-10-2010 00:04
Hi Greg,

The legend contains the "Array(0x....)" probably because your code is using "Array(0x....)" as the data set name. If you do not want to have this label, please remove the data set name when your code adds the layer.

If you need further help, would you mind to inform me the charting part of your code. I will try to find out where does the label comes from.

Regards
Peter Kwan

  Re: Legend
Posted by Greg White on Dec-10-2010 00:19
Here is code:

my $isComparitive = 1;
$data = [ $alparm,       $amparm,   $ahparm,  $avparm ];
$markdata = [ $comp_alparm,       $comp_amparm,   $comp_ahparm,  $comp_avparm ] if $isComparitive;
$labels = ["Low Risk", "Moderate\\nRisk", "High Risk", "Very High"];
$d = new XYChart($bar_chartwide, $bar_charthigh, 0xffffff);

$d->setPlotArea(50, 20, 255, 230, $perlchartdir::Transparent, -1, $perlchartdir::Transparent, 0xe0e0e0);

$legendBox = $d->addLegend(230, 2, 1, "arial.ttf", 8);
$legendBox->setBackground(0xe8f0f8, 0x445566);
$legendBox->setRoundedCorners(5);
$legendBox->setLineStyleKey();

$d->addTitle2(8, "Participants achievable\\nrisk levels", "arial.ttf", 12);

$textbox = $d->yAxis()->setTitle("% of Participants");
$textbox->setFontStyle("arial.ttf");
$textbox->setFontSize(7);
$d->yAxis()->setLabelFormat("{value}%");

$d->xAxis()->setLabels($labels);
$d->xAxis()->setTickLength(0);
$d->yAxis()->setLinearScale(0,100);

if($isComparitive){
$labellayer = $d->addBarLayer($data, $perlchartdir::Transparent, $labels);
$labellayer->setBorderColor($perlchartdir::Transparent);
$labellayer->setAggregateLabelFormat("{value|1}%");
$labellayer->setAggregateLabelStyle("arial.ttf", 7) ;

$markLayer = $d->addBoxWhiskerLayer(undef, undef, undef, undef, $markdata, -1, 0x88fffe);
$markLayer->setLineWidth(2);
$markLayer->setDataGap(0.1);
# Add the legend key for the mark line
$legendBox->addKey("Comparitive\\nGroup", 0x88fffe, 2);

$layer = $d->addBarLayer3($data, $five_colors);
$layer->setBorderColor($perlchartdir::Transparent);
}

  Re: Legend
Posted by Peter Kwan on Dec-10-2010 11:46
Hi Greg,

In your code, please replace:

$labellayer = $d->addBarLayer($data, $perlchartdir::Transparent, $labels);

with:

$labellayer = $d->addBarLayer($data, $perlchartdir::Transparent);

According to ChartDirector documentation, the third parameter to addBarLayer is the name of the data set, which should be a text string. In your original code, an array is used instead. In this case, Perl will automatically coerce the array into a text string, and it becomes the data set name. ChartDirector then include the name in the legend box.

If your change the code and remove the name, then there will be no legend box entry for that data set.

Hope this can help.

Regards
Peter Kwan

  Re: Legend
Posted by Greg White on Dec-10-2010 22:40
Peter,
That solved it.  Thanks again for your excellent support!

Greg