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

Zoom begin and end

3 Answers 59 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Dwight
Top achievements
Rank 1
Dwight asked on 26 Apr 2013, 02:24 PM
Hi all,

I am looking for a way to know which datapoints (or screen coordinates) are in range of my current zoom level.
I'm drawing specific stuff above the graph and don't want to change anything if the user clicks outside the graph.

Any ideas?

Kind regards,
Dwight

3 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 01 May 2013, 12:01 PM
Hi Dwight,

You can use a combination of our conversion API and the ActualRange property of the char axis. For example:

private void RadCartesianChart_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    Point mousePosition = e.GetPosition(radCartesianChart1);
    DataTuple tuple = radCartesianChart1.ConvertPointToData(mousePosition);
 
    double xValue = (double)tuple.FirstlValue;
 
    LinearAxis xAxis = radCartesianChart1.HorizontalAxis as LinearAxis;
    double minimum = xAxis.ActualRange.Minimum;
    double maximum = xAxis.ActualRange.Maximum;
 
    if (xValue < minimum || xValue > maximum)
    {
    }
}

All the best,
Tsvetie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dwight
Top achievements
Rank 1
answered on 02 May 2013, 07:09 AM
Hi Tsvetie,

It seems not to be working, when zoomed in the min & max property of the ActualRange property don't change.
In my example unzoomed the min & max are from 0 to 9. When zoomed in (say from 2 to 3) and clicking outside the chart, they still are 0 and 9.

Kind regards,
Dwight
0
Tsvetie
Telerik team
answered on 06 May 2013, 07:25 PM
Hello Dwight,

Indeed, the actual range property returns the actual minimum and maximum of the entire axis. If you know the current zoom you can easily calculate the visible range of the axis. I have attached a simple application demonstrating the approach that you can use.

Kind regards,
Tsvetie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
Dwight
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Dwight
Top achievements
Rank 1
Share this question
or