Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
Force reloading of XamChart
posted

Hello Everyone,

I have been trying to databind my XamChart (stackedColumn) to display a chart based on a custom data that I have.

UI consist of a XamChart and a selector control which allows user to select what data should be displayed.

Though it works for me when I just do it in code-behind by removing the series (calling clear) on a property change for CurrentGraph in my ViewModel and then adding the data again, but if I set the DataContext on XamChart and then set the DataSource for my Series, it just displays the data for first chart but does not refreshes it again when new option is selected.

Seems like the chart is not being refreshed or reloaded.

I have tried the solutions mentioned an http://news.infragistics.com/forums/t/15543.aspx but it still does not work for me.


This is how I am doing data binding :

            <Grid MinHeight="100" Name="ChartGrid" >
                <igCA:XamChart Name="DataChart" RefreshEnabled="True" Style="{StaticResource XamChartStyle}" DataContext="{Binding Path=CurrentGraph.Results}" >
                    <igCA:XamChart.Scene>
                        <igCA:Scene BorderBrush="Black">
                            <igCA:Scene.GridArea>
                                <igCA:GridArea Style="{StaticResource GridAreaStyle}"/>
                            </igCA:Scene.GridArea>
                        </igCA:Scene>
                    </igCA:XamChart.Scene>
                    <!-- Series -->
                    <igCA:XamChart.Series>
                        <igCA:Series ChartType="StackedColumn" DataSource="{Binding Path=ZAxisValues}"
                                 DataMapping="Label = XAxisValue; Value = YAxisValue" UseDataTemplate="True">
                            <igCA:Series.Marker>
                                <igCA:Marker Foreground="RosyBrown"/>
                            </igCA:Series.Marker>
                        </igCA:Series>
                    </igCA:XamChart.Series>
                    <igCA:XamChart.Axes>
                        <igCA:Axis AxisType="PrimaryX" Animation="{StaticResource AxisAnimation}"
                               MajorGridline="{StaticResource AnimationMarkX}"
                               Label="{StaticResource AnimationLabelsX}"/>

                        <igCA:Axis AxisType="PrimaryY" Animation="{StaticResource AxisAnimation}"
                               MajorGridline="{StaticResource AnimationMarkY}"
                               Label="{StaticResource AnimationLabelsY}">

                            <igCA:Axis.Stripes>
                                <igCA:Stripe Style="{StaticResource StripeStyle}"/>
                            </igCA:Axis.Stripes>

                        </igCA:Axis>
                    </igCA:XamChart.Axes>

                </igCA:XamChart>
            </Grid>


I also have put a property change listener in my code behind just in case it might help :

        void viewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {

            if (e.PropertyName.Equals("CurrentGraphDisplay"))
            {
                DataChart.DataSourceRefresh();
                DataChart.Refresh();
            }

       }

Any clues about how to make it reload the chart

 

Thanks