SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Hello,
I’ve got multiple charts stacked vertically, united in one mouse event group and I’ve hidden all X axes except for the bottom one.
Now I need CursorModifier axis label to always show on the last chart regardless of what chart is receiving mouse events.
If I override IsMaster in ModifierMouseArgs in the OnModifierMouseMove to always be true, I’ve got partly what I need, but then the Y label (and horizontal cursor line) also shows on all charts, which is undesired.
Could you please point me in the right direction on this?
Hi again,
OK, I modified it a bit and it seems to be working properly now. Please, try this code:
public class CursorModifierEx: CursorModifier { private bool _isMaster; public override void OnParentSurfaceRendered(SciChartRenderedMessage e) { base.OnParentSurfaceRendered(e); TryToRemoveRedundantParts(); } public override void OnModifierMouseMove(ModifierMouseArgs e) { _isMaster = e.IsMaster; var overrideArgs = new ModifierMouseArgs( e.IsMaster ? e.MousePoint : new Point(e.MousePoint.X, 0), e.MouseButtons, e.Modifier, e.Delta, true, e.Source ) { Handled = e.Handled }; base.OnModifierMouseMove(overrideArgs); TryToRemoveRedundantParts(); } private void TryToRemoveRedundantParts() { if (!_isMaster) { var cursorAxisLabel = GetCursorYAxisLabel(); if (YAxis.ModifierAxisCanvas.Children.Contains(cursorAxisLabel)) { YAxis.ModifierAxisCanvas.Children.Remove(cursorAxisLabel); } var crosshairsHorizLine = GetHorizontalCursorLine(); if (ModifierSurface.Children.Contains(crosshairsHorizLine)) { ModifierSurface.Children.Remove(crosshairsHorizLine); } } } private TemplatableControl GetCursorYAxisLabel() { return YAxis.ModifierAxisCanvas.Children.OfType<TemplatableControl>().FirstOrDefault(); } private Line GetHorizontalCursorLine() { return ModifierSurface.Children.OfType<Line>().FirstOrDefault(line => line.X1.CompareTo(0d) == 0); } }
If you find any incorrect behavior, maybe in this case it will be better to create new modifier(it’s not hard and doesn’t take you long) or modify source code of Cursor modifier a bit. Please, let us know if you need any further assistance!
Best regards,
Yuriy
Please login first to submit.