0

I am using androidplot-core-0.6.1.jar and I'm modifying the SimpleXYPlotActivity example from the quickstart tutorial. I have removed some items and margin/padding, but what I want to do and can not find a way how, is to remove the space to the left of the chart. I have marked the space I want to remove with red in the image below. Can this be done?

How it looks

Red shows what I want to remove

Code from the activity:

public class MyXYPlotActivity extends Activity {

   private XYPlot plot;

   @Override
   public void onCreate(Bundle savedInstanceState)
   {
       super.onCreate(savedInstanceState);

       requestWindowFeature(Window.FEATURE_NO_TITLE);
       getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
       WindowManager.LayoutParams.FLAG_FULLSCREEN);

       setContentView(R.layout.simple_xy_plot_example);

       setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);

       plot = (XYPlot) findViewById(R.id.mySimpleXYPlot);

       Number[] series1Numbers = {1, 8, 5, 2, 7, 4};

       XYSeries series1 = new SimpleXYSeries(
               Arrays.asList(series1Numbers),          // SimpleXYSeries takes a List so turn our array into a List
               SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
               "Foo");                               // Set the display title of the series

       LineAndPointFormatter series1Format = new LineAndPointFormatter();
       series1Format.setPointLabelFormatter(new PointLabelFormatter());
       series1Format.configure(getApplicationContext(),
               R.xml.line_point_formatter_with_plf1);

       plot.addSeries(series1, series1Format);

       plot.setDomainValueFormat(new DecimalFormat("#"));
       plot.setRangeValueFormat(new DecimalFormat("#"));

       plot.setTitle("Title");
       plot.setRangeBoundaries(0,10, BoundaryMode.FIXED);

       int length = 30;
       plot.setDomainBoundaries(1,length, BoundaryMode.FIXED);

       plot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 1);

       plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);

       plot.setMarkupEnabled(true);

       plot.setTicksPerRangeLabel(1);
       plot.setTicksPerDomainLabel(1);
       plot.getGraphWidget().setDomainLabelOrientation(90);

       plot.getLayoutManager().remove(plot.getLegendWidget());
       plot.getLayoutManager().remove(plot.getRangeLabelWidget());
       plot.getLayoutManager().remove(plot.getDomainLabelWidget());

       plot.setPlotMargins(0, 0, 0, 0);
       plot.setPlotPadding(0, 0, 0, 0);

       plot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);

       plot.getRangeLabelWidget().setHeight(0);
       plot.getRangeLabelWidget().setWidth(0);
       plot.getRangeLabelWidget().setPadding(0, 0, 0, 0);
       plot.getRangeLabelWidget().setMargins(0, 0, 0, 0);

       plot.getDomainLabelWidget().setHeight(0);
       plot.getDomainLabelWidget().setWidth(0);
       plot.getDomainLabelWidget().setPadding(0, 0, 0, 0);
       plot.getDomainLabelWidget().setMargins(0, 0, 0, 0);

   }
}

EDIT: I found the solution:

XYGraphWidget g = plot.getGraphWidget();
g.setRangeLabelWidth(25);
g.setDomainLabelWidth(25);

This above works.

BlueCat
  • 23
  • 4

1 Answers1

0

Looks like you want to reduce/remove the graphWidget's margins and/or padding. Try adding these to your code to see if it is having the desired effect...you'll obviously need to use nonzero values suited for your application:

plot.getGraphWidget().setMarginLeft(0);
plot.getGraphWidget().setPaddingLeft(0);

Also take a look at these similar questions:

Have a GraphWidget fill the entire View in AndroidPlot

How do I remove all space around a chart in AndroidPlot?

Community
  • 1
  • 1
Nick
  • 8,181
  • 4
  • 38
  • 63
  • setMarginsLeft(0) and setPaddingLeft(0) did not have the desired effect – BlueCat Jun 11 '14 at 18:52
  • Can you elaborate? Was there no effect or was the effect too much, too little, not to the desired area or some combination of the above? – Nick Jun 11 '14 at 19:07
  • Nick: Trying the code, nothing changed at all visually. I found something that worked though after checking one of the links you provided, and playing around some. I edited my initial question to include the solution. Thank you. – BlueCat Jun 11 '14 at 19:53