MPAndroidChart
MPAndroidChart copied to clipboard
Marker not visible when outside of chartview area event if cliptochildren = false & cliptopadding = false
When set setClipToChildren and setClipToPadding to false on the chart, the marker view displayed outside of the chart is not visible. I want to put the marker view above the chartview.
To do this in the onDraw I override the yPosition
@Override
public void draw(Canvas canvas, float posX, float posY) {
// take offsets into consideration
int lineChartWidth = parentView.getWidth();
float offsetX = getOffset().getX();
posY = -getHeight(); <-- to put the marker above
float width = getWidth();
if (posX + offsetX < 0) {
offsetX = -posX;
} else if (posX + width + offsetX > lineChartWidth) {
offsetX = lineChartWidth - posX - width;
}
posX += offsetX;
// translate to the correct position and draw
canvas.translate(posX, posY);
draw(canvas);
canvas.translate(-posX, -posY);
}
All the parent of the chart have cliptoChidren = false & clipToPadding = false With the iOS library the result is correct

Device (please complete the following information):
- Device: Samsung TabS2
- Android Version7.0
- Library Version v3.1.0
Thanks in advance : )
If you replace posY = - getHeight() by posY = - (getHeight - 1) it's working ...
override fun getOffsetForDrawingAtPoint(posX: Float, posY: Float): MPPointF {
if (posX > chartView.width - width) {
offset.x = (-width).toFloat()
} else {
offset.x = (-(width / 2)).toFloat()
}
offset.y = -(height / 2).toFloat()
return offset
}
You need to set chart view to MarkerView.chartView before calculation.