Reputation: 289
There is 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>
There is 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);
}
}
I know that data are collected from Array weightDiaryList
, but line of graph not showing. If I replace x and y for, example, 5 and 10, all is ok.
If I using series.setDrawDataPoints(true)
, point showing correctly.
How can I fix it? How to display line for this Graph?
Upvotes: 1
Views: 779
Reputation: 570
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);
Upvotes: 1