Help,About the ChartPageNavigator

TeeChart for ActiveX, COM and ASP
Post Reply
rayao
Newbie
Newbie
Posts: 3
Joined: Wed Oct 28, 2009 12:00 am

Help,About the ChartPageNavigator

Post by rayao » Wed Oct 28, 2009 1:37 pm

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

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Help,About the ChartPageNavigator

Post by Yeray » Fri Oct 30, 2009 12:33 pm

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

rayao
Newbie
Newbie
Posts: 3
Joined: Wed Oct 28, 2009 12:00 am

Re: Help,About the ChartPageNavigator

Post by rayao » Tue Nov 03, 2009 2:11 am

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);

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Help,About the ChartPageNavigator

Post by Yeray » Tue Nov 03, 2009 10:36 am

Hi rayao,

Could you please send us a simple example project we can run as-is to reproduce the problem here?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply