How to get actual visable range when scrolling

3 posts, 0 answers
  1. Coder
    Coder avatar
    8 posts
    Member since:
    Jan 2014

    Posted 16 Feb 2014 Link to this post


    I am using a RadCartesianChart with DateTimeCategoricalAxis.

    I want to be able to get the actual minimum and maximum values seen on my chart for both the x and y axis everytime I scroll.

    I also want to be able to get the data item on mouse click, or the collection of items on mouse drag.

    Is it possible to do this? If so, how?

    I have tried everything, but this nothing works.

    Can Telerik chart support this, or should I be looking elsewhere?

  2. Martin Ivanov
    Martin Ivanov avatar
    1408 posts

    Posted 18 Feb 2014 Link to this post


    You can get the actual minimum and maximum values after scroll by using the ActualVisibleRange property. Note that this property is available only on numerical axes and you cannot get such a range in a categorical axis. You can implement your logic in the RadCartesianChart.ZoomChanged event handler which is invoked every time you zoom in or zoom out.

    As for your second requirement you could use the RadCartesianChart.ConvertPointToData() method, which gets the coordinates of the mouse and creates a data item based on them.
    private void RadCartesianChart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        Point mousePosition = e.GetPosition(this.Chart);
        DataTuple tuple = this.Chart.ConvertPointToData(mousePosition, this.horizontalAxis, this.verticalAxis);
        DateTime Category = (DateTime)tuple.FirstValue;
        var dataItems = ((ICollection<DataItem>)(this.Chart.Series[0] as LineSeries).ItemsSource).Where(x => x.Category == Category);

    Another option would be to use the Selection Behavior of the ChartView and handle its SelectionChanged event. You could also take a look at the Selection demo available with our UI for WPF Demos - once you install the demos locally, navigate to the ChartView example and then select the Selection example.

  3. Coder
    Coder avatar
    8 posts
    Member since:
    Jan 2014

    Posted 18 Feb 2014 in reply to Martin Ivanov Link to this post

    Thanks. I used this approach to get the min and max datetimes on each side of the chart for every PanOffsetChange

    First I calculated the min and max offsets like this:

                Point newMinPoint = new Point(chart.PlotAreaClip.X + e.NewPanOffset.X, 0);
                Point newMaxPoint = new Point(chart.PlotAreaClip.X + +e.NewPanOffset.X + chart.PlotAreaClip.Width, 0);

    then I used ConvertPointToData to get the actual DateTime for these points.
Back to Top