In a previous post, I talked about an example where the chart control’s BoundDataChanged event handler was used to calculate a series summary and display that as a custom field within the chart’s legend box.
The BoundDataChanged event is triggered every time the chart control generates series points based on a data source. While this may not sound very exciting at first, it’s value increases when you consider all the possibilities of being able to perform certain routines before the series are drawn. From being able to retrieve live series data for display elsewhere in your UI, to animating the series as they are being drawn, the possibilities are endless.
So here’s an example… animating the series using series templates. We want the final product to draw the series as it is populating it with points:
The following code is used within the BoundDataChanged event handlerto create the animation for the series template.
1: private void chartControl1_BoundDataChanged(object sender, RoutedEventArgs e) {
2: seriesAnimation.Animations.Clear();
3: foreach (Series series in chartControl1.Diagram.Series) {
4: SeriesAnimation tmpSeriesAnim = new SeriesAnimation();
5: SeriesAnimationAction seriesAction = new SeriesUnwindingAction();
6: tmpSeriesAnim.Actions.Add(seriesAction);
7: seriesAnimation.Animations.Add(tmpSeriesAnim);
8: tmpSeriesAnim.TargetSeries = series;
9: }
10: DoubleAnimation animation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(5)));
11: seriesAnimation.BeginAnimation(ChartAnimationRecord.ProgressProperty, animation, HandoffBehavior.SnapshotAndReplace);
12: }
Give it a try…
Download the source code for this example from CodeCentral: http://www.devexpress.com/Support/Center/e/E2412.aspx
Also, keep an eye out on the DevExpress Channel and this blog for an upcoming video that demonstrates this feature in action.