calculateLegendOffsets method
Rect
calculateLegendOffsets(
- Rect offsets
)
Implementation
Rect calculateLegendOffsets(Rect offsets) {
offsets = const Rect.fromLTRB(0.0, 0.0, 0.0, 0.0);
// setup offsets for legend
if (legend != null && legend!.enabled && !legend!.drawInside) {
switch (legend!.orientation) {
case LegendOrientation.vertical:
switch (legend!.horizontalAlignment) {
case LegendHorizontalAlignment.left:
offsets = Rect.fromLTRB(
min(
legend!.neededWidth,
viewPortHandler!.getChartWidth() *
legend!.maxSizePercent) +
legend!.xOffset,
0.0,
0.0,
0.0);
break;
case LegendHorizontalAlignment.right:
offsets = Rect.fromLTRB(
0.0,
0.0,
min(
legend!.neededWidth,
viewPortHandler!.getChartWidth() *
legend!.maxSizePercent) +
legend!.xOffset,
0.0);
break;
case LegendHorizontalAlignment.center:
switch (legend!.verticalAlignment) {
case LegendVerticalAlignment.top:
offsets = Rect.fromLTRB(
0.0,
min(
legend!.neededHeight,
viewPortHandler!.getChartHeight() *
legend!.maxSizePercent) +
legend!.yOffset,
0.0,
0.0);
break;
case LegendVerticalAlignment.bottom:
offsets = Rect.fromLTRB(
0.0,
0.0,
0.0,
min(
legend!.neededHeight,
viewPortHandler!.getChartHeight() *
legend!.maxSizePercent) +
legend!.yOffset);
break;
default:
break;
}
}
break;
case LegendOrientation.horizontal:
switch (legend!.verticalAlignment) {
case LegendVerticalAlignment.top:
offsets = Rect.fromLTRB(
0.0,
min(
legend!.neededHeight,
viewPortHandler!.getChartHeight() *
legend!.maxSizePercent) +
legend!.yOffset,
0.0,
0.0);
break;
case LegendVerticalAlignment.bottom:
offsets = Rect.fromLTRB(
0.0,
0.0,
0.0,
min(
legend!.neededHeight,
viewPortHandler!.getChartHeight() *
legend!.maxSizePercent) +
legend!.yOffset);
break;
default:
break;
}
break;
}
}
return offsets;
}