Sudhakar kr
Sudhakar kr

Reputation: 67

How to use Markerview in Stacked vertical barchart?

I have problem in displaying custom marker example. When i click on stacked bar chart its showing total value of single barchart but i need to show stacked bar values

"public class MyMarkerView extends MarkerView {

    private final TextView tvContent;

    public MyMarkerView(Context context, int layoutResource) {
        super(context, layoutResource);

        tvContent = findViewById(R.id.tvContent);
    }

    // runs every time the MarkerView is redrawn, can be used to update the
    // content (user-interface)
    @Override
    public void refreshContent(Entry e, Highlight highlight) {

        if (e instanceof CandleEntry) {

            CandleEntry ce = (CandleEntry) e;

            tvContent.setText(Utils.formatNumber(ce.getHigh(), 0, false));
        } else {
            tvContent.setText(Utils.formatNumber(e.getY(), 0, false));
        }

        super.refreshContent(e, highlight);
    }

    private MPPointF mpPointF;

    @Override
    public MPPointF getOffset() {

        if(mpPointF == null){
            mpPointF = new MPPointF(-(getWidth() / 2), -getHeight());
        }
        return mpPointF;
    }

}"

Upvotes: 1

Views: 228

Answers (1)

Adrian S
Adrian S

Reputation: 11

In my case, the solution is change:

e.getY()

to:

((BarEntry) e).getYVals()[highlight.getStackIndex()]

Upvotes: 1

Related Questions