Extra legend does not show the last mark

TeeChart for PHP
Post Reply
Martin
Newbie
Newbie
Posts: 11
Joined: Tue Nov 13, 2012 12:00 am

Extra legend does not show the last mark

Post by Martin » Thu Nov 29, 2012 8:51 am

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?
Attachments
extralegendproblem.JPG
extralegendproblem.JPG (78.84 KiB) Viewed 4562 times

Yeray
Site Admin
Site Admin
Posts: 8587
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Extra legend does not show the last mark

Post by Yeray » Fri Nov 30, 2012 3:35 pm

Hi Martin,

Could you please post the code you used to produce that chart?
Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Image Please read our Bug Fixing Policy

Martin
Newbie
Newbie
Posts: 11
Joined: Tue Nov 13, 2012 12:00 am

Re: Extra legend does not show the last mark

Post by Martin » Fri Nov 30, 2012 3:38 pm

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);   

    }

Yeray
Site Admin
Site Admin
Posts: 8587
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Extra legend does not show the last mark

Post by Yeray » Mon Dec 03, 2012 12:41 pm

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
test1.png (9.53 KiB) Viewed 4497 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 8587
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Extra legend does not show the last mark

Post by Yeray » Mon Dec 03, 2012 1:07 pm

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
test2.png (9.95 KiB) Viewed 4490 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Image Please read our Bug Fixing Policy

Martin
Newbie
Newbie
Posts: 11
Joined: Tue Nov 13, 2012 12:00 am

Re: Extra legend does not show the last mark

Post by Martin » Fri Dec 14, 2012 4:34 pm

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 :oops: )

Yeray
Site Admin
Site Admin
Posts: 8587
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Extra legend does not show the last mark

Post by Yeray » Mon Dec 17, 2012 3:57 pm

Hi Martin,

I think I understand you. The last item in the last legend is drawn below the bottom axis and it's clipped.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Image Please read our Bug Fixing Policy

Martin
Newbie
Newbie
Posts: 11
Joined: Tue Nov 13, 2012 12:00 am

Re: Extra legend does not show the last mark

Post by Martin » Mon Dec 17, 2012 4:40 pm

Exactly :wink:

Post Reply