I have a graph, that needs to be zoomed and panned on the X axis. It has a range of labeled data points, and the idea is to be able to zoom in and move the graph horizontally when zoomed. I'm using a PinchZoomModifier and a TouchPanModifier to achieve this, and it works mostly correctly. But it shouldn't be possible to zoom out of the graph to see what's outside of my data point range, as it doesn't make sense in my context. How can I achieve this?
Asked
Active
Viewed 741 times
2 Answers
0
I don't know what platform you're targetting, but I'm assuming WPF (based on previous question history).
You can limit zoom by using one of the techniques here for Clipping the Axis.VisibleRange on Zoom and Pan.
All the SciChart platforms have similar methods to clip or limit VisibleRange. For instance, SciChart iOS has the VisibleRangeLimit API and SciChart Android has the MinimalZoomConstrain API
Disclosure: I am the tech lead on the scichart projects

Dr. Andrew Burnett-Thompson
- 20,980
- 8
- 88
- 178
-
1Hi, sorry for this, I solved the problem in the mean time, I just forgot to close this question. – Shaggydog Oct 25 '16 at 11:39
0
You can solve this problem with overriding SCIPinchZoomModifier
:
class CustomZoomModifier: SCIPinchZoomModifier {
var maxValue = 3.0
var minValue = -1.0
var currentXZoom = 0.0
var currentYZoom = 0.0
override func performZoom(at mousePoint: CGPoint, xValue: Double, yValue: Double) {
var newXValue = 0.0
var newYvalue = 0.0
if xValue + currentXZoom <= maxValue && xValue + currentXZoom >= minValue {
newXValue = xValue
currentXZoom += xValue
}
if yValue + currentYZoom <= maxValue && yValue + currentYZoom >= minValue {
newYvalue = yValue
currentYZoom += yValue
}
if newXValue != 0.0 || newYvalue != 0.0 {
super.performZoom(at: mousePoint, xValue: newXValue, yValue: newYvalue)
}
}
}

Siphalor
- 712
- 5
- 16

Dariia Prokopovych
- 869
- 7
- 4