SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & 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

When a user clicks on Axis (x or y), ChartModifierBase.OnModifierMouseDown is called. As axis are outside of chart zoom area, this should not be called. Is there anyway to know that ChartModifierBase.OnModifierMouseDown is on axis and not on chart area?

  • You must to post comments
0
0

Hi Manish,

As modifiers can perform operations on the axes, its correct behaviour that ChartModifierBase receives an OnModifierMouseDown event when the mouse is clicked on an axis.

Internally, to check whether the mouse point is inside the main chart area (i.e. not on an axis), RubberBandXyZoomModifier has this code:

public override void OnModifierMouseDown(ModifierMouseArgs e)
{
    if (_isDragging || e.MouseButtons != MouseButtons.Left)
        return;

    var modifierSurfaceBounds = ModifierSurface.GetBoundsRelativeTo(RootGrid);
    bool isClickOnChart = modifierSurfaceBounds.Contains(e.MousePoint);

    // Exit if the mouse down was outside the bounds of the ModifierSurface
    if (!isClickOnChart)
        return;

    // ... 
}

It sounds like you are creating a custom modifier. If so please be aware that all mouse points that are sent to the OnModifierMouse* methods are relative to the parent SciChartSurface.RootGrid. If you wanted to get a mouse point relative to the chart area itself, you can use this code:

    // Translate the mouse point (which is in RootGrid coordinates) relative to the ModifierSurface
    // This accounts for any offset due to left Y-Axis
    var ptTrans = RootGrid.TranslatePoint(e.MousePoint, ModifierSurface);
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.