how to draw a Gantt Chart with Date on X-axis time on Y-axis

13 posts, 0 answers
  1. chandra
    chandra avatar
    21 posts
    Member since:
    Apr 2008

    Posted 02 Jun 2008 Link to this post

    hi,

        I want to draw a Gantt chart with date on X-axis, Time on Y-axis.
        I need to get all the values from XML.
        Can u share some sample code to draw a Gantt chart like for a particular day from one particular time to another particular time.?
    how i need to write a XML so that the chart can bind the XML data to the chart?

    ex:  on 02-06-2008 i should plot the gantt chart from 5:00 P.M to 7.00 P.M

    help is highly appreciated.

    regards,
    chandra

  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 03 Jun 2008 Link to this post

    Hi Chandra,

    There is no need to change the data source (XML in your case). You just need to change the Series Orientation of the RadChart:
    this.radChart1.SeriesOrientation = ChartSeriesOrientation.Vertical; 

    For more information about XML data sources, please, refer to the example in our QSF. There you can also find an example demonstrating Gantt chart ((RadChart >> Chart Types >> Gantt).

    Sincerely yours,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. chandra
    chandra avatar
    21 posts
    Member since:
    Apr 2008

    Posted 03 Jun 2008 Link to this post

    Hi Evtim,

    as per my understanding and according to the example in QFS....  on X-axis we need to draw the chart (From point to To point).but for a particular date how can we have the fromDate and toDate???

    As mentioned in my previous query:
    ex:  For date  02-06-2008,  i need to draw the chart from 5:00 P.M to 7.00 P.M.

    Ranges to plot graph are:
    ------------------------------
    Date range is :
    02-06-2008 to 12-06-2008
    time range is : 0:00 to 24:00

    ex: values in XML are

    <Day Date="02/06/2008" From="02/06/2008 08:45 PM" To="02/06/2008 04:55 AM"></Day>
    <Day Date="21/05/2008" From="21/05/2008 10:45 PM" To="22/05/2008 06:55 AM"></Day>




  5. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 04 Jun 2008 Link to this post

    Hi chandra,

    Unfortunately, plotting dates is not straight-forward. You need to convert the dates to Ole Automation format.
    Please, refer to the following example (especially lines 20, 26 and 61 to 64):
    1 public Form1() 
    2
    3     InitializeComponent(); 
    4
    5  
    6 protected override void OnLoad(EventArgs e) 
    7
    8     base.OnLoad(e); 
    9  
    10     DateTime today = DateTime.Today; 
    11  
    12     // Setup chart orientation 
    13     this.radChart1.SeriesOrientation = ChartSeriesOrientation.Horizontal; 
    14  
    15     // Setup XAxis 
    16     this.radChart1.PlotArea.XAxis.IsZeroBased = false
    17     this.radChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate; 
    18     this.radChart1.PlotArea.XAxis.AutoScale = false
    19     this.radChart1.PlotArea.XAxis.AddRange(today.ToOADate(), today.AddDays(10).ToOADate(), 1); 
    20     this.radChart1.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Inside; 
    21  
    22     // Setup YAxis 
    23     this.radChart1.PlotArea.YAxis.IsZeroBased = false
    24     this.radChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime; 
    25     this.radChart1.PlotArea.YAxis.AutoScale = false
    26     this.radChart1.PlotArea.YAxis.AddRange(today.AddHours(7).ToOADate(), today.AddHours(18).ToOADate(), 1d/24d); 
    27  
    28     // Setup Series 
    29     this.radChart1.Series[0].Type = ChartSeriesType.Gantt; 
    30     this.radChart1.Series[0].DataXColumn = "X"
    31     this.radChart1.Series[0].DataXColumn2 = "X2"
    32     this.radChart1.Series[0].DataYColumn = "Y"
    33     this.radChart1.Series[0].DataYColumn2 = "Y2"
    34  
    35     // Data Bind 
    36     this.radChart1.Series[0].Appearance.LabelAppearance.Visible = false
    37     this.radChart1.DataSource = GenerateSource("Table"); 
    38     this.radChart1.DataMember = "Table"
    39     this.radChart1.DataBind(); 
    40
    41  
    42 private DataSet GenerateSource(string tableName) 
    43
    44  
    45     double[,] input = new double[3, 2] { 
    46         { 8, 12 }, { 9, 14}, { 13, 18.5} 
    47     }; 
    48  
    49     DataTable table = new DataTable(tableName); 
    50     table.Columns.Add("X"typeof(double)); 
    51     table.Columns.Add("X2"typeof(double)); 
    52     table.Columns.Add("Y"typeof(double)); 
    53     table.Columns.Add("Y2"typeof(double)); 
    54  
    55     DateTime start = DateTime.Today; 
    56  
    57     for(int i = 0; i < 3; i++ ) 
    58     { 
    59         DataRow row = table.NewRow(); 
    60  
    61         row["X"] = start.AddDays(i).ToOADate(); 
    62         row["X2"] = start.AddDays(i + 1).ToOADate(); 
    63         row["Y"] = start.AddHours(input[i, 0]).ToOADate(); 
    64         row["Y2"] = start.AddHours(input[i, 1]).ToOADate(); 
    65  
    66         table.Rows.Add(row); 
    67     } 
    68  
    69     DataSet dataSet = new DataSet(); 
    70     dataSet.Tables.Add(table); 
    71     return dataSet; 
    72
    As you can see, all dates are converted to double using DateTime.ToOADate().

    I hope this information will help you solve the problem. If you have further assistance, drop me a line.

    All the best,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. chandra
    chandra avatar
    21 posts
    Member since:
    Apr 2008

    Posted 05 Jun 2008 Link to this post

    hi Evtim,

    Very very thanks for your Reply.
    Thank you. It has satisfied my requirement.


    But one thing.

    on Y-axis we are taking the short time.
    It is displaying the short time on Y- axis as
       12:00 AM
       01:00 AM
           .........
           .........
       10:00 PM       like this.

    But I want to Display them as 12, 01,02,03,.......13,14,15,16,17.......

    My actual Requirement is
    DD/MM/YYYY                                  DD/MM/YYYY
    06/05/2008                                         07/05/2008
           |                                                      |
          V                                                    V
        10,   12,  14,  16,  18,  20,  22,  24,  02,  04,  06,  08,  10

    Is it possible? If so Plz share the sample code.


    Thanks and Regards,
    Chandra.

  7. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 09 Jun 2008 Link to this post

    Hi chandra,

    You just need to specify the string format that is to be used on the corresponding axis:
    this.radChart1.PlotArea.YAxis.Appearance.CustomFormat = "HH"

    For more information on string formatting, please, refer to the following blog:
       http://blog.stevex.net/index.php/string-formatting-in-csharp/




    Regards,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. chandra
    chandra avatar
    21 posts
    Member since:
    Apr 2008

    Posted 09 Jun 2008 Link to this post

    hi,

    Very very thanks for your reply.

    We are taking the Time on Y-axis. I want the change color of the bar, if the difference between the Y2 and Y is less than 4:00 hours.

    Ex: 
    We are taking the input[]. In this one we have difined the values for Y and Y2.
    I want the chartItem color in red, if  (Y2   -   Y  <  4.00).

    and

    I want to show the label.
    if I set  this.radChart1.Series[0].Appearance.LabelAppearance.Visible=true,
    It is showing the label in double format(39589.0555556).
    But I want the  label as difference of Y2,Y          i.e 4.0, 3.6, 5.8 ...


    I want to display these labels inside the Bar
    EX:-

              ____          ____
              |       |         |       |
              |4.6  |         | 3.5 |
              |       |         ____
              ____
     
    If it is zero, i don't want to show label.
  9. chandra
    chandra avatar
    21 posts
    Member since:
    Apr 2008

    Posted 11 Jun 2008 Link to this post

    hi,

    I found the solution for the above Requirements.

    I did like this.


    1 //set the visibility of the label to true 
    2 radChart1.Series[0].Appearance.LabelAppearance.Visible = true
    3  
    4 //set the label location to inside the data item bar 
    5 radChart1.Series[0].Appearance.LabelAppearance.LabelLocation =   Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside; 
    6            
    7 //set the position of the label inside the data item bar to center 
    8  radChart1.Series[0].Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Center; 
    9  
    10  //create the chart series items collection 
    11  ChartSeriesItemsCollection items = this.radChart1.Series[0].Items; 
    12  for (int i = 0; i < items.Count; i++) 
    13  { 
    14             // if the item value is zero, set the label visibility to false; 
    15             if(radChart1.Series[0].Items[i].Name=="0") 
    16                     items[i].Label.Visible = false
    17  
    18            // set the fill type as solid(optional). 
    19            items[i].Appearance.FillStyle.FillType =Telerik.Charting.Styles.FillType.Solid;           
    20           // if the difference between the Yvalue2 and Yvalue is less than 4 hours 
    21           // set the maincolor of the item bar to red. 
    22           if (radChart1.Series[0].Items[i].YValue2 - radChart1.Series[0].Items[i].YValue <= 0.16742770169863013698630136986301) 
    23           { 
    24                     items[i].Appearance.FillStyle.MainColor = Color.Red; 
    25           } 
    26           else 
    27           { 
    28                 items[i].Appearance.FillStyle.MainColor =                                    Color.FromArgb(102,255,0); 
    29           } 
    30
    31  
    32  

    If there is any better way to solve this one, plz share the code


    Thanks and Regards,
    Chandra.

  10. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 12 Jun 2008 Link to this post

    Hello chandra,

    I'm glad you found a solution to the problem and shared it with the community.

    Let us know if you need further assistance.

    Regards,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. kiran
    kiran avatar
    36 posts
    Member since:
    May 2008

    Posted 10 Jul 2008 Link to this post

    Hi Evtim,

    I have the same requirement like drawing the gantt chart with date on x-axis and time on y-axis. In your example to chandra you have given like showing the continuos dates data. but i have a requirement of showing the discontinuos dates data. i am unable to do the same with code you have provided in this post.

    i am using the datalabelscolumn property to show the discontinuos dates on x-axis but on y-axis i am unable to plot the values (for discontinuous dates 1,2,4,8 june and 1 july ). I have to plot four serieses.The following sample xml data i have to plot on the gantt chart.
     
    <Day Date="01/06/2008" Start0="525" Stop0="625" Start1="675" Stop1="800" Start2="875" Stop2="900" Start3="975" Stop3="1100" ></Day>  
    <Day Date="02/06/2008" Start0="645" Stop0="800" Start1="840" Stop1="920" Start2="975" Stop2="1000" Start3="1075" Stop3="1200"></Day> 
    <Day Date="04/06/2008" Start0="200" Stop0="400" Start1="500" Stop1="700" Start2="775" Stop2="800" Start3="875" Stop3="950"></Day> 
    <Day Date="08/06/2008" Start0="320" Stop0="700" Start1="800" Stop1="900" Start2="1000" Stop2="1050" Start3="1100" Stop3="1200"></Day> 
    <Day Date="01/07/2008" Start0="60" Stop0="71" Start1="525" Stop1="700" Start2="775" Stop2="800" Start3="875" Stop3="900"></Day> 
    Start0="525" Stop0="625"   means on 01/06/2008 from 525 minutes to 625 minutes  
    start0,stop0 - series0
    start1,stop1 - series1
    start2,stop2 - series2
    start3,stop3 - series3

    i should have the chart like(I donot want to show the dates like 03,05,06,09...30 on the chart). We should show only the available dates data only.
    |
    |
    |
    -----------------------------------------------
     01/06        02/06     04/06      08/06    01/07

    Could you please provide a sample application / sample code which shows the discontinuous dates data in Gantt Chart. I need to resolve this problem as soon as possible. Please help me out.

    Thanks in advance.

    Regards,
    Kiran
  12. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 10 Jul 2008 Link to this post

    Hello kiran,

    You can manually add items to both XAxis and YAxis and set the desired values as you like. Here is an example demonstrating how to add custom items on the YAxis:
    1 double[] values = {  
    2     DateTime.Today.ToOADate(),  
    3     DateTime.Today.AddDays(1).ToOADate(), 
    4     DateTime.Today.AddDays(2).ToOADate(), 
    5     DateTime.Today.AddDays(3).ToOADate(), 
    6     DateTime.Today.AddDays(7).ToOADate(), 
    7     DateTime.Today.AddDays(11).ToOADate(), 
    8     DateTime.Today.AddDays(13).ToOADate(), 
    9     DateTime.Today.AddDays(17).ToOADate(), 
    10     DateTime.Today.AddDays(18).ToOADate() 
    11 }; 
    12  
    13 this.radChart1.PlotArea.YAxis.IsZeroBased = false
    14 this.radChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate; 
    15 this.radChart1.PlotArea.YAxis.AutoScale = false
    16 for (int i = 0; i < values.Length; i++) 
    17
    18     ChartAxisItem item = new ChartAxisItem(); 
    19     item.Value = Convert.ToDecimal(values[i]); 
    20     this.radChart1.PlotArea.YAxis.AddItem(item); 
    21

    Should you have further questions, just drop us a line.




    Regards,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. kiran
    kiran avatar
    36 posts
    Member since:
    May 2008

    Posted 10 Jul 2008 Link to this post

    Hi Evtim,

    This is not what i am expecting. i am binding the XML data to the chart. For gantt chart i hope we need four data items. X,X2,Y,Y2.

    The following is the full code i am using. please go through it and do let me know the error in my code.

    Day Date="02/06/2008" From0="525" To0="625" From1="675" To1="800" From2="875" To2="900" From3="975" To3="1100" ></Day>  
        <Day Date="03/06/2008" From0="645" To0="800" From1="840" To1="920" From2="975" To2="1000" From3="1075" To3="1200"></Day> 
        <Day Date="04/06/2008" From0="200" To0="400" From1="500" To1="700" From2="775" To2="800" From3="875" To3="950"></Day> 
        <Day Date="06/06/2008" From0="320" To0="700" From1="800" To1="900" From2="1000" To2="1050" From3="1100" To3="1200"></Day> 
        <Day Date="07/06/2008" From0="60" To0="71" From1="525" To1="700" From2="775" To2="800" From3="875" To3="900"></Day> 
        <Day Date="08/06/2008" From0="120" To0="560" From1="700" To1="925" From2="975" To2="1000" From3="1075" To3="1200"></Day> 
        <Day Date="09/06/2008" From0="150" To0="300" From1="525" To1="700" From2="775" To2="800" From3="875" To3="1000"></Day> 
        <Day Date="10/06/2008" From0="525" To0="625" From1="675" To1="900" From2="975" To2="1000" From3="1075" To3="1200"></Day> 
        <Day Date="11/06/2008" From0="645" To0="800" From1="840" To1="920" From2="975" To2="1100" From3="1175" To3="1200"></Day> 
        <Day Date="12/06/2008" From0="800" To0="900" From1="925" To1="940" From2="975" To2="1000" From3="1100" To3="1200"></Day> 
        <Day Date="13/06/2008" From0="428" To0="900" From1="995" To1="1040" From2="1075" To2="1150" From3="1175" To3="1200"></Day> 
     

    The C# code is:


    private void LoadDataToUsageDataChart()  
            {  
     
                //Create the XMLDocument Object  
                usageXmlDocument = new XmlDocument();  
                //Load the XMLDocument  
                usageXmlDocument.Load("../../XML/UsageData.xml");  
                //Create the XMLNodeList  
                usageXmlNodeList = usageXmlDocument.SelectNodes("//Years");  
     
                //Count the number of Days that the Graph can show Data  
                countTheDaysUsed();  
                dsUsageData.Tables.Clear();  
                dtGameData.Columns.Clear();  
     
                ChartSeries CS2 = new ChartSeries();  
                ChartSeries CS3 = new ChartSeries();  
     
                gphGameStats.Series.AddRange(new Telerik.Charting.ChartSeries[] {  
                CS2, CS3});  
     
                //Define the Data Table Columns along with their types  
     
                dtGameData.Columns.Add("SeriesDate", typeof(double));  
                dtGameData.Columns.Add("Series0X", typeof(double));  
                dtGameData.Columns.Add("Series0X2", typeof(double));  
                dtGameData.Columns.Add("Series0Y", typeof(double));  
                dtGameData.Columns.Add("Series0Y2", typeof(double));  
                dtGameData.Columns.Add("Series0Label", typeof(double));  
                              
                dtGameData.Columns.Add("Series1Y", typeof(double));  
                dtGameData.Columns.Add("Series1Y2", typeof(double));  
                dtGameData.Columns.Add("Series1Label", typeof(double));  
     
                dtGameData.Columns.Add("Series2Y", typeof(double));  
                dtGameData.Columns.Add("Series2Y2", typeof(double));  
                dtGameData.Columns.Add("Series2Label", typeof(double));  
     
                dtGameData.Columns.Add("Series3Y", typeof(double));  
                dtGameData.Columns.Add("Series3Y2", typeof(double));  
                dtGameData.Columns.Add("Series3Label", typeof(double));  
                 
                //Read the XML file data into Data Table  
                usageXmlNodeList = usageXmlDocument.SelectNodes("//Years");  
                foreach (XmlNode node in usageXmlNodeList)  
                {  
                    if (node.HasChildNodes)  
                    {  
                        readUsageChildNodeData(node.ChildNodes);  
                    }  
                }  
                dsUsageData.Tables.Add(dtGameData);  
     
     
                //Set Chart series Orientation Programatically  
                gphGameStats.SeriesOrientation = ChartSeriesOrientation.Vertical;  
     
     
                //Setup XAxis  
                ApplyXaxisSettingsToChart(gphGameStats);  
                gphGameStats.PlotArea.XAxis.IsZeroBased = false;  
                gphGameStats.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate;  
                gphGameStats.PlotArea.XAxis.AutoScale = false;  
                gphGameStats.PlotArea.XAxis.Appearance.CustomFormat = "dd/MM/yy";  
                gphGameStats.PlotArea.XAxis.DataLabelsColumn = "Series0X";  
                
     
                // Setup YAxis   
                gphGameStats.PlotArea.YAxis.IsZeroBased = false;  
                gphGameStats.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;  
                gphGameStats.PlotArea.YAxis.AutoScale = false;  
                gphGameStats.PlotArea.YAxis.Appearance.CustomFormat = "HH";  
              
                gphGameStats.PlotArea.YAxis.AddRange(YAxisStartTime.AddHours(2).ToOADate(), YAxisStartTime.AddHours(26).ToOADate(), 1d / 12d);  
               // Setup Series   
     
                gphGameStats.Series[0].Type = ChartSeriesType.Gantt;  
                gphGameStats.Series[0].DataXColumn = "Series0X";  
                gphGameStats.Series[0].DataXColumn2 = "Series0X2";  
                gphGameStats.Series[0].DataYColumn = "Series0Y";  
                gphGameStats.Series[0].DataYColumn2 = "Series0Y2";  
                gphGameStats.Series[0].DataLabelsColumn = "Series0Label";  
                gphGameStats.Series[0].Name = "UsageData";  
     
                gphGameStats.Series[1].Type = ChartSeriesType.Gantt;  
                gphGameStats.Series[1].DataXColumn = "Series0X";  
                gphGameStats.Series[1].DataXColumn2 = "Series0X2";  
                gphGameStats.Series[1].DataYColumn = "Series1Y";  
                gphGameStats.Series[1].DataYColumn2 = "Series1Y2";  
                gphGameStats.Series[1].DataLabelsColumn = "Series1Label";  
                gphGameStats.Series[1].Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;  
     
                gphGameStats.Series[2].Type = ChartSeriesType.Gantt;  
                gphGameStats.Series[2].DataXColumn = "Series0X";  
                gphGameStats.Series[2].DataXColumn2 = "Series0X2";  
                gphGameStats.Series[2].DataYColumn = "Series2Y";  
                gphGameStats.Series[2].DataYColumn2 = "Series2Y2";  
                gphGameStats.Series[2].DataLabelsColumn = "Series2Label";  
                gphGameStats.Series[2].Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;  
     
     
                gphGameStats.Series[3].Type = ChartSeriesType.Gantt;  
                gphGameStats.Series[3].DataXColumn = "Series0X";  
                gphGameStats.Series[3].DataXColumn2 = "Series0X2";  
                gphGameStats.Series[3].DataYColumn = "Series3Y";  
                gphGameStats.Series[3].DataYColumn2 = "Series3Y2";  
                gphGameStats.Series[3].DataLabelsColumn = "Series3Label";  
                gphGameStats.Series[3].Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;  
     
                //Set the Label Appearance  
                gphGameStats.Series[0].Appearance.BarWidthPercent = 50;  
                gphGameStats.Series[0].Appearance.LabelAppearance.Visible = true;  
                gphGameStats.Series[0].Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;  
                gphGameStats.Series[0].Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Center;  
     
                gphGameStats.Series[1].Appearance.BarWidthPercent = 50;  
                gphGameStats.Series[1].Appearance.LabelAppearance.Visible = true;  
                gphGameStats.Series[1].Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;  
                gphGameStats.Series[1].Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Center;  
                //gphGameStats.Series[1].Appearance.FillStyle.MainColor = Color.Purple;  
     
     
                //Set the DataSource, DataMember  for the Chart  
                gphGameStats.DataManager.DataSource = dsUsageData;  
                gphGameStats.DataManager.DataMember = "UsageData";  
     
     
                //Bind the Data to Chart  
                gphGameStats.DataBind();  
                 
                //Update the Chart with newly added data  
                gphGameStats.UpdateGraphics();  
     
                //Refresh the chart  
                gphGameStats.Refresh();  
            }  
     
            private void readUsageChildNodeData(XmlNodeList xmlNodeList)  
            {  
                foreach (XmlNode node in xmlNodeList)  
                {  
                    //create the New DataRow  
                    dataRow = dtGameData.NewRow();  
     
                    //Check whether the node has child nodes or not  
                    //if there call the same function with the child node list.  
                    //otherwise add the XML data to the Data row  
                    if (node.HasChildNodes)  
                    {  
                        readUsageChildNodeData(node.ChildNodes);  
                    }  
                    else  
                    {  
     
                        //Specify the Date formats.  
                        String[] formats ={ "dd/MM/yyyy", "dd/MM/yy" };  
     
                        //set the chart start date.  
                        if (daysUsedCountRef == 0)  
                        {  
                            startDate = DateTime.ParseExact(node.Attributes.GetNamedItem("Date").Value.ToString(), formats,  
                                                            System.Globalization.CultureInfo.InvariantCulture,  
                                                            System.Globalization.DateTimeStyles.NoCurrentDateDefault);  
     
                            GraphStartTime = startDate.Date.AddHours(10);  
                            YAxisStartTime = startDate.Date.AddHours(10);  
                        }  
     
                        CurrentDate = DateTime.ParseExact(node.Attributes.GetNamedItem("Date").Value.ToString(), formats,  
                                                            System.Globalization.CultureInfo.InvariantCulture,  
                                                            System.Globalization.DateTimeStyles.NoCurrentDateDefault);  
     
                                                    
                        //put the Series 0 values in the row.  
                        dataRow["Series0X"] = CurrentDate.Date.AddHours(0).ToOADate();  
                        dataRow["Series0X2"] = CurrentDate.Date.AddHours(23).ToOADate();  
                          
                        double FromMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("From0").Value.ToString());  
                        double ToMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("To0").Value.ToString());  
     
                        dataRow["Series0Y"] = GraphStartTime.AddHours(FromMinutes / 60).AddHours(2).ToOADate();  
                        dataRow["Series0Y2"] = GraphStartTime.AddHours(ToMinutes / 60).AddHours(2).ToOADate();  
                        dataRow["Series0Label"] = Math.Round((ToMinutes - FromMinutes) / 60, 1);  
                                                               
     
                        FromMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("From1").Value.ToString());  
                        ToMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("To1").Value.ToString());  
     
                        dataRow["Series1Y"] = GraphStartTime.AddHours(FromMinutes / 60).AddHours(2).ToOADate();  
                        dataRow["Series1Y2"] = GraphStartTime.AddHours(ToMinutes / 60).AddHours(2).ToOADate();  
                        dataRow["Series1Label"] = Math.Round((ToMinutes - FromMinutes) / 60, 1);  
     
                        FromMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("From2").Value.ToString());  
                        ToMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("To2").Value.ToString());  
                        dataRow["Series2Y"] = GraphStartTime.AddHours(FromMinutes / 60).AddHours(2).ToOADate();  
                        dataRow["Series2Y2"] = GraphStartTime.AddHours(ToMinutes / 60).AddHours(2).ToOADate();  
                        dataRow["Series2Label"] = Math.Round((ToMinutes - FromMinutes) / 60, 1);  
     
     
                        FromMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("From3").Value.ToString());  
                        ToMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("To3").Value.ToString());  
                        dataRow["Series3Y"] = GraphStartTime.AddHours(FromMinutes / 60).AddHours(2).ToOADate();  
                        dataRow["Series3Y2"] = GraphStartTime.AddHours(ToMinutes / 60).AddHours(2).ToOADate();  
                        dataRow["Series3Label"] = Math.Round((ToMinutes - FromMinutes) / 60, 1);  
     
     
                        //Increament the daysUsedCountRef by one  
                        daysUsedCountRef++;  
     
                        //Add the Data row to the Datatable  
                        dtGameData.Rows.Add(dataRow);  
     
                    }//end of else condition  
     
                }//end of for each loop  
     
            }//end of the readChildNodeData 



    Please look into the code and share us the comments.

    I do not want to hard code the items into the values[] array.  Please share a sample application to plot the discontinuos dates. I m in a big trouble now.

    Thanks in advance.

    Regards,
    kiran
  14. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 11 Jul 2008 Link to this post

    Hello kiran,

    Please, find the answer to your question in the other support ticket.

    Regards,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for WinForms is Visual Studio 2017 Ready