2012-12-19 37 views
1

我有一個lineGraph的浮動值在x軸和y軸?我的問題是,如何設置像日期或months.I的名稱x軸的字符串值現在用GraphView-3.0.jar library.my代碼在圖上的x軸上設置字符串值?

values_list.add(1.0); 
values_list.add(5.0); 
values_list.add(9.0); 
values_list.add(12.0); 
values_list.add(17.0); 
values_list.add(1.0); 
values_list.add(13.0); 
values_list.add(23.0); 
graphData = new GraphViewData[(values_list.size())]; 
double price_copy = 0; 
for (int i = 0; i < values_list.size(); i++) { 
    price_copy = values_list.get(i); 
    graphData[i] = new GraphViewData(i, price_copy); 

} 
GraphView graphView; 

graphView = new LineGraphView(this // context 
     , "");// graphView.addSeries(exampleSeries);// data 
graphView.addSeries(new GraphViewSeries("values", 
     new GraphViewStyle(Color.rgb(00, 00, 128), 3), 
     graphData)); 

graphView.setShowLegend(true); 
// set view port, start=2, size=40 
graphView.setViewPort(0, 10); 
graphView.setScalable(true); 
graphView.setScrollable(true); 

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

而且我不知道AchartEngine想法,謝謝提前。

+0

你必須更加具體。首先,提醒每個人你正在使用的圖形庫。其次,你想設置'String'值在哪裏?在軸上?在傳奇?作爲軸標題?在個人數據點上? – mango

+0

感謝芒果和布倫德爾提出的寶貴建議。 –

回答

1

使用achart引擎庫。你可以在谷歌搜索。它幫助我。謝謝

+1

對不起,但在這種情況下,只是更改整個圖形庫並不是一個可接受的答案 – appsthatmatter

0

只需使用標籤格式化程序。您可以將您的x標籤作爲字符串存儲在數組中。

例如:

final String[] xLabels = new String[] { 
    "foo", "bar", "third", "bla", "more" 
}; 
GraphView graphView = new LineGraphView(this, "example") { 
   @Override 
   protected String formatLabel(double value, boolean isValueX) { 
      if (isValueX) { 
         return xLabels[(int) value]; 
      } else { 
         // return y label as number 
         return super.formatLabel(value, isValueX); // let the y-value be normal-formatted 
      } 
   } 
};