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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

I am trying to display data values on mouse move as displayed by green rectangle in attached image. Values displayed are not correct. I use following logic to calculate point values on mouse move.

internal void UpdateCoordinates(System.Windows.Point point)
{
double xD = xAxis.MajorDelta;
int xDecimals = 1;
if (xD < 1)
{
xDecimals = (int)Math.Round(Math.Abs(Math.Log10(xD))) + 1;
}

        double x = Math.Round(xAxis.GetCurrentCoordinateCalculator().GetDataValue(point.X), xDecimals);

        double yD = yAxis.MajorDelta;
        int yDecimals = 1;
        if (yD &lt; 1)
        {
            yDecimals = (int)Math.Round(Math.Abs(Math.Log10(yD))) + 1;
        }

        double y = Math.Round(yAxis.GetCurrentCoordinateCalculator().GetDataValue(point.Y), yDecimals);

        coordinates.Visibility = System.Windows.Visibility.Visible;
        coordinates.Content = string.Format(&quot;({0},{1})&quot;, x, y);
    }
Images
  • You must to post comments
0
0

Hi Manish,

Which element’s mousemove event are you subscribing to? If you subscribed to SciChartSurface.MouseMove then please note the Mouse point will be relative to the SciChartSurface control (which includes the left YAxis), not relative to the chart pane.

To get the correct output you will have to transform the mouse point using the following code:

// Transforms a mouse point from the RootGrid (which hosts the ScichartSurface) 
// relative to the ModifierSurface (which is overlaid on the chart area only)
var transformedPoint = sciChartSurface.RootGrid.TranslatePoint(inputPoint, sciChartSurface.ModifierSurface);

Now that the mouse point is relative to the ModifierSurface (which covers the chart viewport area) the hit-test will work.

You can see another example of this transformation in the following example:
http://http://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/InspectDatapoints/HitTestDatapoints.xaml

// Taken from example IWantTo/InspectDataPoints/HitTestDataPoints
private void SciChartSurfaceMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
   // Perform the hit test relative to the GridLinesPanel
   Point mousePoint = e.GetPosition(sciChartSurface.GridLinesPanel as UIElement);
}

Finally, it sounds to me like you are trying to replicate the behaviour of the RolloverModifier? Have you considered using this modifier instead in your code?

If you need some custom actions then creating a ChartModifier (that inherits or replaces RolloverModifier) might be the best way to go.

Feel free to post if you need further assistance.

Best regards,
Andrew

  • manishdoshi
    I am using OnModifierMouseMove on custom modifier that I have defined to get mouse move public override void OnModifierMouseMove(ModifierMouseArgs e)
  • Andrew
    Then this code which we use in the modifiers should work: public override void OnModifierMouseMove(ModifierMouseArgs e) { // Transforms a mouse point from the RootGrid (which hosts the ScichartSurface) // relative to the ModifierSurface (which is overlaid on the chart area only) var transformedPoint = RootGrid.TranslatePoint(e.MousePoint, ParentSurface.ModifierSurface); }
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.