Пример #1
0
  @Override
  protected void drawHighlights() {

    // if there are values to highlight and highlighnting is enabled, do it
    if (mHighlightEnabled && valuesToHighlight()) {

      float sliceangle = getSliceAngle();
      float factor = getFactor();

      PointF c = getCenterOffsets();

      for (int i = 0; i < mIndicesToHightlight.length; i++) {

        RadarDataSet set =
            mCurrentData.getDataSetByIndex(mIndicesToHightlight[i].getDataSetIndex());

        if (set == null) continue;

        mHighlightPaint.setColor(set.getHighLightColor());

        // get the index to highlight
        int xIndex = mIndicesToHightlight[i].getXIndex();

        Entry e = set.getEntryForXIndex(xIndex);
        int j = set.getEntryPosition(e);
        float y = e.getVal();

        PointF p = getPosition(c, y * factor, sliceangle * j + mRotationAngle);

        float[] pts = new float[] {p.x, 0, p.x, getHeight(), 0, p.y, getWidth(), p.y};

        mDrawCanvas.drawLines(pts, mHighlightPaint);
      }
    }
  }
Пример #2
0
  @Override
  protected void drawValues() {

    // if values are drawn
    if (mDrawYValues) {

      float sliceangle = getSliceAngle();

      // calculate the factor that is needed for transforming the value to
      // pixels
      float factor = getFactor();

      PointF c = getCenterOffsets();

      float yoffset = Utils.convertDpToPixel(5f);

      for (int i = 0; i < mCurrentData.getDataSetCount(); i++) {

        RadarDataSet dataSet = mCurrentData.getDataSetByIndex(i);
        ArrayList<Entry> entries = dataSet.getYVals();

        for (int j = 0; j < entries.size(); j++) {

          Entry e = entries.get(j);

          PointF p = getPosition(c, e.getVal() * factor, sliceangle * j + mRotationAngle);

          if (mDrawUnitInChart)
            mDrawCanvas.drawText(
                mValueFormatter.getFormattedValue(e.getVal()) + mUnit,
                p.x,
                p.y - yoffset,
                mValuePaint);
          else
            mDrawCanvas.drawText(
                mValueFormatter.getFormattedValue(e.getVal()), p.x, p.y - yoffset, mValuePaint);
        }
      }
    }
  }
Пример #3
0
  @Override
  protected void drawData() {

    ArrayList<RadarDataSet> dataSets = mCurrentData.getDataSets();

    float sliceangle = getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = getFactor();

    PointF c = getCenterOffsets();

    for (int i = 0; i < mCurrentData.getDataSetCount(); i++) {

      RadarDataSet dataSet = dataSets.get(i);
      ArrayList<Entry> entries = dataSet.getYVals();

      Path surface = new Path();

      for (int j = 0; j < entries.size(); j++) {

        mRenderPaint.setColor(dataSet.getColor(j));

        Entry e = entries.get(j);

        PointF p = getPosition(c, e.getVal() * factor, sliceangle * j + mRotationAngle);

        if (j == 0) surface.moveTo(p.x, p.y);
        else surface.lineTo(p.x, p.y);
      }

      surface.close();

      // draw filled
      if (dataSet.isDrawFilledEnabled()) {
        mRenderPaint.setStyle(Paint.Style.FILL);
        mRenderPaint.setAlpha(dataSet.getFillAlpha());
        mDrawCanvas.drawPath(surface, mRenderPaint);
        mRenderPaint.setAlpha(255);
      }

      mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
      mRenderPaint.setStyle(Paint.Style.STROKE);

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