GraphView не показывает линейный график
Есть xml
:
<?xml version="1.0" encoding="utf-8"?>
<com.jjoe64.graphview.GraphView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dip"
android:id="@+id/graph">
</com.jjoe64.graphview.GraphView>
Есть java
:
LineGraphSeries<DataPoint> series;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_graph_weight);
GraphView graph = findViewById(R.id.graph);
for (int i = 0; i < FragmentDiaryWeight.weightDiaryList.size(); i++) {
series = new LineGraphSeries<>(new DataPoint[]{
new DataPoint(Integer.parseInt(FragmentDiaryWeight.weightDiaryList.get(i).getmDay()), Integer.parseInt(FragmentDiaryWeight.weightDiaryList.get(i).getmWeight())),
});
graph.addSeries(series);
}
}
Я знаю, что данные собираются из массива weightDiaryList
, но линия графика не отображается. Если я заменю x и y, например, на 5 и 10, все в порядке.
Если я использую series.setDrawDataPoints(true)
, точка показывает правильно.
Как я могу это исправить? Как отобразить строку для этого графика?
1 ответ
GraphView graph = findViewById(R.id.graph);
for (int i = 0; i < FragmentDiaryWeight.weightDiaryList.size(); i++) {
series = new LineGraphSeries<>(new DataPoint[]{
new DataPoint(Integer.parseInt(FragmentDiaryWeight.weightDiaryList.get(i).getmDay()), Integer.parseInt(FragmentDiaryWeight.weightDiaryList.get(i).getmWeight())),
});
}
graph.addSeries(series);