Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9206549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:11:58+00:00 2026-06-18T00:11:58+00:00

I’ve got a minimalist chart using androidPlot in an application, and have been trying

  • 0

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:

What my chart looks like

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:11:59+00:00Added an answer on June 18, 2026 at 12:11 am

    The Plot itself (mDynamicPlot in your example) is essentially a collection of widgets positioned in a shared space. The actual class that handles the positioning is LayoutManager.

    In addition to positioning, the size of the Widget will also need to be adjusted to fill the entire Plot. Each Widget keeps track of its own size using an instance of SizeMetrics. You can modify the size of any Widget by invoking setSize(SizeMetrics newInstance); The “chart” area you are interested in corresponds to the XYGraphWidget. 

    I have not personally tested this but I believe the code below should do what you want:

    // get a handle to the XYGraphWidget:

    Widget gw = mDynamicPlot.getGraphWidget();
    
    // FILL mode with values of 0 means fill 100% of container:
    SizeMetrics sm = new SizeMetrics(0,SizeLayoutType.FILL,
                                     0,SizeLayoutType.FILL));
    gw.setSize(sm);
    
    // get a handle to the layout manager:
    LayoutManager lm = mDynamicPlot.getLayoutManager();
    
    // position the upper left corner of gw in the upper left corner of the space 
    // controlled by lm.
    lm.position(gw, 0, XLayoutStyle.ABSOLUTE_FROM_LEFT,
                0, YLayoutStyle.ABSOLUTE_FROM_TOP);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have been unable to fix a problem with Java Unicode and encoding. The
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.