RadPieChart won't update for the second time

2 posts, 0 answers
  1. Kadir Kilicoglu
    Kadir Kilicoglu avatar
    11 posts
    Member since:
    Apr 2010

    Posted 03 Dec 2013 Link to this post

    <telerikChart:RadPieChart x:Name="rpcChart" Grid.Row="0" Margin="0,15,0,0">
                            <telerikChart:PieSeries SelectedPointOffset="0.3" SliceStyleSelector="{StaticResource PieSliceSelector}"  RadiusFactor="0.7">
     
                                <telerikChart:PieSeries.SliceStyles>
                                    <Style TargetType="Path">
                                        <Setter Property="Fill">
                                            <Setter.Value>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <LinearGradientBrush.GradientStops>
                                                        <GradientStopCollection>
                                                            <GradientStop Color="{StaticResource Nephritis}" Offset="0"/>
                                                            <GradientStop Color="{StaticResource Peter River}" Offset="1"/>
                                                        </GradientStopCollection>
                                                    </LinearGradientBrush.GradientStops>
                                                </LinearGradientBrush>
                                            </Setter.Value>
                                        </Setter>
     
                                    </Style>
                                    <Style TargetType="Path">
                                        <Setter Property="Fill">
                                            <Setter.Value>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <LinearGradientBrush.GradientStops>
                                                        <GradientStopCollection>
                                                            <GradientStop Color="{StaticResource Alizarin}" Offset="0"/>
                                                            <GradientStop Color="{StaticResource Carrot}" Offset="1"/>
                                                        </GradientStopCollection>
                                                    </LinearGradientBrush.GradientStops>
                                                </LinearGradientBrush>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </telerikChart:PieSeries.SliceStyles>
                                <telerikChart:PieSeries.LabelDefinitions>
                                    <telerikChart:ChartSeriesLabelDefinition Binding="Text">
                                        <telerikChart:ChartSeriesLabelDefinition.Template>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Value, StringFormat=\{0:C\}}" FontWeight="Bold" FontFamily="Segoe UI Semibold" Visibility="{Binding Value, ConverterParameter=Value, Converter={StaticResource AmountToVisibilityConverter}}">
                                                    <TextBlock.Foreground>
                                                        <SolidColorBrush Color="{StaticResource Clouds}"/>
                                                    </TextBlock.Foreground>
                                                </TextBlock>
                                            </DataTemplate>
                                        </telerikChart:ChartSeriesLabelDefinition.Template>
                                    </telerikChart:ChartSeriesLabelDefinition>
                                </telerikChart:PieSeries.LabelDefinitions>
                                <telerikChart:PieSeries.AngleRange>
                                    <telerikChartEngine:AngleRange StartAngle="90" SweepAngle="360"/>
                                </telerikChart:PieSeries.AngleRange>
                            </telerikChart:PieSeries>
                        </telerikChart:RadPieChart>

    Above code is my RadPieChart. And this is how i fill it:

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                base.OnNavigatedTo(e);
                rpcChart.Series[0].ItemsSource = new double[] { 20, 30 };
            }

    And this is the styleselector:

    public class PieSliceSelector : StyleSelector
        {
            public override System.Windows.Style SelectStyle(object item, DependencyObject container)
            {
                var dataPoint = item as PieDataPoint;
                var dataContainer = container as PieSeries;
                Style style = new Style(typeof(Path));
     
                //Setting the pie slice color:
                if (dataPoint.Value >= 0 && dataPoint.CollectionIndex == 0)
                {
                    style = dataContainer.SliceStyles[0];
                    dataPoint.IsSelected = true;
                }
                else
                {
                    style = dataContainer.SliceStyles[1];
                }
     
                return style;
     
                //return base.SelectStyle(item, container);
            }
        }


    This is the code i change my datapoints via 3 different buttons on the page which names are Daily,Weekly,Monthly:

    private void Daily_Tapped(object sender, System.Windows.Input.GestureEventArgs e)
            {
                rpcChart.Series[0].ItemsSource = new double[] { 20, 30 };
            }
     
            private void Weekly_Tapped(object sender, System.Windows.Input.GestureEventArgs e)
            {
                rpcChart.Series[0].ItemsSource = new double[] { 5, 50 };
            }
     
            private void Monthly_Tapped(object sender, System.Windows.Input.GestureEventArgs e)
            {
                rpcChart.Series[0].ItemsSource = new double[] { 70, 13 };
            }

    PROBLEM IS:

    When i click one of the buttons (say 'Daily' button) RadPieChart updates the chart for the first time. But when i click to another button (say 'Monthly' button) there is no updating. I'm debuggin the application and ItemSource values looks fine. But chart visual doesn't update itself? Stucked here over 3 days. Any idea?

  2. Kadir Kilicoglu
    Kadir Kilicoglu avatar
    11 posts
    Member since:
    Apr 2010

    Posted 03 Dec 2013 Link to this post

    Yea ' found the problem: StyleSelector. Removed and problem gone. Thanks to me :) 

    Advice: Be carefull on this kind a selectors 
  3. DevCraft banner
Back to Top