@Override public void renderAxisLabels(Canvas c) { if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled()) return; mAxisLabelPaint.setTypeface(mYAxis.getTypeface()); mAxisLabelPaint.setTextSize(mYAxis.getTextSize()); mAxisLabelPaint.setColor(mYAxis.getTextColor()); PointF center = mChart.getCenterOffsets(); float factor = mChart.getFactor(); int labelCount = mYAxis.mEntryCount; for (int j = 0; j < labelCount; j++) { if (j == labelCount - 1 && mYAxis.isDrawTopYLabelEntryEnabled() == false) break; float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor; PointF p = Utils.getPosition(center, r, mChart.getRotationAngle()); String label = mYAxis.getFormattedLabel(j); c.drawText(label, p.x + 10, p.y, mAxisLabelPaint); } }
@Override public void renderLimitLines(Canvas c) { List<LimitLine> limitLines = mYAxis.getLimitLines(); if (limitLines == null) return; float sliceangle = mChart.getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = mChart.getFactor(); PointF center = mChart.getCenterOffsets(); for (int i = 0; i < limitLines.size(); i++) { LimitLine l = limitLines.get(i); if (!l.isEnabled()) continue; mLimitLinePaint.setColor(l.getLineColor()); mLimitLinePaint.setPathEffect(l.getDashPathEffect()); mLimitLinePaint.setStrokeWidth(l.getLineWidth()); float r = (l.getLimit() - mChart.getYChartMin()) * factor; Path limitPath = new Path(); for (int j = 0; j < mChart.getData().getXValCount(); j++) { PointF p = Utils.getPosition(center, r, sliceangle * j + mChart.getRotationAngle()); if (j == 0) limitPath.moveTo(p.x, p.y); else limitPath.lineTo(p.x, p.y); } limitPath.close(); c.drawPath(limitPath, mLimitLinePaint); } }