2
我使用androidplot實現了一個繪圖。下面是一些片段:繪圖沒有正確顯示(Androidplot lib)
的.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
的和LineAndPointFormatter
的選擇(無論是在Java代碼和XML) - 顏色,填充,描繪了 - 一切我能想到的。並由此產生的陰謀是總是藍色像這樣。如果你看起來足夠近,你會看到它背後有一個格式正確的情節 - 有座標軸,圖例,數據系列等等,但我不知道如何擺脫這個藍色覆蓋!