MPAndroidChart, Y-Axis Scale gets updated but lines are not

余生颓废 提交于 2019-12-25 09:22:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!