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
|