Skip to content

Commit

Permalink
Custom text alignment for no-data
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Jan 22, 2020
1 parent 3f54750 commit 912427e
Showing 1 changed file with 26 additions and 2 deletions.
Expand Up @@ -398,8 +398,23 @@ protected void onDraw(Canvas canvas) {
boolean hasText = !TextUtils.isEmpty(mNoDataText);

if (hasText) {
MPPointF c = getCenter();
canvas.drawText(mNoDataText, c.x, c.y, mInfoPaint);
MPPointF pt = getCenter();

switch (mInfoPaint.getTextAlign()) {
case LEFT:
pt.x = 0;
canvas.drawText(mNoDataText, pt.x, pt.y, mInfoPaint);
break;

case RIGHT:
pt.x *= 2.0;
canvas.drawText(mNoDataText, pt.x, pt.y, mInfoPaint);
break;

default:
canvas.drawText(mNoDataText, pt.x, pt.y, mInfoPaint);
break;
}
}

return;
Expand Down Expand Up @@ -1162,6 +1177,15 @@ public void setNoDataTextTypeface(Typeface tf) {
mInfoPaint.setTypeface(tf);
}

/**
* alignment of the no data text
*
* @param align
*/
public void setNoDataTextAlignment(Align align) {
mInfoPaint.setTextAlign(align);
}

/**
* Set this to false to disable all gestures and touches on the chart,
* default: true
Expand Down

0 comments on commit 912427e

Please sign in to comment.