Search code examples
androidplotandroidplot

Plot not shown correctly (Androidplot lib)


I implemented a plot using androidplot. Here are some snippets:

.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" />

code

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

link to 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();
}

And this is what I get in the end: output plot

I tried manipulating XYPlot's and LineAndPointFormatter's options (both in java code and xml) - colors, fills, paints - everything I could think of. And the resulting plot was always blue like this. If you look close enough you will see that behind it there is a properly formatted plot - with axes, legend, data series, etc. But I do not know how to get rid of this blue overlay!


Solution

  • plot.disableAllMarkup(). That's it.