We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DateTime in Gantt Chart

Thread ID:





56157 Feb 9,2007 09:07 PM UTC Feb 12,2007 07:39 PM UTC WinForms 4
Tags: Chart
Asked On February 9, 2007 09:07 PM UTC

I want to display the Gantt chart where on the YAxist there is DeveloperNames in String and on Yaxis there is DateTime. For each developer there is Time schedule they have to follow. Here is my code. Is this the way to do it. Please advice me.
Did i added the point correctly.

1) When i tried to enalble the Tooltips. I see some vierd double number when i hover over any element of the Chart.
2) My goal is to display the Duration of the development cycle when i hover over the perticular element in the Graph..

this.chartControl1.PrimaryXAxis.OpposedPosition = true;
//X axis is DateTime
this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.DateTime;
this.chartControl1.PrimaryXAxis.RangeType = ChartAxisRangeType.Auto;
this.chartControl1.PrimaryXAxis.DateTimeFormat = "MM/dd";
// Y axis with Labels
this.chartControl1.PrimaryYAxis.LabelsImpl = new LabelModel(new string[] { "Scott", "Nathalie", "Brad", "Ronak" });
this.chartControl1.PrimaryYAxis.ValueType = ChartValueType.Custom;

//Title of Axis
this.chartControl1.PrimaryXAxis.Title = "Days";
this.chartControl1.PrimaryYAxis.Title = "Developer Name";

ChartSeries Task = this.chartControl1.Model.NewSeries("Beta1",ChartSeriesType.Gantt);
DateTime start = DateTime.Now;
//start = DateTime.Now.Date;
Task.Points.Add(0, new DateTime[] { start, start.AddDays(4) });
Task.Points.Add(1, new DateTime[] { start.AddDays(-3), start.AddDays(3) });
Task.Points.Add(2, new DateTime[] { start.AddDays(-1), start.AddDays(4) });
Task.Points.Add(3, new DateTime[] { start, start.AddDays(2) });
Task.Style.PointWidth = 0.5f;

Replied On February 9, 2007 09:10 PM UTC

One more thing...
* Not working code for tool tips..

this.chartControl1.ShowToolTips = true;
Task.Style.ToolTip = "Ronak";

Why this thing does not work. When i hover my mouse over the Each element of the Chart it gets highlighted, after some time i see the Tooltip but instad of the String "Ronak". It is some vierd Double Number.

Replied On February 9, 2007 11:16 PM UTC

I tried the Sample example given in the Evaluation Center of the Tooltip, but it does not work.

Chart Tooltip :

It shows the number when you put your mouse over any region of the Chart. I want to display the TimeSpan in Days in above Gantt chart in this tooltips but i dont know how to do it. Can you please help I have already found how to get the TimeSpan...Here is my code, basically it disaply the Timespan of task.

this.chartControl1.Series[1].Style.DisplayText = true;
this.chartControl1.Series[1].Style.TextOrientation = ChartTextOrientation.Smart;
for (int i = 0; i < Task1.Points.Count; i++)
TimeSpan tp = Task1.Points[i].GetYValuesAsDateTime()[0].Subtract(Task1.Points[i].GetYValuesAsDateTime()[1]);
Task1.Styles[i].Text = Math.Abs(tp.TotalDays).ToString();

Administrator [Syncfusion]
Replied On February 10, 2007 03:01 AM UTC

Hi Ronak,

Thanks for your detailed explanation and code snippets.

The PointsToolTipFormat property of chart series works with five formats,

"{0}" - series Name
"{1}" - SeriesStyle.ToolTip;
"{2}" - SeriesStyle[i].ToolTip; - this is what we want.
"{3}" - series.Points[ index ].X;
"{4+i}" - series.Points[ index ].YValues[i];

You need to employ the third format for your requirement, it is a customize tool tip format that we can set to any string to series style.

Below is the modified code of yours.


this.chartControl1.ShowToolTips =true;

Task.PointsToolTipFormat ="{2}";

for (int i = 0; i < Task.Points.Count; i++)
TimeSpan tp = Task.Points[i].GetYValuesAsDateTime()[0].Subtract(Task.Points[i].GetYValuesAsDateTime()[1]);
Task.Styles[i].ToolTipFormat = string.Format("Days : {0}",Math.Abs(tp.TotalDays).ToString());

Also kindly take a look at the attached sample.


Please let me know if you have any queries.


Replied On February 12, 2007 07:39 PM UTC

Hi Rajesh,

Thanks for your input that did the trick. I am getting into realm of Charts..


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon