Spacing between left side of legend border and symbols

TeeChart for ActiveX, COM and ASP
Post Reply
thatnerdyguy
Newbie
Newbie
Posts: 14
Joined: Thu May 18, 2006 12:00 am

Spacing between left side of legend border and symbols

Post by thatnerdyguy » Wed Jun 27, 2007 2:37 pm

Is there a way to set the spacing between the left side of the legend border and the legend symbols (legend set to show on the right, with symbols on the left side inside the legend). It seems right now TChart uses a fixed spacing of 5 pixels or something like that.

I'm asking because in our app, the user can zoom out, and 5 pixels soon disappears to 0 pixels between the symbols and left side of the legend.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Jul 02, 2007 9:35 am

Hi,

the only way to customize the position of the legend symbol is by using the OnLegendDrawSymbol event. Here you can check the actual boundaries of the symbol rectangle and draw a customized one.

Following code could be used to change the left position :

Code: Select all

Private Sub Form_Load()
  TChart1.Legend.Symbol.Visible = False
End With
End Sub

Private Sub TChart1_OnLegendDrawSymbol(ByVal Series As Long, ByVal ValueIndex As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)
  With TChart1
   If Series <> -1 Then
    .Canvas.Brush.Color = .Series(Series).Color
    .Canvas.Rectangle Left + 3, Top, Left + 13, Top + 10
   End If
  End With
End Sub

Post Reply