renderAxisLabels method

  1. @override
void renderAxisLabels(
  1. Canvas c
)
override

Draws the axis labels onto c. Does nothing when the axis or its labels are disabled.

Implementation

@override
void renderAxisLabels(ui.Canvas c) {
  if (!xAxis.isEnabled || !xAxis.isDrawLabelsEnabled) return;

  final yoffset = Utils.convertDpToPixel(xAxis.yOffset);

  paintAxisLabels.typeface = xAxis.typeface;
  paintAxisLabels.textSize = Utils.convertDpToPixel(xAxis.textSize);
  paintAxisLabels.color = xAxis.textColor;

  final pointF = MPPointF.getInstance(0, 0);
  switch (xAxis.position) {
    case XAxisPosition.TOP:
      pointF.x = 0.5;
      pointF.y = 1.0;
      drawLabels(c, viewPortHandler.contentTop - yoffset, pointF);
    case XAxisPosition.TOP_INSIDE:
      pointF.x = 0.5;
      pointF.y = 1.0;
      drawLabels(
        c,
        viewPortHandler.contentTop + yoffset + xAxis.labelRotatedHeight,
        pointF,
      );
    case XAxisPosition.BOTTOM:
      pointF.x = 0.5;
      pointF.y = 0.0;
      drawLabels(c, viewPortHandler.contentBottom + yoffset, pointF);
    case XAxisPosition.BOTTOM_INSIDE:
      pointF.x = 0.5;
      pointF.y = 0.0;
      drawLabels(
        c,
        viewPortHandler.contentBottom - yoffset - xAxis.labelRotatedHeight,
        pointF,
      );
    case XAxisPosition.BOTH_SIDED:
      pointF.x = 0.5;
      pointF.y = 1.0;
      drawLabels(c, viewPortHandler.contentTop - yoffset, pointF);
      pointF.x = 0.5;
      pointF.y = 0.0;
      drawLabels(c, viewPortHandler.contentBottom + yoffset, pointF);
  }
  MPPointF.recycleInstance(pointF);
}