Hello,
What I was just looking for the combination of a Column and Line chart where half y axis is used. I must be dynamic, because I never know what type of chart the user will choose and over how many signals it will go. When I try the example, the result is not correct. It allows the Series F not see. This is a part of my code used.
Thanks in advance.
'Line chart '***************************************************************************Dim axisX2 As New AxisItem()axisX2.OrientationType = AxisNumber.X2_AxisaxisX2.DataType = AxisDataType.NumericaxisX2.Labels.ItemFormatString = ""axisX2.Labels.Orientation = TextOrientation.VerticalLeftFacingaxisX2.Extent = 40myChartArea.Axes.Add(axisX2)With axisY.axisNumber = AxisNumber.Y_Axis.RangeType = AxisRangeType.Automatic.DataType = AxisDataType.Numeric.Labels.ItemFormatString = "".Labels.Orientation = TextOrientation.Custom.Extent = 40End WithDim app As New LineChartAppearanceapp.NullHandling = NullHandling.DontPlotDim seriesC As XYSeries = GetXYSeriesBound()Dim seriesD As XYSeries = GetXYSeriesUnBound()Me.UltraChart1.CompositeChart.Series.Add(seriesC)Me.UltraChart1.CompositeChart.Series.Add(seriesD)' Customize the series colors.seriesC.PEs.Add(New PaintElement(Drawing.Color.Green))seriesD.PEs.Add(New PaintElement(Drawing.Color.Blue))Dim myScatterLayer As New ChartLayerAppearance()myScatterLayer.ChartType = ChartType.ScatterChartCType(myScatterLayer.ChartTypeAppearance, ScatterChartAppearance).ConnectWithLines = TruemyScatterLayer.ChartArea = myChartAreamyScatterLayer.AxisX = axisX2myScatterLayer.AxisY = axisYmyScatterLayer.Series.Add(seriesC)myScatterLayer.Series.Add(seriesD)Me.UltraChart1.CompositeChart.ChartLayers.Add(myScatterLayer)' Add the second layer to the legend.myLegend.ChartLayers.Add(myScatterLayer)'Column chart'***************************************************************************Dim axisY2 As New AxisItem()Dim axisX As New AxisItem()axisX.OrientationType = AxisNumber.X_AxisaxisX.DataType = AxisDataType.StringaxisX.SetLabelAxisType = SetLabelAxisType.GroupBySeriesaxisX.Labels.ItemFormatString = "<ITEM_LABEL>"axisX.Labels.Orientation = TextOrientation.VerticalLeftFacingaxisY.OrientationType = AxisNumber.Y_AxisaxisY.DataType = AxisDataType.NumericaxisY.Labels.ItemFormatString = "<DATA_VALUE:0.#>"myChartArea.Axes.Add(axisX)myChartArea.Axes.Add(axisY)axisY2.OrientationType = AxisNumber.Y2_AxisaxisY2.DataType = AxisDataType.NumericaxisY2.Labels.ItemFormatString = "<DATA_VALUE:0.#>"myChartArea.Axes.Add(axisY2)Dim myColumnLayer As New ChartLayerAppearance()Dim myColumnLayer1 As New ChartLayerAppearance()myColumnLayer.ChartType = ChartType.ColumnChartmyColumnLayer1.ChartType = ChartType.ColumnChartmyColumnLayer.ChartArea = myChartAreamyColumnLayer1.ChartArea = myChartAreamyColumnLayer.AxisX = axisXmyColumnLayer.AxisY = axisYmyColumnLayer1.AxisX = axisXmyColumnLayer1.AxisY2 = axisY2Dim seriesA As NumericSeries = GetNumericSeriesBound()Dim seriesB As NumericSeries = GetNumericSeriesUnBound()Dim seriesF As NumericSeries = GetNumericSeriesBound1()myColumnLayer.Series.Add(seriesA)myColumnLayer1.Series.Add(seriesB)myColumnLayer.Series.Add(seriesF)Me.UltraChart1.CompositeChart.Series.Add(seriesA)Me.UltraChart1.CompositeChart.Series.Add(seriesB)Me.UltraChart1.CompositeChart.Series.Add(seriesF)myColumnLayer.SwapRowsAndColumns = TrueMe.UltraChart1.CompositeChart.ChartLayers.Add(myColumnLayer)Me.UltraChart1.CompositeChart.ChartLayers.Add(myColumnLayer1)myLegend.ChartLayers.Add(myColumnLayer)myLegend.Bounds = New Rectangle(0, 75, 20, 25)myLegend.BoundsMeasureType = MeasureType.PercentagemyLegend.PE.ElementType = PaintElementType.GradientmyLegend.PE.FillGradientStyle = GradientStyle.ForwardDiagonalmyLegend.PE.Fill = Drawing.Color.CornflowerBluemyLegend.PE.FillStopColor = Drawing.Color.TransparentmyLegend.Border.CornerRadius = 10myLegend.Border.Thickness = 0Me.UltraChart1.CompositeChart.Legends.Add(myLegend)Me.UltraChart1.InvalidateLayers()
End Sub Private Shared Function GetData() As DataTable Dim table As New DataTable() table = New DataTable table.Columns.Add("Label Column", GetType(String)) table.Columns.Add("Waarde Column", GetType(Double)) table.Columns.Add("Another Waarde Column", GetType(Double)) table.Rows.Add(New Object() {"2000", 1.0, 3.0}) table.Rows.Add(New Object() {"2001", 2.0, 2.0}) table.Rows.Add(New Object() {"2002", 3.0, 1.0}) table.Rows.Add(New Object() {"2003", 4.0, 2.0}) table.Rows.Add(New Object() {"2004", 5.0, 3.0}) Return table End Function Private Shared Function GetNumericSeriesUnBound() As NumericSeries Dim series As New NumericSeries() series.Label = "Series B" ' this code populates the series using unbound data series.Points.Add(New NumericDataPoint(5.0, "2000", False)) series.Points.Add(New NumericDataPoint(4.0, "2001", False)) series.Points.Add(New NumericDataPoint(3.0, "2002", False)) series.Points.Add(New NumericDataPoint(2.0, "2003", False)) series.Points.Add(New NumericDataPoint(1.0, "2004", False)) Return series End Function Private Function GetXYSeriesUnBound() As XYSeries Dim series As New XYSeries() series.Label = "Hello" ' this code populates the series using unbound data series.Points.Add(New XYDataPoint(1.0, 1.0, "2000", False)) series.Points.Add(New XYDataPoint(2.0, 2.0, "2001", False)) series.Points.Add(New XYDataPoint(3.0, 3.0, "2002", False)) series.Points.Add(New XYDataPoint(4.0, 4.0, "2003", False)) series.Points.Add(New XYDataPoint(5.0, 5.0, "2004", False)) Return series End Function Private Function GetXYSeriesBound() As XYSeries Dim series As New XYSeries() series.Label = "Series C" ' this code populates the series from an external data source Dim table As DataTable = GetData() series.Data.DataSource = table series.Data.LabelColumn = "Label Column" series.Data.ValueXColumn = "Waarde Column" series.Data.ValueYColumn = "Another Waarde Column" Return series End Function Private Shared Function GetNumericSeriesBound() As NumericSeries Dim series As New NumericSeries() series.Label = "Series A" ' this code populates the series from an external data source Dim table As DataTable = GetData() series.Data.DataSource = table series.Data.LabelColumn = "Label Column" series.Data.ValueColumn = "Waarde Column" Return series End Function Private Shared Function GetNumericSeriesBound1() As NumericSeries Dim series As New NumericSeries() series.Label = "Series F" ' this code populates the series from an external data source Dim table As DataTable = GetData() series.Data.DataSource = table series.Data.LabelColumn = "Label Column" series.Data.ValueColumn = "Another Waarde Column" Return series End Function
End Sub
Private Shared Function GetData() As DataTable Dim table As New DataTable() table = New DataTable table.Columns.Add("Label Column", GetType(String)) table.Columns.Add("Waarde Column", GetType(Double)) table.Columns.Add("Another Waarde Column", GetType(Double)) table.Rows.Add(New Object() {"2000", 1.0, 3.0}) table.Rows.Add(New Object() {"2001", 2.0, 2.0}) table.Rows.Add(New Object() {"2002", 3.0, 1.0}) table.Rows.Add(New Object() {"2003", 4.0, 2.0}) table.Rows.Add(New Object() {"2004", 5.0, 3.0}) Return table End Function Private Shared Function GetNumericSeriesUnBound() As NumericSeries Dim series As New NumericSeries() series.Label = "Series B" ' this code populates the series using unbound data series.Points.Add(New NumericDataPoint(5.0, "2000", False)) series.Points.Add(New NumericDataPoint(4.0, "2001", False)) series.Points.Add(New NumericDataPoint(3.0, "2002", False)) series.Points.Add(New NumericDataPoint(2.0, "2003", False)) series.Points.Add(New NumericDataPoint(1.0, "2004", False)) Return series End Function Private Function GetXYSeriesUnBound() As XYSeries Dim series As New XYSeries() series.Label = "Hello" ' this code populates the series using unbound data series.Points.Add(New XYDataPoint(1.0, 1.0, "2000", False)) series.Points.Add(New XYDataPoint(2.0, 2.0, "2001", False)) series.Points.Add(New XYDataPoint(3.0, 3.0, "2002", False)) series.Points.Add(New XYDataPoint(4.0, 4.0, "2003", False)) series.Points.Add(New XYDataPoint(5.0, 5.0, "2004", False)) Return series End Function Private Function GetXYSeriesBound() As XYSeries Dim series As New XYSeries() series.Label = "Series C" ' this code populates the series from an external data source Dim table As DataTable = GetData() series.Data.DataSource = table series.Data.LabelColumn = "Label Column" series.Data.ValueXColumn = "Waarde Column" series.Data.ValueYColumn = "Another Waarde Column" Return series End Function Private Shared Function GetNumericSeriesBound() As NumericSeries Dim series As New NumericSeries() series.Label = "Series A" ' this code populates the series from an external data source Dim table As DataTable = GetData() series.Data.DataSource = table series.Data.LabelColumn = "Label Column" series.Data.ValueColumn = "Waarde Column" Return series End Function Private Shared Function GetNumericSeriesBound1() As NumericSeries Dim series As New NumericSeries() series.Label = "Series F" ' this code populates the series from an external data source Dim table As DataTable = GetData() series.Data.DataSource = table series.Data.LabelColumn = "Label Column" series.Data.ValueColumn = "Another Waarde Column" Return series End Function
Me.UltraChart1.ChartType = ChartType.Composite myChartArea = Me.UltraChart1.CompositeChart.ChartAreas(0) Me.UltraChart1.CompositeChart.ChartAreas.Add(myChartArea)
Sub CreateChart()
Dim myLegend As New CompositeLegend() Dim myChartArea As New ChartArea() Dim axisY As New AxisItem()
Hello Max,
I am one step closer to the chart that they asked.
What am I doing wrong. I try to add a second layer (type = Column chart) because this will used the second y-axes. But then I see this Wrong.png is not good it should be Ok.png)
Johan
I don't really understand what your expectation is. Here's what I get when I run the code you have provided. Is the image not correct? And if so, how? If you intend to show all 3 numeric series, you should add them to the same column layer. Also, seriesF appears to be visible.