MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Line Chart - Fill Color on Screen Rotate Bug

Open rgray00 opened this issue 11 years ago • 2 comments

in 2.0.8 on screen rotation the chart would fill correctly. I am overriding orientation changes so that the activity on create is not called again via these settings in my manifest:

android:configChanges="keyboardHidden|orientation|screenSize"

screen shot 2015-04-08 at 10 38 57 am screen shot 2015-04-08 at 10 39 09 am

In 2.0.9 - The portrait view is the same, but the landscape fill looks like this below:

screen shot 2015-04-08 at 10 45 10 am

Here is chart code:

LineDataSet priceData = new LineDataSet(yVal, "Price");
        priceData.setLineWidth(2f);
        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));
        }
        priceData.setDrawCircles(false);
        priceData.setDrawValues(false);
        priceData.setDrawFilled(true);

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

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

Should I redraw chart on orientation change now?

rgray00 avatar Apr 08 '15 14:04 rgray00

Have you tried redrawing it? Does it resolve the issue?

PhilJay avatar Apr 08 '15 16:04 PhilJay

Please try again with the latest commit and see if it works now.

PhilJay avatar Apr 09 '15 13:04 PhilJay