Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 cast from Date to ChartCalendar
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Plutiko

8 Posts

Posted - 11 Sep 2003 :  15:23:20  Show Profile  Reply with Quote
Hello
I want to plot a XY line chart. On the x-as I would like have some date. The I don't know how I can translate an array of the type Date to an array of the type ChartCalendar. Does somebody has an example how you cast it?
I hope somebody can help,

thank you

Plutiko

quinncurtis

1164 Posts

Posted - 11 Sep 2003 :  15:45:48  Show Profile  Reply with Quote
Do you mean the DateTime class, rather than a Date class. I could find no reference to a Date class in .Net.

The QCChart2D ChartCalendar class has a constructor that accepts a DateTime class.

If you want language specific example you will need to specify whether you are using C# or VB.
Go to Top of Page

Plutiko

8 Posts

Posted - 11 Sep 2003 :  16:07:15  Show Profile  Reply with Quote
I'm using VB.net
I tried it also with an array of the type DateTime, but I couldn't let ik work. If you have an example I would appreciate it.
Go to Top of Page

Plutiko

8 Posts

Posted - 11 Sep 2003 :  16:24:32  Show Profile  Reply with Quote
Maybe easier when I adjust the code that doesn't work.

Public Sub PasteData(ByVal skew As ArrayList, ByVal ATM As ArrayList)
skewArray = skew
ATMArray = ATM
End Sub

Private Sub InitializeChart()
Dim chartVu As ChartView = Me
Dim skew As New ArrayList()
Dim ATM(ATMArray.Count) As Double
Dim arrayExp(ATMArray.Count) As ChartCalendar
Dim DT As DateTime
Dim x As skewprm
Dim i As Integer

For Each x In skew
DT = CType((x.getExpDate), DateTime)
arrayExp(i) = DT
i = i + 1
Next

Dim Dataset1 As New TimeSimpleDataset("First", arrayExp, ATM)

The line arrayExp(i) = DT doesn't work
any clue?
Go to Top of Page

quinncurtis

1164 Posts

Posted - 11 Sep 2003 :  16:41:56  Show Profile  Reply with Quote
Here is a modified version of the date initialization section in the InitializeChart method of the EditChartExample example program. It creates a DateTime array with dates separated by 3 months, and copies that to a ChartCalendar array.

Dim x1(nnumpnts - 1) As ChartCalendar
Dim y1(nnumpnts - 1) As Double
Dim y2(nnumpnts - 1) As Double
Dim startdatetime As DateTime = New DateTime(2003, 1, 1)
Dim datetimearray(nnumpnts - 1) As DateTime
For i = 0 To nnumpnts - 1
datetimearray(i) = startdatetime.AddMonths(i * 3)
Next
y1(0) = 100
y2(0) = 30
For i = 0 To nnumpnts - 1
x1(i) = New ChartCalendar(datetimearray(i))
If (i > 0) Then
y1(i) += y1((i-1))+(5+i)*(0.75- ChartSupport.GetRandomDouble())
y2(i) += y2((i-1))+(15+i)*(0.95- ChartSupport.GetRandomDouble())
End If
Next
Go to Top of Page

Plutiko

8 Posts

Posted - 11 Sep 2003 :  16:57:51  Show Profile  Reply with Quote
Thank you, that works perfectly
Go to Top of Page

quinncurtis

1164 Posts

Posted - 11 Sep 2003 :  16:58:31  Show Profile  Reply with Quote
You can't assign disimilar types

arrayExp(i) = DT

where arrayExp(i) is of type ChartCalendar and DT is of type DateTime.

I think this code should work, assuming that DT is a valid date for all i. I think you have a dangerous, unitialzied i variable in your code.


i = 0
For Each x In skew
DT = CType((x.getExpDate), DateTime)
arrayExp(i) = new ChartCalendar(DT)
i = i + 1
Next

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07