layout method

  1. @override
void layout(
  1. Rectangle<int> componentBounds,
  2. Rectangle<int> drawAreaBounds
)
override

Layout this component.

Implementation

@override
void layout(Rectangle<int> componentBounds, Rectangle<int> drawAreaBounds) {
  super.layout(componentBounds, drawAreaBounds);

  // We are purposely clearing the viewport starting domain and data size
  // post layout.
  //
  // Originally we set a flag in [setScaleViewport] to recalculate viewport
  // settings on next scale update and then reset the flag. This doesn't work
  // because chart's measure cycle provides different ranges to the scale,
  // causing the scale to update multiple times before it is finalized after
  // layout.
  //
  // By resetting the viewport after layout, we guarantee the correct range
  // was used to apply the viewport and behaviors that update the viewport
  // based on translate and scale changes will not be affected (pan/zoom).
  (scale! as OrdinalScale).setViewport(null, null);
}