MPAndroidChart fill color gradient

前端 未结 3 1783
失恋的感觉
失恋的感觉 2020-12-15 09:44

Is it possible with MPAndroidChart (or any other Android chart library) to fill the chart under the draw line with a gradient color? Something like this:

set         


        
3条回答
  •  [愿得一人]
    2020-12-15 10:19

    You can use the following two methods:

    LineRadarDataSet#setDrawFilled(boolean isFilled); 
    LineRadarDataSet#setFillDrawable(Drawable d);
    

    Here's a link to the javadoc for that class.

    This is the example from the MPAndroidChart sample project:

    set1.setDrawFilled(true);
    if (Utils.getSDKInt() >= 18) {
        // fill drawable only supported on api level 18 and above
        Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red);
        set1.setFillDrawable(drawable);
    }
    else {
        set1.setFillColor(Color.BLACK);
    }
    

    In fade_red.xml:

    
    
        
    
    

    Here's a sample of what it looks like on a LineChart:

提交回复
热议问题