3
votes

following this (Android - Fill the color between two lines using MPAndroidChart) answer I was able to fill with color the space between two lines using AndroidMPChart library.

But now I want to customize the filling color to have:

  • the areas above the boundarySet filled with blue color;

  • the areas below the boundarySet filled with green color.

Like in the following screenshot (please note that the blue line is a lineSet, so it could be that it is not a limit line):

enter image description here

I would like to customize the line color of the chart, setting it as the filling:

  • blue color for the line above the boundarySet;

  • green color for the line below the boundary set.

Is it possible? I'm not able to find anything similar in the examples using MPAndroidChart.

Thank you!

2
I think You can draw two lines with different color. In first line(add values greater than 20) set blue color and In second line add values less than 20 set color green.Yamini
Could you provide me an example? It is not clear to me how to build the two lines having the LineDataSetsManuela
@Manuela have you got the any solution.Can you tell me how to do it?Narender Reddy

2 Answers

0
votes

you can try to override the drawLinear in LineChartRender

0
votes

This has worked for me:

dataSet.setFillFormatter(new DefaultFillFormatter() {
    @Override
    public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
        return 22500;// its value of midel Y line 
    }
});