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

Message ListMessage List     Post MessagePost Message

  I can't seem to get lines to show up in the legend
Posted by Anneliese on Apr-26-2012 05:54
Attachments:
Hi,

I've been reading other posts on this, but I can't seem to get it to work for me. My bar
chart has a mean marked with a blue line (using addMark). I want show a blue line in the
legend. I thought that a way I could do this would be to add a line layer to my plot with no
data in it and then as long as it's labeled, I thought it should automatically appear in the
legend. It's appearing in my legend, but it's showing a square instead of a line... What am
I doing wrong?


# Create a XYChart object of size 250 x 250 pixels
$object_width = 400;
$object_height = 250;
$c = new XYChart($object_width, $object_height);

$legendBox1 = $c->addLegend(250, 50, true, "arialb.ttf", 7);
$legendBox1->addKey2(0,"Normal Range",0xECC3BF);

# Add line layers
$layer = $c->addLineLayer();
$ds = $layer->addDataSet(array(), 0x153E7E, "Mean of Normal Range: $mean");
$layer->setLineWidth(2);

# Set the plotarea at (30, 20) and of size 200 x 200 pixels
$plot_width = $object_width - 200;
$plot_height = $object_height - 50;
$c->setPlotArea(30, 20, $plot_width, $plot_height);


#title
$c->addTitle($labels[0], "Timesb.dfont", 14);

# Add a bar chart layer using the given data
foreach($data[0] as $key => $value)
{
$newData[]=$value;
}
$barLayerObj = $c->addBarLayer($newData,0x3299CC,"Sample Mean: $newData[0]");
$barLayerObj->setBorderColor(Transparent, barLighting(0.75, 2.0));

# y axis
$lb = $mean-(5*$sd);
$ub = $mean+(5*$sd);
$c->yAxis->setLinearScale($lb,$ub);

$c->yAxis->addMark($mean,0x153E7E);
//add normal range
$c->yAxis->addZone($normalRange[0],$normalRange[1],0xECC3BF);

# Set the labels on the x axis.
$c->xAxis->setLabels($labels);

Thanks in advance!
Anneliese
Screen Shot 2012-04-25 at 3.45.42 PM.png

  Re: I can't seem to get lines to show up in the legend
Posted by Peter Kwan on Apr-26-2012 23:52
Hi Anneliese,

ChartDirector will use a "line style" key only if the chart contains a line that has a "line style" (eg. dash line), or a line that has a symbol. Otherwise it will default to a box style key.

To force using line style keys for lines, you may use:

$legendBox1->setLineStyleKey();

Hope this can help.

Regards
Peter Kwan

  Re: I can't seem to get lines to show up in the legend
Posted by Anneliese on Apr-27-2012 00:00
Aha! Thank you so much!!