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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:22:03+00:00 2026-06-13T13:22:03+00:00

My goal is create a graph that will hide and show a series depending

  • 0

My goal is create a graph that will hide and show a series depending on user actions. I thought to do that by first clearing the graph and dataset and renderers and then reinserting the new values. Much like the .clear() method of Arraylists, I was wondering if there was some type of similar functionality built for the XYMultipleSeriesRenderer. I noticed that the XYMultipleSeriesDataset was lacking similar functionality, but i was able to resolve that (i think, i can’t be sure yet) by doing

        for(int i = 0; i < dataset.getSeriesCount(); i++) {
            dataset.removeSeries(i);
        }

Luckily XYMultipleSeriesRenderer seems to have a getrenderercount type of method, but not a remove method that takes ints. All i see is a remove function that doesn’t take ints, just actual series renderer names.

Here is more code if that helps:

private void excecuteGraph() {
    //      add series to the complete dataset
    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
    XYMultipleSeriesRenderer mrenderer = new XYMultipleSeriesRenderer();

    switch (graphCase ){
    case -1:
        dataset.addSeries(series0);
        dataset.addSeries(series1);
        dataset.addSeries(series2);
        dataset.addSeries(series3);     

        //          create the individual renderers, customize settings for each
        XYSeriesRenderer renderer1 = new XYSeriesRenderer();
        renderer1.setColor(Color.BLUE);
        renderer1.setLineWidth(3);
        XYSeriesRenderer renderer2 = new XYSeriesRenderer();
        renderer2.setColor(Color.DKGRAY);
        renderer2.setLineWidth(3);
        XYSeriesRenderer renderer3 = new XYSeriesRenderer();
        renderer3.setColor(Color.RED);      
        renderer3.setLineWidth(3);
        XYSeriesRenderer renderer4 = new XYSeriesRenderer();
        renderer4.setColor(Color.WHITE);        
        renderer4.setLineWidth(3);

        //          add renderers to the complete multirenderer, customize settings for it
        mrenderer.addSeriesRenderer(renderer1);
        mrenderer.addSeriesRenderer(renderer2);
        mrenderer.addSeriesRenderer(renderer3);
        mrenderer.addSeriesRenderer(renderer4);
        break;
    case 0:
        for(int i = 0; i < dataset.getSeriesCount(); i++) {
            dataset.removeSeries(i);
        }

        dataset.addSeries(series0);
        XYSeriesRenderer renderer00 = new XYSeriesRenderer();
        renderer00.setColor(Color.BLUE);
        renderer00.setLineWidth(3);
        mrenderer.addSeriesRenderer(renderer00);
        break;
    case 1:
        for(int i = 0; i < dataset.getSeriesCount(); i++) {
            dataset.removeSeries(i);
            Log.d("testingGraph", dataset.toString());
        }

        dataset.addSeries(series1);
        XYSeriesRenderer renderer10 = new XYSeriesRenderer();
        renderer10.setColor(Color.DKGRAY);
        renderer10.setLineWidth(3);
        mrenderer.addSeriesRenderer(renderer10);
        break;
    case 2:
        for(int i = 0; i < dataset.getSeriesCount(); i++) {
            dataset.removeSeries(i);
        }
        dataset.addSeries(series2);
        XYSeriesRenderer renderer20 = new XYSeriesRenderer();
        renderer20.setColor(Color.RED);     
        renderer20.setLineWidth(3);
        mrenderer.addSeriesRenderer(renderer20);
    case 3:
        for(int i = 0; i < dataset.getSeriesCount(); i++) {
            dataset.removeSeries(i);
        }
        dataset.addSeries(series3);
        XYSeriesRenderer renderer30 = new XYSeriesRenderer();
        renderer30.setColor(Color.WHITE);       
        renderer30.setLineWidth(3);
        mrenderer.addSeriesRenderer(renderer30);
    }

    mrenderer.setYTitle("Accuracy (%)");
    mrenderer.setYAxisMin(0);
    mrenderer.setYAxisMax(100);
    mrenderer.setApplyBackgroundColor(true);
    mrenderer.setBackgroundColor(Color.TRANSPARENT);

    //      Get the chart view result, add it to the linear layout
    GraphicalView mChartView = ChartFactory.getTimeChartView(this, dataset,
            mrenderer, "MM/dd/yyyy");

    LinearLayout graphLayout = (LinearLayout) findViewById(R.id.layout_graph);
    graphLayout.addView(mChartView, new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));        

    if (mChartView !=null) {
        mChartView.repaint();
    }

}
  • 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-13T13:22:04+00:00Added an answer on June 13, 2026 at 1:22 pm

    Not sure I understand your question entirely, but I can give you some clues.

    To remove all renderers in an XYMultipleSeriesRenderer:

    renderer.removeAllRenderers();
    

    To remove all series in an XYMultipleSeriesDataset:

    int size = dataset.getSeriesCount();
    for (int i = 0; i < size; i++) {
      // always remove the first element because once you remove one element,
      // the size of the list becomes size - 1 and so on
      dataset.removeSeries(0);
    }
    

    However, if you want to hide one single series, then just remove that one and not all of them.

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

Sidebar

Related Questions

My goal is to create an entry form (addnew.php) that will allow me to
The goal is to create a program which will effectively let the user create
My goal is to create a validated IP address field that will be validated
Goal: create webservice that will query database and return rows, then pass it to
My goal is to create a time zone converter that will compare two different
My goal is to create a version of the app that will expire after
Hi here's the goal: to create an automatic bit of content that toggles open
High Level Goal: Create a single Maven Web Application project that can be used
My goal is to create a sqlite database file that would be downloaded by
My goal is to create an eBook that I can read with the Mobipocket

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.