The stacked bars not visible

2 posts, 0 answers
  1. Purna
    Purna avatar
    9 posts
    Member since:
    Nov 2017

    Posted 14 Nov Link to this post

    I have the following code for generating a stackedbar chart, but the bars are not visible. I have attached the screen shot of chart as well.

    Can you please help me point out the issue

     

    Class ChartDatas
            Public SalesRep As String
            Public LastYearValue As Double
            Public CurYearValue As Double
            Public BudgetedValue As Double

            Public Sub New(ByVal strSalesRep As String, dbLastYearVal As Double, dbCurYearVal As Double, dbBudgetedVal As Double)
                SalesRep = strSalesRep
                LastYearValue = dbLastYearVal
                CurYearValue = dbCurYearVal
                BudgetedValue = dbBudgetedVal
            End Sub
        End Class

        Private Sub ShowChart()
           
            chtComparison.SeriesMappings.Clear()
            chtComparison.DefaultView.ChartLegend.Visibility = Visibility.Collapsed
            chtComparison.DefaultView.ChartArea.DataSeries.Clear()
            chtComparison.DefaultView.ChartLegend.UseAutoGeneratedItems = True

            Dim SeriesColor As Color
            Dim seriesDef As StackedBarSeriesDefinition

            Dim ListChartData As New List(Of ChartDatas)
            ListChartData.Add(New ChartDatas("Sales Rep1", 100, 200, 300))
            ListChartData.Add(New ChartDatas("Sales Rep2", 200, 300, 200))
            ListChartData.Add(New ChartDatas("Sales Rep3", 50, 300, 200))

            Dim SeriesMap1 As New SeriesMapping() With {.LegendLabel = "Series1"}
            SeriesMap1.ItemMappings.Add(New ItemMapping("LastYearValue", DataPointMember.YValue))
            SeriesMap1.ItemMappings.Add(New ItemMapping("SalesRep", DataPointMember.XCategory))
            'SeriesMap1.SeriesDefinition = New StackedBarSeriesDefinition() With {.ShowItemLabels = True}
            SeriesColor = Color.FromRgb(0, 0, 255)
            seriesDef = New StackedBarSeriesDefinition With {.ShowItemLabels = True}
            seriesDef.Appearance.Fill = New SolidColorBrush(SeriesColor)
            SeriesMap1.SeriesDefinition = seriesDef

            Dim SeriesMap2 As New SeriesMapping() With {.LegendLabel = "Series2"}
            SeriesMap2.ItemMappings.Add(New ItemMapping("CurYearValue", DataPointMember.YValue))
            SeriesMap2.ItemMappings.Add(New ItemMapping("SalesRep", DataPointMember.XCategory))
            'SeriesMap2.SeriesDefinition = New StackedBarSeriesDefinition() With {.ShowItemLabels = True}
            SeriesColor = Color.FromRgb(0, 255, 0)
            seriesDef = New StackedBarSeriesDefinition With {.ShowItemLabels = True}
            seriesDef.Appearance.Fill = New SolidColorBrush(SeriesColor)
            SeriesMap2.SeriesDefinition = seriesDef

            Dim SeriesMap3 As New SeriesMapping() With {.LegendLabel = "Series3"}
            SeriesMap3.ItemMappings.Add(New ItemMapping("BudgetedValue", DataPointMember.YValue))
            SeriesMap3.ItemMappings.Add(New ItemMapping("SalesRep", DataPointMember.XCategory))
            SeriesColor = Color.FromRgb(255, 0, 0)
            seriesDef = New StackedBarSeriesDefinition With {.ShowItemLabels = True}
            seriesDef.Appearance.Fill = New SolidColorBrush(SeriesColor)
            SeriesMap3.SeriesDefinition = seriesDef

            'chtComparison.DefaultView.ChartArea.AxisY.AutoRange = False
            'chtComparison.DefaultView.ChartArea.AxisY.AddRange(0, 1000, 100)

            chtComparison.SeriesMappings.Add(SeriesMap1)
            chtComparison.SeriesMappings.Add(SeriesMap2)
            chtComparison.SeriesMappings.Add(SeriesMap3)
            chtComparison.ItemsSource = ListChartData

        End Sub

     

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1475 posts

    Posted 17 Nov Link to this post

    Hello Purna,

    RadChart is our old charting component. Please use RadChartView instead. Here are some resources on the matter.
    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top