onHintTick method

  1. @protected
void onHintTick()

Shift domain viewport on hint animation ticks.

Implementation

@protected
void onHintTick() {
  final percent = hintAnimationPercent;

  final scaleFactor = _lerpDouble(
      _initialViewportScalingFactor, _targetViewportScalingFactor, percent);

  var translatePx = _lerpDouble(
      _initialViewportTranslatePx, _targetViewportTranslatePx, percent);

  // If there is a scale factor animation, need to scale the translatePx so
  // the animation appears to be zooming in on the viewport when there is no
  // [maxHintTranslate] provided.
  //
  // If there is a translate hint, the animation will still first zoom in
  // and then translate the [maxHintTranslate] amount.
  if (_initialViewportScalingFactor != _targetViewportScalingFactor) {
    translatePx = translatePx * percent;
  }

  final chart = this.chart!;
  final domainAxis = chart.domainAxis!;
  domainAxis.setViewportSettings(scaleFactor, translatePx,
      drawAreaWidth: chart.drawAreaBounds.width);

  if (percent >= 1.0) {
    stopHintAnimation();
    chart.redraw();
  } else {
    chart.redraw(skipAnimation: true, skipLayout: true);
  }
}