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 8909469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:26:18+00:00 2026-06-15T03:26:18+00:00

Right now i am creating a barchart in android using AChartEngine.After getting run of

  • 0

enter image description here

enter image description here

Right now i am creating a barchart in android using AChartEngine.After getting run of my application,at-first the emulator is showing like the first below image. But i need to show like the second below image how to do this?

And also i need to change the color for the background and also i wanna change the bar-charts colors,
How to do these things?

I have tried these codes, but not working

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

Please find my sources for reference.

Chart.java

public class Chart extends Activity {
EditText edt1, edt2;
TextView txtv1;
Button btn;
Bundle data;

String[] orderNo = new String[10];
int[] freightRate = new int[10];
int[] marginPercent = new int[10];

@Override
public void onCreate(Bundle savedInstanceState)     {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    edt1 = (EditText) findViewById(R.id.editText1);
    edt2 = (EditText) findViewById(R.id.editText2);
    btn = (Button) findViewById(R.id.button1);

    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            getTMSChart(edt1.getText().toString(), edt2.getText().toString());
            Intent intnt = new Intent(v.getContext(), BarGraphActivity.class);
            intnt.putExtras(data);

            startActivity(intnt);
        }
    });
}

public void getTMSChart(String FromDate, String ToDate) 
{

    System.setProperty("http.keepAlive", "false");
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

    envelope.dotNet = true;

    String METHOD = "GetTMSChart";
    String NAMESPACE = "http://tempuri.org/";
    String SOAP_ACTION = "http://tempuri.org/GetTMSChart";
    String URL = "http://54.251.60.177/TMSOrdersService/TMSDetails.asmx";

    SoapObject request = new SoapObject(NAMESPACE, METHOD);

    request.addProperty("FromDate", FromDate.trim());
    request.addProperty("ToDate", ToDate.trim());
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapObject result = (SoapObject) envelope.bodyIn;
        SoapObject root = (SoapObject) ((SoapObject) (result).getProperty(0)).getProperty("NewDataSet");
        int tablesCount = root.getPropertyCount();

        data = new Bundle();

        for (int i = 0; i < tablesCount; i++) {

            SoapObject table = (SoapObject) root.getProperty(i);
            orderNo[i] = table.getPropertyAsString("Order_No");
            freightRate[i] = Integer.parseInt(table.getPropertyAsString("Freight_Rate"));
            marginPercent[i] = Integer.parseInt(table.getPropertyAsString("Margin_Percent"));               

/*Toast.makeText(getApplicationContext(), "Order No:" + orderNo[i] + "\nFreigtRate:" + freightRate[i] + "\nMarginPc:" + marginPercent[i], Toast.LENGTH_SHORT).show();*/
        }
        data.putStringArray("orderno", orderNo);
        data.putIntArray("freightrate", freightRate);
        data.putIntArray("marginpercent", marginPercent);
        data.putInt("count",tablesCount);
    }
catch (Exception e) 
{
    Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    e.printStackTrace();
    }   }}

BarGraphActivity.java

public class BarGraphActivity extends Activity{

String[] orderNo = new String[10];
int[] freightRate = new int[10];
int[] marginPercent = new int[10];
int count;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main1);

    Bundle idata = getIntent().getExtras();
    if (idata !=null)
    {
        orderNo = idata.getStringArray("orderno");  
        freightRate = idata.getIntArray("freightrate");
        marginPercent = idata.getIntArray("marginpercent");
        count = idata.getInt("count");


        CategorySeries series = new CategorySeries("Order-FreightRate Graph");
        for ( int i = 0; i < count; i++){
            series.add(orderNo[i], freightRate[i]);
        }


        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(series.toXYSeries());

        XYSeriesRenderer renderer = new XYSeriesRenderer();
        renderer.setDisplayChartValues(true);
        //renderer.setChartValuesSpacing(1);



        XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
        mRenderer.addSeriesRenderer(renderer);

        for ( int i = 0; i < count; i++){
            mRenderer.addXTextLabel(i+1, orderNo[i]);
            }

        mRenderer.setZoomButtonsVisible(true);
        mRenderer.setBarSpacing(0.5);


        Intent intent = ChartFactory.getBarChartIntent(getApplicationContext(), dataset, mRenderer, Type.DEFAULT);
        startActivity(intent);      
        }        }  }

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-15T03:26:19+00:00Added an answer on June 15, 2026 at 3:26 am

    Hi if you want to change background color for your chart just use these methods

       mrenderer.setApplyBackgroundColor(true);
       mrenderer.setBackgroundColor(Color.parseColor("#898989")); // here you have to give hexa decimal code 
       mrenderer.setMarginsColor(Color.parseColor("#898989")); // here you have to give hexa decimal code
    

    If you want to change your bar color means just do like this

           int[] colors = new int[] { Color.parseColor("#DAE1EB"), Color.parseColor("#406193")};
         int color_length = colors.length;
         for (int i = 0; i < color_length; i++) 
         {
             SimpleSeriesRenderer r = new SimpleSeriesRenderer();
             r.setColor(colors[i]);
             r.setChartValuesSpacing(5);
             mrenderer.addSeriesRenderer(r);
         }   
    

    If you are creating multiple renderer means use different color for the dual bar. If you are creating single bar means give only one color. It will works.

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

Sidebar

Related Questions

I am creating android/iphone application using Titanium Studio and right now stack with a
I'm writing my first MVC app right now and am creating a new MembershipProvider
I'm writing my first MVC app right now and am creating a new MembershipProvider
So I am creating a table from a view right now like this: CREATE
I want to create objects dynamically. Right now I'm creating them manually like this
Right now I'm creating an application for WP7 and have recieved alot of feedback
I am creating a store using Active Merchant and PayPal sandbox right now. It
right now I'm creating an array and using: render :json => @comments This would
Right now I'm creating an application to manage the inventory. We receive products very
I'm trying to learn python (using python3.2), and right now I'm creating a program

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.