calculateOffsets method

  1. @override
void calculateOffsets()
override

Calculates the offsets of the chart to the border depending on the position of an eventual legend or depending on the length of the y-axis and x-axis labels and their position

Implementation

@override
void calculateOffsets() {
  super.calculateOffsets();
  // prevent nullpointer when no data set
  if (getData() == null) return;

  double diameter = getDiameter();
  double radius = diameter / 2;

  MPPointF c = getCenterOffsets();

  double shift = (getData() as PieData).getDataSet().getSelectionShift()!;

  // create the circle box that will contain the pie-chart (the bounds of
  // the pie-chart)
  _circleBox = Rect.fromLTRB(c.x - radius + shift, c.y - radius + shift,
      c.x + radius - shift, c.y + radius - shift);

  MPPointF.recycleInstance(c);
}