簡體   English   中英

GraphView 不顯示折線圖

[英]GraphView not showing line graph

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);
    }
}

我知道數據是從 Array weightDiaryList收集的,但沒有顯示圖形線。 如果我將 x 和 y 替換為例如 5 和 10,則一切正常。

如果我使用series.setDrawDataPoints(true) ,點顯示正確。

我該如何解決? 如何顯示此圖表的線條?

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM