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>
- bbmat asked 9 years ago
- last edited 9 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 9 years ago
- last edited 9 years ago
-
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.
-
You are right! I have updated my answer with a code sample. Please take a look
-
That works very nicely, thanks.
- You must login to post comments
Please login first to submit.