effectiveDataLabelAlignment method

  1. @override
ChartDataLabelAlignment effectiveDataLabelAlignment(
  1. ChartDataLabelAlignment alignment,
  2. ChartDataPointType position,
  3. ChartElementParentData? previous,
  4. ChartElementParentData current,
  5. ChartElementParentData? next,
)
override

Implementation

@override
ChartDataLabelAlignment effectiveDataLabelAlignment(
    ChartDataLabelAlignment alignment,
    ChartDataPointType position,
    ChartElementParentData? previous,
    ChartElementParentData current,
    ChartElementParentData? next) {
  final int index = current.dataPointIndex;
  if (position == ChartDataPointType.open) {
    final num open = openValues[index];
    final num close = closeValues[index];
    return open <= close
        ? ChartDataLabelAlignment.top
        : ChartDataLabelAlignment.bottom;
  } else if (position == ChartDataPointType.close) {
    final num open = openValues[index];
    final num close = closeValues[index];
    return close <= open
        ? ChartDataLabelAlignment.top
        : ChartDataLabelAlignment.bottom;
  }

  return alignment == ChartDataLabelAlignment.auto
      ? ChartDataLabelAlignment.outer
      : alignment;
}