Akshay Bhalla
Akshay Bhalla

Reputation: 145

Vertical Scroll bar for Top and Bottom Legends

I want to align my legend to the Bottom of my chart because the no of Character present in my legend are around 100.

Please let me know how I can provide a vertical toolbar to that so that legend box size remains constant also whether there is a way we can round off the Text in label.

enter image description here

Thanks Akshay

Upvotes: 0

Views: 106

Answers (1)

Yeray
Yeray

Reputation: 5039

The tcLegendScrollBar tool is designed to show the items in the legend that don't fit in the legend rectangle, not to limit the number of characters shown in the items. Here it is an example usign it:

Private Sub Form_Load()
  TChart1.Aspect.View3D = False

  Dim i As Integer
  For i = 0 To 10
    TChart1.AddSeries scFastLine
    TChart1.Series(i).FillSampleValues 10
    TChart1.Series(i).Title = "this is a very very veeeeeeery long string to be shown in the legend as title for the series " + Str$(i)
  Next i

  TChart1.Legend.MaxNumRows = 5
  TChart1.Tools.Add tcLegendScrollBar
End Sub

To limit the length of the strings in the legend you can use the OnGetLegendText event. Ie:

Private Sub TChart1_OnGetLegendText(ByVal LegendStyle As Long, ByVal ValueIndex As Long, LegendText As String)
  LegendText = Left$(LegendText, 10) + "..."
End Sub

Upvotes: 1

Related Questions