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
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
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
Line graph, bug with legend and only one series name?
-
- Newbie
- Posts: 5
- Joined: Mon Jan 30, 2012 12:00 am
Re: Line graph, bug with legend and only one series name?
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:
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 5
- Joined: Mon Jan 30, 2012 12:00 am
Re: Line graph, bug with legend and only one series name?
Thank you
I had been looking for something like this command and couldn't find it
I had been looking for something like this command and couldn't find it