getLabelCountY method

  1. @override
int getLabelCountY()
override

Gets how many labels the graph should display in Y axis. If _initialLabelCountY is not supplied, which means labelCountY was not supplied in the constructor, the label counts is dynamic (depending on canvas height).

Implementation

@override
int getLabelCountY() {
  if (_initialLabelCountY != null) return _initialLabelCountY!;

  var divider = 45;
  if (ctx.canvas.height.toDouble() < 600) {
    divider = 45;
  } else if (ctx.canvas.height.toDouble() < 1200) {
    divider = 80;
  } else {
    divider = 100;
  }

  return max((ctx.canvas.height.toDouble()/divider).truncate(), 2);
}