-1

Hello i am using this solution MpAndroidChart set background between limit lines but graph lines are hiding behind the background color see the below image.

enter image description here

image

Give me any solution, thanks in advance.

Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31
Jack D
  • 119
  • 1
  • 1
  • 11
  • can you please show me your code then I will help u out of this – Muhammad Saad Rafique Nov 08 '17 at 07:01
  • Hi this is my code – Jack D Nov 08 '17 at 07:09
  • float rangeLow = 66f; float rangeHigh = 120f; YAxis fillAxis = lineChart.getAxisLeft(); float increment = (rangeHigh - rangeLow) / 20; float metricLine = rangeLow; for(int i = 0; i < 20; i++) { LimitLine llRange = new LimitLine(metricLine, ""); llRange.setLineColor(Color.parseColor("#f2befb")); llRange.setLineWidth(100f); fillAxis.addLimitLine(llRange); metricLine = metricLine + increment; } – Jack D Nov 08 '17 at 07:09

2 Answers2

1
YAxis yAxis = mChart.getAxisLeft();
yAxis.setDrawLimitLinesBehindData(true);
A pant
  • 11
  • 1
  • 5
  • 1
    Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you’ve made. – rollstuhlfahrer May 02 '18 at 07:05
0

Instead of this:

 llRange.setLineColor(Color.parseColor("#f2befb"));

Use this:

 llRange.setLineColor(Color.parseColor("#80f2befb"));

I added 80 in start of your color which makes it 50% transparent. For transperancy you can add number before your color hex code as follows:

0% = #00
10% = #16
20% = #32
30% = #48
40% = #64
50% = #80
60% = #96
70% = #112
80% = #128
90% = #144
Muhammad Saad Rafique
  • 3,158
  • 1
  • 13
  • 21