Hi,
I've had a Gantt chart working fine for a while binding to a datatable with columns (GanttSeries, GanttTask, GanttStart, GanttEnd). Im now trying to turn this into a composite chart to layer two gantt charts on top of each other. I have a composite chart working with linechart (based on the doc example) so I copied this and adapted for the Gantt but its not working.
I've constructed the Gantt series manually so I can work with my existing DAL and the above data table.
Can anyone see what im doing wrong?
{
GanttSeries value;
}
GanttItem item = new GanttItem();
DateTime starttime = (DateTime)row["GanttStart"];
item.Times.Add(new GanttTimeEntry(starttime,endtime));
this.myChartArea.Axes.Clear();
//Create New Axis
globalAxisX.OrientationType = AxisNumber.X_Axis;
globalAxisX.SetLabelAxisType = SetLabelAxisType.ContinuousData;
globalAxisX.LineThickness = 1;
globalAxisX.RangeMin = starttime.Ticks;
globalAxisX.RangeMax = endtime.Ticks;
globalAxisY.OrientationType = AxisNumber.Y_Axis;
globalAxisY.LineThickness = 1;
myChartArea.Axes.Add(globalAxisX);
myChartArea.Axes.Add(globalAxisY);
layer.ChartArea = myChartArea;
layer.AxisX = globalAxisX;
layer.AxisY = globalAxisY;
layer.Series.Add(serieskvp.Value);
this.ganttchart1.CompositeChart.ChartLayers.Add(layer);
Thanks,
You just need to specify the chart type of your layer and add it to the layers collection of the composite chart. Also, each series needs to be added to both layer.Series and chart.CompositeChart.Series.
dt.Rows.Add(new object[ { DateTime.Now, DateTime.Now.AddDays(1), "task1", 0, 0, 100, "id1" });dt.Rows.Add(new object[ { DateTime.Now.AddDays(3), DateTime.Now.AddDays(5), "task2", 0, 0, 100, "id1" });ChartArea area = new ChartArea();ultraChart1.CompositeChart.ChartAreas.Add(area);
AxisItem y = new AxisItem(ultraChart1, AxisNumber.Y_Axis);y.DataType = AxisDataType.String;area.Axes.Add(y);
ChartLayerAppearance layer = new ChartLayerAppearance();ultraChart1.CompositeChart.ChartLayers.Add(layer);layer.ChartType = ChartType.GanttChart;layer.ChartArea = area;layer.AxisX = x;layer.AxisY = y;layer.Series.Add(s);
ultraChart1.CompositeChart.Series.Add(s);
Does this sample also work with 9.1? See result of sample code below