Unplanned
Last Updated: 07 May 2020 08:01 by ADMIN
Dayanand
Created on: 30 Apr 2020 16:11
Category: UI for Xamarin
Type: Bug Report
2
Chart Series not Detecting Property Changes

The chart's series are not detecting property changed notifications on items in the series.

Note:

  • This works as expected in UWP
  • The series also doesn't seem to detect any ItemsSource property changes either.

Reproducible

If you have a data model where the properties are using INotifyPropertyChanged, for example from your NotifyPropertyChangedBase

public class Item : NotifyPropertyChangedBase
{
    private DateTime date;
    private int value;

    public DateTime Date
    {
        get => date;
        set => UpdateValue(ref date, value);
    }

    public int Value
    {
        get => value;
        set => UpdateValue(ref this.value, value);
    }
}

Here's a view model to use, invoke the command to observe the problem

public class MainViewModel : NotifyPropertyChangedBase
{
    public MainViewModel()
    {
        var rand = new Random();

        DataPoints = new ObservableCollection<Item>(Enumerable.Range(1,5).Select(i=>new Item
        {
            Date = DateTime.Today.AddDays(-i),
            Value = rand.Next(1,10)
        }));

        ChangeDataCommand = new Command(() =>
        {
            foreach (var dataPoint in DataPoints)
            {
                dataPoint.Value = rand.Next(1, 20);
            }
        });
    }

    private ObservableCollection<Item> dataPoints;
    public ObservableCollection<Item> DataPoints
    {
        get => dataPoints;
        set => UpdateValue(ref dataPoints, value);
    }

    public Command ChangeDataCommand { get; set; }
}

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <telerikChart:RadCartesianChart x:Name="Chart">
        <telerikChart:RadCartesianChart.HorizontalAxis>
            <telerikChart:DateTimeContinuousAxis LabelFormat="MM-dd"
                                                 LabelFitMode="Rotate" />
        </telerikChart:RadCartesianChart.HorizontalAxis>
        <telerikChart:RadCartesianChart.VerticalAxis>
            <telerikChart:NumericalAxis Minimum="0" Maximum="10"/>
        </telerikChart:RadCartesianChart.VerticalAxis>
        <telerikChart:RadCartesianChart.Series>
            <telerikChart:LineSeries ValueBinding="Value"
                                           CategoryBinding="Date"
                                           ItemsSource="{Binding DataPoints}" />
        </telerikChart:RadCartesianChart.Series>
    </telerikChart:RadCartesianChart>

    <Button Text="Change Data"
            Command="{Binding ChangeDataCommand}"
            HorizontalOptions="Fill"
            Margin="5"
            Grid.Row="1"/>
</Grid>

1 comment
ADMIN
Yana
Posted on: 07 May 2020 08:01

Hi Dayanand,

Thank you for reporting this issue in Chart control. I've updated the status of the item to "Unplanned" as I confirm it's an valid issue on our side and we'll have it in mind. 

Please follow the feedback item to get notified on status changes.

I am sorry for any inconvenience caused.

Regards,
Yana
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.