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
780
Animate repeated explosion & collapse in PieChart.
posted

Hi, I have a PieChart where I want to give the user the ability to explode the series and then collapse it back.  I have that working, but I want those actions to be animated.  I can get it to animate the explosion, but not the collapse back.  Is this possible at all?

The code I'm trying now is below.  isExploded is a bool on the control that I initialize to false so I can keep track of the state to change.

Thanks,
Keith

---------
<igChart:XamWebChart x:Name="XamWebChart1" >
<igChart:XamWebChart.Series>
    <igChart:Series ChartType="Pie" Label="Hello"  >
        <igChart:Series.DataPoints>
  <igChart:DataPoint Value="10" Label="0" />
  <igChart:DataPoint Value="10" Label="1" />
  <igChart:DataPoint Value="10" Label="2"  />
        </igChart:Series.DataPoints>
</igChart:XamWebChart.Series>
</igChart:XamWebChart>

Code behind:

bool isExploded = false;

private void Button_Click(object sender, RoutedEventArgs e)
{
    isExploded = !isExploded;
    ChartParameter pExploded = new ChartParameter(ChartParameterType.Exploded, isExploded);

    Animation animation = new Animation()
    {
 Sequential = true,
 BeginTime = TimeSpan.FromTicks(0),
 Duration = new Duration(TimeSpan.FromMilliseconds(250))
    };
    ChartParameter pAnimation = new ChartParameter(
 ChartParameterType.ExplodedAnimation,
animation);

    this.XamWebChart1.Series[0].ChartParameters.Clear();
    this.XamWebChart1.Series[0].ChartParameters.Add(pAnimation);
    this.XamWebChart1.Series[0].ChartParameters.Add(pExploded);
}