MPAndroidChart
MPAndroidChart copied to clipboard
LineChart SetDrawFilled sometimes does not fill on versions > 2.0.9
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();
Any insight is appreciated, love using this library!
Can you check if this is fixed with the latest commit at https://github.com/tinsukE/MPAndroidChart?
It looks like this resolved the issue. Nice! send a PR to @PhilJay
I've done so already =)