customize scale labels

TeeChart for ActiveX, COM and ASP
Post Reply
hugh
Newbie
Newbie
Posts: 33
Joined: Tue Jan 15, 2008 12:00 am

customize scale labels

Post by hugh » Mon Mar 24, 2008 8:29 pm

Hi,

Does anybody have some experience in customizing scale labels? All I want to do is to make the most left x-sxale label left-bound - the most right bound label right bound - and keep all the other labels centered for multiscaled X-axis

How do I get it working also in zoom mode?

Thanks,
huh

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 25, 2008 1:00 pm

Hi hugh,

Yes, you can do something like this:

Code: Select all

Private Sub Form_Load()
With TChart1.Series(0)
    .Clear
    .Add 123, "First", clTeeColor
    .Add 456, "Second", clTeeColor
    .Add 321, "Third", clTeeColor
    .Add 234, "Last", clTeeColor
End With
End Sub


Private Sub TChart1_OnDrawAxisLabel(ByVal Axis As Long, ByVal X As Long, ByVal Y As Long, LabelText As String)
With TChart1
  If Axis = 0 Then
    If X = TChart1.Axis.Bottom.CalcXPosValue(TChart1.Axis.Bottom.Minimum) Then
       .Canvas.Font.Bold = True
       .Canvas.TextAlign = ctaLeft
    Else
      If X = TChart1.Axis.Bottom.CalcXPosValue(TChart1.Axis.Bottom.Maximum) Then ' // last label
       .Canvas.Font.Bold = True
       .Canvas.TextAlign = ctaRight
      Else
       .Canvas.Font.Bold = False
      End If
    End If
  End If
End With
End Sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

hugh
Newbie
Newbie
Posts: 33
Joined: Tue Jan 15, 2008 12:00 am

customize scale labels

Post by hugh » Tue Mar 25, 2008 1:58 pm

Thanks, Narcis

That works great for full scale - however how can I do the same while zooming - this way the maximum and minumum value comparison does not work anymore - How can I identify the first and last value to be modified while zooming?

Thanks,

Hugh

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Mar 27, 2008 10:16 am

Hi Hugh,

You can do something like this:

Code: Select all

Private Sub Form_Load()
    With TChart1.Series(0)
        .Clear
        .Add 123, "First", clTeeColor
        .Add 456, "Second", clTeeColor
        .Add 321, "Third", clTeeColor
        .Add 234, "Last", clTeeColor
    End With
End Sub

Private Sub TChart1_OnDrawAxisLabel(ByVal Axis As Long, ByVal X As Long, ByVal Y As Long, LabelText As String)
    With TChart1
      If Axis = 0 Then
        If X = TChart1.Axis.Bottom.CalcXPosValue(TChart1.Axis.Bottom.Minimum) Then
           .Canvas.Font.Bold = True
           .Canvas.TextAlign = ctaLeft
        Else
          If X = TChart1.Axis.Bottom.CalcXPosValue(TChart1.Axis.Bottom.Maximum) Then ' // last label
           .Canvas.Font.Bold = True
           .Canvas.TextAlign = ctaRight
          Else
           .Canvas.Font.Bold = False
          End If
        End If
      End If
    End With
End Sub

Private Sub TChart1_OnZoom()
    TChart1.Environment.InternalRepaint
    
    With TChart1.Axis.Bottom
        .Labels.Clear
        
        For i = .Minimum To .Maximum
            .Labels.Add i, CStr(i)
        Next
        
        .Labels.Add .Maximum, CStr(.Maximum)
    End With
End Sub
For original labels to be restored when unzooming you'll be able to use the code below in the next v8 maintenance release:

Code: Select all

Private Sub TChart1_OnUndoZoom()    
    TChart1.Axis.Bottom.Labels.Automatic = True
    TChart1.Repaint
End Sub
If you are interested on that feature we can send you the .ocx with this new feature included.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

hugh
Newbie
Newbie
Posts: 33
Joined: Tue Jan 15, 2008 12:00 am

Post by hugh » Tue Apr 01, 2008 2:07 pm

Hi Narcis,

Yes - I would like to try the new ocx -

Thanks,

Gerhard

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Apr 01, 2008 2:40 pm

Hi hugh,

Ok, I'll send you an e-mail with the URL to download it.

Remember you'll need to unregister old .ocx and register new one as described on this thread.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply