Axis labels with multiple series

TeeChart for ActiveX, COM and ASP
Post Reply
MikeC
Newbie
Newbie
Posts: 8
Joined: Mon May 21, 2001 4:00 am
Location: W. Yorkshire, UK

Axis labels with multiple series

Post by MikeC » Thu May 20, 2004 8:39 am

Hi there,

I have a 'live' chart on a web page that contains 2 series that both have their 'LabelSource' assigned so that I can display a 'MarksTip' when govering over a point with the mouse. I only want to display the labels for the second series on the bottom axis (which is a datetime). As far as I can tell the following code (vbscript on the web page) should stop the labels being shown for the first series (which are descriptive strings) but I'm not having any luck :

sub TChart1_OnGetAxisLabel(Axis, SeriesIndex, ValueIndex, LabelText)
If Axis = 3 Then
If TChart1.SeriesCount > 1 Then
If SeriesIndex = 0 Then
LabelText = ""
End If
End If
End If
end sub

Any ideas :?:

Cheers,

Mike

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu May 20, 2004 1:52 pm

Hi Mike,

which TeeChart version are you using ?
I've modified the example included in the TC v6 under :
C:\Program Files\Steema Software\TeeChart Pro v6 ActiveX Control\ExamplesVisual Basic\Visual Basic 5 & 6\ADO Databases
and works fine, it shows the DataTime labels. Could you please test it ? See the code below modified :

Code: Select all

Private Sub Command1_Click()
' This example uses Microsoft OLE DB
' ActiveX Data Objects 2.0 Library.

' declare a Connection and RecordSet variables...
Dim Data As New ADODB.Connection
Dim Record As New ADODB.Recordset
Dim Record1 As New ADODB.Recordset

  ' Open the sample table and database...
  ' The "TeeChart Pro Database" ODBC DSN is
  ' automatically added when installing TeeChart Pro...
  Data.Open "TeeChart Pro Database"
  
  Record.Open "employee", Data, 1, 1
  ' Retrieve records....
  TChart1.Series(0).Clear
  TChart1.Series(0).DataSource = Record
  TChart1.Series(0).YValues.ValueSource = Record.Fields(1).Name
  TChart1.Series(0).LabelsSource = Record.Fields(0).Name
  
  Record1.Open "employee", Data, 1, 1
  TChart1.AddSeries scBar
  TChart1.Series(1).ColorEachPoint = True
  TChart1.Series(1).DataSource = Record1
  TChart1.Series(1).YValues.ValueSource = Record.Fields(1).Name
  TChart1.Series(1).LabelsSource = Record.Fields(2).Name
  
  ' release variables...
  Set Record = Nothing
  Set Record1 = Nothing
  
  Set Data = Nothing
End Sub

Private Sub Command2_Click()
  End
End Sub

Private Sub TChart1_OnDblClick()
  TChart1.ShowEditor
End Sub

Private Sub TChart1_OnGetAxisLabel(ByVal Axis As Long, ByVal SeriesIndex As Long, ByVal ValueIndex As Long, LabelText As String)
If Axis = 3 Then
  If TChart1.SeriesCount > 1 Then
    If SeriesIndex = 0 Then
      LabelText = ""
    End If
  End If
End If
End Sub

MikeC
Newbie
Newbie
Posts: 8
Joined: Mon May 21, 2001 4:00 am
Location: W. Yorkshire, UK

Post by MikeC » Fri May 21, 2004 8:49 am

Pep,

We're using version 6 of teechart.

The chart contains 2 series, which are built from 2 different recordsets.

The first recordset contains 2 fields - a value and a date field.
The second recordset contains 3 fields - a value , a date field and a description field (which I display when the user hovers over a point on the second series with the mouse - this bit works fine).

I'm setting the charts up as follows :

TChart1.Series(0).YValues.ValueSource = Recordset1.Fields(0).Name
TChart1.Series(0).XValues.ValueSource = Recordset1.Fields(1).Name
TChart1.Series(0).LabelsSource = Recordset1.Fields(1).Name

TChart1.Series(1).YValues.ValueSource = Recordset2.Fields(0).Name
TChart1.Series(1).XValues.ValueSource = Recordset2.Fields(1).Name
TChart1.Series(1).LabelsSource = Recordset2.Fields(2).Name

(If I don't set the XValues.ValueSource on both series then the bottom (date) axis gets screwed up - I'm not sure if this is part of the problem).

Then on the web page I've got a bit of vbscript as follows :

sub TChart1_OnGetAxisLabel(Axis, SeriesIndex, ValueIndex, LabelText)
If Axis = 3 Then
If TChart1.SeriesCount > 1 Then
If SeriesIndex = 0 Then
LabelText = ""
End If
End If
End If
end sub


Am I doing something obviously wrong ?

I just can't seem to stop the chart displaying the bottom axis labels from the second series (the descriptions appear over the top of the date labels from the first series)

Please help - this is driving me crazy :?

Cheers,

Mike

MikeC
Newbie
Newbie
Posts: 8
Joined: Mon May 21, 2001 4:00 am
Location: W. Yorkshire, UK

Post by MikeC » Wed Jun 23, 2004 8:37 am

Pep,

I've been away for a while - but now I'm back hassling you again !
:D

The code below is the VBScript equivalent of the code sample you posted but it doesn't stop the axis labels from the first series being displayed - I'm sure this will work in VB but I've had no success as VBScript on a web page :

sub TChart1_OnGetAxisLabel(Axis, SeriesIndex, ValueIndex, LabelText)
If Axis = 3 Then
If TChart1.SeriesCount > 1 Then
If SeriesIndex = 0 Then
LabelText = ""
End If
End If
End If
end sub

Is there any reason why this shouldn't work ?

Best regards,

Mike

MikeC
Newbie
Newbie
Posts: 8
Joined: Mon May 21, 2001 4:00 am
Location: W. Yorkshire, UK

Post by MikeC » Fri Jun 25, 2004 8:42 am

Hello there Steema - is there anybody there :(

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jun 25, 2004 10:42 am

Hi Mike,

have you checked that it pass through the "if" ? (I mean "if SeriesIndex..").

MikeC
Newbie
Newbie
Posts: 8
Joined: Mon May 21, 2001 4:00 am
Location: W. Yorkshire, UK

Post by MikeC » Fri Jun 25, 2004 11:49 am

Hi Pep,

Yes - I've stuck an alert in the VBScript to show me in a messagebox the labels I DON'T want to see - so I know it's passing through OK.

It's just not setting the 'LabelText' to ""

It's as though it's read-only in a VBScript ?

Can you duplicate this problem with a VBScript on a web page at your end (just try setting the axis labels to 'test') ?

Cheers,

Mike

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Jun 29, 2004 12:38 am

Hi Mike,

the problem here is that you cannot asign values to variables in this manner. You can modify Axis labels in ASP using the technique outlined in the example accessible from:
C:\Program Files\TeeChart Pro v6 ActiveX Control\Examples\Internet Explorer\ASPHome.htm

called "Page showing 4 different export formats"
(http://localhost/TeeChart6/CompareOutput.asp). The first Chart, the "Live" example, has its left axis labels modified using the technique that can be seen in the source.

Post Reply