layout method

  1. @override
void layout(
  1. LayoutExpansion parentLayoutExpansion
)

Lays out the area containing the Y axis labels.

Out of calls to all container's layout by the parent ChartTopContainer.layout, the call to this object's layout is second, after LegendContainer.layout. This YContainer.layout calculates YContainer's labels width, the width taken by this container for the Y axis labels.

The remaining horizontal width of ChartTopContainer.chartArea minus YContainer's labels width provides remaining available horizontal space for the GridLinesContainer and XContainer.

Implementation

@override
void layout(LayoutExpansion parentLayoutExpansion) {
  // axisYMin and axisYMax define end points of the Y axis, in the YContainer
  //   coordinates.
  // todo 0-layout: layoutExpansion - max of yLabel height, and the 2 paddings

  // todo 0-layout flip Min and Max and find a place which reverses
  // Note: axisYMin > axisYMax ALWAYS.
  //       axisYMin should be called axisYBottom, and axisYMin should be called axisYTop,
  //       expressing the Y axis starts on top = 0.0, ends on bottom = 400 something.
  double axisYMin =
      parentLayoutExpansion.height - (chartTopContainer.data.chartOptions.xContainerOptions.xBottomMinTicksHeight);

  // todo 0-layout: max of this and some padding
  double axisYMax = _yLabelsMaxHeightFromFirstLayout / 2;

  // Even when Y container not shown and painted, this._yLabelContainers is needed later in yLabelsMaxHeight;
  //   and chartTopContainer.yLabelsCreator is needed in [PointsColumns.scale],
  //   so we cannot just skip layout completely at the beginning.
  if (!chartTopContainer.data.chartOptions.yContainerOptions.isYContainerShown) {
    _yLabelContainers = List.empty(growable: false);
    chartTopContainer.yLabelsCreator = _createLabelsAndPositionIn(axisYMin, axisYMax);
    return;
  }

  _createLabelsAndLayoutThisContainerWithLabels(axisYMin, axisYMax);

  double yLabelsContainerWidth =
      _yLabelContainers.map((yLabelContainer) => yLabelContainer.layoutSize.width).reduce(math.max) +
          2 * chartTopContainer.data.chartOptions.yContainerOptions.yLabelsPadLR;

  layoutSize = ui.Size(yLabelsContainerWidth, parentLayoutExpansion.height);
}