effectiveDataLabelAlignment method
ChartDataLabelAlignment
effectiveDataLabelAlignment(
- ChartDataLabelAlignment alignment,
- ChartDataPointType position,
- ChartElementParentData? previous,
- ChartElementParentData current,
- 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 lower = lowerValues[index];
final num upper = upperValues[index];
return lower >= upper
? ChartDataLabelAlignment.top
: ChartDataLabelAlignment.bottom;
} else if (position == ChartDataPointType.close) {
final num lower = lowerValues[index];
final num upper = upperValues[index];
return upper <= lower
? ChartDataLabelAlignment.top
: ChartDataLabelAlignment.bottom;
} else if (position == ChartDataPointType.outliers) {
return ChartDataLabelAlignment.bottom;
} else if (position == ChartDataPointType.median) {
return ChartDataLabelAlignment.middle;
}
return alignment == ChartDataLabelAlignment.auto
? ChartDataLabelAlignment.outer
: alignment;
}