Skip to content Skip to sidebar Skip to footer

Can I Draw A Gradient Linechart With Mpandroidchart?

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

Solution 1:

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

@OverridepublicvoidonStart() {
    super.onStart();
    getView().post(newRunnable() {
        @Overridepublicvoidrun() {
            setupGradient(chartDaySpeed);
        }
    });
}

privatevoidsetupGradient(LineChart mChart) {
    Paintpaint= mChart.getRenderer().getPaintRender();
    intheight= mChart.getHeight();

    LinearGradientlinGrad=newLinearGradient(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

Post a Comment for "Can I Draw A Gradient Linechart With Mpandroidchart?"