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.