setViewportSettings method

void setViewportSettings(
  1. double viewportScale,
  2. double viewportTranslatePx, {
  3. int? drawAreaWidth,
  4. int? drawAreaHeight,
})

Configures the zoom and translate.

viewportScale is the zoom factor to use, likely >= 1.0 where 1.0 maps the complete data extents to the output range, and 2.0 only maps half the data to the output range.

viewportTranslatePx is the translate/pan to use in pixel units, likely <= 0 which shifts the start of the data before the edge of the chart giving us a pan.

drawAreaWidth is the width of the draw area for the series data in pixel units, at minimum viewport scale level (1.0). When provided, drawAreaHeight is the height of the draw area for the series data in pixel units, at minimum viewport scale level (1.0). When provided, viewportTranslatePx will be clamped such that the axis cannot be panned beyond the bounds of the data.

Implementation

void setViewportSettings(double viewportScale, double viewportTranslatePx,
    {int? drawAreaWidth, int? drawAreaHeight}) {
  // Don't let the viewport be panned beyond the bounds of the data.
  viewportTranslatePx = _clampTranslatePx(viewportScale, viewportTranslatePx,
      drawAreaWidth: drawAreaWidth, drawAreaHeight: drawAreaHeight);

  scale!.setViewportSettings(viewportScale, viewportTranslatePx);
}