MPAndroidChart
MPAndroidChart copied to clipboard
Line Chart - Fill Color on Screen Rotate Bug
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"

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

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?
Have you tried redrawing it? Does it resolve the issue?
Please try again with the latest commit and see if it works now.