示例#1
0
  @Override
  protected void drawValues() {

    // if values are drawn
    if (mDrawYValues && mCurrentData.getYValCount() < mMaxVisibleCount * mScaleX) {

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

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

        LineDataSet dataSet = dataSets.get(i);

        // make sure the values do not interfear with the circles
        int valOffset = (int) (dataSet.getCircleSize() * 1.75f);

        if (!dataSet.isDrawCirclesEnabled()) valOffset = valOffset / 2;

        ArrayList<Entry> entries = dataSet.getYVals();

        float[] positions = generateTransformedValuesLineScatter(entries);

        for (int j = 0; j < positions.length * mPhaseX; j += 2) {

          if (isOffContentRight(positions[j])) break;

          if (isOffContentLeft(positions[j])
              || isOffContentTop(positions[j + 1])
              || isOffContentBottom(positions[j + 1])) continue;

          float val = entries.get(j / 2).getVal();

          if (mDrawUnitInChart) {

            mDrawCanvas.drawText(
                mValueFormatter.getFormattedValue(val) + mUnit,
                positions[j],
                positions[j + 1] - valOffset,
                mValuePaint);
          } else {

            mDrawCanvas.drawText(
                mValueFormatter.getFormattedValue(val),
                positions[j],
                positions[j + 1] - valOffset,
                mValuePaint);
          }
        }
      }
    }
  }
示例#2
0
  /** draws the circle value indicators */
  @Override
  protected void drawAdditional() {

    mRenderPaint.setStyle(Paint.Style.FILL);

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

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

      LineDataSet dataSet = dataSets.get(i);

      // if drawing circles is enabled for this dataset
      if (dataSet.isDrawCirclesEnabled()) {

        ArrayList<Entry> entries = dataSet.getYVals();

        float[] positions = generateTransformedValuesLineScatter(entries);

        for (int j = 0; j < positions.length * mPhaseX; j += 2) {

          // Set the color for the currently drawn value. If the index
          // is
          // out of bounds, reuse colors.
          mRenderPaint.setColor(dataSet.getCircleColor(j / 2));

          if (isOffContentRight(positions[j])) break;

          // make sure the circles don't do shitty things outside
          // bounds
          if (isOffContentLeft(positions[j])
              || isOffContentTop(positions[j + 1])
              || isOffContentBottom(positions[j + 1])) continue;

          mDrawCanvas.drawCircle(
              positions[j], positions[j + 1], dataSet.getCircleSize(), mRenderPaint);
          mDrawCanvas.drawCircle(
              positions[j], positions[j + 1], dataSet.getCircleSize() / 2f, mCirclePaintInner);
        }
      } // else do nothing
    }
  }