Assign different fonts to the Points Labels on Line Graph

TeeChart for ActiveX, COM and ASP
Post Reply
CS
Newbie
Newbie
Posts: 22
Joined: Sat Jun 08, 2002 4:00 am

Assign different fonts to the Points Labels on Line Graph

Post by CS » Tue Jun 01, 2010 8:50 am

Hi,

I am Tchart5x user.

I have a requirement in which I need to show the point labels in different fonts.
I am able to set the different colors using .Series(0).PointColor(0) property.

Is there any way to set different fonts for the points ?


Thanks,
Kailas

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

Re: Assign different fonts to the Points Labels on Line Graph

Post by Yeray » Thu Jun 03, 2010 10:54 am

Hi Kalias,

I'm afraid this is not possible since the font property is a property for the whole series (TChart1.Series(0).Marks.Font) not for each value.
What you could do is to draw your text directly to the canvas like in the following example:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
  
  TChart1.AddSeries scPoint
  
  For i = 0 To 19
    TChart1.Series(0).Add Rnd * 100, "point nº" + Str$(i), clTeeColor
  Next i
  
  TChart1.Series(0).Marks.Font
End Sub

Private Sub TChart1_OnAfterDraw()
  Dim i As Integer
  For i = 0 To TChart1.Series(0).Count - 1
    TChart1.Canvas.Font.Size = (i Mod 10) + 10
    TChart1.Canvas.TextOut TChart1.Series(0).CalcXPos(i), TChart1.Series(0).CalcYPos(i), TChart1.Series(0).PointLabel(i)
  Next i
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

CS
Newbie
Newbie
Posts: 22
Joined: Sat Jun 08, 2002 4:00 am

Re: Assign different fonts to the Points Labels on Line Graph

Post by CS » Tue Oct 26, 2010 8:42 am

I have requirement where I want to draw Rectangle around a text which I am plotting with help from you previously.

Can you help on this ?

Also I need to draw the text in between two point. I have attached attachment for more details.

Values used for this :

Thanks,
CS
TextWithRectangle1.jpeg
Draw Text and Rectangle
TextWithRectangle1.jpeg (24.64 KiB) Viewed 7921 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Assign different fonts to the Points Labels on Line Graph

Post by Sandra » Tue Oct 26, 2010 1:48 pm

Hello CS,

I have made a simple example for you using rectangle tool. Please check if next code works as you want:

Code: Select all

Private Sub Form_Load()
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
 
  TChart1.AddSeries scLine
  TeeCommander1.Chart = TChart1

  For i = 0 To 19
    TChart1.Series(0).Add Rnd * 100, "point nº" + Str$(i), clTeeColor
  Next i
  TChart1.Environment.InternalRepaint
End Sub
Private Sub TChart1_OnAfterDraw()
  Dim i As Integer
  TChart1.Tools.Clear
  For i = 0 To TChart1.Series(0).Count - 1
    TChart1.Canvas.Font.Size = (i Mod 10) + 10
     With TChart1
        .Tools.Add tcRectangle
        .Tools.Items(i).asRectangle.Shape.CustomPosition = True
        .Tools.Items(i).asRectangle.AutoSize = True
        .Tools.Items(i).asRectangle.Shape.Transparency = 30
        .Tools.Items(i).asRectangle.Left = .Series(0).CalcXPos(i)
        .Tools.Items(i).asRectangle.Top = .Series(0).CalcYPos(i)
        .Tools.Items(i).asRectangle.Text = TChart1.Series(0).PointLabel(i)
    End With
  Next i
End Sub
Private Sub TChart1_OnScroll()
TChart1.Environment.InternalRepaint
End Sub

Private Sub TChart1_OnUndoZoom()
TChart1.Environment.InternalRepaint
End Sub
Private Sub TChart1_OnZoom()
  TChart1.Environment.InternalRepaint
End Sub
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

CS
Newbie
Newbie
Posts: 22
Joined: Sat Jun 08, 2002 4:00 am

Re: Assign different fonts to the Points Labels on Line Graph

Post by CS » Wed Oct 27, 2010 3:00 am

Hi ,

version 5 in which I don't see tcRectangle and TCommander

used "TeeChart5Activex.exe" for installation. We are calling the tchart componets from VB 6.

Thanks
CS

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

Re: Assign different fonts to the Points Labels on Line Graph

Post by Narcís » Wed Oct 27, 2010 7:14 am

Hi CS,

TeeCommander is not relevant for the example. You can use Annotation tools instead of Rectangle tools in v5 then. They work pretty much the same way.
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