1
votes

Can we add MarkerView to PieChart and HorizontalBarChart from MPAndroidChart library?

I did try adding the MarkerView to the pie chart as the following:

TooltipView tooltipView = new TooltipView(context,R.layout.tooltip_layout, metadata);
chart.setMarkerView(tooltipView);

But when I click on the slice of the pie chart, no MarkerView is shown. Also, the same thing happens for horizontal bar chart.

2
Instead of downvoting, probably you could just answer. - Arjun Issar
I have the same issue with HorizontalBarChart. I'm using v2.1.3 of MPAndroidChart library. My implementation of custom MarkerView is correct, because if I simply change HorizontalBarChart to BarChart everything works as expected. Once I return HorizontalBarChart back, no markers are displayed. - HitOdessit

2 Answers

1
votes

As of today, PieChart and HorizontalBarChart do not support MarkerView. Nevertheless, this is high on my list and will probably be added soon in the future.

0
votes

It's difficult to tell from your question, but here are some things to check:

  • Ensure that ToolTipView extends MarkerView
  • Also make sure that you implement the refreshContent(), getXOffSet() and getYOffSet() methods.

That should allow you to view the marker view item.

I am not sure what the metadata value you are entering does, as the refresh method should allow you access the currently selected value and its data.