MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Fill LineChart sometimes not working

Open warmax opened this issue 11 years ago • 27 comments

With last version 2.0.8 sometimes the chart is not filled. When I revert back to 2.0.7 it works again.

set1.setDrawFilled(true); set1.setFillColor(getResources().getColor(R.color.red_down)); mChart.setData(data) mChart.invalidate();

regards

warmax avatar Mar 16 '15 23:03 warmax

Could you describe the situation in more detail? Which setup (which data) causes the chart not to be filled correctly? Could you provide a screenshot of what it looks like?

PhilJay avatar Mar 17 '15 22:03 PhilJay

Data is coming from a financial api so it's changing quite a bit.... some charts are just fine but others are not filled (I haven't been able to find a pattern). I attach a screenshot with v2.0.7 and v2.0.8 on the same chart:

mp207

mp_208

If you have any ideas of how can I help, please let me know.

warmax avatar Mar 17 '15 23:03 warmax

Okay so the whole area is simply not filled. That is quite weird. How many values are you plotting?

If the issue occurs, could you tell me if you can find the following warning message in your logcat: "Path too large to be rendered into a texture"

Thank you!

PhilJay avatar Mar 17 '15 23:03 PhilJay

Yes I'm getting that error in logcat.

491 values -> not working 515 values -> not working 1545 values -> not working 128 values ->working 261 values ->working 781 values -> working, strange??

warmax avatar Mar 17 '15 23:03 warmax

may be you can debug the view which can not be working well using your data, and this way may solve this problem fast.

xu6148152 avatar Mar 18 '15 02:03 xu6148152

Alright. Does the issue occur instantly, or only when zooming in?

PhilJay avatar Mar 18 '15 13:03 PhilJay

Could you try the latest commit and see if you are still having the issue?

PhilJay avatar Mar 19 '15 15:03 PhilJay

Hi phil, just checked with last commit and it worked fine!

Thanks

warmax avatar Mar 19 '15 21:03 warmax

Good to know, I thought I might have fixed it!

PhilJay avatar Mar 19 '15 21:03 PhilJay

I am still having this exact issue, it was working in 2.0.7, just updated my gradle build to 2.0.8 today and got the irregular fill behavior:

These are two diff charts with fill working and not working: screen shot 2015-03-20 at 2 35 40 pm

LineDataSet priceData = new LineDataSet(yVal, "Price");
        priceData.setLineWidth(2f);
        priceData.setDrawFilled(true);
        priceData.setColor(getResources().getColor(R.color.positive_green_line));
        priceData.setFillColor(getResources().getColor(R.color.positive_green_fill));
        priceData.setDrawCircles(false);
        priceData.setDrawValues(false);

        ArrayList<LineDataSet> dataSets = new ArrayList<>();
        dataSets.add(priceData);

        LineData data = new LineData(xVal, dataSets);
        lineChart.getAxisLeft().setStartAtZero(false);
        lineChart.setData(data);

screen shot 2015-03-20 at 2 35 57 pm

LineDataSet sentimentData = new LineDataSet(yVal, "Sentiment");
        sentimentData.setLineWidth(0f);
        sentimentData.setDrawFilled(true);
        sentimentData.setFillColor(getResources().getColor(R.color.stock_up_green));
        sentimentData.setColor(getResources().getColor(R.color.stock_up_green));
        sentimentData.setDrawCircles(false);
        sentimentData.setDrawValues(false);

        ArrayList<LineDataSet> dataSets = new ArrayList<>();
        dataSets.add(sentimentData);

        LineData data = new LineData(xVal, dataSets);

        lineChart.getAxisLeft().setAxisMaxValue(100);
        lineChart.setData(data);

rgray00 avatar Mar 20 '15 18:03 rgray00

Have you tried the latest commit? There is no release-version with this fix yet!

PhilJay avatar Mar 20 '15 19:03 PhilJay

This bug is back in the main branch.

Had to change: c.drawPath(cubicPath, mRenderPaint); to: mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

regards

MarcSalvat avatar Apr 19 '15 21:04 MarcSalvat

Just upgraded to 2.1.0 and am still experiencing this bug

rgray00 avatar May 08 '15 21:05 rgray00

I am facing this issue too, with version 2.1.0. The chart is correctly filled when first drawn, but when I start to zoom, it is no longer filled and I only have the line.

As asked in a previous comment, I do have the following in my log:

Path too large to be rendered into a texture

Any idea @PhilJay ?

MGaetan89 avatar Jun 10 '15 06:06 MGaetan89

I can see in logs (2.1.0): "Shape too large to be rendered into a texture"

adammach avatar Jun 11 '15 10:06 adammach

Are you all using cubic lines?

PhilJay avatar Jun 11 '15 11:06 PhilJay

I'm not (I am using the default configuration). But if I call lineDataSet.setDrawCubic(true), then the chart is filled even when zoomed/dragged.

MGaetan89 avatar Jun 11 '15 11:06 MGaetan89

@PhilJay If I use cubic I agree, that it's working fine.

adammach avatar Jun 11 '15 11:06 adammach

Okay good then I can narrow down the issue to normal (straight) lines, I will have a look at it.

PhilJay avatar Jun 11 '15 11:06 PhilJay

If the chart dimension is large (200dp x 200dp) then all line charts (normal, straight lines) fail (instantly) to fill the area. If the chart dimension is small (40dp x 100dp) then some will fail and some will work. I got the same result every time.

ayltai avatar Jun 12 '15 18:06 ayltai