I am trying to create a custom XYPlot with Androidplot but can't seem to fully configure it.
This is my code:
XYSeries series = new SimpleXYSeries(Arrays.asList(dates), Arrays.asList(times), "Time on level");
// Create a formatter to use for drawing a series using LineAndPointRenderer:
LineAndPointFormatter formatter = new LineAndPointFormatter(Color.rgb(0, 100, 0), Color.rgb(0, 100, 0), null, new PointLabelFormatter(Color.BLUE));
totalTimePlot.setRangeValueFormat(new DecimalFormat("#.#"));
totalTimePlot.setGridPadding(0, 0, 0, 200);
totalTimePlot.setBackgroundColor(Color.WHITE);
totalTimePlot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
totalTimePlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
totalTimePlot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
totalTimePlot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);
totalTimePlot.setTicksPerDomainLabel(1);
totalTimePlot.setRangeStepValue(10);
totalTimePlot.getGraphWidget().setDomainLabelOrientation(-90);
totalTimePlot.setMarkupEnabled(false);
totalTimePlot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);
totalTimePlot.setDomainValueFormat(new Format() {
SimpleDateFormat sdf = new SimpleDateFormat("EEE(MM.dd)-HH:mm:ss");
@Override
public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field) {
long timestamp = ((Number) object).longValue();
Date date = new Date(timestamp);
return sdf.format(date, buffer, field);
}
@Override
public Object parseObject(String string, ParsePosition position) {
return null;
}
});
totalTimePlot.getGraphWidget().setPaddingLeft(4);
totalTimePlot.addSeries(series, formatter);
And this is the end result:
As you can see this is very ugly. Can you help me at least configure it so that the Range labels are displayed. I would also like to know how to make the background white as well as have the first and last "ticks" visible.
Thank you.
EDIT:
I managed to include the first and last value by setting the boundaries. But the other problems remain.