Page 1 of 1

Assign different fonts to the Points Labels on Line Graph

Posted: Tue Jun 01, 2010 8:50 am
by 6924564
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

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

Posted: Thu Jun 03, 2010 10:54 am
by yeray
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

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

Posted: Tue Oct 26, 2010 8:42 am
by 6924564
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 7925 times

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

Posted: Tue Oct 26, 2010 1:48 pm
by 10050769
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,

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

Posted: Wed Oct 27, 2010 3:00 am
by 6924564
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

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

Posted: Wed Oct 27, 2010 7:14 am
by narcis
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.