Page 1 of 1

Spacing between left side of legend border and symbols

Posted: Wed Jun 27, 2007 2:37 pm
by 9531332
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.

Posted: Mon Jul 02, 2007 9:35 am
by Pep
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