Page 1 of 1

Legend position code

Posted: Mon Nov 08, 2004 8:03 am
by 6919485
Hi,

Can anyone provide a simple code example to place the legend inside and infront of the grid, located at the top-right corner of the grid?

I need it to stay there even when resizing the window/chart...

Posted: Mon Nov 08, 2004 8:49 am
by Pep
Hi,

you can use similar code to the following :

Code: Select all

Private Sub Form_Load()
With TChart1
    .AddSeries scLine
    .Series(0).FillSampleValues (10)
    .Legend.LegendStyle = lsSeries
    .Legend.CustomPosition = True
    .Axis.Top.Visible = True
    .Aspect.View3D = False
    .Environment.InternalRepaint
End With
End Sub

Private Sub TChart1_OnAfterDraw()
    TChart1.Legend.Left = TChart1.Axis.Right.Position - (TChart1.Legend.ShapeBounds.Right - TChart1.Legend.ShapeBounds.Left)
    TChart1.Legend.Top = TChart1.Axis.Top.Position
End Sub