LegendScrollBar as required

TeeChart for ActiveX, COM and ASP
Post Reply
LAL
Newbie
Newbie
Posts: 40
Joined: Fri Jun 20, 2008 12:00 am

LegendScrollBar as required

Post by LAL » Tue Mar 10, 2009 3:51 am

Is there a way to only display a LegendScrollBar tool if it is needed?

I mean, can I detect if the number of series' I have can't be displayed in the legend and in that case, add the scroll bar?

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Tue Mar 10, 2009 9:26 am

Hi LVL,

You could compare the height of the legend with the legend height that X series need to be shown without scrollbar and activate or deactivate it:

Code: Select all

Private Sub TChart1_OnGetLegendRect(Left As Long, Top As Long, Right As Long, Bottom As Long)
  legendHeight = Bottom - Top
  wishedHeight = TChart1.Series(0).Count * 14

  If legendHeight < wishedHeight Then
    TChart1.Tools.Items(0).Active = True
  Else
    TChart1.Tools.Items(0).Active = False
  End If
End Sub
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

LAL
Newbie
Newbie
Posts: 40
Joined: Fri Jun 20, 2008 12:00 am

Thanks!

Post by LAL » Tue Mar 10, 2009 7:52 pm

Thanks Yeray - I actually studied the object model a bit more and solved it like this:

Code: Select all

int nNumInLegend = m_Chart.GetLegend().GetLastValue() - m_Chart.GetLegend().GetFirstValue();

if (nNumInLegend < m_nNumSeries)
{
...

Post Reply