ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to......my date array
Posted by JJJ on Sep-16-2011 13:58
Attachments:
Hi Peter:

I am using ChartDirector for .NET

i need.... show.....my date...

Thanks Peter

my date array  -->
20110616
20110818
20110819
20110822
20110823
20110824
20110825
20110826
20110829
20110830
20110831
20110901
20110902
未命名 - 1.jpg

  Re: How to......my date array
Posted by Peter Kwan on Sep-17-2011 01:43
Hi JJJ,

You mention "my date array  --> 20110616 ....". Would you mind to clarify what is "my date array" mean? In C#, a date array should be a variable of type "System.DateTime[]". Are your data stored in a DateTime[] array?

Note that 20110616 is not a date or time in .NET syntax. If your variable is displayed as 20110616, it is either a number or a text string. In programming, please make sure you use the syntax of your programming language to represent dates. For C#, it is by using System.DateTime objects.

If your data are not available in .NET syntax, you would need to write code to convert them to .NET syntax before passing them to ChartDirector.

For example, if your data are numbers like 20110616, not dates, then you may conver them to .NET DateTime using:

DateTime[] myDates = new DateTime[myNumbers.Length];
for (int i = 0; i < myTextStrings.Length; ++i) {
    int n = (int)myNumbers[i];
    myDates[i] = new DateTime(n/10000, (n % 10000) / 100, n % 100);
}

Hope this can help.

Regards
Peter Kwan

  Re: How to......my date array
Posted by JJJ on Sep-19-2011 14:57
my code

    ArrayList data_t = new ArrayList();//datetime
    ArrayList data_c = new ArrayList();//
    ArrayList data_v = new ArrayList();//
    ArrayList data_l = new ArrayList();//
    ArrayList data_h = new ArrayList();//
    ArrayList data_o = new ArrayList();//

    //List<string> aaaa = new List<string>();
    string[] arr2 = new string[] { "20110616", "20110818", "20110819", "20110822", "20110823" };


    XmlDocument doc = new XmlDocument();
    try////////////////////////////////////////////////////////////////////////////////////////
    {
        infoName_MapPath = Server.MapPath("./K.xml");//
        doc.Load(infoName_MapPath);
    }catch(Exception e){
        infoName_MapPath = Server.MapPath("./K_temp.xml");//
        doc.Load(infoName_MapPath);
    }
    foreach (XmlNode node in doc.SelectNodes("CHART/ROW1"))
    {
        data_t.Add(double.Parse(node.Attributes["t"].Value));
        data_c.Add(double.Parse(node.Attributes["c"].Value));
        data_v.Add(double.Parse(node.Attributes["v"].Value));
        data_l.Add(double.Parse(node.Attributes["l"].Value));
        data_h.Add(double.Parse(node.Attributes["h"].Value));
        data_o.Add(double.Parse(node.Attributes["o"].Value));
Response.Write(node.Attributes["c"].Value);
    }


    double[] data_tt = (double[])data_t.ToArray(typeof(double));
    double[] data_cc = (double[])data_c.ToArray(typeof(double));
    double[] data_vv = (double[])data_v.ToArray(typeof(double));
    double[] data_ll = (double[])data_l.ToArray(typeof(double));
    double[] data_hh = (double[])data_h.ToArray(typeof(double));
    double[] data_oo = (double[])data_o.ToArray(typeof(double));


    //double[] timeStamps = rantable.getCol(0);
    double[] timeStamps = arr2;
    double[] highData = data_hh;
    double[] lowData = data_ll;
    double[] openData = data_oo;
    double[] closeData = data_cc;
    double[] volData = data_vv;



how to.........  arr2(string)  --> convert --> to  double[] timeStamps ??

Thanks

  Re: How to......my date array
Posted by JJJ on Sep-19-2011 20:36
Attachments:
i try again

code----> finance2.aspx

add

    DateTime baseDate = DateTime.ParseExact("20110809", "yyyyMMdd", null);
    DateTime baseDate1 = DateTime.ParseExact("20110810", "yyyyMMdd", null);
    DateTime baseDate2 = DateTime.ParseExact("20110811", "yyyyMMdd", null);
    DateTime baseDate3 = DateTime.ParseExact("20110812", "yyyyMMdd", null);
    DateTime baseDate4 = DateTime.ParseExact("20110813", "yyyyMMdd", null);

    double[] baseNumber = new double[10];//string[] arrStringB = new string[4];
    baseNumber[0] = baseDate.ToOADate();// convert the datetime to double
    baseNumber[1] = baseDate1.ToOADate();// convert the datetime to double
    baseNumber[2] = baseDate2.ToOADate();// convert the datetime to double
    baseNumber[3] = baseDate3.ToOADate();// convert the datetime to double
    baseNumber[4] = baseDate4.ToOADate();// convert the datetime to double

    double[] timeStamps = baseNumber;



but ... time....it's error...........
未命名 - 1.jpg

  Re: How to......my date array
Posted by Peter Kwan on Sep-20-2011 00:23
Hi JJJ,

Please use:

DateTime[] timeStamps = {baseDate, baseDate1, baseDate3, baseDate3, baseDate4};

Also, note that in finance2.aspx, in the sample code the "extraDays" is set to 30, which means the first 30 data points will not be displayed. Please make sure you change it to 0 for your case.

Hope this can help.

Regards
Peter Kwan

  Re: How to......my date array
Posted by JJJ on Sep-20-2011 09:06
Thank you Peter.