Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
890
Composite Chart Axis Labels Disappear
posted

I have a composite chart with a barchart and a stacked bar chart.  I need the stacked bar chart to display behind the bar chart because it shows a rating for the bar chart with a different colour for each section.  I have everything working ok except that when I add the stacked bar chart first, I don't get any labels on my Y axis.  The label values are supposed to be defined by the bar chart.  If I add the bar chart first, I get the labels, but the bars appear behind the colours of the stacked bar chart and it is hard to read.

For this screenshot, I added the bar chart, then the stacked bar chart, the the bar chart a second time.  I'm sure there is a better way to do this.  Any help would be appreciated.

Here is my code if you want to see it:

        myChart.ChartType = ChartType.Composite

        Dim area As ChartArea = New ChartArea()

        myChart.CompositeChart.ChartAreas.Add(area)

 

        Dim YAxis As AxisItem = New AxisItem(myChart, AxisNumber.Y_Axis)

        YAxis.DataType = AxisDataType.String

        YAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries

        YAxis.Labels.ItemFormat = AxisItemLabelFormat.ItemLabel

        YAxis.Labels.SeriesLabels.Format = AxisSeriesLabelFormat.SeriesLabel

        area.Axes.Add(YAxis)

 

        Dim XAxis As AxisItem = New AxisItem(myChart, AxisNumber.X_Axis)

        XAxis.DataType = AxisDataType.Numeric

        XAxis.Labels.ItemFormat = AxisItemLabelFormat.DataValue

        area.Axes.Add(XAxis)

 

        With XAxis

            .SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.ContinuousData

            .TickmarkInterval = 0

            .Visible = True

            .LineThickness = 1

            .TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart

            .Extent = 35

            Try

                .RangeType = Infragistics.UltraChart.Shared.Styles.AxisRangeType.Custom

                .RangeMin = 0

                .RangeMax = 120

            Catch ex As Exception

            End Try

 

            With .Labels

                .ItemFormatString = "<DATA_VALUE:0>"

                .HorizontalAlign = Drawing.StringAlignment.Near

                .Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing

                .VerticalAlign = Drawing.StringAlignment.Center

                .FontColor = Drawing.Color.Gray

                With .Layout

                    .Behavior = Infragistics.UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.Auto

                End With

                With .SeriesLabels

                    .HorizontalAlign = Drawing.StringAlignment.Near

                    .Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing

                    .VerticalAlign = Drawing.StringAlignment.Center

                    .FontColor = Drawing.Color.Gray

                    With .Layout

                        .Behavior = Infragistics.UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.Auto

                    End With

                End With

            End With

        End With

 

        With YAxis

            .TickmarkInterval = 0

            .Visible = True

            .LineThickness = 1

            .TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart

            .Extent = 70

            With .Labels

                .ItemFormatString = "<ITEM_LABEL>"

                .HorizontalAlign = Drawing.StringAlignment.Far

                .Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal

                .VerticalAlign = Drawing.StringAlignment.Center

                .FontColor = Drawing.Color.Gray

                With .Layout

                    .Behavior = Infragistics.UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.None

                End With

                With .SeriesLabels

                    .HorizontalAlign = Drawing.StringAlignment.Far

                    .Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal

                    .VerticalAlign = Drawing.StringAlignment.Center

                    .FontColor = Drawing.Color.Gray

                    With .Layout

                        .Behavior = Infragistics.UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.None

                    End With

                End With

            End With

        End With

 

        With myChart

            .Height = 500

            .Width = 900

            With .ColorModel

                .AlphaLevel = 255

                .ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.LinearRange

                .ColorBegin = Drawing.Color.Gray

                .ColorEnd = Drawing.Color.Gray

            End With

 

            With .Data

                .SwapRowsAndColumns = True

                .ZeroAligned = True

                With .EmptyStyle

                    .LineStyle.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dash

                End With

            End With

 

        myChart.CompositeChart.Series.Add(MainSeries)

 

        myChart.CompositeChart.Series.Add(RatingSeries)

 

        Dim MainChartLayer As ChartLayerAppearance = New ChartLayerAppearance()

 

        MainChartLayer.AxisX = XAxis

        MainChartLayer.AxisY = YAxis

        MainChartLayer.ChartArea = area

        MainChartLayer.ChartType = ChartType.BarChart

        MainChartLayer.Series.Add(MainSeries)

        MainChartLayer.SwapRowsAndColumns = True

 

        Dim MainChartAppearance As New BarChartAppearance

        Dim MainChartText As New ChartTextAppearance

        MainChartText.ItemFormatString = "<DATA_VALUE:0>"

        MainChartText.Visible = True

        MainChartText.HorizontalAlign = StringAlignment.Far

        MainChartAppearance.ChartText.Add(MainChartText)

        MainChartText.Column = -2

        MainChartText.Row = -2

        MainChartLayer.ChartTypeAppearance = MainChartAppearance

 

        Dim RatingLayer As ChartLayerAppearance = New ChartLayerAppearance()

        RatingLayer.AxisX = XAxis

        RatingLayer.AxisY = YAxis

        RatingLayer.ChartArea = area

        RatingLayer.ChartType = ChartType.StackBarChart

        RatingLayer.Series.Add(RatingSeries)

 

        myChart.CompositeChart.ChartLayers.Add(MainChartLayer)

        myChart.CompositeChart.ChartLayers.Add(RatingLayer)

        myChart.CompositeChart.ChartLayers.Add(MainChartLayer)