I want to show a label with specific data when a value is selected like in the demo-Image of what I want:

so I paste this code (found in the source of the exemple):
protected RectF mOnValueSelectedRectF = new RectF();
@Override
public void onValueSelected(Entry e, Highlight h) {
    if (e == null)
        return;
    RectF bounds = mOnValueSelectedRectF;
    mChart.getBarBounds((BarEntry) e, bounds);
    MPPointF position = mChart.getPosition(e, AxisDependency.LEFT);
    Log.i("bounds", bounds.toString());
    Log.i("position", position.toString());
    Log.i("x-index",
            "low: " + mChart.getLowestVisibleX() + ", high: "
                    + mChart.getHighestVisibleX());
    MPPointF.recycleInstance(position);
}
but it doesn't work, the log are displayed but nothing happen on the screen. What I have forget or miss
To display a marker with something inside when a value is selected we have to use a MarkerView and not the valueSelected listener.
All the necessary doc for create yours is here : https://github.com/PhilJay/MPAndroidChart/wiki/IMarker-Interface
Have you written below the line in your code?
mChart.setOnChartValueSelectedListener(this);
                        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