Can I/How do I bind to a date range from ChartPanAndZoomBehavior on a DateTimeContinuousAxis?

4 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    2 posts
    Member since:
    Mar 2013

    Posted 25 Jun 2013 Link to this post

    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:
    <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()";
        }
    }
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 28 Jun 2013 Link to this post

    Hi Jeremy,

    You can retrieve the currently visible range from the ActualVisibleRange property of DateTimeContinuousAxis.


    Best regards,
    Ves
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jeremy
    Jeremy avatar
    2 posts
    Member since:
    Mar 2013

    Posted 08 Jul 2013 Link to this post

    Sorry for the delayed reply. I was pulled off of this and was unable to test this until this morning.  We're using the Telerik RadControls for WPF Q1 2013 and that is not a property of the DateTimeContinuousAxis. ActualRange is a property on the other hand, but it doesn't update. Right now I'm putting an event handler on LayoutUpdated on the DateTimeContinuousAxis and after I change the range I put a breakpoint in it so I can use the immediate window to check the values. The ActualRange value does not update when I change the visible range of the chart.

    Is there anything you can advise me to do that might help?
  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 11 Jul 2013 Link to this post

    Hi Jeremy,

    Support for such scenarios was the reason why we exposed the ActualVisibleRange property. Please, upgrade to RadControls for WPF 2013 Q2 in order to take advantage of this property.

    Best regards,
    Ves
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top