PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.52k stars 9.01k forks source link

LineChart MarkerView doesn't show the contents #4139

Open AliKhoshraftar opened 6 years ago

AliKhoshraftar commented 6 years ago

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

}

CreazyBlade commented 6 years ago

I have the same problem.

JoshanTandukar commented 5 years ago

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.

Shubham1992 commented 3 years ago

Getting the sae issue. Did you find any soultion?

r4jiv007 commented 3 years ago

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

sagarkondhare commented 3 years ago

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

saeedmpt commented 3 years ago

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

DeepakRattan commented 1 year ago

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

Sabboo commented 9 months ago

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:textDirectionproperty 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.

i-m-aj commented 2 months ago

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