我可以使用mpAndroidChart绘制渐变线图吗? [英] Can I draw a gradient linechart with mpAndroidChart?
本文介绍了我可以使用mpAndroidChart绘制渐变线图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以画出图中的线条图吗?如果可以,我该怎么做才能更改线条颜色?谢谢!
Can I draw a lineChart looks like in the picture? If can, what should I do to change the line colors? Thank you!
我所绘制的东西看起来像两幅图,这两条线是相同的颜色,并且昨天没有incom.我应该怎么做才能将线变为渐变色并仅显示最后一个markerView?
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 ?
推荐答案
我找到了解决方法! 请检查Lance Gleason的教程.非常简单.这是其中的一些代码:
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);
}
这也是结果:
这篇关于我可以使用mpAndroidChart绘制渐变线图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文