MPAndroidChart
MPAndroidChart copied to clipboard
LineChart MarkerView doesn't show the contents
hi, i'm working with this library . in my case it's showing chart in a fragment , i need custom MarkerView to show after tap on each line data entry. i used lib's sample ( LineChartActivity1 ) marker background as my custom marker background. the only problem is showing textViews texts , markers only show it's background and textviews always are empty.
It's my code :
public class AsanfitChartMarkerView extends MarkerView {
private TextView tvChartMarkerValue;
private TextView tvChartMarkerDate;
public AsanfitChartMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvChartMarkerValue = findViewById(R.id.tvChartMarkerValue);
tvChartMarkerDate = findViewById(R.id.tvChartMarkerDate);
}
@SuppressLint("SetTextI18n")
@Override
public void refreshContent(Entry e, Highlight highlight) {
if (e.getData() != null && e.getData() instanceof ChartEntryType) {
PersianDate persianDate = new PersianDate((long) e.getX());
tvChartMarkerDate.setText("تاریخ : " + persianDate.getShYear() + "/" + persianDate.getShMonth() + "/" + persianDate.getShDay());
switch ((ChartEntryType) e.getData()) {
case WAIST:
tvChartMarkerValue.setText("Test");
break;
case WEIGHT:
tvChartMarkerValue.setText("Text 2");
break;
}
}
super.refreshContent(e, highlight);
}
@Override
public MPPointF getOffset() {
return new MPPointF(-(getWidth() / 2), -getHeight());
}
}
I have the same problem.
Seems like I found the problem. The marker opens or shows but doesn't show the value. MarkerView class doesnt have the method to set the value have to override the class. Can you guys give it a check.Hope it helps.
Getting the sae issue. Did you find any soultion?
looks like the MarkerView doesn't support RTL language, when I removed the Arabic text, it's showing the numeric values (in English) properly. @PhilJay
the issue is not yet resolved. i am facing this issue
use
tvLabelDate.setText("l تاریخ"); tvLabelPrice.setText("l قیمت");
I am facing the same issue. MakerView is shown without any content. Please let me know if any fixes found.
I was facing the same issue and here is the approach I go with:
I have created a CustomMarkerView
class that extends MarkerView
class. In my CustomMarkerView
XML layout I had to set the android:textDirection
property to LTR.
First, in RTL mode the MarkerView
was showing but with no content, after these updates its now showing the content.
Note: I have not yet test this on multiple devices and I was trying it on Emulator.
Try adding
// this line
super.refreshContent(e, highlight);