android achartengine:即使没有绘图数据也显示轴

时间:2014-03-12 10:25:50

标签: 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);

1 个答案:

答案 0 :(得分:0)

为了显示轴,图表需要知道它必须显示的值范围。如果没有向数据集添加任何值,则可以通过以下方式设置范围:

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