Can I draw a gradient linechart with mpAndroidChart?

血红的双手。 提交于 2020-01-04 02:07:11

问题


Can I draw a lineChart looks like in the picture? If can, what should I do to change the line colors? Thank you!

what I have draw looks like the picture two,which the line is the same color and there is no yesterday incom.what should I do to change the line into gradient color and only show the last markerView ?

The picture I have drawn.


回答1:


I've found workaround! Please check this tutorial by Lance Gleason. It is pretty simple. Here is some code from it:

@Override
public void onStart() {
    super.onStart();
    getView().post(new Runnable() {
        @Override
        public void run() {
            setupGradient(chartDaySpeed);
        }
    });
}

private void setupGradient(LineChart mChart) {
    Paint paint = mChart.getRenderer().getPaintRender();
    int height = mChart.getHeight();

    LinearGradient linGrad = new LinearGradient(0, 0, 0, height,
            getResources().getColor(android.R.color.holo_green_light),
            getResources().getColor(android.R.color.holo_red_light),
            Shader.TileMode.REPEAT);
    paint.setShader(linGrad);
}

Also here is result:

Line chart gradient result



来源:https://stackoverflow.com/questions/33748145/can-i-draw-a-gradient-linechart-with-mpandroidchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!