自定义标记-MPAndroidChart [英] Customize the marker - MPAndroidChart

查看:79
本文介绍了自定义标记-MPAndroidChart的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 MPAndroidChart 创建了一个简单的条形图.出于标记的目的,我扩展了 MarkerView .我需要一个如git hub所示的标记,如下所示:

I've created a Simple Bar Chart using MPAndroidChart. For the purpose of Marker I'm extending MarkerView. I need a marker as shown in the git hub, like this:

但是我没有得到那个箭头.所以它看起来不像是注释,它是一个矩形框:/

But I'm not getting that arrow. So it is not looking like a comment, it's a rectangular box :/

为了使它看起来像注释框,而不是我应该使用的类的矩形框.我已经检查了 IMarker MarkerImage ,但是不确定应该继续哪个.

In order to make it look like a comment box instead of a rectangular box which class I should use. I've checked IMarker, MarkerImage but not sure which I should proceed with.

甚至 MPPointF 都不起作用.无法导入包

And even MPPointF isn't working. Can't import the package

导入com.github.mikephil.charting.utils.MPPointF;

代码:

@Override
public void refreshContent(Entry e, Highlight highlight) { 
    tv_turnOver.setText("Turn over: " + (int) e.getVal());

    /*
    if (e instanceof CandleEntry) {

        CandleEntry ce = (CandleEntry) e;

        tv_label.setText("" + Utils.formatNumber(ce.getVal(), 0, true));
    } else {

        tv_label.setText("" + Utils.formatNumber(e.getXIndex(), 0, true));
    }*/

    //  super.refreshContent(e, highlight);
}

推荐答案

https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/main/res/drawable-nodpi/marker2.png

使用图片作为背景

就这样...

就这样吗?!!!

我使用背景图像来代替箭头,而不是背景颜色红色".

Instead of the background colour 'Red', I've used this image to get that arrow.

这篇关于自定义标记-MPAndroidChart的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆