use of com.github.mikephil.charting.utils.LimitLine in project carat by amplab.
the class BarLineChartBase method drawLimitLines.
/**
* Draws the limit lines if there are one.
*/
private void drawLimitLines() {
ArrayList<LimitLine> limitLines = mData.getLimitLines();
if (limitLines == null)
return;
float[] pts = new float[4];
for (int i = 0; i < limitLines.size(); i++) {
LimitLine l = limitLines.get(i);
pts[1] = l.getLimit();
pts[3] = l.getLimit();
mTrans.pointValuesToPixel(pts);
pts[0] = 0;
pts[2] = getWidth();
mLimitLinePaint.setColor(l.getLineColor());
mLimitLinePaint.setPathEffect(l.getDashPathEffect());
mLimitLinePaint.setStrokeWidth(l.getLineWidth());
mDrawCanvas.drawLines(pts, mLimitLinePaint);
// if drawing the limit-value is enabled
if (l.isDrawValueEnabled()) {
PointF pos = getPosition(new Entry(l.getLimit(), 0));
// save text align
Align align = mValuePaint.getTextAlign();
float xOffset = Utils.convertDpToPixel(4f);
float yOffset = l.getLineWidth() + xOffset;
String label = mValueFormatter.getFormattedValue(l.getLimit());
if (mDrawUnitInChart)
label += mUnit;
if (l.getLabelPosition() == LimitLabelPosition.RIGHT) {
mValuePaint.setTextAlign(Align.RIGHT);
mDrawCanvas.drawText(label, getWidth() - mOffsetRight - xOffset, pos.y - yOffset, mValuePaint);
} else {
mValuePaint.setTextAlign(Align.LEFT);
mDrawCanvas.drawText(label, mOffsetLeft + xOffset, pos.y - yOffset, mValuePaint);
}
mValuePaint.setTextAlign(align);
}
}
}
use of com.github.mikephil.charting.utils.LimitLine in project carat by amplab.
the class RadarChart method drawLimitLines.
/**
* Draws the limit lines if there are one.
*/
private void drawLimitLines() {
ArrayList<LimitLine> limitLines = mData.getLimitLines();
if (limitLines == null)
return;
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 < limitLines.size(); i++) {
LimitLine l = limitLines.get(i);
mLimitLinePaint.setColor(l.getLineColor());
mLimitLinePaint.setPathEffect(l.getDashPathEffect());
mLimitLinePaint.setStrokeWidth(l.getLineWidth());
float r = l.getLimit() * factor;
Path limitPath = new Path();
for (int j = 0; j < mData.getXValCount(); j++) {
PointF p = getPosition(c, r, sliceangle * j + mRotationAngle);
if (j == 0)
limitPath.moveTo(p.x, p.y);
else
limitPath.lineTo(p.x, p.y);
}
limitPath.close();
mDrawCanvas.drawPath(limitPath, mLimitLinePaint);
}
}
Aggregations