Help with varying Time intervals of datetime in X Axis

TeeChart for ActiveX, COM and ASP
Post Reply
Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Help with varying Time intervals of datetime in X Axis

Post by Shawn » Fri Aug 19, 2005 2:26 pm

I have a graph , X Axis Datetime in Mm/dd/Yyyy/hh:mm
Y Axis - Double

The problem is I have varying series(everytime I click on a combobox, depending on the value returned I add 3 serires or 8 series or whatever)

Each series have different graph points.

One series might have datetime ranging btwn 1999 - 2000 and another series might have date ranging from 2004 - 2005. And I want to see all the series in the same graph no matter what time interval they all lie in. I will just have to scroll.

How do I show all the series together in one graph, and then I can also zoom on one certain graph too.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Aug 19, 2005 4:10 pm

Hi Shawn,

You have two options:

1) Default option. If you have a series ranging from 1999 to 2000 and another one ranging from 2004-2005, your bottom axis will be authomatically scaled from 1999 to 2005 leaving a gap where there's no data.

2) Using a separate horizontal axes for every series (or group of series). This will let you have all series in the same chart area with its independent scale. For more information on how to use custom axes please have a look at the TeeChart tutorials and features demo available at TeeChart's program group.

Both options will let you zoom the chart.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

T think the default option make sense but...

Post by Shawn » Fri Aug 19, 2005 6:26 pm

It is only that My datetime has intervals as small as hours,

SO I am not able to see the X Axis (which can be 08/01/2005 12:10:22 AM)

I tried just drawing the next series as just the next point and start all over again, and only show the datetime as just labels, but then it shows the labels correctly only for the first series.

here is my snippet of code

Code: Select all

Private Function LoadGraph()

      t = 0

       With TChart1.Axis.Bottom
            .Title.Caption = "Inspection Date"
            .Automatic = True
       End With
        
       With TChart1.Axis.Left
            .Title.Caption = "Corrosion Rate"
            .Automatic = True
       End With


      'Get the no: of series to add
     'For each series
           'get the no: of points to add
           For K = 0 To UBound(No.OfPoints)
              With TChart1.Series(j)
                   If IsNull(arProbes(4, K)) Then
                       .AddXY t, 0, CDate(arProbes(3, K)), clTeeColor
                   Else
                        .AddXY t, arProbes(4, K), CDate(arProbes(3, K)),               clTeeColor
                   End If
              End With
              
          t = t + 1
          Next
              
    Next

End Function

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Aug 22, 2005 11:24 am

Hi Shawn,

The problem may be related to text bottom axis labels with more than one series as was on that case (it's in .NET but also applies to VCL and ActiveX versions).

However, to be 100% sure, could you please post an example we can run "as-is" to reproduce the problem here? You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Datetime with many series

Post by Shawn » Wed Aug 24, 2005 2:51 pm

I am having issues with atatching,
here is the code
Please put a command1 button and Tchart1 chart in the form and use the code below.

'****************************************

Private Sub command1_Click()
LoadGraph

End Sub
'****************************************

Public Function LoadGraph()

TChart1.RemoveAllSeries

'i am actually getting this mina nd max date according to the least and biggest date in the dates i return from the DB
'Set the X Axis and Y Axis

With TChart1.Axis.Bottom
.Automatic = False
'.SetMinMax CDate("01/01/2005"), CDate("12/31/2005")
.MaximumOffset = 4
.MinimumOffset = 4
.Labels.Separation = 0
.Labels.Size = 25
End With

With TChart1.Axis.Left
.Title.Caption = "Corrosion Rate"
.Automatic = False
.MaximumOffset = 4
.MinimumOffset = 4
.Labels.Size = 25
End With


For j = 0 To 5
'add a series
TChart1.AddSeries (scFastLine)
For k = 0 To j+3
With TChart1.Series(j)
.XValues.DateTime = True
.AddXY CDate(DateTime.Now + j ), CDbl(j), "", clTeeColor
.Marks.Arrow.Visible = True
.Marks.Arrow.Width = 5
.Marks.Arrow.Style = psDot
.Marks.Arrow.Color = TChart1.Series(j).Color

End With

Next
Next


With TChart1.Axis.Bottom
.Title.Caption = "Inspection Date"
.Increment = TChart1.GetDateTimeStep(dtOneDay)
.Labels.DateTimeFormat = "mm/dd/yyyy"
.Automatic = False
End With

End If

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Aug 24, 2005 3:14 pm

Hi Shawn,

Could you please check that you pasted the full code as at the bottom of the snippet you posted there's and "End If" which doesn't make much sense.

If you have problems posting to the newsgroups you can send the example directly to me.

Thanks in advance.
Last edited by Narcís on Wed Oct 04, 2006 11:28 am, edited 1 time in total.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

my bad, I have sent u the code at the above mentioned addres

Post by Shawn » Wed Aug 24, 2005 3:51 pm

It was end function not end if 8O

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Aug 25, 2005 1:29 pm

Hi Shawn,
It was end function not end if
That was my suspect but I wanted to check with you.

The code below works for me, could you please test if it works for you?

Code: Select all

Private Sub Form_Load()
    LoadGraph
End Sub

Public Function LoadGraph()
    TChart1.RemoveAllSeries

    'i am actually getting this mina nd max date according to the least and biggest date in the dates i return from the DB
    'Set the X Axis and Y Axis
    With TChart1.Axis.Bottom
            .Automatic = False
            .SetMinMax CDate("01/01/2005"), CDate("12/31/2005")
            .MaximumOffset = 4
            .MinimumOffset = 4
            .Labels.Separation = 0
            .Labels.Size = 25
    End With

    With TChart1.Axis.Left
            .Title.Caption = "Corrosion Rate"
            .Automatic = False
            .MaximumOffset = 4
            .MinimumOffset = 4
            .Labels.Size = 25
    End With

    For j = 0 To 5
        'add a series
        TChart1.AddSeries (scFastLine)
    
        For k = 0 To j + 3
            With TChart1.Series(j)
                .XValues.DateTime = True
                .AddXY Rnd(100), Rnd(100), "", clTeeColor
                .AddXY CDate(DateTime.Now + j), CDbl(j), "", clTeeColor
                .Marks.Arrow.Visible = True
                .Marks.Arrow.Width = 5
                .Marks.Arrow.Style = psDot
                .Marks.Arrow.Color = TChart1.Series(j).Color
            End With
        Next
    Next

    With TChart1.Axis.Bottom
         .Title.Caption = "Inspection Date"
         .Increment = TChart1.GetDateTimeStep(dtOneDay)
         .Labels.DateTimeFormat = "mm/dd/yyyy"
         .Automatic = False 'This is redundant
    End With
End Function
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Have a doubt

Post by Shawn » Thu Aug 25, 2005 3:40 pm

Narcis,

So i think the differnce u made is in this line
.AddXY Rnd(100), Rnd(100), "", clTeeColor
.AddXY CDate(DateTime.Now + j), CDbl(j), "", clTeeColor

Can you tell me why u added the first line?(are we adding two points at the same time)

Also when I set min and max of axis , is there something like I cannot put a slider on the graph to show only say 2 or 5 points at a time in the graph

Smitha

Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Have a doubt

Post by Shawn » Thu Aug 25, 2005 3:48 pm

Narcis,

So i think the differnce u made is in this line
.AddXY Rnd(100), Rnd(100), "", clTeeColor
.AddXY CDate(DateTime.Now + j), CDbl(j), "", clTeeColor

Can you tell me why u added the first line?(are we adding two points at the same time)

Also when I set min and max of axis , is there something like I cannot put a slider on the graph to show only say 2 or 5 points at a time in the graph



Smitha

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Aug 25, 2005 4:04 pm

Hi Smitha,

Sorry, but I wrongly I posted code I used for testing. The problem is that although you are iterating with a for loop you are always adding the same point as the DateTime and j values are the same during the loop. Using FastLine series as you used, those points are not visible as 2 points are necessary to draw a line. In the code below I changed the series type to a Line series and forced its pointer to be visible so that you can already see the points you added.

Code: Select all

Private Sub Form_Load()
    LoadGraph
End Sub

Public Function LoadGraph()
    TChart1.RemoveAllSeries

    'i am actually getting this mina nd max date according to the least and biggest date in the dates i return from the DB
    'Set the X Axis and Y Axis
    With TChart1.Axis.Bottom
            .Automatic = False
            .SetMinMax CDate("01/01/2005"), CDate("12/31/2005")
            .MaximumOffset = 4
            .MinimumOffset = 4
            .Labels.Separation = 0
            .Labels.Size = 25
    End With

    With TChart1.Axis.Left
            .Title.Caption = "Corrosion Rate"
            .Automatic = False
            .MaximumOffset = 4
            .MinimumOffset = 4
            .Labels.Size = 25
    End With

    For j = 0 To 5
        'add a series
        'TChart1.AddSeries (scFastLine)
        TChart1.AddSeries (scLine)
    
        For k = 0 To j + 3
            With TChart1.Series(j)
                .XValues.DateTime = True
                .AddXY CDate(DateTime.Now + j), CDbl(j), "", clTeeColor
                .Marks.Arrow.Visible = True
                .Marks.Arrow.Width = 5
                .Marks.Arrow.Style = psDot
                .Marks.Arrow.Color = TChart1.Series(j).Color
                
                .asLine.Pointer.Visible = True 'Only with scLine series
            End With
        Next
    Next

    With TChart1.Axis.Bottom
         .Title.Caption = "Inspection Date"
         .Increment = TChart1.GetDateTimeStep(dtOneDay)
         .Labels.DateTimeFormat = "mm/dd/yyyy"
    End With
End Function
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply