DataSource property

TeeChart for ActiveX, COM and ASP
Post Reply
nefis
Newbie
Newbie
Posts: 62
Joined: Wed Oct 22, 2003 4:00 am
Location: chicago

DataSource property

Post by nefis » Tue Dec 23, 2003 12:16 pm

Hello,

I assign an ADO recordset to the property. Then i add a new record to the recordset. The new record doesn't show up in the chart!
What's wrong?

nefis

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

Post by Pep » Tue Dec 23, 2003 3:15 pm

Hi Nefis,

have you tried to use the ITChart.RefreshData and CheckDataSource methods when the records has been modified ?

Josep Lluis Jorge
http://support.steema.com

nefis
Newbie
Newbie
Posts: 62
Joined: Wed Oct 22, 2003 4:00 am
Location: chicago

Post by nefis » Tue Dec 23, 2003 9:20 pm

Pep wrote:Hi Nefis,

have you tried to use the ITChart.RefreshData and CheckDataSource methods when the records has been modified ?

Josep Lluis Jorge
http://support.steema.com
Could you please to tell me what's wrong with the code. It's running but no points are showed:

Code: Select all

Option Explicit
  
Private Const DField = "DT"
Private Const VField = "Value"
Private Const TimeFrame = 1 / (24 * 60 * 12) '5 sec
Private rs As ADODB.Recordset

Private Sub Form_Load()
  Set rs = New ADODB.Recordset
  Call rs.Fields.Append(DField, adDate)
  Call rs.Fields.Append(VField, adDouble)
  Call rs.Open
  
  Call TChart1.AddSeries(scLine)
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
  TChart1.Axis.Left.Otherside = True
  TChart1.Series(0).DataSource = rs
  TChart1.Series(0).ValueLists.Items(0).DateTime = True
  TChart1.Series(0).ValueLists.Items(0).ValueSource = DField
  TChart1.Series(0).ValueLists.Items(1).ValueSource = VField
  
  Timer1.Interval = 1000
End Sub

Private Sub Form_Resize()
  Call TChart1.Move(0, 0, Width - 100, Height - 400)
End Sub

Private Sub Timer1_Timer()
  Static t As Double
  Static DT As Date
  
  If TChart1.Series(0).Count = 0 Then
    t = 1000
    DT = Now
    'Call TChart1.Series(0).AddXY(DT, t, "", vbRed)
    Call AddPoint(DT, t)
  Else
    t = t - Rnd + 0.5
    DT = DT + TimeFrame
    'Call TChart1.Series(0).AddXY(DT, t, "", vbRed)
    Call AddPoint(DT, t)
  End If
End Sub

Private Sub AddPoint(DT As Date, Value As Double)
  rs.AddNew
    rs(DField) = DT
    rs(VField) = Value
  rs.Update
  Call TChart1.Series(0).CheckDataSource
End Sub

Marc
Site Admin
Site Admin
Posts: 1271
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Tue Dec 23, 2003 9:45 pm

Hello Nefis,

In this case, when datasourcing to a Recordset you'll need to reset the Datasource property when modifying the Recordset. That's due to an internal issue that may be ironed out in a future release.

ie.

Code: Select all

Private Sub AddPoint(DT As Date, Value As Double) 
  rs.AddNew 
    rs(DField) = DT 
    rs(VField) = Value 
  rs.Update 
  TChart1.Series(0).DataSource = rs 
End Sub
I can't find a reference to this in the documentation. I'll make a note for a description to be included in the next update.

Regards,
Marc Meumann
Steema Support

nefis
Newbie
Newbie
Posts: 62
Joined: Wed Oct 22, 2003 4:00 am
Location: chicago

Post by nefis » Wed Dec 24, 2003 8:21 am

Thanks, it's helped.
I have a question though. Will it slow down an app? I mean does TeeChart get all data from ADO recordset again? Or just new records?

nefis

Marc
Site Admin
Site Admin
Posts: 1271
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Wed Dec 24, 2003 2:41 pm

Hello Nefis,

TeeChart re-reads the Recordset but 'enbloc' so I don't think you'll notice a performance overhead. CheckDatasource would need to do something similar too as to reflect changes in existing records (as well as to pick-up new records) the entire Recordset would need to be scanned.

Regards,
Marc Meumann
Steema Support

nefis
Newbie
Newbie
Posts: 62
Joined: Wed Oct 22, 2003 4:00 am
Location: chicago

Post by nefis » Sat Dec 27, 2003 8:24 am

Marc wrote:Hello Nefis,

TeeChart re-reads the Recordset but 'enbloc' so I don't think you'll notice a performance overhead. CheckDatasource would need to do something similar too as to reflect changes in existing records (as well as to pick-up new records) the entire Recordset would need to be scanned.

Regards,
Marc Meumann
Steema Support
Marc,
i would do it a bit different. ADO Recordset provides comprehensive set of events which could be used to update only changed records.

nefis

Post Reply