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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:07:30+00:00 2026-05-31T13:07:30+00:00

I am trying to make two lines appear in a graph according to this

  • 0

I am trying to make two lines appear in a graph according to this video:
http://www.youtube.com/watch?v=5DGldVzC-bU

My code:

public class LineGraph {
    public Intent getIntent(Context context){


        int[] x = {1,2,3,4,5,6,7,8,9,10}; 
        int[] y = {31,29,54,94,75,36,47,118,92,10};



        TimeSeries series = new TimeSeries("Line1");
        for (int i=0;i<x.length;i++){
            series.add(x[i],y[i]);
        }

        int[] x2 = {1,2,3,4,5,6,7,8,9,10}; 
        int[] y2 = {39,145,35,87,2,65,48,49,100,106};

        TimeSeries series2 = new TimeSeries("Line2");
        for (int i=0;i<x2.length;i++){
            series.add(x2[i],y2[i]);
        }



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



        XYSeriesRenderer renderer = new XYSeriesRenderer();
        renderer.setColor(Color.CYAN);
        renderer.setPointStyle(PointStyle.SQUARE);
        renderer.setFillPoints(true);
        renderer.setLineWidth(3);
        renderer.setDisplayChartValues(true);

        XYSeriesRenderer renderer2 = new XYSeriesRenderer();
        renderer2.setColor(Color.BLACK);
        renderer2.setPointStyle(PointStyle.CIRCLE);
        renderer2.setFillPoints(true);
        renderer2.setLineWidth(3);
        renderer2.setDisplayChartValues(true);

        XYMultipleSeriesRenderer mrenderer = new XYMultipleSeriesRenderer();
        mrenderer.addSeriesRenderer(renderer);
        mrenderer.addSeriesRenderer(renderer2);

        mrenderer.setChartTitle("title");

        mrenderer.setBackgroundColor(Color.WHITE);

        mrenderer.setShowGrid(true);
        mrenderer.setApplyBackgroundColor(true);

        mrenderer.setXTitle("Days");
        mrenderer.setYTitle("datas");

        mrenderer.setGridColor(Color.GRAY);
    //  mrenderer.setZoomButtonsVisible(true);

        Intent intent = ChartFactory.getLineChartIntent(context, dataset, mrenderer, "Line graph title");
        return intent;

    }

Practically the same as in the video. But my doesnt work, instead of getting two different lines, I get only one. When the last data of the first line (x) ends it goes to the first data of the second line (x2), so the second line continues from the first one.
Thanks in advance!

  • 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-05-31T13:07:31+00:00Added an answer on May 31, 2026 at 1:07 pm

    Shouldn’t the following:

    series.add(x2[i],y2[i]);
    

    be actually:

    series2.add(x2[i],y2[i]);
    

    Note the ‘2’.

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

Sidebar

Related Questions

I am trying to make two ajax requests in parallel using jQuery like this:
After wasting two days with this question (and trying to make it work), I've
I'm trying to make two lines that follows the mouse every time the MouseMove
I'm trying to make two Kinects getting along under the same application. I've tried
I'm trying to make two transparent images (having the same size/dimension) overlap within a
I am trying to make two .exe files in c where first one store
I'm trying to make two columns — sidebar and content. Minimum height of each
I'm new to C++ and trying to make two simple functions, but something goes
I'm trying to make JTextPane with two columns, both aligning to left like that:
I am trying to make a form using two drop down select menus: one

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.