I'm new to using the RadCartesianChart and to WPF in general and I'm having a problem figuring out how to get a value out of the chart. I don't care if it's via command, event handler, binding, or whatever as long as I can get the data. I have a DateTimeContinuousAxis as my HorizontalAxis and 2 LineSeries both binding to list of objects that all have a DateTime on them and 2 other values. Each LineSeries binds to a different one of the values. This seems to work for getting the values on the chart.
Then I added a ChartPanAndZoomBehavior to the chart and I can now zoom into a portion of the whole, which is great and very slick. However, I want to make other things on the page show information based on the date range that the user is now examining data for. The closest I got was using the LayoutUpdated on part of it and getting the HorizontalAxis's ActualRange, but that didn't reflect the fact that you it had been zoomed.
So my question in a nutshell is: Using a DateTimeContinuousAxis as my HorizontalAxis and a ChartPanAndZoomBehavior, how can I get the date range that the user is looking to use for other controls?
My chart:
The ItemsSource is a List<TasksDueOnDay>:
Then I added a ChartPanAndZoomBehavior to the chart and I can now zoom into a portion of the whole, which is great and very slick. However, I want to make other things on the page show information based on the date range that the user is now examining data for. The closest I got was using the LayoutUpdated on part of it and getting the HorizontalAxis's ActualRange, but that didn't reflect the fact that you it had been zoomed.
So my question in a nutshell is: Using a DateTimeContinuousAxis as my HorizontalAxis and a ChartPanAndZoomBehavior, how can I get the date range that the user is looking to use for other controls?
My chart:
<chart:RadCartesianChart Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="LineGraph"> <chart:RadCartesianChart.HorizontalAxis> <telerik:DateTimeContinuousAxis MajorStep="4" MajorStepUnit="Week"> <telerik:DateTimeContinuousAxis.LabelTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <TextBlock HorizontalAlignment="Center" Text="{Binding StringFormat='MMMM dd'}" /> <TextBlock HorizontalAlignment="Center" Text="{Binding StringFormat=yyyy}" /> </StackPanel> </DataTemplate> </telerik:DateTimeContinuousAxis.LabelTemplate> </telerik:DateTimeContinuousAxis> </chart:RadCartesianChart.HorizontalAxis> <chart:RadCartesianChart.VerticalAxis> <telerik:LinearAxis Title="Count" LabelInterval="1" Minimum="0" /> </chart:RadCartesianChart.VerticalAxis> <chart:RadCartesianChart.Grid> <telerik:CartesianChartGrid MajorLinesVisibility="Y" StripLinesVisibility="Y"> <telerik:CartesianChartGrid.YStripeBrushes> <SolidColorBrush Color="Transparent" /> <SolidColorBrush Opacity="0.15" Color="Gray" /> </telerik:CartesianChartGrid.YStripeBrushes> </telerik:CartesianChartGrid> </chart:RadCartesianChart.Grid> <telerik:RadCartesianChart.Behaviors> <telerik:ChartTrackBallBehavior ShowIntersectionPoints="True" /> <telerik:ChartPanAndZoomBehavior PanMode="Horizontal" ZoomMode="Horizontal" /> </telerik:RadCartesianChart.Behaviors> <telerik:LineSeries CategoryBinding="Day" ClipToPlotArea="False" CombineMode="Stack" ItemsSource="{Binding TasksByDay}" Stroke="{StaticResource OnTrackFillAccentBrush}" StrokeThickness="0" Tag="Area" TrackBallInfoTemplate="{StaticResource trackBallInfoTemplate}" TrackBallTemplate="{StaticResource trackBallOnTrackTemplate}" ValueBinding="OnTrack" /> <telerik:LineSeries CategoryBinding="Day" ClipToPlotArea="False" CombineMode="Stack" ItemsSource="{Binding TasksByDay}" Stroke="{StaticResource OverDueFillAccentBrush}" StrokeThickness="0" Tag="Area" TrackBallInfoTemplate="{StaticResource trackBallEmptyInfoTemplate}" TrackBallTemplate="{StaticResource trackBallOverDueTemplate}" ValueBinding="OverDue" /></chart:RadCartesianChart>The ItemsSource is a List<TasksDueOnDay>:
public class TasksDueOnDay{ public DateTime Day { get; set; } public int OnTrack { get; set; } public int OverDue { get; set; } public override string ToString() { return "TasksDueOnDay.ToString()"; }}