Bars are not redrawing when item source is updated

2 posts, 0 answers
  1. Thomas
    Thomas avatar
    2 posts
    Member since:
    Jul 2017

    Posted 22 Jul Link to this post

    Hi all,

     

     

    we have a XAML chart which works fine if data is set in the viewmodel when the page is drawn. If we update the observable collection (itemsource) later, only the x-axis labels are drawn but neither the bars nor the Y-axis is drawn (Xamarin Forms latest version with latests version of Telerik charts)

     

    Here is our XAML:

     

          <telerikChart:RadCartesianChart Grid.Row="6" Margin="35,0,10,5" BackgroundColor="Red">
        
            <telerikChart:RadCartesianChart.Palette>      
              <telerikChart:ChartPalette>
                  <telerikChart:ChartPalette.Entries>
                      <telerikChart:PaletteEntry FillColor="White" StrokeColor="White"/>
                      <telerikChart:PaletteEntry FillColor="Pink" StrokeColor="Pink" />
                  </telerikChart:ChartPalette.Entries>
                </telerikChart:ChartPalette>
            </telerikChart:RadCartesianChart.Palette>  

            <telerikChart:RadCartesianChart.Grid> 
                  <telerikChart:CartesianChartGrid StripLinesVisibility="None" YStripeColor="Red" YStripeAlternativeColor="Red" XStripeColor="Red" XStripeAlternativeColor="Red"/>   
            </telerikChart:RadCartesianChart.Grid> 

            <telerikChart:RadCartesianChart.HorizontalAxis>
              <telerikChart:CategoricalAxis LineColor="White" LabelTextColor="White" GapLength="0.7"/>
            </telerikChart:RadCartesianChart.HorizontalAxis>
            <telerikChart:RadCartesianChart.VerticalAxis>
              <telerikChart:NumericalAxis LineColor="Red" LabelTextColor="White"/>
            </telerikChart:RadCartesianChart.VerticalAxis>   
                
            <telerikChart:RadCartesianChart.Series>
              <telerikChart:BarSeries CombineMode="Cluster" ItemsSource="{Binding Revenue, Mode=TwoWay}">
                <telerikChart:BarSeries.ValueBinding>
                  <telerikChart:PropertyNameDataPointBinding PropertyName="Value"/>
                </telerikChart:BarSeries.ValueBinding>
                <telerikChart:BarSeries.CategoryBinding>
                  <telerikChart:PropertyNameDataPointBinding PropertyName="Category"/>
                </telerikChart:BarSeries.CategoryBinding>
              </telerikChart:BarSeries>
              <telerikChart:BarSeries CombineMode="Cluster" ItemsSource="{Binding Expenditure, Mode=TwoWay}">
                <telerikChart:BarSeries.ValueBinding>
                  <telerikChart:PropertyNameDataPointBinding PropertyName="Value"/>
                </telerikChart:BarSeries.ValueBinding>
                <telerikChart:BarSeries.CategoryBinding>
                  <telerikChart:PropertyNameDataPointBinding PropertyName="Category"/>
                </telerikChart:BarSeries.CategoryBinding>
              </telerikChart:BarSeries>
            </telerikChart:RadCartesianChart.Series>
                  
          </telerikChart:RadCartesianChart>

     

    And here is the code which then updates the viewmodel - as said, the labels (Category) on the X-Axis work, but not the values or the Y-Axis:

     

                try {
                    List<SumStat> sumStatList = bindableDataPackage.sumStats;
                    var revenues = new ObservableCollection<CategoricalData>();
                    var expenditures = new ObservableCollection<CategoricalData>();

                    foreach (var stat in sumStatList) {
                        if (stat.sumplus < 50000) { 
                            revenues.Add(new CategoricalData { Category = stat.day, Value = stat.sumplus });
                            expenditures.Add(new CategoricalData { Category = stat.day, Value = stat.summinus });
                        }
                    }

    // these 2 properties of type observable collection trigger the update
                    Revenue = revenues;
                    Expenditure = expenditures;
                    

                } catch (Exception e) {
                    StarFinanz.Core.Diagnostics.Trace.TraceInformation("Error: " + e.Message);
                }

  2. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    484 posts

    Posted 25 Jul Link to this post

    Hi Thomas,

    I see that you've already had an opportunity to review the discussion in this thread about your question. the development team is aware of it and are working on it now.

    Rosita has shared the URL to the Feedback Portal item for this in that thread. For your convenience, here it is again. You can follow it to be notified of status changes. 

    Regards,
    Lance | Tech Support Engineer, Sr.
    Progress 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
Back to Top