getLabelCountX method

  1. @override
int getLabelCountX()
override

Gets how many labels the graph should display in X axis. If _initialLabelCountX is not supplied, which means labelCountX was not supplied in the constructor, the label counts is dynamic (depending on canvas width).

Implementation

@override
int getLabelCountX() {
  if (_initialLabelCountX != null) return _initialLabelCountX!;

  var divider = 75;
  if (ctx.canvas.width < 600) {
    divider = 75;
  } else if (ctx.canvas.width < 1200) {
    divider = 100;
  } else {
    divider = 200;
  }

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