Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
485
Polar Chart : Get Chart coordinates on mouse move.
posted

I am doing the following:

 

In FillsceneGraph event ..

xAxis = (

IAdvanceAxis)e.Grid["X"];

yAxis = (

IAdvanceAxis)e.Grid["Y"];

And in Mouse event ..

 

string xVal = xAxis.MapInverse(e.X).ToString();

 

string yVal = yAxis.MapInverse(e.Y).ToString();

The xVal is much higher than the maximum (360) , greater than 50000 in my case .

The yVal falls within the range (0 -90). But not accurate.

Like composite chart, do I need to do something different for Polar Chart?

Thanks

Anil

Parents
  • 28496
    Suggested Answer
    Offline posted

    this is trickier in polar chart, since cartesian coordinates have to be translated into polar coordinates and vice-versa.  the following code will calculate the angle and yValue.

    void ultraChart1_MouseDown(object sender, MouseEventArgs e)

    {

    if (this.XAxis == null || this.YAxis == null)

    {

    return;

    }

     

    Rectangle layerBounds = this.XAxis.ChartCore.GetChartLayer().GetOuterBounds();

    Point center = new Point(layerBounds.Width / 2, layerBounds.Height / 2);

    center.Offset(layerBounds.X, layerBounds.Y);

     

    Point mousePoint = new Point(e.X, e.Y);           

    double angle = Math.Atan2(mousePoint.Y - center.Y, mousePoint.X - center.X);

    angle = Geometry.RadianToDegree(angle);

     

    double yDistanceFromCenter = e.Y - center.Y;

    double yValue = (double)this.YAxis.MapInverse(this.YAxis.MapMinimum - yDistanceFromCenter);

    }

Reply Children
No Data