I'm using the MPAndroidChart library which has a string written on the chart if no data is available yet.
If the string is too long, it seems to just overflow to both sides of the screen so I'm wondering if it's possible to make that text use multiple lines, because neither \n
, <p>
, nor <br>
work.
The method to set that text is chart.setNoDataText(String)
where chart is a LineChart view.
It is impossible, if you take a look at source of the library, here how it draws text
@Override
protected void onDraw(Canvas canvas) {
if (mData == null) {
boolean hasText = !TextUtils.isEmpty(mNoDataText);
if (hasText) {
MPPointF c = getCenter();
canvas.drawText(mNoDataText, c.x, c.y, mInfoPaint);
}
return;
}
if (!mOffsetsCalculated) {
calculateOffsets();
mOffsetsCalculated = true;
}
}
Here main line is
canvas.drawText(mNoDataText, c.x, c.y, mInfoPaint);
Library draws text mNoDataText
as single line, starting from c.x, c.y.canvas.drawText()
doesn't know how to handle newlines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With