SciChart 缩小限制

Limit for zooming out in SciChart

我有一个图表,需要在 X 轴上缩放和平移。它有一系列标记的数据点,其想法是能够在缩放时放大和水平移动图形。 我正在使用 PinchZoomModifier 和 TouchPanModifier 来实现这一点,并且它基本上可以正常工作。 但是应该不可能缩小图表以查看我的数据点范围之外的内容,因为它在我的上下文中没有意义。我怎样才能做到这一点?

我不知道您的目标平台是什么,但我假设是 WPF(基于之前的问题历史记录)。

您可以使用此处针对 Clipping the Axis.VisibleRange on Zoom and Pan 的一种技术来限制缩放。

所有SciChart平台都有类似的方法来裁剪或限制VisibleRange。例如,SciChart iOS has the VisibleRangeLimit API and SciChart Android has the MinimalZoomConstrain API

披露:我是 scichart 项目的技术负责人

您可以通过重写 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)
    }
  }
}