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

  • Home
  • SEARCH
  • 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 8436811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:17:04+00:00 2026-06-10T07:17:04+00:00

I am right now trying to create a bar-chart in android using achartengine,hopefully i

  • 0

I am right now trying to create a bar-chart in android using achartengine,hopefully i have created it,but here the problem is the bars which i have created are displaying too nearer with each bars, i need to show those bars with the below orders(ord1,ord2 etc,..) which are all on the x-axis?

Can any one please let me know the solution to over come this issue?

The following image will make clear,please find it

enter image description here

Please find my sources for reference

BarActivity.java

 public class BarActivity extends Activity 
 { 
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    Intent intent = createIntent();
    startActivity(intent);
}


 public Intent createIntent() 

 {

String[] titles = new String[] { "Order's profit of the year", " " };
List<double[]> values = new ArrayList<double[]>();
values.add(new double[] { 29, 83, 47, 33 });
values.add(new double[] {});

int[] colors = new int[] { Color.WHITE, Color.BLACK};

XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
renderer.setOrientation(Orientation.HORIZONTAL);

setChartSettings(renderer, "Profit for the year 2012", " ", " ", 0,100, 0,100, Color.GRAY, Color.LTGRAY);

renderer.setXLabels(1);
renderer.setYLabels(10);

renderer.addXTextLabel(10.75, "ord1");
renderer.addXTextLabel(20.75, "ord2");
renderer.addXTextLabel(30.75, "ord3");
renderer.addXTextLabel(40.75, "ord4");

int length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) 
{
  SimpleSeriesRenderer seriesRenderer = renderer.getSeriesRendererAt(i);
  seriesRenderer.setDisplayChartValues(true);
  }

return ChartFactory.getBarChartIntent(this, buildBarDataset(titles, values), renderer,Type.DEFAULT);
}

protected XYMultipleSeriesRenderer buildBarRenderer(int[] colors) 
{

// creates a SeriesRenderer and initializes it with useful default values as well as colors

    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();

    renderer.setAxisTitleTextSize(16);

    renderer.setChartTitleTextSize(20);

    renderer.setLabelsTextSize(15);

    renderer.setLegendTextSize(15);

    int length = colors.length;

    for (int i = 0; i < length; i++) 
    {
      SimpleSeriesRenderer r = new SimpleSeriesRenderer();
      r.setColor(colors[i]);
      renderer.addSeriesRenderer(r);
    }
    return renderer;
  }

   protected void setChartSettings(XYMultipleSeriesRenderer renderer, String title, String xTitle,
   String yTitle, double xMin, double xMax, double yMin, double yMax, int axesColor,int labelsColor) 
  {

  // sets lots of default values for this renderer

   renderer.setChartTitle(title);

   renderer.setXTitle(xTitle);
   renderer.setYTitle(yTitle);

   renderer.setXAxisMin(xMin);
   renderer.setXAxisMax(xMax);

   renderer.setYAxisMin(yMin);
   renderer.setYAxisMax(yMax);

   renderer.setAxesColor(axesColor);
   renderer.setLabelsColor(labelsColor);

   renderer.setApplyBackgroundColor(true);
   renderer.setBackgroundColor(Color.BLACK);

}

protected XYMultipleSeriesDataset buildBarDataset(String[] titles, List<double[]> values) 
{

    // adds the axis titles and values into the dataset

    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
    int length = titles.length;

    for (int i = 0; i < length; i++) 
    {
      CategorySeries series = new CategorySeries(titles[i]);
      double[] v = values.get(i);
      int seriesLength = v.length;
      for (int k = 0; k < seriesLength; k++) 
      {
        series.add(v[k]);
      }

      dataset.addSeries(series.toXYSeries());
     }
    return dataset;
    }
  }

Thanks for your precious time!..

  • 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-10T07:17:05+00:00Added an answer on June 10, 2026 at 7:17 am

    You are calling setChartSettings with some parameters that set the X axis visual range between 0 and 100 and the same for the Y axis. You can tweak these parameters for having a better relaxed display.

    You can also play with renderer.setBarSpacing() for tweaking the spacing between bars in a ber chart.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a faster query, right now i have large databases. My
So I'm trying to create a forum with avatars, but right now the text
I have an issue right now with a program im trying to create. The
Right now i am trying to create a graph in android by self learning.After
Right now i am trying to create a graph in android,after searching from google
I am trying to create a multi threaded PHP application right now. I have
I am trying to create a sub navigation. Right now I have two subnav.
I'm trying to create an android keyboard, right now I want it just to
I am trying to create a Listview with multiple strings. Right now I have
Right now I am trying to create a producer/consumer thread, the producer thread goes

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.