Line graph, bug with legend and only one series name?

TeeChart for PHP
Post Reply
gatorworks
Newbie
Newbie
Posts: 5
Joined: Mon Jan 30, 2012 12:00 am

Line graph, bug with legend and only one series name?

Post by gatorworks » Tue Feb 07, 2012 3:06 am

When I give my line a series name, the legend refuses to show the series name unless there are multiple series

For example:

With the following series title set,
$myline->setTitle("UTILITIES Actual");

The graph will not display the series under one title in the legend, but instead shows a legend entry for each point on the graph
Image

The only work-around for this is to draw a 'fake line' on top of one of the axes
$line_fake=new Line($c->getChart());
$line_fake->setTitle(" ");
$line_fake->setLabels($labels);
$line_fake->addArray($data_fake);
$line_fake->setColor(new Color(128,128,128));

Now, I get the desired result, except for the extra line that appears in the legend
Image

Is there any other way to do this?

I think that the natural behavior for legends should be to use the series title if it exists, otherwise do a point-by-point listing

Thanks

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

Re: Line graph, bug with legend and only one series name?

Post by Yeray » Wed Feb 08, 2012 12:27 pm

Hi,

By default, the Legend's LegendStyle::$AUTO is used. This LegendStyle shows the values if only one series is visible and shows the series' names if more than one series are visible.
If you want to force the legend to show the series' names, event if there's only one series, you can use LegendStyle::$SERIES as follows:

Code: Select all

$chart1->getLegend()->setLegendStyle(LegendStyle::$SERIES);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

gatorworks
Newbie
Newbie
Posts: 5
Joined: Mon Jan 30, 2012 12:00 am

Re: Line graph, bug with legend and only one series name?

Post by gatorworks » Wed Feb 08, 2012 2:12 pm

Thank you

I had been looking for something like this command and couldn't find it

Post Reply