Hello,
I am trying to create a Gantt Chart application by using your ChartWebControl. I have finally reached some result from the forums.But I have still some questions such as:
1) How can I set the custom origin property of Y axis?
2) Is it possible to set X axis labels as my desired date values?
3) and finally how can I use series.add method in the code.
If you can look at the code below than you can easily understand my problems
ChartSeries series = this.ChartWebControl1.Model.NewSeries("SeriesName",ChartSeriesType.Gantt);
this.ChartWebControl1.PrimaryXAxis.ValueType = ChartValueType.DateTime;
this.ChartWebControl1.PrimaryYAxis.ValueType = ChartValueType.Custom;
//this.ChartWebControl1.PrimaryYAxis.Labels.Add("erdem");
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task1", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task2", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task3", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task4", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(Convert.ToDateTime("01/Jun/2007"), Convert.ToDateTime("20/Jul/2007"), 5, ChartDateTimeIntervalType.Days);
this.ChartWebControl1.PrimaryXAxis.DateTimeFormat = "dd/MM/yyyy";
this.ChartWebControl1.PrimaryXAxis.LabelRotate = true;
this.ChartWebControl1.PrimaryXAxis.CustomOrigin = true;
this.ChartWebControl1.ChartArea.PrimaryXAxis.LabelRotateAngle = 90;
this.ChartWebControl1.Series.Add(series);
//series.Points.Add(1, 1, 5);
//series.Points.Add(2, 4, 7);
//series.Points.Add(3, 4, 8);
//series.Points.Add(4, 8, 9);
AD
Administrator
Syncfusion Team
March 11, 2009 07:33 PM UTC
Sorry.Ihad a mistake.Last few lines of the code is like this:
//series.Points.Add("01 Jun 2007", 1, 5);
//series.Points.Add("01 Jun 2007", 4, 7);
//series.Points.Add("03 Jun 2007", 4, 8);
//series.Points.Add("05 Jun 2007", 8, 9);
But it doesnt work. I use 7.1.0.20 trial version..
>Hello,
I am trying to create a Gantt Chart application by using your ChartWebControl. I have finally reached some result from the forums.But I have still some questions such as:
1) How can I set the custom origin property of Y axis?
2) Is it possible to set X axis labels as my desired date values?
3) and finally how can I use series.add method in the code.
If you can look at the code below than you can easily understand my problems
ChartSeries series = this.ChartWebControl1.Model.NewSeries("SeriesName",ChartSeriesType.Gantt);
this.ChartWebControl1.PrimaryXAxis.ValueType = ChartValueType.DateTime;
this.ChartWebControl1.PrimaryYAxis.ValueType = ChartValueType.Custom;
//this.ChartWebControl1.PrimaryYAxis.Labels.Add("erdem");
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task1", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task2", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task3", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task4", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(Convert.ToDateTime("01/Jun/2007"), Convert.ToDateTime("20/Jul/2007"), 5, ChartDateTimeIntervalType.Days);
this.ChartWebControl1.PrimaryXAxis.DateTimeFormat = "dd/MM/yyyy";
this.ChartWebControl1.PrimaryXAxis.LabelRotate = true;
this.ChartWebControl1.PrimaryXAxis.CustomOrigin = true;
this.ChartWebControl1.ChartArea.PrimaryXAxis.LabelRotateAngle = 90;
this.ChartWebControl1.Series.Add(series);
//series.Points.Add(1, 1, 5);
//series.Points.Add(2, 4, 7);
//series.Points.Add(3, 4, 8);
//series.Points.Add(4, 8, 9);
--
MS
Manimala S
Syncfusion Team
March 12, 2009 11:32 AM UTC
Hi erdem,
Here are the answers for your questions:
1) How can I set the custom origin property of Y axis?
You can set this using the custom origin property of the chartaxis class.
2) Is it possible to set X axis labels as my desired date values?
Yes it is possible to set x-axis labels as desired date values.
3)How can I use series.add method in the code.
you have to add the series for gantt chart in the following manner.
series.Points.Add(0, start, start.AddDays(2));
series.Points.Add(1, start.AddDays(1), start.AddDays(3));
series.Points.Add(2, start.AddDays(3), start.AddDays(6));
series.Points.Add(3, start.AddDays(6), start.AddDays(10));
series.Points.Add(4, start.AddDays(10), start.AddDays(15));
series.Points.Add(5, start.AddDays(15), start.AddDays(20));
And here is the sample code:
Give this in specific event handler.
this.ChartWebControl1.ChartFormatAxisLabel += new Syncfusion.Windows.Forms.Chart.ChartFormatAxisLabelEventHandler(this.chartControl1_ChartFormatAxisLabel);
this.ChartWebControl1.LegendPosition = ChartDock.Top;
ChartSeries series = this.ChartWebControl1.Model.NewSeries("GanttChart", ChartSeriesType.Gantt);
DateTime start = new DateTime(2007, 6, 1);
this.ChartWebControl1.PrimaryXAxis.RangeType = ChartAxisRangeType.Set;
this.ChartWebControl1.PrimaryXAxis.ValueType = ChartValueType.DateTime;
this.ChartWebControl1.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(start,start.AddDays(20), 1, ChartDateTimeIntervalType.Days);
this.ChartWebControl1.PrimaryXAxis.DateTimeFormat = "dd/MM/yyyy";
this.ChartWebControl1.PrimaryYAxis.ValueType = ChartValueType.Double;
this.ChartWebControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
this.ChartWebControl1.PrimaryYAxis.Range = new MinMaxInfo(0, 6, 1);
this.ChartWebControl1.PrimaryYAxis.CustomOrigin = true;
this.ChartWebControl1.PrimaryYAxis.Origin = 4;
this.ChartWebControl1.PrimaryXAxis.LabelRotate = true;
this.ChartWebControl1.PrimaryXAxis.LabelRotateAngle = 90;
series.Points.Add(0, start, start.AddDays(2));
series.Points.Add(1, start.AddDays(1), start.AddDays(3));
series.Points.Add(2, start.AddDays(3), start.AddDays(6));
series.Points.Add(3, start.AddDays(6), start.AddDays(10));
series.Points.Add(4, start.AddDays(10), start.AddDays(15));
series.Points.Add(5, start.AddDays(15), start.AddDays(20));
this.ChartWebControl1.Series.Add(series);
}
private void chartControl1_ChartFormatAxisLabel(object sender, ChartFormatAxisLabelEventArgs e)
{
if (e.AxisOrientation == ChartOrientation.Vertical)
{
if (e.Value >= 0 && e.Value < this.ChartWebControl1.Series[0].Points.Count)
e.Label = String.Format("Task {0}", e.Value + 1);
else
e.Label = String.Empty;
}
else
{
e.Label = e.ValueAsDate.ToString("MM/dd/yy");
}
e.Handled = true;
}
Thanks,
Manimala.
AD
Administrator
Syncfusion Team
March 12, 2009 01:25 PM UTC
Thank you very much for your attention.
I will try it.
Erdem
>Hello,
I am trying to create a Gantt Chart application by using your ChartWebControl. I have finally reached some result from the forums.But I have still some questions such as:
1) How can I set the custom origin property of Y axis?
2) Is it possible to set X axis labels as my desired date values?
3) and finally how can I use series.add method in the code.
If you can look at the code below than you can easily understand my problems
ChartSeries series = this.ChartWebControl1.Model.NewSeries("SeriesName",ChartSeriesType.Gantt);
this.ChartWebControl1.PrimaryXAxis.ValueType = ChartValueType.DateTime;
this.ChartWebControl1.PrimaryYAxis.ValueType = ChartValueType.Custom;
//this.ChartWebControl1.PrimaryYAxis.Labels.Add("erdem");
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task1", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task2", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task3", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryYAxis.Labels.Add(new ChartAxisLabel("Task4", Color.Yellow, new Font("Caliber", 8), 5, "", ChartValueType.Custom));
this.ChartWebControl1.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(Convert.ToDateTime("01/Jun/2007"), Convert.ToDateTime("20/Jul/2007"), 5, ChartDateTimeIntervalType.Days);
this.ChartWebControl1.PrimaryXAxis.DateTimeFormat = "dd/MM/yyyy";
this.ChartWebControl1.PrimaryXAxis.LabelRotate = true;
this.ChartWebControl1.PrimaryXAxis.CustomOrigin = true;
this.ChartWebControl1.ChartArea.PrimaryXAxis.LabelRotateAngle = 90;
this.ChartWebControl1.Series.Add(series);
//series.Points.Add(1, 1, 5);
//series.Points.Add(2, 4, 7);
//series.Points.Add(3, 4, 8);
//series.Points.Add(4, 8, 9);
MS
Manimala S
Syncfusion Team
March 13, 2009 12:11 PM UTC
Hi Erdem,
Thanks for the update.
Please, let me know if you have any difficulty.
Thanks,
Manimala.