Page 1 of 1

Help,About the ChartPageNavigator

Posted: Wed Oct 28, 2009 1:37 pm
by 15054544
Hi,
I'v Three questions:
First,I wanto add (x,y) Array, and the x is DataTime ,the y is a float,How to set the x is DateTime in VC++? and What function should i use? Series(0).AddXY(x,y,label,0) the x is required a double ,Does it have other function to add the x is DateTime? Thanks


Second, Does the ChartPageNavigator have Message Handle function,I want to know which page is shown now?

Besides i want a day's data show in one page,and when click the next page, Teechart show the data of next day?

Expect u reply .....Thanks
Rayao

Re: Help,About the ChartPageNavigator

Posted: Fri Oct 30, 2009 12:33 pm
by yeray
Hi rayao,
rayao wrote:First,I wanto add (x,y) Array, and the x is DataTime ,the y is a float,How to set the x is DateTime in VC++? and What function should i use? Series(0).AddXY(x,y,label,0) the x is required a double ,Does it have other function to add the x is DateTime? Thanks
I'm afraid there is no Add method that accepts datetimes but note that datetimes are, in fact, doubles. So you may format your datetimes to doubles if they are not accepted directly by the AddXY method, add them to the series, and then you could set your series x values to be datetimes.
rayao wrote:Second, Does the ChartPageNavigator have Message Handle function,I want to know which page is shown now?
Yes the following gives the current page:

Code: Select all

m_Chart1.GetPage().GetCount()
rayao wrote:Besides i want a day's data show in one page,and when click the next page, Teechart show the data of next day?
This isn't possible using the automatic pagination feature because it only uses the MaxPointsPerPage property to calculate each page. But you can achieve it doing your own SetMinMax calls. Here is an example in VB6:

Code: Select all

Dim DayShown As Integer

Private Sub Form_Load()
  TeeCommander1.Chart = TChart1
   
  TChart1.Aspect.View3D = False
  
  TChart1.AddSeries scPoint
  TChart1.Series(0).XValues.DateTime = True
 
  Dim Day, hour As Integer
  Dim mydate As Date
 
  For Day = 1 To 5
    For hour = 8 To 20
      mydate = Str$(Day) & "/10/2009 " & Str$(hour) & ":00"
      TChart1.Series(0).AddXY mydate, Rnd * 100, "", clTeeColor
    Next hour
  Next Day
  
  TChart1.Header.Text.Text = "Showing 5 days"
  DayShown = 1
End Sub

Private Sub DayDown_Click()
  If DayShown > 1 Then
    DayShown = DayShown - 1
  End If
  ShowDay DayShown
End Sub

Private Sub DayUp_Click()
  If DayShown < Day(TChart1.Series(0).XValues.Maximum) Then
    DayShown = DayShown + 1
  End If
  ShowDay DayShown
End Sub

Private Sub ShowDay(ByVal nDay As Integer)
  Dim i As Integer
  Dim tmpMin, tmpMax As Integer
  tmpMin = -1
  tmpMax = -1
  With TChart1.Series(0)
    For i = 1 To .Count - 1
      If Day(.XValues.Value(i)) = DayShown Then
        If tmpMin = -1 And tmpMax = -1 Then
          tmpMin = i
          tmpMax = i
        Else
          If .XValues.Value(i) < .XValues.Value(tmpMin) Then
            tmpMin = i
          End If
          If .XValues.Value(i) > .XValues.Value(tmpMax) Then
            tmpMax = i
          End If
        End If
      End If
    Next i
    TChart1.Axis.Bottom.SetMinMax .XValues.Value(tmpMin), .XValues.Value(tmpMax)
  End With
  
  TChart1.Header.Text.Text = "Current day: " + Str$(DayShown)
  
  TChart1.Environment.InternalRepaint
End Sub

Re: Help,About the ChartPageNavigator

Posted: Tue Nov 03, 2009 2:11 am
by 15054544
hi,thanks your reply.....but i have tried the code....the result is showing noting except the X axis is 1900-1-1....1900--1-3..and so on,I donot know what problem i meet?
m_ChartRTV.Series(0).GetXValues().SetDateTime(TRUE);
CString strDate;
COleDateTime m_Date;
for (int i=0;i<10;i++)
{
strDate=_T("1/10/2009 10:30");
m_Date.ParseDateTime(strDate);
m_ChartRTV.Series(0).AddXY(m_Date,i,_T(""),clTeeColor);
}
m_ChartRTV.Series(0).AddXY(m_Date,11,_T(""),clTeeColor);

Re: Help,About the ChartPageNavigator

Posted: Tue Nov 03, 2009 10:36 am
by yeray
Hi rayao,

Could you please send us a simple example project we can run as-is to reproduce the problem here?