Hi,
Is it possible to combine a Gantt Chart and a Line Chart? I want to have a set of data that will be displayed in the Gantt and another set of data in the Line.
I'm just trying to put together a sample data set where this can be displayed. I want to do this programmatically from scratch.
Thanks,
Andez
OK,
Finally came across an example:
https://es.infragistics.com/help/winforms/chart-creating-a-composite-chart-in-code-part-1-of-2
and
https://es.infragistics.com/help/winforms/chart-creating-a-composite-chart-in-code-part-2-of-2
I can display 2 seperate charts - one gantt and one line. Now the tricky part is combining them. When I attempt this, I can display the gantt chart but not the line.
Can 2 charts share a DateTime X Axis between layers? I've tried fifddling with the axis to no avail. My code is as follows:
Private Sub CreateCombinedComposite()
' this causes a problem...
' Me.UltraChart2 = New WebUI.UltraWebChart.UltraChart()
' build the composite chart
Me.UltraChart2.ChartType = [Shared].Styles.ChartType.Composite
' create a chart area
Dim ca1 As New ChartArea()
ca1.BoundsMeasureType = [Shared].Styles.MeasureType.Pixels
ca1.Bounds = New Rectangle(2, 2, 500, 500)
ca1.Visible = True
Me.UltraChart2.CompositeChart.ChartAreas.Add(ca1)
' create axis
Dim axisX As New AxisItem
Dim axisY As New AxisItem
axisY.OrientationType = [Shared].Styles.AxisNumber.Y_Axis
axisY.Labels.ItemFormatString = "<ITEM_LABEL>"
axisY.Labels.Orientation = [Shared].Styles.TextOrientation.VerticalRightFacing
axisY.DataType = [Shared].Styles.AxisDataType.String
axisY.SetLabelAxisType = Core.Layers.SetLabelAxisType.GroupBySeries
axisX.OrientationType = [Shared].Styles.AxisNumber.X_Axis
'axisX.SetLabelAxisType = Core.Layers.SetLabelAxisType.GroupBySeries
axisX.Labels.ItemFormatString = "<ITEM_LABEL:dd-MM-yy>"
axisX.Labels.Orientation = [Shared].Styles.TextOrientation.VerticalRightFacing
axisX.DataType = [Shared].Styles.AxisDataType.Time
ca1.Axes.Clear()
ca1.Axes.Add(axisX)
ca1.Axes.Add(axisY)
' create chart layer appearence
Dim cla1 As New ChartLayerAppearance()
cla1.ChartType = [Shared].Styles.ChartType.GanttChart
cla1.AxisX = axisX
cla1.AxisY = axisY
cla1.ChartArea = ca1
Me.UltraChart2.CompositeChart.ChartLayers.Add(cla1)
' add a series to the layer appearence
Dim gs1 As GanttSeries = CreateSeries("BS1")
gs1.Visible = True
cla1.Series.Add(gs1)
Me.UltraChart2.CompositeChart.Series.Add(gs1)
'----------------------
' add a line chart
' Dim ca2 As New ChartArea()
'Me.UltraChart2.CompositeChart.ChartAreas.Add(ca2)
Dim axisX2 As New AxisItem
'Dim axisY2 As New AxisItem
Dim axisY2_1 As New AxisItem
'axisY2.OrientationType = [Shared].Styles.AxisNumber.Y_Axis
'axisY2.Labels.ItemFormatString = "<DATA_VALUE:0.#>"
'axisY2.Labels.Orientation = [Shared].Styles.TextOrientation.Horizontal
'axisY2.DataType = [Shared].Styles.AxisDataType.Numeric
'axisY2.RangeType = [Shared].Styles.AxisRangeType.Automatic
axisX2.OrientationType = [Shared].Styles.AxisNumber.X2_Axis
axisX2.SetLabelAxisType = Core.Layers.SetLabelAxisType.GroupBySeries
axisX2.Labels.ItemFormatString = "<ITEM_LABEL:dd-MM-yy>"
axisX2.Labels.Orientation = [Shared].Styles.TextOrientation.VerticalRightFacing
axisX2.DataType = [Shared].Styles.AxisDataType.Time
axisY2_1.Labels.ItemFormatString = "<DATA_VALUE:0.#>"
axisY2_1.OrientationType = [Shared].Styles.AxisNumber.Y2_Axis
axisY2_1.Labels.Visible = True
axisY2_1.DataType = [Shared].Styles.AxisDataType.Numeric
axisY2_1.Labels.Orientation = [Shared].Styles.TextOrientation.Horizontal
axisY2_1.RangeType = [Shared].Styles.AxisRangeType.Custom
axisY2_1.RangeMin = 0
axisY2_1.RangeMax = 12000
ca1.Axes.Add(axisX2)
'ca2.Axes.Add(axisY2)
'ca2.Axes.Add(axisY2_1)
ca1.Axes.Add(axisY2_1)
Dim cla2 As New ChartLayerAppearance()
cla2.ChartType = [Shared].Styles.ChartType.LineChart
cla2.AxisX = axisX
'cla2.a
'cla2.AxisY = axisY2_1 'axisY2
cla2.AxisY2 = axisY2_1
cla2.ChartArea = ca1
'cla2.AxisY2 = axisY2_1
Me.UltraChart2.CompositeChart.ChartLayers.Add(cla2)
Dim nts1 As NumericTimeSeries = CreateNumericTimeSeries()
'cla2.Series.Clear()
'cla2.Series.Add(nts1)
cla2.Series.Add(nts1)
Me.UltraChart2.CompositeChart.Series.Add(nts1)
End Sub
Private Function CreateSeries(ByVal label As String) As GanttSeries
Dim gs As New GanttSeries(label)
gs.Label = label
Dim giTaskA As New GanttItem("Task A")
Dim giTaskB As New GanttItem("Task B")
Dim giTaskC As New GanttItem("Task C")
giTaskA.Label = "Task A"
giTaskA.Times.Add("1-April-2009", "10-April-2009")
giTaskB.Label = "Task B"
giTaskB.Times.Add("10-April-2009", "15-April-2009")
giTaskC.Label = "Task C"
giTaskC.Times.Add("13-April-2009", "20-April-2009")
gs.Items.Add(giTaskA)
gs.Items.Add(giTaskB)
gs.Items.Add(giTaskC)
Return gs
End Function
Private Function CreateNumericTimeSeries() As NumericTimeSeries
Dim ns As New NumericTimeSeries()
ns.Visible = True
ns.Label = "eee"
ns.Points.Add(New NumericTimeDataPoint("1-April-2009", 1, "1", False))
ns.Points.Add(New NumericTimeDataPoint("1-May-2009", 1000, "2", False))
ns.Points.Add(New NumericTimeDataPoint("1-June-2009", 10000, "3", False))
ns.Points.Add(New NumericTimeDataPoint("1-July-2009", 10000, "4", False))
ns.Points.Add(New NumericTimeDataPoint("1-August-2009", 10000, "5", False))
Return ns
Any help appreciated!!
yes, they can share an x axis.
you are very close, all you have to do now is set cla2.AxisY = axisY2_1. you don't need to set the AxisY2 property for a line chart layer.
I am working on a similar issue. I want to display two charts vertically having different Y Axis but sharing the same X- Axis. I have been able to divide the whole chart into 2 chart separate charts by making it a composite chart. The bottom one is a line chart and the top one needs to be a Gantt chart.
I can display a line or a column chart on top but some how can't display the Gantt chart. I am sure the GantDataSource I am using is correct as it works on a separate individual chart properly. But when I try to add the same in a composite chart it shows an empty Gantt Chart but a proper line chart.
Here is my code
this.graph.ChartType = ChartType.Composite; // main chart
// For the Line Chart
ChartArea LineArea = new ChartArea();
LineArea.Border.CornerRadius = 33;
LineArea.Border.Raised = true;
LineArea.Bounds = new Rectangle(1, 55, 98, 25);
LineArea.BoundsMeasureType = Infragistics.UltraChart.Shared.Styles.MeasureType.Percentage;
LineArea.Key = "Bottom Area";
// For the Gantt Chart
ChartArea GanttArea = new ChartArea();
GanttArea.Border.CornerRadius = 33;
GanttArea.Border.Raised = true;
GanttArea.Bounds = new Rectangle(1, 2, 98, 50);
GanttArea.BoundsMeasureType = Infragistics.UltraChart.Shared.Styles.MeasureType.Percentage;
GanttArea.Key = "Top Area";
this.graph.CompositeChart.ChartAreas.Add(GanttArea);
//Create Axis Item
AxisItem axisX = new AxisItem();
axisX.OrientationType = AxisNumber.X_Axis;
axisX.DataType = AxisDataType.String;
axisX.SetLabelAxisType = SetLabelAxisType.GroupBySeries;
axisX.Labels.ItemFormatString = "<ITEM_LABEL>";
axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing;
AxisItem axisY = new AxisItem();
axisY.OrientationType = AxisNumber.Y_Axis;
axisY.DataType = AxisDataType.Numeric;
axisY.Labels.ItemFormatString = "<DATA_VALUE:0.#>";
GanttArea.Axes.Add(axisX);
GanttArea.Axes.Add(axisY);
NumericSeries seriesA = new NumericSeries();
seriesA.Data.DataSource = dao.GetGanttDataTable();
seriesA.DataBind();
this.graph.CompositeChart.Series.Add(seriesA);
ChartLayerAppearance myGanttLayer = new ChartLayerAppearance();
myGanttLayer .ChartType = ChartType.GanttChart;
myGanttLayer .ChartArea = GanttArea;
myGanttLayer .AxisX = axisX;
myGanttLayer .AxisY = axisY;
myGanttLayer .Series.Add(seriesA);
this.graph.CompositeChart.ChartLayers.Add(myGanttLayer );
There is something going wrong in me binding the data or specifying the access. If I have to reproduce a Gantt Chart only then all I did was
this.GanttGraph.Data.DataSource = dao.GetGanttDataTable();
this.GanttGraph.DataBind();
GanttGraph.GanttChart.ShowOwners = true;
GanttGraph.Axis.X.Visible = false;
Here is a sample of the GantDataSource
GanttDataSource gantt_data = new GanttDataSource();
GanttSeries seriesA = gantt_data.Series.Add("");
GanttItem task1 = seriesA.Items.Add("");
task1.Times.Add(DateTime.Parse("04/04/2010 12:00 PM"), DateTime.Parse("05/04/2010 12:00 PM"));
task1.Times.Add(DateTime.Parse("05/10/2010 12:00 PM"), DateTime.Parse("06/04/2010 12:00 PM"));
task1.Times[0].PercentComplete = 100;
task1.Times[0].Owner = "Ketaki";
task1.Times[1].Owner = "Ketaki";
Thanks in advnace.
Ketaki
Is this thread closed?
Thanks. But I started that new thread and got my answers.
Thanks again.
no, but it looks like you got an answer here: https://es.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/42797/multiple-y-axis-for-a-gantt-chart-drawn-in-a-composite-chart/237924#237924
do you still need a response?