2012-08-12 189 views
0

我正在使用GraphView庫,我想使用方法GraphViewData來顯示LineGraph。說實話,我不知道如何用這個庫生成LineGraph。所以我刪除了顯示LineGraph的示例模擬數據,並用我自己的x數據和y數據替換了它。GraphView庫x和y軸

但我做錯了什麼,它不顯示線條它的自我,只有它填補了X軸和Y軸:

Bundle extras = getIntent().getExtras(); 
if(extras != null) { 
    valueX = extras.getDouble("xValue"); 
    valueY = extras.getDouble("yValue"); 
    Log.d("X = " + valueX, " Y = " + valueY); 
} 

GraphViewSeries exampleSeries = new GraphViewSeries(
    new GraphViewData[] { 
     new GraphViewData(valueX, valueY) 
    }); 

// graph with dynamically genereated horizontal and vertical labels 
GraphView graphView; 
graphView = new LineGraphView(
    this,       // context 
    "Incomming Bluetooth Data"); // heading 
graphView.addSeries(exampleSeries); // data 

LinearLayout layout = (LinearLayout) findViewById(R.id.graph1); 
layout.addView(graphView); 

回答

1

你只定義座標1分。 要繪製線條,您需要定義2個不同點的座標。

在數組中添加另一個具有不同X和Y值的GraphViewData。