Page 1 of 1

DataSource property

Posted: Tue Dec 23, 2003 12:16 pm
by 9079459
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

Posted: Tue Dec 23, 2003 3:15 pm
by Pep
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

Posted: Tue Dec 23, 2003 9:20 pm
by 9079459
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

Posted: Tue Dec 23, 2003 9:45 pm
by Marc
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

Posted: Wed Dec 24, 2003 8:21 am
by 9079459
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

Posted: Wed Dec 24, 2003 2:41 pm
by Marc
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

Posted: Sat Dec 27, 2003 8:24 am
by 9079459
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