This is a migrated thread and some comments may be shown as answers.

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

3 Answers 129 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 25 Jun 2013, 08:38 PM
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()";
    }
}

3 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 28 Jun 2013, 04:23 PM
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 >>
0
Jeremy
Top achievements
Rank 1
answered on 08 Jul 2013, 04:09 PM
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?
0
Ves
Telerik team
answered on 11 Jul 2013, 01:02 PM
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 >>
Tags
ChartView
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Ves
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or