iOS & macOS Charting Documentation - SciChart iOS & macOS Charts SDK v4.x

The SCIZoomPanModifier

SciChart iOS provides an inertial scrolling / panning behavior via the SCIZoomPanModifier, available out of the box.

Besides common features which are inherited from the SCIChartModifierBase class, the SCIZoomPanModifier allows to control its specific features via the following properties:

There are several modes defined by the SCIClipMode enumeration:

  • None - Means you can pan right off the edge of the data into uncharted space.
  • StretchAtExtents - Causes a zooming (stretch) action when you reach the edge of the data.
  • ClipAtMin - Forces the panning operation to stop suddenly at the minimum of the data, but expand at the maximum.
  • ClipAtMax - Forces the panning operation to stop suddenly at the maximum of the data, but expand at the minimum.
  • ClipAtExtents - Forces the panning operation to stop suddenly at the extents of the data.

There are two touch events defined by the SCIZoomState enumeration, which can be used to get or set current interaction state of the surface:

  • AtExtents indicates that the zoom level is at extents.
  • UserZooming indicates User has initiated a Zoom operation.

The allowsGestureOnAxis property enables or disables the application of modifiers, such as pan and pinch gestures, specifically on axis elements. This property controls whether dragging or pinching gestures performed by the user on the axis will trigger the associated modifier actions.

  • true- Enables the modifier actions (pan, pinch) on the axis.
  • false - Disables the modifier actions (pan, pinch) on the axis. The default value for allowsGestureOnAxis is false.

It is particularly useful in scenarios where you may want to restrict or allow user interactions specifically on the axis, while still allowing interactions elsewhere on the chart surface.

Adding a SCIZoomPanModifier to a Chart

Any Chart Modifier can be added to a SCIChartSurface via theISCIChartSurface.chartModifiers property and SCIZoomPanModifier is no difference:

// Assume a surface has been created and configured somewhere id<ISCIChartSurface> surface; // Create a Modifier SCIZoomPanModifier *zoomPanModifier = [SCIZoomPanModifier new]; zoomPanModifier.direction = SCIDirection2D_XDirection; zoomPanModifier.clipModeX = SCIClipMode_StretchAtExtents; zoomPanModifier.clipModeY = SCIClipMode_None; zoomPanModifier.zoomExtentsY = YES; // Add the modifier to the surface [self.surface.chartModifiers add:zoomPanModifier];
// Assume a surface has been created and configured somewhere let surface: ISCIChartSurface // Create a Modifier let zoomPanModifier = SCIZoomPanModifier() zoomPanModifier.direction = .xDirection zoomPanModifier.clipModeX = .stretchAtExtents zoomPanModifier.clipModeY = .none zoomPanModifier.zoomExtentsY = true // Add the modifier to the surface self.surface.chartModifiers.add(zoomPanModifier)
// Assume a surface has been created and configured somewhere IISCIChartSurface surface; // Create a Modifier var zoomPanModifier = new SCIZoomPanModifier(); zoomPanModifier.Direction = SCIDirection2D.XDirection; zoomPanModifier.ClipModeX = SCIClipMode.StretchAtExtents; zoomPanModifier.ClipModeY = SCIClipMode.None; zoomPanModifier.ZoomExtentsY = true; // Add the modifier to the surface Surface.ChartModifiers.Add(zoomPanModifier);

Additional Properties

Restricting Interaction to a Single Direction (X or Y)

Interaction for this modifier can be limited to a specific axis direction by configuring the direction property. Set direction to one of the SCIDirection2D values to restrict the modifier to the X-axis, Y-axis, or both.

zoomPanModifier.direction = SCIDirection2D_XyDirection; // Allows interaction in both directions zoomPanModifier.direction = SCIDirection2D_XDirection; // X-axis only zoomPanModifier.direction = SCIDirection2D_YDirection; // Y-axis only
zoomPanModifier.direction = .xyDirection // Allows interaction in both directions zoomPanModifier.direction = .xDirection // X-axis only zoomPanModifier.direction = .yDirection // Y-axis only

Include/Exclude Certain Axis from Pan Zoom

The SCIZoomPanModifier allows you to include or exclude certain axis from the pan zoom operation. This feature is especially useful in multiple-axis charts, where you may want to pan only selected axes while keeping others fixed. By default all axis are included, to exclude one or more X or Y axis, set the following property:

// Exclude a specific axis from the pan zoom operation [zoomPanModifier includeXAxis:xAxis isIncluded:NO]; [zoomPanModifier includeYAxis:yAxis isIncluded:NO]; // Include a specific axis from the pan zoom operation [zoomPanModifier includeXAxis:xAxis isIncluded:YES]; [zoomPanModifier includeYAxis:yAxis isIncluded:YES]; // Reset flags [zoomPanModifier includeAll]; [zoomPanModifier excludeAll];
// Exclude a specific axis from the pan zoom operation zoomPanModifier.includeXAxis(xAxis, isIncluded: false) zoomPanModifier.includeYAxis(yAxis, isIncluded: false) // Include a specific axis from the pan zoom operation zoomPanModifier.includeXAxis(xAxis, isIncluded: true) zoomPanModifier.includeYAxis(yAxis, isIncluded: true) // Reset flags zoomPanModifier.includeAll() zoomPanModifier.excludeAll()

NOTE: To learn more about features available, please visit the Chart Modifier APIs article.

NOTE: The setDisableTouchEvent: method is used to allow or prevent userInteraction of a surface view when it is inside a scroll view. It accepts disableTouchEvent, a Boolean value that determines whether user touch events are ignored or not. YES - Touch events will be ignored (i.e., user interaction is disabled). NO - Touch events will be recognized (i.e., user interaction is enabled).