我有一个图表,需要在 X 轴上进行缩放和平移。它具有一系列标记的数据点,其想法是能够放大并在缩放时水平移动图形。我正在使用 PinchZoomModifier 和 TouchPanModifier 来实现这一点,并且它工作正常。但是应该不可能缩小图表以查看我的数据点范围之外的内容,因为这在我的上下文中没有意义。我怎样才能做到这一点?
问问题
561 次
2 回答
0
我不知道你的目标是什么平台,但我假设 WPF(基于以前的问题历史)。
您可以使用此处用于在 Zoom 和 Pan 上裁剪 Axis.VisibleRange的技术之一来限制缩放。
所有 SciChart 平台都有类似的方法来剪辑或限制 VisibleRange。例如,SciChart iOS 有 VisibleRangeLimit API,SciChart Android 有 MinimalZoomConstrain API
披露:我是 scichart 项目的技术负责人
于 2016-10-19T15:38:10.660 回答
0
您可以通过覆盖来解决此问题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)
}
}
}
于 2018-01-03T13:43:48.110 回答