This is a migrated thread and some comments may be shown as answers.
Bars are not redrawing when item source is updated
1 Answer 27 Views
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 22 Jul 2017, 10:25 AM

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);
            }

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 25 Jul 2017, 06:48 PM
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
Tags
Chart
Asked by
Thomas
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or