I have a realtime linear chart with multiple x/y axes. When I am zooming the surface, I am changing the X/Y AutoRange mode from AutoRange.Always to AutoRange.Never, which allows me to have Modifiers zooming and panning on a realtime AutoRange chart.
After, I want to re-enable AutoRange when ZoomExtents (double click) occurs.
See below:
public class ZoomExtentsXAxesModifier : ZoomExtentsModifier { private Point _startPoint; private bool _isMouseDoubleClick; public override void OnModifierMouseDown(ModifierMouseArgs e) { base.OnModifierMouseDown(e); if(e.Modifier == MouseModifier.Ctrl) return; if (e.MouseButtons == MouseButtons.Left) _startPoint = e.MousePoint; _isMouseDoubleClick = false; } public override void OnModifierMouseUp(ModifierMouseArgs e) { base.OnModifierMouseUp(e); if (e.Modifier == MouseModifier.Ctrl) return; if (e.MouseButtons != MouseButtons.Left || _startPoint == e.MousePoint || _isMouseDoubleClick) return; using (ParentSurface.SuspendUpdates()) { foreach (var axise in XAxes.Where(axise => axise.AutoRange != AutoRange.Never)) { axise.AutoRange = AutoRange.Never; axise.Zoom(_startPoint.X, e.MousePoint.X); } foreach (var axise in YAxes.Where(axise => axise.AutoRange != AutoRange.Never)) { axise.AutoRange = AutoRange.Never; axise.Zoom(_startPoint.Y, e.MousePoint.Y); } } } public override void OnModifierDoubleClick(ModifierMouseArgs e) { base.OnModifierDoubleClick(e); if (e.Modifier == MouseModifier.Ctrl) return; foreach (var axise in XAxes) axise.AutoRange = AutoRange.Always; foreach (var axise in YAxes) axise.AutoRange = AutoRange.Always; _isMouseDoubleClick = true; } }
For the one chart it is working ok, but when I have more then 2 charts, it is zooming incorect? What can I solve this? I need to recieve one event, when user is zooming, panning or resizing chart. Is it possible?
Thanks,
Arthur
- Arthur Romanov asked 11 years ago
- You must login to post comments
Hi,
Please, try translating the mouse point relative to ModifierSurface before using it. Refer to the following code:
_startPoint = GetPointRelativeTo(e.MousePoint, ModifierSurface);
Thing are done in this way in modifiers code. Also, maybe you need to play around with the ReceiveHandledEvents property (if your modifiers are connected together via MouseEventGroup).
Regarding the second question, we don’t provide such an event, but there is the SciChartSurface.Rendered event, which will be fired after each redraw (initiated either by pan, or zoom, or resize operation). Alternatively, you can subscribe to the AxisBase.VisibleRangeChanged event or extend modifiers classes and introduce your own events for them. So in this case you need to subscribe to the SizeChanged event.
Hope this helps,
Best regards,
Yuriy
- Yuriy Zadereckiy answered 11 years ago
-
Thank you!!!
- You must login to post comments
You can also check if the mouse is on a specific Axis, or on the main chart area by using this technique: ChartModifierBase Get Notification of MouseDown on Axis or Chart
We also explain how to translate points relative to the central chart area (the Modifier Surface) here: ChartModifierBase OnModifierMouseDown reports coordinates incorrectly.
Hope this helps!
Andrew
- Andrew Burnett-Thompson answered 10 years ago
- You must login to post comments
Please login first to submit.