1

私はこのライブラリを使用しています: https://github.com/jjoe64/GraphView-Demos for Draw chart in my application.this library is work but when I want to draw new chart or redraw not work

このリンクは表示されますが機能しません: GraphView と resetData

アクティビティでチャートを描画するための私のコード:

GraphViewData[] newData = new GraphViewData[arrayWeight.size()];
    int i = 0;
    String date_now = "";

    for (Weight w : arrayWeight) {
        i += 1;
        date_now = w.getdate();
        date_now = date_now.substring(8);

        newData[arrayWeight.indexOf(w)] = new GraphViewData(
                Integer.parseInt(date_now), w.getWeight());

    }

    GraphViewSeries exampleSeries = new GraphViewSeries(newData);
    exampleSeries.resetData(newData);
    GraphView graphView = new LineGraphView(this, "weight");
    graphView.redrawAll();
    graphView.setVerticalLabels(new String[] { "100", "50", "1" });
    graphView.setShowLegend(true);
    graphView.setBackgroundColor(Color.GRAY);

    graphView.addSeries(exampleSeries); // data
    LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
    layout.addView(graphView);
4

1 に答える 1

2

グラフを新しいデータで埋めたい場合は、新しいグラフビュー オブジェクトを作成する必要はなく、新しいグラフビュー シリーズ オブジェクトを作成する必要もありません。resetData を使用して、graphviewseries オブジェクトのデータを変更するだけです。GraphView-Demos プロジェクトを詳しく見てみましょう。実際の例があります。

于 2014-02-19T11:32:46.050 に答える