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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:47:48+00:00 2026-06-05T06:47:48+00:00

I am trying to integrate Achart engine in my activity class to show a

  • 0

I am trying to integrate Achart engine in my activity class to show a line chart but the problem is i have to make menu on the chart activity.And i don’t have access to that activity.
the code i am using is below.

       public class AchartActivity extends Activity implements OnClickListener
      {
        Button b1;
        @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

       b1=(Button)findViewById(R.id.button1);
       b1.setOnClickListener(this);
      }

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    double[] a1 = new double[] { 18, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 };
    double[] a2 = new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2,13.9 };
    showChart(a1,a2);
}


void showChart(double[] a1,double[] a2 )
{
    String[] titles = new String[] { "Crete", "Corfu" };
    List<double[]> x = new ArrayList<double[]>();
    for (int i = 0; i < titles.length; i++) {
      x.add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
    }
    List<double[]> values = new ArrayList<double[]>();
    values.add(a1);
    values.add(a2);

    int[] colors = new int[] { Color.BLUE, Color.GREEN};
    PointStyle[] styles = new PointStyle[] { PointStyle.CIRCLE, PointStyle.DIAMOND,
        };
    XYMultipleSeriesRenderer renderer;
    renderer = new XYMultipleSeriesRenderer();
    renderer.setAxisTitleTextSize(16);
    renderer.setChartTitleTextSize(20);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setPointSize(5f);
    renderer.setMargins(new int[] { 20, 30, 15, 20 });
    int length = colors.length;
    for (int i = 0; i < length; i++) {
      XYSeriesRenderer r = new XYSeriesRenderer();
      r.setColor(colors[i]);
      r.setPointStyle(styles[i]);
      renderer.addSeriesRenderer(r);
    }
    int length1 = renderer.getSeriesRendererCount();
    for (int i = 0; i < length1; i++) {
      ((XYSeriesRenderer) renderer.getSeriesRendererAt(i)).setFillPoints(true);
    }

    renderer.setChartTitle("Average temperature");
    renderer.setXTitle("Month");
    renderer.setYTitle("Temperature(degree celcius)");
    renderer.setXAxisMin(0.5);
    renderer.setXAxisMax(12.5);
    renderer.setYAxisMin(-10);
    renderer.setYAxisMax( 40);
    renderer.setAxesColor(Color.LTGRAY);
    renderer.setLabelsColor(Color.LTGRAY);
    renderer.setXLabels(12);
    renderer.setYLabels(10);
    renderer.setShowGrid(true);
    renderer.setXLabelsAlign(Align.RIGHT);
    renderer.setYLabelsAlign(Align.RIGHT);
    renderer.setZoomButtonsVisible(true);
    renderer.setPanLimits(new double[] { -10, 20, -10, 40 });
    renderer.setZoomLimits(new double[] { -10, 20, -10, 40 });
    XYMultipleSeriesDataset dataset=null;
    dataset = new XYMultipleSeriesDataset();

    int length2 = titles.length;
    for (int i = 0; i < length2; i++) {
      XYSeries series = new XYSeries(titles[i], 0);
      double[] xV = x.get(i);
      double[] yV = values.get(i);
      int seriesLength = xV.length;
      for (int k = 0; k < seriesLength; k++) {
        series.add(xV[k], yV[k]);
      }
      dataset.addSeries(series);
    }

    Intent intent = ChartFactory.getLineChartIntent(this, dataset,
        renderer, "Average temperature");
    startActivity(intent);
}

}

  • 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-05T06:47:50+00:00Added an answer on June 5, 2026 at 6:47 am

    this was done easily by just changing the method used above.
    i.e

         ChartFactory.getLineChartIntent(this, dataset,
        renderer, "Average temperature");
    

    i used the method

          ChartFactory.getLineChartView(this,dataset, renderer);
    

    the above function returned an object of

       GraphicalView
    

    now this graphical view object can be easily set in our layout and hence i was able to draw the chart in my own activity class.

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

Sidebar

Related Questions

I am trying to integrate a Hibernate application into a proprietary framework. My problem
I'm trying to integrate the Google Federated Login with a premier apps account, but
I'm trying integrate spring with hibernate but catch exception on project start. Caused by:
I'm trying integrate spring with hibernate but catch NamingException: Context is read only stacktrace
I'm trying to integrate facebook login on a site I'm working on, but so
I am trying to integrate kiip in my android app . I have downloaded
I'm trying to integrate Jawr into my Spring application: <bean abstract=true id=jawrBase class=net.jawr.web.servlet.JawrSpringController> <property
I am trying to integrate isotope but Iam having problems getting it to work
I am trying to integrate Facebook into my app and have already implemented MGTwitterEngine
I am trying to integrate forem with thumbs_up. I have inherited the forem Post

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.