SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
How would I go about creating a modifier (or extending an existing one?) that will allow the user to doubleclick on the y-axis to set the y-axis extents to the y-values in the visible x-range? can I capture a doubleclick on the y-axis?
I would like to reserve the doubleclick on the surface for other features, that’s why I don’t use the zoomextents modifier.
Thank you for your question! Please check out our series on the ChartModifier API as a basis. This will talk you through the basics and also we have a series of example modifiers to show what this powerful API can do.
To detect if a click was on the YAxis, check out this article: ChartModifierBase Get Notification of MouseDown on Axis or Chart pane
Basically what I would suggest is to override ChartModifierBase.OnModifierDoubleClick and use the technique above to determine where the click was.
Finally, to Zoom to Extents programmatically, you can call the method SciChartSurface.ZoomExtentsY().
Hope this helps!
MyBase.OnModifierDoubleClick(e)If IsPointWithinBounds(e.MousePoint, ModifierSurface) Then Dim pt = GetPointRelativeTo(e.MousePoint, ModifierSurface) If ActivateAlert Then Dim workorderForm = New Workorder(pt.X, _measurementCollection, _mainViewModel, _mainWindow) workorderForm.Show() Else Dim timePlot = New TimeSeries(pt.X, _measurementCollection, _mainViewModel) timePlot.Show() End If End If End Sub
Thanks for the help, here is my code for others who might be interested:
Imports Abt.Controls.SciChart.ChartModifiers Imports Abt.Controls.SciChart.Visuals Public Class ZoomExtentsOnYAxisModifier Inherits ChartModifierBase Public Overrides Sub OnModifierDoubleClick(e As ModifierMouseArgs) MyBase.OnModifierDoubleClick(e) Dim isOnYAxis As Boolean = IsPointWithinBounds(e.MousePoint, YAxis) If isOnYAxis Then TryCast(ParentSurface, SciChartSurface).ZoomExtentsY() End If End Sub End Class
Please login first to submit.