2014-03-12 61 views
1

正試圖在Android應用程序中繪製帶有achartengine的折線圖。該圖每隔幾秒自動刷新一次。問題是:如果沒有要繪製的數據,軸將不可見。即使沒有任何可以繪製的圖形,我如何使軸出現? 請幫忙。android achartengine:即使沒有繪圖數據,也顯示座標軸

private XYMultipleSeriesDataset graphDataset = null; 
private XYMultipleSeriesRenderer graphRenderer = null; 
private GraphicalView graphView; 

..... 
..... 

    this.graphDataset = new XYMultipleSeriesDataset(); 
    this.graphRenderer = new XYMultipleSeriesRenderer(); 
    this.graphRenderer.setXLabels(0); 
... 
/// other initialization code, like labels & fonts 
... 
// then i add the data to the series 
     XYSeries series = new XYSeries("Simple graph"); 
      for (int i=0; i<valueArray.size();i++) { 
       series.add(valueArray.get(i), yValue.get(i)); 
      } 
    this.graphDataset.addSeries(series); 
      .... 
      // then I do renderer initialization 
    XYSeriesRenderer xyRenderer = this.setChartLineProperties(index); 
      ... 
      // then finally initializing the graphview 
    this.graphView = ChartFactory.getLineChartView(this, this.graphDataset, 
      this.graphRenderer); 
+0

您可以顯示您在做什麼? – keshav

回答

0

爲了顯示軸,圖表需要知道它必須顯示哪些值範圍。如果數據集中沒有添加任何值,則範圍可以通過以下方式設置:

renderer.setXAxisMin(minX); 
renderer.setXAxisMax(maxX); 
renderer.setYAxisMin(minY); 
renderer.setYAxisMax(maxY); 
+0

謝謝@丹。無論如何,我認爲這是設定的。讓我再檢查一次,然後回來!感謝您在achartengine lib上的精彩工作! – user2903200

+0

我已經這樣做了。還有什麼遺漏嗎?請幫忙。 – user2903200

+0

你爲minX,maxX,minY,maxY設置了什麼值? –