问题
I am using MPAndroidChart. I have the following Activity - StockDetail.Java
public class StockDetail extends AppCompatActivity{ ArrayList historicalData=null;
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences prefs=getApplicationContext().getSharedPreferences("arrayList",Context.MODE_PRIVATE); try { historicalData = (ArrayList<HistoricalData>) ObjectSerializer.deserialize(prefs.getString( Utils.ARRAY_LIST, ObjectSerializer.serialize(new ArrayList<HistoricalData>()))); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } setContentView(R.layout.stock_detail); LineChart lineChart=(LineChart) findViewById(R.id.lineChart); List<Entry> datas=new ArrayList<>(); ArrayList<Float> floats=getDateInFloatValues(historicalData); HistoricalData hData; for (int i=0; i<historicalData.size(); i++) { hData=historicalData.get(i); datas.add(new Entry(floats.get(i),Float.parseFloat(hData.getHigh()))); } LineDataSet lineDataSet=new LineDataSet(datas,"LineData"); lineDataSet.setColor(R.color.material_red_700); LineData lineData=new LineData(lineDataSet); lineChart.setData(lineData); lineChart.invalidate(); }
}
The Y-Axis scale gets updated but there are no lines and Here is the screenshot:
Image_1 Y-Axis scale updated
It seems like there is some problem with my code, Please let me know
回答1:
I fixed the problem, i was using beta version of MPAndroidChart then i changed the app level build.gradle to
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
Everything works now
来源:https://stackoverflow.com/questions/39736352/mpandroidchart-y-axis-scale-gets-updated-but-lines-are-not