Pre loader

Synching ModifierGroup with MouseManager.MouseEventGroup problem - Zoom works, Pan doesn't

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

Hi All,

I’m having a problem which is probably due to lack of understanding of how the events system works. Having said that I’ve read other entries that suggest there’s a bit of confusion about MouseEventGroup – either way I can’t get this to do what I want and don’t understand why it isn’t working. Anyway – the problem:

I have XAML definition of a chart surface that includes the following:

<s:SciChartSurface.ChartModifier>
    <s:ModifierGroup s:MouseManager.MouseEventGroup="appLinkedChartGroup">
        <s:RubberBandXyZoomModifier x:Name="rubberBandZoomModifier" IsEnabled="True" IsXAxisOnly="False" IsAnimated="True" ExecuteOn="MouseRightButton" ZoomExtentsY="False" ReceiveHandledEvents="True"/>
        <s:ZoomPanModifier x:Name="zoomPanModifier" ExecuteOn="MouseLeftButton" ZoomExtentsY="False" ReceiveHandledEvents="True" IsEnabled="True"/>
        <s:ZoomExtentsModifier x:Name="zoomExtentsModifier" ExecuteOn="MouseDoubleClick" ReceiveHandledEvents="True"/>
        <s:MouseWheelZoomModifier ActionType="Zoom" XyDirection="XYDirection" ReceiveHandledEvents="True"/>
    </s:ModifierGroup>
</s:SciChartSurface.ChartModifier>

We want to offer a feature that takes the plotted sets of series and dynamically split them into separate charts and have all the zooming and panning facilities synched so all charts are manipulated identically.

In my Code behind constructor I set the MouseEventGroup(0 as follows:

this.sciChartSurface.ChartModifier.MouseEventGroup = “appLinkedChartGroup”;

so all created charts should now be connected.

However : When I run the code the RubberBandXyZoomModifier, ZoomExtentsModifier and MouseWheelZoomModifier all work as expected but the ZoomPanModifier only pans the chart that was clicked on (even though the desired effect can be achieved with a shift mousewheel action)

Anybody got any ideas????

As an aside – if I want to link the axis scroll bars (defined outside the ChartModifier() group with the X and Y axis) – How would I do that?

Thanks

  • You must to post comments
1
0

Hi Stuart,

The reason for this is when you use MouseEventGroup, the mouse event is marked as handled by the parent chart, and the child chart cannot handle the event. You may need to set ChartModifier.ReceiveHandledEvents = true on modifiers which are not working correctly to enable them.

Take a look at this article: How to Add Mouse Interaction to SciChart

ChartModifier Precedence (Handled Events)

ChartModifiers obey a precedence, rather like WPF RoutedEvents. If you have a number of modifiers in a SciChartSurface, then the first
modifier that handles an event marks it as e.Handled. Subsequent
modifiers will not receive the event.

For instance, consider the following code:

<s:SciChartSurface>
      <s:SciChartSurface.ChartModifier>
          <!—Groups many ChartModifiers on a single chart with mouse-event precedence -->
          <s:ModifierGroup>
               <!—Provides zoom on mouse-drag, handles MouseUp on successful zoom-->
               <s:RubberBandXyZoomModifier/>
               <!—Selects Series on mouse-up -->
               <s:SeriesSelectionModifier/>
          </s:ModifierGroup>
      </s:SciChartSurface.ChartModifier> </s:SciChartSurface>
  

If you drag the chart, then the series will not be selected too, because the RubberBandXyZoomModiifer marks MouseUp as Handled. The
SeriesSelectionModifier relies on MouseUp to select. If the event is
handled then it will not select.

So far this is all intuitive and good. But what about this case?

<s:SciChartSurface>
      <s:SciChartSurface.ChartModifier>
          <!—Groups many ChartModifiers on a single chart with mouse-event
  precedence -->
          <s:ModifierGroup>
               <!—Provides pan on mouse-drag, handles MouseDown, MouseMove on
  pan-->
               <s:ZoomPanModifier/>
               <!—Provides a cursor on mouse-move, requires MouseMove event
  -->
               <s:CursorModifier/>
          </s:ModifierGroup>
      </s:SciChartSurface.ChartModifier>
  </s:SciChartSurface>
  

Oh dear … Now if you mouse-drag the chart the cursor will not move with the mouse. Why is this occurring? Because the ZoomPanModiifer
marks the MouseMove event as handled, the CursorModifier never
receives it. This functionality is intended to prevent bad
interactions between modifiers such as selection and zoom on click,
but in this case it is hindering us.

Working around event handling with ReceiveHandledEvents

The solution to the above problem is to set ReceiveHandledEvents=True on a modifier. This way the modifier will receive *all events, even
those marked as handled. Try the following code for instance:*

<s:SciChartSurface>
      <s:SciChartSurface.ChartModifier>
          <!—Groups many ChartModifiers on a single chart with mouse-event
  precedence -->
          <s:ModifierGroup>
               <!—Provides pan on mouse-drag, handles MouseDown, MouseMove on
  pan-->
               <s:ZoomPanModifier/>
               <!—Provides a cursor on mouse-move, requires MouseMove event
  -->
               <s:CursorModifier ReceiveHandledEvents=”True”/>
          </s:ModifierGroup>
      </s:SciChartSurface.ChartModifier>
  </s:SciChartSurface>
  

Be careful with this flag though as it could enable event handling where it should not occur.

  • You must to post comments
0
0

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support-dev.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

  • Andrew Burnett-Thompson
    It does work - you have to indent with tab using notepad++. Officially it should not work but it does! public void Foo() { this.Check().This().Out(); }
  • Andrew Burnett-Thompson
    I'm not sure the YAxisDragModifier is enabled for multi-chart synchronization. It makes no sense for it to. Unless you intended to have the YAxis.VisibleRanges exactly the same, in which case, a TwoWay binding would be a better way to achieve this.
  • Stuart McCullough
    "It makes no sense for it to" - couldn't agree more! Unfortunately we're dealing with people who tell you what they want on a "current thought in their head" basis and never string all the thoughts together to see a big picture. Never mind, I'll keep asking the questions for now anyway :-) Oh! and I take it the previous comment code snippet about tab in Notepad++ belongs to another post?
  • Andrew Burnett-Thompson
    You could override this behaviour if you wanted to by creating a custom chart modifier, but please do pass on - that it is intentional on our part to not link YAxisDragModifier in multiple charts. Our chart-modifiers are relatively self contained and we do provide an API for creating your own / deriving from ours. Take a look at https://www.scichart.com/questions/question/panning-an-axis-by-dragging-the-mouse which showcases a custom pan modifier. The property to tell if a mouse event came from this chart, or another chart is e.Master (where e == ModifierMouseArgs). Building your own custom modifier here is a bit OTT though, I would just suggest maybe allow YAxisDrags to be decoupled :) Best regards, Andrew
  • Stuart McCullough
    I refer the honourable gentleman back to my previous comment of "couldn't agree more" and thank you for the additional information about it being intentional. This is a very much rushed project and we haven't got time to put non-standard behaviour in. Anyway - the point of going to SciChart was for us to adopt some standard behaviour so I can hardly see them arguing for something non-standard lol
  • You must to post comments
0
0

Hi Andrew,

I saw that article on my initial hunt for information – and it makes perfect sense, but I’ve already set all the modifiers to ReceiveHandledEvents=”True” as can be seen in my original code snippets.

Is there somewhere else I should be looking in the XAML that might be swallowing the relevant events?

/Stuart

  • Andrew Burnett-Thompson
    No nothing. However ... I wonder - have you bound the XAxis.VisibleRanges of all the synchronized charts together as well? This is also required when synchronizing multiple charts. Take a look at our demo source for guidance: https://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/ZoomAndPanAChart/SynchronizeMouseAcrossCharts.xaml
  • Stuart McCullough
    Hi Andrew - You may be on to something there as I haven't bound the axis visible ranges. I'll have to come back to this one as we need to change a lot of fundamentals e.g. currently the xaxis is a datetime but needs to change to a numeric but that isn't going to happen in this sprint. Apart from that, I believe the behaviour is actually what they need and they will agree eventually, but for now it's just bugging me I can't get it to do what I want it too :-( Aside from that - I now need to work out why it crashes when there aren't any child charts to pass the mouse events on to! I'll post a new topic when I get the data together.
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies