Page 1 of 1
Legend Series Order
Posted: Wed Aug 20, 2008 4:13 am
by 15049432
I have added my series in a particular order so that they draw correctly, however that isn't the order I'd like them to display in the chart legend.
So is it possible to control the series order in the legend without changing the order of th series themselves?
Posted: Wed Aug 20, 2008 8:22 am
by yeray
Hi LVL,
I'm afraid that the feature you doesn't exist. But there are others that you may haven't seen such as OnGetLegendText and OnLegendDrawSymbol events. And also...
You can hide a series to be shown:
Code: Select all
TChart1.Series(0).ShowInLegend = False
Or you could simply invert the legend items order:
Finally, you always could customize your legend at maximum drawing directly to the canvas what you want.
Posted: Thu Aug 21, 2008 8:46 pm
by 15049432
Yeray,
Thanks for the reply...I actually worked around this using a combination of hiding series from the legend and adding dummy series just for the legend.
Posted: Fri Aug 22, 2008 8:23 am
by yeray
Hi,
Here is a portion of code showing how you could draw a custom legend directly to the canvas. Only to show how you could also do it.
Code: Select all
Private Sub TChart1_OnAfterDraw()
With TChart1.Canvas
'legend rect
.Rectangle TChart1.ChartBounds.Right - 85, 100, TChart1.ChartBounds.Right - 15, 200
'series 1
.Brush.Color = TChart1.Series(0).Color
.Rectangle TChart1.ChartBounds.Right - 80, 107, TChart1.ChartBounds.Right - 70, 117
.Brush.Color = vbWhite
.TextOut TChart1.ChartBounds.Right - 65, 105, "Series 1"
'series 2
'...
End With
End Sub