MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

LineChart SetDrawFilled sometimes does not fill on versions > 2.0.9

Open rgray00 opened this issue 11 years ago • 4 comments

Code stays the same, results do not:

 ArrayList<String> xVal = new ArrayList<>();
 ArrayList<Entry> yVal = new ArrayList<>();

        for(int i=0; i < dataPoints.size(); i++){
            xVal.add(formatTime(dataPoints.get(i).EndTime));

            if(dataPoints.get(i).Close != 0.0f){
                yVal.add(new Entry(dataPoints.get(i).Close, i));
            }
        }

        LineDataSet priceData = new LineDataSet(yVal, "Price");
        priceData.setLineWidth(2f);
        priceData.setDrawCircles(false);
        priceData.setDrawValues(false);
        priceData.setDrawFilled(true);
        if(mPriceChange > 0){
            priceData.setColor(getResources().getColor(R.color.positive_green_line));
            priceData.setFillColor(getResources().getColor(R.color.positive_green_fill));
        }
        else {
            priceData.setColor(getResources().getColor(R.color.negative_red_line));
            priceData.setFillColor(getResources().getColor(R.color.negative_red_fill));
        }

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

        LineData data = new LineData(xVal, dataSets);
        lineChart.getAxisLeft().setStartAtZero(false);
        lineChart.getAxisLeft().setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
        lineChart.getAxisLeft().setValueFormatter(new PriceFormatter());
        lineChart.setDescription("");
        lineChart.getAxisRight().setEnabled(false);
        lineChart.getLegend().setEnabled(false);
        lineChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
        lineChart.getXAxis().setAvoidFirstLastClipping(true);
        lineChart.setTouchEnabled(false);

        lineChart.setData(data);
        lineChart.invalidate();

rgray00 avatar Jul 21 '15 18:07 rgray00

Any insight is appreciated, love using this library!

rgray00 avatar Jul 27 '15 15:07 rgray00

Can you check if this is fixed with the latest commit at https://github.com/tinsukE/MPAndroidChart?

tinsukE avatar Oct 02 '15 09:10 tinsukE

It looks like this resolved the issue. Nice! send a PR to @PhilJay

rgray00 avatar Oct 02 '15 16:10 rgray00

I've done so already =)

tinsukE avatar Oct 03 '15 01:10 tinsukE