This is a migrated thread and some comments may be shown as answers.

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

1 Answer 127 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
kiran
Top achievements
Rank 1
kiran asked on 03 Jun 2008, 02:33 PM
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

1 Answer, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 04 Jun 2008, 01:02 PM
Hello kiran,

Thanks for writing, here is an example demonstrating gantt chart with different date-time formats:
(see lines 17 and 24)
public Form1() 
    InitializeComponent(); 
 
protected override void OnLoad(EventArgs e) 
    base.OnLoad(e); 
 
    DateTime today = DateTime.Today; 
 
    // Setup chart orientation 
    this.radChart1.SeriesOrientation = ChartSeriesOrientation.Horizontal; 
 
    // Setup XAxis 
    this.radChart1.PlotArea.XAxis.IsZeroBased = false
    this.radChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate; 
    this.radChart1.PlotArea.XAxis.AutoScale = false
    this.radChart1.PlotArea.XAxis.AddRange(today.ToOADate(), today.AddDays(10).ToOADate(), 1); 
    this.radChart1.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Inside; 
 
    // Setup YAxis 
    this.radChart1.PlotArea.YAxis.IsZeroBased = false
    this.radChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime; 
    this.radChart1.PlotArea.YAxis.AutoScale = false
    this.radChart1.PlotArea.YAxis.AddRange(today.AddHours(7).ToOADate(), today.AddHours(18).ToOADate(), 1d / 24d); 
 
    // Setup Series 
    this.radChart1.Series[0].Type = ChartSeriesType.Gantt; 
    this.radChart1.Series[0].DataXColumn = "X"
    this.radChart1.Series[0].DataXColumn2 = "X2"
    this.radChart1.Series[0].DataYColumn = "Y"
    this.radChart1.Series[0].DataYColumn2 = "Y2"
 
    // Data Bind 
    this.radChart1.Series[0].Appearance.LabelAppearance.Visible = false
    this.radChart1.DataSource = GenerateSource("Table"); 
    this.radChart1.DataMember = "Table"
    this.radChart1.DataBind(); 
 
private DataSet GenerateSource(string tableName) 
 
    double[,] input = new double[3, 2] { 
        { 8, 12 }, { 9, 14}, { 13, 18.5} 
    }; 
 
    DataTable table = new DataTable(tableName); 
    table.Columns.Add("X"typeof(double)); 
    table.Columns.Add("X2"typeof(double)); 
    table.Columns.Add("Y"typeof(double)); 
    table.Columns.Add("Y2"typeof(double)); 
 
    DateTime start = DateTime.Today; 
 
    for (int i = 0; i < 3; i++) 
    { 
        DataRow row = table.NewRow(); 
 
        row["X"] = start.AddDays(i).ToOADate(); 
        row["X2"] = start.AddDays(i + 1).ToOADate(); 
        row["Y"] = start.AddHours(input[i, 0]).ToOADate(); 
        row["Y2"] = start.AddHours(input[i, 1]).ToOADate(); 
 
        table.Rows.Add(row); 
    } 
 
    DataSet dataSet = new DataSet(); 
    dataSet.Tables.Add(table); 
    return dataSet; 

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
Tags
Chart (obsolete as of Q1 2013)
Asked by
kiran
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Share this question
or