Issue with Stacked 100 Bar Series and Line Series

2 posts, 0 answers
  1. JP
    JP avatar
    5 posts
    Member since:
    Jan 2015

    Posted 22 May 2015 Link to this post

    Hi,

    I am trying to have a single chart with a Stacked 100 Bar series with a Line Series over it, however the line series doesn't want to show.

     

    Example code:

    <telerik:RadCartesianChart.Series>
                        <telerik:BarSeries x:Name="barSeries1" CategoryBinding="MyDateTime"
                                       ValueBinding="RedValue"
      ItemsSource="{Binding MyDataSource}"
      CombineMode="Stack100">
                            <telerik:BarSeries.PointTemplate>
                                <DataTemplate>
                                    <Rectangle Fill="Red"/>
                                </DataTemplate>
                            </telerik:BarSeries.PointTemplate>
                        </telerik:BarSeries>
                            <telerik:BarSeries x:Name="barSeries2" CategoryBinding="MyDateTime"
                                       ValueBinding="GreenValue"
      ItemsSource="{Binding MyDataSource}"
                                               CombineMode="Stack100"
      >
                            <telerik:BarSeries.PointTemplate>
                                <DataTemplate>
                                    <Rectangle Fill="Green"/>
                                </DataTemplate>
                            </telerik:BarSeries.PointTemplate>
                        </telerik:BarSeries> 
                        <telerik:LineSeries x:Name="lineSeries1" CategoryBinding="MyDateTime" ValueBinding="MyValue" Stroke="Black" 
      ItemsSource="{Binding MyDataSource}"
       />
    </telerik:RadCartesianChart.Series>

     Any assistance would be greatly appreciated.

  2. Anna
    Admin
    Anna avatar
    99 posts

    Posted 25 May 2015 Link to this post

    Hi,

    The reason why the line series doesn't show is that the bar series have Stack100 set as CombineMode. This combine mode automatically calculates the values of the bars as percentage of all the bars in the stack and the line series becomes incompatible with it.

    To display the series in your scenario, you can use couple approaches. One thing that you can try is to use the Stack mode instead and calculate the values of the bar series in your view model, so that they stack as they would in Stack100. In this case you will have to set the Maximum property of the linear (vertical) axis, in order to prevent it from leaving an offset between its max value and the max value plotted on the chart.

    Another option is to define an additional linear axis as a static resource and use it for all series which have Stack100 as CombineMode. You can read a bit more about multiple axes in this documentation article

    I hope this will be helpful. Please, let us know if you have any further questions.

    Regards,
    Anna
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top