2014-03-12 62 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设置了什么值? –