I've got a minimalist chart using androidPlot in an application, and have been trying to remove extraneous visual elements. I've got everything done, except that I cannot get rid of some empty spaces around the chart itself within the view. Here's what it looks like with markup turned on, just sitting in the root view of an Activity:
How can I eliminate the black space between the inner chart boundaries and the outer view boundary? Here's my code:
mDynamicPlot = (XYPlot) findViewById(R.id.dynamicPlot);
mDynamicPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0"));
mDynamicPlot.addSeries(mCpuData, new LineAndPointFormatter(Color.rgb(51, 204, 255), null, Color.rgb(8, 153, 194)));
mDynamicPlot.setDomainStepMode(XYStepMode.INCREMENT_BY_VAL);
mDynamicPlot.setRangeBoundaries(0, 100, BoundaryMode.FIXED);
mDynamicPlot.setDomainStepValue(10);
mDynamicPlot.setRangeStepValue(5.0d);
mDynamicPlot.setRangeValueFormat(new DecimalFormat("#"));
mDynamicPlot.setTicksPerDomainLabel(Integer.MAX_VALUE);
mDynamicPlot.getLayoutManager().remove(mDynamicPlot.getLegendWidget());
mDynamicPlot.getLayoutManager().remove(mDynamicPlot.getRangeLabelWidget());
mDynamicPlot.getLayoutManager().remove(mDynamicPlot.getDomainLabelWidget());
mDynamicPlot.getLayoutManager().remove(mDynamicPlot.getTitleWidget());
mDynamicPlot.getGraphWidget().setMarginTop(10);
mDynamicPlot.setBackgroundPaint(null);
mDynamicPlot.getGraphWidget().setBackgroundPaint(null);
mDynamicPlot.getGraphWidget().setGridBackgroundPaint(null);
mDynamicPlot.getGraphWidget().setDomainLabelPaint(null);
mDynamicPlot.getGraphWidget().setDomainOriginLabelPaint(null);
mDynamicPlot.getGraphWidget().setGridLinePaint(null);
mDynamicPlot.getGraphWidget().setDomainOriginLinePaint(null);
mDynamicPlot.getGraphWidget().setRangeOriginLinePaint(null);
mDynamicPlot.setDrawBorderEnabled(false);
And my XML. The right margin is to offset the left space which I want to get rid of:
<com.androidplot.xy.XYPlot
android:id="@+id/dynamicPlot"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_marginTop="16dp"
android:layout_marginRight="10dp"
title="Dynamic Plot" />
Nothing I do in XML seems to affect the inner bounds, including changing the enclosing layout gravity. I have also tried these, to no effect:
mDynamicPlot.getRangeLabelWidget().setHeight(0);
mDynamicPlot.getRangeLabelWidget().setPadding(0, 0, 0, 0);
mDynamicPlot.getRangeLabelWidget().setMargins(0, 0, 0, 0);
mDynamicPlot.getLegendWidget().setSize(new SizeMetrics(0, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.ABSOLUTE));
mDynamicPlot.getRangeLabelWidget().setSize(new SizeMetrics(0, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.ABSOLUTE));
mDynamicPlot.getDomainLabelWidget().setSize(new SizeMetrics(0, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.ABSOLUTE));
What do I need to do to get rid of all that black space?
See Question&Answers more detail:
os