Displaying the grid lines at the graph points

TeeChart for ActiveX, COM and ASP
Post Reply
rama
Newbie
Newbie
Posts: 33
Joined: Thu Jul 29, 2004 4:00 am

Displaying the grid lines at the graph points

Post by rama » Tue Jul 19, 2005 9:13 am

Hi,

I am using Teechart Pro V6.0. In a graph I am drawing three curves. But the grid lines ad bottom axis labels are displaying only at Series0 points. But not at all the series points. Please provide a sample.

Thanks & Regards,
Rama

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

Post by Narcís » Wed Jul 20, 2005 7:40 am

Hi Rama,

To achieve what you request you have two options:

1) Setting label style to "talText" and add labels as text (event they are numeric) when using AddXY. This way you'll have all labels displayed.

2) Using an axis for each series adding as many custom axes as necessary.
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

rama
Newbie
Newbie
Posts: 33
Joined: Thu Jul 29, 2004 4:00 am

Post by rama » Thu Jul 21, 2005 7:28 am

Hi Narcis,

I tried the option 1. But it did not solved the problem. Please find a sample code below.

Private Sub Form_Load()
Dim i As Integer
Dim j As Double
With TChart1
.Aspect.View3D = False
.AddSeries scLine
For i = 0 To 9
j = i + 0.5
.Series(0).AddXY j, j * j, Str(j), vbRed
Next i
.AddSeries scLine
.Series(1).SetFunction tfSmoothing
.Series(1).DataSource = "Series0"
.Series(0).asLine.LinePen.Visible = False
.Series(0).ShowInLegend = False
.Series(0).asLine.Pointer.Visible = True
.Series(0).asLine.Pointer.Style = psStar

.AddSeries scLine
For i = 0 To 9
j = i + 0.75
.Series(2).AddXY j, j * j, Str(j), vbRed
Next i
.AddSeries scLine
.Series(3).SetFunction tfSmoothing
.Series(3).DataSource = "Series2"
.Series(2).asLine.LinePen.Visible = False
.Series(2).ShowInLegend = False
.Series(2).asLine.Pointer.Visible = True
.Series(2).asLine.Pointer.Style = psStar
.Axis.Bottom.Labels.Style = talText
End With
End Sub

I am seeing the grid lines and labels at the "Series0". But I want to show the grid lines and lables at "Series2" also. It is not displaying.

Could you please provide a sample which displays the grid lines at "series2" points also.

Thanks & Regards,
Rama

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 Jul 21, 2005 8:35 am

Hi rama,

That's because you haven't added labels for those series. However you can add them by implementing something like the code below in the OnGetAxisLabel event.

Code: Select all

Private Sub TChart1_OnGetAxisLabel(ByVal Axis As Long, ByVal SeriesIndex As Long, ByVal ValueIndex As Long, LabelText As String)
    If ((Axis = 3) And (SeriesIndex = 3)) Then
        LabelText = CStr(TChart1.Series(SeriesIndex).XValues.Value(ValueIndex))
    End If
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

rama
Newbie
Newbie
Posts: 33
Joined: Thu Jul 29, 2004 4:00 am

Post by rama » Fri Jul 22, 2005 5:26 am

Hi narcis,

Thank you for your example. In your example the condition is
If ((Axis = 3) And (SeriesIndex = 3)) Then
I want to draw the grid lines and the lables for the "Series2" not for the "Series3".

So I changed the condition to SeriesIndex = 2. But it is not entering into the if condition at all. I do not know the reason. Even in my application also happening the same.

I debugged and saw. It is started the SeriesIndex at -1. Then SeriesIndex to 0,1 and 3. I do not know why SeriesIndex 2 did not come.

Could you please verify with this sample it self and let me know the workaround.

Thanks & Regards,
Rama

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

Post by Narcís » Fri Jul 22, 2005 11:56 am

Hi Rama,

Sorry, I think I was wrong with what I told you. To show all labels in the same axis you should set style as:

Code: Select all

.Axis.Bottom.Labels.Style = talMark


Using this code you get the same as what I told you before:

Code: Select all

Private Sub Form_Load()
Dim i As Integer
Dim j As Double
With TChart1
.Aspect.View3D = False
.AddSeries scLine
For i = 0 To 9
j = i + 0.5
.Series(0).AddXY j, j * j, Str(j), vbRed
Next i
.AddSeries scLine
.Series(1).SetFunction tfSmoothing
.Series(1).DataSource = "Series0"
.Series(0).asLine.LinePen.Visible = False
.Series(0).ShowInLegend = False
.Series(0).asLine.Pointer.Visible = True
.Series(0).asLine.Pointer.Style = psStar
 
.AddSeries scLine
For i = 0 To 9
j = i + 0.75
.Series(2).AddXY j, j * j, Str(j), vbRed
Next i
.AddSeries scLine
.Series(3).SetFunction tfSmoothing
.Series(3).DataSource = "Series2"
.Series(2).asLine.LinePen.Visible = False
.Series(2).ShowInLegend = False
.Series(2).asLine.Pointer.Visible = True
.Series(2).asLine.Pointer.Style = psStar
.Axis.Bottom.Labels.Style = talMark
End With
End Sub


If then you want to show all series labels you should use more than one axis as shown in the code below. This example shows all series labels at the same axis (but they are different axes):

Code: Select all

Private Sub Form_Load()
Dim i As Integer
Dim j As Double
With TChart1
.Aspect.View3D = False
.AddSeries scLine
'black labels
For i = 0 To 9
j = i + 0.5
.Series(0).AddXY j, j * j, Str(j), vbRed
Next i
 
'red labels
.AddSeries scLine
.Series(1).SetFunction tfSmoothing
.Series(1).DataSource = "Series0"
axis1 = .Axis.AddCustom(True)
.Axis.Custom(axis1).Labels.Font.Color = vbRed
.Series(1).HorizontalAxisCustom = axis1
 
.Series(0).asLine.LinePen.Visible = False
.Series(0).ShowInLegend = False
.Series(0).asLine.Pointer.Visible = True
.Series(0).asLine.Pointer.Style = psStar
 

.AddSeries scLine
' green labels
For i = 0 To 9
j = i + 0.75
.Series(2).AddXY j, j * j, Str(j), vbRed
Next i
axis2 = .Axis.AddCustom(True)
.Axis.Custom(axis2).Labels.Font.Color = vbGreen
.Series(2).HorizontalAxisCustom = axis2
 
.AddSeries scLine
'yellow labels
.Series(3).SetFunction tfSmoothing
.Series(3).DataSource = "Series2"
axis3 = .Axis.AddCustom(True)
.Axis.Custom(axis3).Labels.Font.Color = vbYellow
.Series(3).HorizontalAxisCustom = axis3
 
.Series(2).asLine.LinePen.Visible = False
.Series(2).ShowInLegend = False
.Series(2).asLine.Pointer.Visible = True
.Series(2).asLine.Pointer.Style = psStar
.Axis.Bottom.Labels.Style = talAuto
End With
End Sub
Then you can make visible or invisible the labels you using:

Code: Select all

TChart1.Axis.Custom(axis2).Visible = False
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