if (highlightEntry != null) {
float width = markerTextPaint.measureText(highlightEntry.getXLabel()) + 50;
highlightPointX = highlightPointX - width / 2;
if (highlightPointX < contentRect.left) {
highlightPointX = contentRect.left;
}
if (highlightPointX > contentRect.right - width) {
highlightPointX = contentRect.right - width;
}
markerInsets.left= highlightPointX + inset;
markerInsets.top = contentRect.top + inset;
markerInsets.right = markerInsets.left + width - inset * 2;
markerInsets.bottom = markerInsets.top + height - inset * 2;
canvas.drawText(highlightEntry.getXLabel(),
markerInsets.left + markerInsets.width() / 2,
(markerInsets.top + markerInsets.bottom - fontMetrics.top - fontMetrics.bottom) / 2,
markerTextPaint);
canvas.drawRect(markerInsets, markerBorderPaint);
canvas.clipRect(markerInsets, Region.Op.XOR);
}
}
}