I am currently playing with a Polar Plot that is from 0-360 degrees for it’s XAxis (phase). I am trying to determine the “next” coordinates on a keypress.
Currently I am trying:
ModifierSurface.Clear();
foreach (var series in this.ParentSurface.RenderableSeries)
{
var nextPhase = (double)series.DataSeries.XValues[_phaseIndex];
var nextAmp = (double)series.DataSeries.YValues[_phaseIndex];
var xCoordinate = series.XAxis.GetCurrentCoordinateCalculator().GetCoordinate(nextPhase);
var yCoordinate = series.YAxis.GetCurrentCoordinateCalculator().GetCoordinate(nextAmp);
DrawCursor(xCoordinate, yCoordinate, nextPhase, nextAmp);
}
Unfortunately I am not getting the point coordinate I am expecting for drawing my next “cursor info” window.
_phaseIndex is currently 340, and I want to increment it to 341 and get the next X/Y pair location. But I can’t seem to get the location.
Any help would be great!
Thanks!
Geranon
- James McDuffie asked 9 years ago
- last edited 9 years ago
- You must login to post comments
Hi there,
In polar chart coordinates returned by coordinate calculators are in polar format. In polar chart coordinate calculators just transform data value to pixel coordinates and vice versa in polar coordinate space.
To draw or place some UI element on ModifierSurface you need to transform those coordinates to cartesian coordinate space. To do this you could use ITransformationStrategy which allows to transform pixel coordinates from polar to cartesian coordinate space and vice versa in polar chart. In non polar chart it does nothing and just returns passed coordinates because they don’t require any transformatios.
You could find this transformation strategy in chart services and in this case your code will look like this:
var nextPhase = (double)series.DataSeries.XValues[_phaseIndex]; // polar x data value
var nextAmp = (double)series.DataSeries.YValues[_phaseIndex]; // polar y data value
var xCoordinate = series.XAxis.GetCurrentCoordinateCalculator().GetCoordinate(nextPhase); // polar x pixel coordinate
var yCoordinate = series.YAxis.GetCurrentCoordinateCalculator().GetCoordinate(nextAmp); // polar y pixel coordinate
var transformationStrategy = Services.GetService<IStrategyManager>().GetTransformationStrategy();
var cartesianPoint = transformationStrategy.ReverseTransform(new Point(xCoordinate , yCoordinate)); // transform polar point to cartesian
DrawCursor(cartesianPoint.X, cartesianPoint.Y , nextPhase, nextAmp);
Could you try this approach and tell whether it is suitable for you? Hope it helps!
Best regards, Yura
- Yura Khariton answered 9 years ago
-
Worked perfectly! Thank you so much! Now if you guys can finish the implementation around rotating the XAxis!
- You must login to post comments
Please login first to submit.