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
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);
David,
Thanks. I did something similar.
Here is my code ..
private void update_scene(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e){ polarlayer = e.ChartCore.GetChartLayer() as PolarLayer;
And then OnMouseMove...
double dip = 0, azimuth = 0, factor = 0;int radius = polarlayer.RadiusResolved;factor = 90d / radius;System.Drawing.Point center = polarlayer.CenterResolved;System.Drawing.Point selection = e.Location;
double xdist = (selection.X - center.X) * factor;double ydist = (selection.Y - center.Y) * factor;
if (xdist == 0 && ydist == 0) // when clicked at the exact center{ dip = 0; azimuth = 0;}else if (xdist == 0) // along y axis{ dip = ydist; azimuth = (center.Y > selection.Y) ? 180 : 0;}else if (ydist == 0) // along xaxis{ dip = xdist; azimuth = (center.X > selection.X) ? 90 : 270;}
else // when clicked in any other area..{ dip = Math.Sqrt((xdist * xdist) + (ydist * ydist));
azimuth = Math.Atan(ydist / xdist) * (180 / Math.PI);
if (selection.X > center.X) { azimuth += 90; } else { azimuth += 270; }}dip = Math.Abs(Math.Round(dip, 2)); azimuth = Math.Abs(Math.Round(azimuth, 2));
if (dip <= 90 && azimuth <= 360)
do what you need to do