This project is read-only.

Column Chart updated after data changed

Oct 2, 2013 at 11:55 AM
Edited Oct 2, 2013 at 11:58 AM
I am developing a windows 8 phone app and using a column chart in one of the pages. The problem is the chart is not updated after data changed Unless i navigated backwards and forward.

the app architecture is MVVM, I put other elements in the page and updated the in the same method as a test and they updated successfully.

Also If i set the CategoryXAxis.Visibility to TRUE it generates NULL REFERENCE EXCEPTION


<chart:SparrowChart Foreground="{StaticResource PhoneAccentBrush}">
                <chart:Legend Padding="10" Foreground="{StaticResource PhoneAccentBrush}" Header="Calories per every meal"/>
                CrossLineStyle="{StaticResource crossLineStyle}"  
                MinorLineStyle="{StaticResource minorcrossLineStyle}"
                MajorLineStyle="{StaticResource crossLineStyle}" 
                AxisLineStyle="{StaticResource axisLineStyle}" 
                MinValue="0" Interval="500"  
                ShowCrossLines="True" Header="Calories" />
                                Fill="{StaticResource PhoneAccentBrush}"
                                PointsSource="{Binding MealsChartData}"                           XPath="Meal" 
                                Foreground="{StaticResource PhoneAccentBrush}"




private async void InitMealsData()
        this.MealsChartData = new ObservableCollection<ChartModel>();
        Repository<Meal> meals = new Repository<Meal>();
        ObservableCollection<Meal> data= await meals.GetAll("Meals.xml");
        //Create collection from logged data in a certain day
        if (data.Count > 0) 
            foreach (Meal item in data)
                if (item.Date.Date == this.SelectedDate.Value.Date)
                    double MealTotalClas = 0;
                    foreach (Food f in item.Foods)
                        MealTotalClas += f.Calories;

                    string MealName = item.MealType.ToString();
                    this.MealsChartData.Add(new ChartModel { Meal = MealName, Calories = MealTotalClas });                           

This method called every time selected date changed;