我在显示自定义标记示例时遇到问题。当我单击堆积的条形图时,它显示单个条形图的总价值,但我需要显示堆积的条形图
“公共类MyMarkerView扩展了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;
}
}"
答案 0 :(得分:0)
就我而言,解决方案是更改:
e.getY()
收件人:
((BarEntry) e).getYVals()[highlight.getStackIndex()]