Page 1 of 1
Extra legend does not show the last mark
Posted: Thu Nov 29, 2012 8:51 am
by 15964102
I have added three extra legends on my chart.
Two of them show the marks/labels/legend correctly
Only the first one gives problems.
It only shows 3 of the 4 labels.
When I add a fifth label it also shows 3 labels.
What's wrong?
Re: Extra legend does not show the last mark
Posted: Fri Nov 30, 2012 3:35 pm
by yeray
Hi Martin,
Could you please post the code you used to produce that chart?
Thanks in advance.
Re: Extra legend does not show the last mark
Posted: Fri Nov 30, 2012 3:38 pm
by 15964102
Code: Select all
public function fill($labels,$series)
{
$labels = null;
$top = 700;
$left = 40;
foreach ($series as $serie) {
$bar = new ModalityHorzBar($this->chart,true,false,false,-5);
//waardes
foreach ($serie->getPoints() as $point) {
$value = $point->getValuesY();
$text = $point->getText();
$color = $point->getColor();
$bar->getBar()->addYTextColor($value, $text, $color);
}
$bar->setLeftLabel($serie->getIndex(),$serie->getLabel());
// Add the Extra Legend Tool
$top = $top - 190;
$extraLegend = new ExtraLegend($this->chart->getChart());
$extraLegend->setSeries($bar->getBar());
$extraLegend->getLegend()->setLeft($left);
$extraLegend->getLegend()->setTop($top);
$extraLegend->getLegend()->setTextStyle(LegendTextStyle::$XVALUE);
}
// Legenda
$this->chart->getLegend()->setLegendStyle(LegendStyle::$VALUES);
}
Re: Extra legend does not show the last mark
Posted: Mon Dec 03, 2012 12:41 pm
by yeray
Hi Martin,
The code you posted isn't complete. Please, note we need a simple example project we can run as-is to reproduce the problem here.
I'm trying to reproduce it with this:
Code: Select all
$chart = new TChart(700,500);
$chart->getAspect()->setView3D(false);
for ($i=0; $i<4; $i++) {
$bar = new HorizBar($chart->getChart());
$bar->fillSampleValues(4);
$bar->setMultiBar(MultiBars::$STACKED);
$bar->getMarks()->setVisible(false);
}
$chart->doInvalidate();
for ($i=0; $i<4; $i++) {
$extraLegend = new ExtraLegend($chart->getChart());
$extraLegend->setSeries($chart->getSeries($i));
$extraLegend->getLegend()->setLeft(30);
$extraLegend->getLegend()->setTop($chart->getSeries(0)->calcYPos($i));
}
$chart->render();
But I get a legend for each series, all them with the same color, not a legend for each valueIndex:
- test1.png (9.53 KiB) Viewed 53988 times
Re: Extra legend does not show the last mark
Posted: Mon Dec 03, 2012 1:07 pm
by yeray
Hi again,
Instead of the above, you could use some dummy series for the legends. In the example below, I create a dummy series, hidden, with the values and colors to show next to each horizontal stacked bar:
Code: Select all
$chart->getAspect()->setView3D(false);
for ($i=0; $i<4; $i++) {
$bar = new HorizBar($chart->getChart());
$bar->fillSampleValues(4);
$bar->setMultiBar(MultiBars::$STACKED);
$bar->getMarks()->setVisible(false);
}
$chart->doInvalidate();
$seriesCount = $chart->getSeriesCount();
$maxCount = 0;
for ($i=0; $i<$seriesCount; $i++) {
$maxCount=max($maxCount, $chart->getSeries($i)->getCount());
}
for ($valueIndex=0; $valueIndex<$maxCount; $valueIndex++) {
$extraLegend = new ExtraLegend($chart->getChart());
$dummyBar = new Bar($chart->getChart());
$dummyBar->setActive(false);
for ($seriesIndex=0; $seriesIndex<$seriesCount; $seriesIndex++) {
if ($valueIndex < $chart->getSeries($seriesIndex)->getCount()) {
$dummyBar->addYColor($chart->getSeries($seriesIndex)->getXValues()->getValue($valueIndex), $chart->getSeries($seriesIndex)->getColor());
}
}
$extraLegend->setSeries($dummyBar);
$extraLegend->getLegend()->setLeft(30);
$extraLegend->getLegend()->setTop($chart->getSeries(0)->calcYPos($valueIndex));
}
$chart->render();
- test2.png (9.95 KiB) Viewed 53981 times
Re: Extra legend does not show the last mark
Posted: Fri Dec 14, 2012 4:34 pm
by 15964102
Problem was : the value was in the legend but its position was to low. When I positioned it higher it did show the complete legend. (I hope you can understand - don't know how to explane
)
Re: Extra legend does not show the last mark
Posted: Mon Dec 17, 2012 3:57 pm
by yeray
Hi Martin,
I think I understand you. The last item in the last legend is drawn below the bottom axis and it's clipped.
Re: Extra legend does not show the last mark
Posted: Mon Dec 17, 2012 4:40 pm
by 15964102
Exactly