INNER CODE UNIT · Java
drawLegend
jjoe64/GraphView · src/main/java/com/jjoe64/graphview/CursorMode.java:138
protected void drawLegend(Canvas canvas) {
mTextPaint.setTextSize(mStyles.textSize);
mTextPaint.setColor(mStyles.textColor);
int shapeSize = (int) (mStyles.textSize*0.8d);
// width
int legendWidth = mStyles.width;
if (legendWidth == 0) {
// auto
legendWidth = cachedLegendWidth;
if (legendWidth == 0) {
Rect textBounds = new Rect();
for (Map.Entry<BaseSeries, DataPointInterface> entry : mCurrentSelection.entrySet()) {
String txt = getTextForSeries(entry.getKey(), entry.getValue());
mTextPaint.getTextBounds(txt, 0, txt.length(), textBounds);
legendWidth = Math.max(legendWidth, textBounds.width());