MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

LineChart MarkerView doesn't show the contents

Open AliKhoshraftar opened this issue 6 years ago • 9 comments

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());
}

}

AliKhoshraftar avatar Jul 05 '18 21:07 AliKhoshraftar

I have the same problem.

CreazyBlade avatar Jul 24 '18 01:07 CreazyBlade

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.

JoshanTandukar avatar Dec 19 '18 10:12 JoshanTandukar

Getting the sae issue. Did you find any soultion?

Shubham1992 avatar Jan 13 '21 09:01 Shubham1992

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

r4jiv007 avatar Mar 22 '21 06:03 r4jiv007

the issue is not yet resolved. i am facing this issue

sagarkondhare avatar May 06 '21 21:05 sagarkondhare

use tvLabelDate.setText("l تاریخ"); tvLabelPrice.setText("l قیمت");

saeedmpt avatar Aug 09 '21 06:08 saeedmpt

I am facing the same issue. MakerView is shown without any content. Please let me know if any fixes found.

DeepakRattan avatar Nov 17 '22 03:11 DeepakRattan

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.

Sabboo avatar Nov 29 '23 09:11 Sabboo

Try adding
// this line super.refreshContent(e, highlight);

i-m-aj avatar Jul 10 '24 10:07 i-m-aj