2

我使用 androidplot 实现了一个情节。以下是一些片段:

.xml

<com.androidplot.xy.XYPlot
        android:id="@+id/plot"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="5px"
        android:layout_marginLeft="5px"
        android:layout_marginRight="5px"
        android:layout_marginTop="10px"
        title="Dynamic Plot" />

代码

private XYPlot plot;
// DynamicSerie implements XYSerie
private DynamicSerie XSerie, YSerie;
...
// this thread is just for redrawing
private class PlotTimerTask extends TimerTask {
    @Override
    public void run() {
        try{
            plot.postRedraw();
        }catch(InterruptedException e){
            e.printStackTrace();
        }
    }
}
...
// most if this init looks just like in Androidplot.com tutorial

教程链接

plot = (XYPlot) findViewById(R.id.plot);
XSerie = new DynamicSerie(DataSeries.X_VEC, "X Axis Acc");
YSerie = new DynamicSerie(DataSeries.Y_VEC, "Y Axis Acc");
LineAndPointFormatter f1 = new LineAndPointFormatter(Color.rgb(0, 0, 200), null, Color.rgb(0, 0, 80));
f1.getFillPaint().setAlpha(220);
plot.addSeries(XSerie, f1);
plot.addSeries(YSerie, new LineAndPointFormatter(Color.rgb(0, 0, 0), null, Color.rgb(0, 80, 0)));
plot.setGridPadding(5, 0, 5, 0);
...
@Override
protected void onPause() {
    timerTask.cancel();
    timer.purge();
    super.onPause();
}
@Override
protected void onResume() {
    timerTask = new PlotTimerTask();
    timer.schedule(timerTask, 0, Constants.PLOT_REFRESH_RATE);
    super.onResume();
}

这就是我最终得到的: 输出图

我尝试操作XYPlot's 和LineAndPointFormatter' 选项(在 java 代码和 xml 中)——颜色、填充、绘画——我能想到的一切。由此产生的情节总是像这样是蓝色的。如果你看得足够近,你会看到它后面有一个格式正确的图 - 带有轴、图例、数据系列等。但我不知道如何摆脱这个蓝色覆盖!

4

1 回答 1

3

plot.disableAllMarkup(). 而已。

于 2012-08-17T08:49:57.923 回答