Page 1 of 1
Help with varying Time intervals of datetime in X Axis
Posted: Fri Aug 19, 2005 2:26 pm
by 9079416
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.
Posted: Fri Aug 19, 2005 4:10 pm
by narcis
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.
T think the default option make sense but...
Posted: Fri Aug 19, 2005 6:26 pm
by 9079416
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
Posted: Mon Aug 22, 2005 11:24 am
by narcis
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.
Datetime with many series
Posted: Wed Aug 24, 2005 2:51 pm
by 9079416
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
Posted: Wed Aug 24, 2005 3:14 pm
by narcis
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.
my bad, I have sent u the code at the above mentioned addres
Posted: Wed Aug 24, 2005 3:51 pm
by 9079416
It was end function not end if 8O
Posted: Thu Aug 25, 2005 1:29 pm
by narcis
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
Have a doubt
Posted: Thu Aug 25, 2005 3:40 pm
by 9079416
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
Have a doubt
Posted: Thu Aug 25, 2005 3:48 pm
by 9079416
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
Posted: Thu Aug 25, 2005 4:04 pm
by narcis
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