Pre loader

Getting the current Coordinates from a X or Y Value on a polar plot

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

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

  • You must to post comments
1
0

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

  • James McDuffie
    Worked perfectly! Thank you so much! Now if you guys can finish the implementation around rotating the XAxis!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.