Pre loader

Left clicking within one chart (SciChartSurface) selects a series on another chart when using shared MouseEventGroup and when using SeriesSelectionModifier

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

Answered
0
0

Hi,

I have 2 separate charts (SciChartSurface) and my goal is to enable mouse selection of a series on only the chart surface that contains the series. I do not share renderable series and not even data series between different chart surfaces. I am not sure why a series on the second chart surface is selected when I click on an area within the first chart surface. How can I prevent this from happening?

Could it be this is a bug in that SeriesSelectionModifier checks for hitpoints beyond the chart surface on which the mouse hit occurred? I verified and this problem only occurs when sharing Chart Modifiers via MouseManager. Attaching the MouseManager.MouseEventGroup to each individual modifier does not seem to work, it looks like it has to be attached to “ModifierGroup”. So I am still stuck with this problem.

<s:SciChartSurface.ChartModifier>
            <s:ModifierGroup s:MouseManager.MouseEventGroup="MyMouseEventGroup">

                <s:SeriesSelectionModifier ReceiveHandledEvents="True">
                    <s:SeriesSelectionModifier.SelectedSeriesStyle>
                        <Style TargetType="s:BaseRenderableSeries">
                            <Setter Property="StrokeThickness" Value="10"/>
                        </Style>
                    </s:SeriesSelectionModifier.SelectedSeriesStyle>
                </s:SeriesSelectionModifier>

                <s:RubberBandXyZoomModifier ReceiveHandledEvents="True" IsAnimated = "False" IsXAxisOnly = "True" ExecuteOn = "MouseRightButton"/>
                <s:CursorModifier ReceiveHandledEvents="True" SourceMode="AllSeries" ShowAxisLabels="True" />
                <s:ZoomPanModifier ReceiveHandledEvents="True" XyDirection="XYDirection" ClipModeX = "ClipAtExtents" ExecuteOn ="MouseLeftButton"/>
                <s:MouseWheelZoomModifier ReceiveHandledEvents="True" XyDirection = "XDirection"/>
                <s:ZoomExtentsModifier ReceiveHandledEvents="True" IsAnimated = "False" ExecuteOn = "MouseDoubleClick"/>
                <s:LegendModifier ReceiveHandledEvents="True" Name="GeneralLegend" ShowLegend="True" LegendPlacement ="Inside" GetLegendDataFor="AllSeries" Margin="10" LegendItemTemplate="{StaticResource LegendItemTemplate}"/>


            </s:ModifierGroup>
        </s:SciChartSurface.ChartModifier>
  • You must to post comments
Best Answer
0
0

Hi Matt,

This is a side-effect of our MouseManager.MouseEventGroup, which shares mouse events across the chart. The SeriesSelectionModifier in chart B receives the event from chart A and may select a series if it exists on the X-Y point under the mouse.

To disable this, simply set SeriesSelectionModifier.ReceiveHandledEvents = false. Secondary events are already handled by the master chart, so setting this flag will cause SeriesSelectionModifier to ignore events from other charts when MouseManager.MouseEventGroup is used.

Note: This can cause issues with order of modifiers, but I notice that your SeriesSelectionModifier is first in the list, so in your case, there should be no side-effects.

EDIT

As matt points out in comments, this causes the second chart to never have selection of series. A better and more complete way to achieve this is to subclass SeriesSelectionModifier and prevent slave (secondary) mouse events from working:

public class SeriesSelectionModifierEx : SeriesSelectionModifier
{

        /// <summary>
        /// When overriden in a derived class, called to handle the Slave <see cref="ChartModifierBase" /> MouseMove event
        /// </summary>
        /// <param name="mousePoint">The current Mouse-point</param>
        protected override void HandleSlaveMouseEvent(Point mousePoint)
        {
            // Deliberately do not call HandleMasterMouseEvent
            // HandleMasterMouseEvent(mousePoint);
        }
}

Best regards,
Andrew

  • bbmat
    I tried that already but unfortunately with this settting only the first chart allows selection of series. When pointing with the mouse on a series on any other chart the selection does not work.
  • Andrew Burnett-Thompson
    You are right! I have updated my answer with a code sample. Please take a look
  • bbmat
    That works very nicely, thanks.
  • You must to post comments
Showing 1 result
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