Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Chart > Gantt chart with two different value format types for x-axis and y-axis

Not answered Gantt chart with two different value format types for x-axis and y-axis

Feed from this thread
  • kiran avatar

    Posted on Jun 3, 2008 (permalink)

    Hi Telerik team,

    is there any way to draw a gantt with x-axis (with value format is SHORTDATE) and y-axis (with value format SHORT TIME)?

    if so please send me the sample code or approach to do the same.

    Help is highly appreciated.

    regards,
    kiran

    Reply

  • Dwight Dwight admin's avatar

    Posted on Jun 4, 2008 (permalink)

    Hello kiran,

    Thanks for writing, here is an example demonstrating gantt chart with different date-time formats:
    (see lines 17 and 24)
    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

    Should you have further questions, do not hesitate to contact me.

    Regards,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Chart > Gantt chart with two different value format types for x-axis and y-axis
Related resources for "Gantt chart with two different value format types for x-axis and y-axis"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]