drawDataSet method

void drawDataSet(
  1. Canvas c,
  2. IRadarDataSet dataSet,
  3. int mostEntries
)

Draws the RadarDataSet

@param c @param dataSet @param mostEntries the entry count of the dataset with the most entries

Implementation

void drawDataSet(Canvas c, IRadarDataSet dataSet, int mostEntries) {
  double phaseX = animator!.getPhaseX();
  double phaseY = animator!.getPhaseY();

  double sliceAngle = _painter!.getSliceAngle();

  // calculate the factor that is needed for transforming the value to
  // pixels
  double factor = _painter!.getFactor();

  MPPointF center = _painter!.getCenterOffsets();
  MPPointF pOut = MPPointF.getInstance1(0, 0);
  Path surface = mDrawDataSetSurfacePathBuffer;
  surface.reset();

  bool hasMovedToPoint = false;

  for (int j = 0; j < dataSet.getEntryCount(); j++) {
    renderPaint!.color = dataSet.getColor2(j);

    RadarEntry e = dataSet.getEntryForIndex(j)!;

    Utils.getPosition(
        center,
        (e.y - _painter!.getYChartMin()!) * factor * phaseY,
        sliceAngle * j * phaseX + _painter!.getRotationAngle(),
        pOut);

    if (pOut.x.isNaN) continue;

    if (!hasMovedToPoint) {
      surface.moveTo(pOut.x, pOut.y);
      hasMovedToPoint = true;
    } else {
      surface.lineTo(pOut.x, pOut.y);
    }
  }

  if (dataSet.getEntryCount() > mostEntries) {
    // if this is not the largest set, draw a line to the center before closing
    surface.lineTo(center.x, center.y);
  }

  surface.close();

  if (dataSet.isDrawFilledEnabled()) {
//      final Drawable drawable = dataSet.getFillDrawable();
//      if (drawable != null) {
//
//        drawFilledPath(c, surface, drawable);
//      } else {

    if (dataSet.isGradientEnabled()) {
      drawFilledPath3(
          c,
          surface,
          dataSet.getGradientColor1()!.startColor.value,
          dataSet.getGradientColor1()!.endColor.value,
          dataSet.getFillAlpha());
    } else {
      drawFilledPath2(
          c, surface, dataSet.getFillColor().value, dataSet.getFillAlpha());
    }
//      }
  }

  renderPaint
    ?..strokeWidth = dataSet.getLineWidth()!
    ..style = PaintingStyle.stroke;

  // draw the line (only if filled is disabled or alpha is below 255)
  if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255) {
    c.drawPath(surface, renderPaint!);
  }

  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
}