I want to show x and y value on single tap on chart. I followed all steps but still it's not working. Is there anything going wrong?
This is my code
LineData data = new LineData(getDataSet());
chart.setData(data);
chart.setDrawMarkerViews(true);
chart.setTouchEnabled(true);
chart.getDescription().setEnabled(false);
chart.setOnChartGestureListener(this);
chart.setHighlightPerTapEnabled(true);
CustomMarkerView mv = new CustomMarkerView(this,R.layout.custom_marker_view_layout);
mv.setChartView(chart);
mv.setOffset(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
chart.setMarkerView(mv);
chart.setPinchZoom(false);
chart.setDrawGridBackground(false);
following is my code for custom marker view
public class CustomMarkerView extends MarkerView {
private TextView tvContent;
public CustomMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvContent = (TextView) findViewById(R.id.tvContent);
}
@Override
public void refreshContent(Entry e, Highlight highlight) {
if (e instanceof CandleEntry) {
CandleEntry ce = (CandleEntry) e;
tvContent.setText("" + Utils.formatNumber(ce.getHigh(), 0, true));
} else {
tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true));
}
super.refreshContent(e, highlight);
}
@Override
public MPPointF getOffset() {
return new MPPointF(-(getWidth() / 2), -getHeight());
}
}