SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

1
0

Hello,
I have a polar chart in my wpf application and I want to get data value from pixel coordinates, once the user has
clicked on scichart surface. This is what I tried:

   mouseClick = (s, arg) =>
        {
            var mousePoint = arg.GetPosition((UIElement)this.sciChartSurface.GridLinesPanel);

    //From cartesian to polar conversion
            double xpolar = Math.Atan(mousePoint2.Y / mousePoint2.X);
            double ypolar = Math.Sqrt(Math.Pow(mousePoint2.X, 2) + Math.Pow(mousePoint2.Y, 2));

            double a = sciChartSurface.RenderableSeries[_trace_index].XAxis.GetCurrentCoordinateCalculator().GetDataValue(xpolar);
            double b = sciChartSurface.RenderableSeries[_trace_index].YAxis.GetCurrentCoordinateCalculator().GetDataValue(ypolar);
};

This code gets mouse point coordinates, then it converts pixel coordinates to polar, and then (a,b) data are obtained with
GetCurrentCoordinateCalculator().GetDataValue(), but a and b have some strange values. I’ve tried just the opposite (from data value to pixel coordinate using GetCoordinate()), but it still doesn’t work. Any ideas? Is it possible to get data from pixel coordinates in polar chart?

Thanks in advance,
Juan

Version
v3.5.0.7128
  • You must to post comments
1
0

Hello Juan,

Sorry for long waiting.

If I get you properly you want get data value from pixel coordinate. So you just have to Get mouse point according to SciChart and
using MainGrid translate it according to ModifierSurface. You don’t have to calculate Polar calculations.

I made some code for you according to your sample to demonstrate how it should be.

        mouseClick = (s, arg) =>
        {

            var mousePoint = arg.GetPosition((UIElement)sciChartSurface);
            var mousePointAccordingToCoordinates = sciChartSurface.RootGrid.TranslatePoint(mousePoint,
                sciChartSurface.ModifierSurface);

            double a =
                sciChartSurface.RenderableSeries[0].XAxis.GetCurrentCoordinateCalculator()
                    .GetDataValue(mousePointAccordingToCoordinates .X);
            double b =
                sciChartSurface.RenderableSeries[0].YAxis.GetCurrentCoordinateCalculator()
                    .GetDataValue(mousePointAccordingToCoordinates .Y);
        };

Hope this will help.

Best regards,
Markiyan

  • You must to post comments
1
0

Hi there,

We found what was the issue but we will resolve it in version 4.3. Also we will add some note about that to the documentation.

We prepared code workaround for you until we fixed it:

mouseClick = (s, arg) =>
{                
    var mousePoint = arg.GetPosition(sciChart);
    var mousePointAccordingToCoordinates = sciChart.RootGrid.TranslatePoint(mousePoint, sciChart.ModifierSurface);

    var strategyManager = sciChart.Services.GetService<IStrategyManager>();
    var transformStrategy = strategyManager.GetTransformationStrategy();
    var transformPoint = transformStrategy.Transform(mousePointAccordigToCoordinates);

    var a = sciChart.XAxis.GetDataValue(transformPoint.X);
    var b = sciChart.YAxis.GetDataValue(transformPoint.Y);
};

Please try it out and let us know if the workaround works for you too.

Hope this helps,

Best regards,

Taras B.
SciChart Developer

  • You must to post comments
0
0

Hello Markiyan,

Thanks for your response.

I have implemented your code, but I still have strange values. In fact, I get the same X value in “mousePointAccordingToCoordinates” and in “a” variable. It seems that GetDataValue() has no effect. Also, when I insert a CursorModifier, I get the same value as well (it seems that this value is x pixel coordinate instead of dataseries value, see attached picture) Am I doing somethign wrong? Is there anything else to do?

Thanks!

Regards,
Juan

Images
  • Yuriy
    Hi Juan, we are looking into this issue. We’ll let you know once it’s investigated. Please bear with us untill that.
  • Juan Antonio Diaz
    Ok, thanks!
  • You must to post comments
0
0

Hi Taras,

Yes, your code works fine!
Thanks

Regards,
Juan

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.