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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:34:18+00:00 2026-06-02T23:34:18+00:00

I am implementing achartengine within a ViewPager. The view holding the chart has a

  • 0

I am implementing achartengine within a ViewPager. The view holding the chart has a spinner with 7 options where you can choose which data you want to view. 6 of the options return a PieChartView and the last one returns a TimeChartView.

The PieChartView charts update and redraw as expected, but when selecting the TimeChartView option, nothing happens. The view stays with the previously selected PieChartView and doesn’t throw an error. I’ve implemented TimeChartView successfully elsewhere in the app and comparisons of the code and the data feeding the chart haven’t thrown up any flags, so I can only assume that my method of switching graph types is incorrect.

The code extract below is the part which deals with switching the views; any advice would be appreciated.

try{
        //if mChartView is already created (has data)
        //we need to invalidate it because it will only accept
        //data less than or equal to the length of data it currently has
        if(mChartView != null){
            mChartView.invalidate();
        }
        if(graphType >= 6){
            mChartView = ChartFactory.getTimeChartView(ctx, mDataset, genericXYRenderer, "MM/dd");
            genericXYRenderer.setClickEnabled(false);
        }else{
            mChartView = ChartFactory.getPieChartView(ctx, genericSeries, genericRenderer);
      genericRenderer.setClickEnabled(false);
      genericRenderer.setSelectableBuffer(10);
        }


      layout.addView(mChartView, new LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
     mChartView.repaint();
    } catch (Exception e) {
        Log.e("[appname]", "Error trying to set ChartView", e);
        m_Logger = new Logger();
    m_Logger.error(e);
}

Many Thanks,
Dave

  • 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-02T23:34:20+00:00Added an answer on June 2, 2026 at 11:34 pm

    Ok. So the PieCharts were updating because mChart view held a reference to PieChartView and the spinner options were providing it with array data in the same format (albeit different sizes).

    Calling

    mChartView.invalidate();
    

    (I’m guessing) just cleared the data it held, but still kept a reference to a PieChartView. When the TimeChartView option was selected, the array data was in a different format which was incompatible with a PieChartView. Not sure why it didn’t throw an error.

    Anyway, the solution was to replace the .invalidate() call with:

    layout.removeView(mChartView);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an app in which i am implementing Achart engine line chart.
I am implementing an achartengine line graph. I don't want to display the title
When implementing the Strategy Pattern, where does one put the code that determines which
When implementing the ISerializable interface in C#, we provide a constructor which takes a
In implementing faceted search, if the number of options is 7 or less, I
Implementing Document-View pattern I faced the problem: standard generic collections and dictionaries ( List<T>
When implementing a Matrix construct using arrays, which would be more efficient? Using a
When implementing a Scala trait, one has to implement the trait's methods and the
Implementing ArrayAccess Interface in PHP , We can access Object Properties as Array Keys
Implementing equals() and hashCode() for simple data POJOs is cluttering my code and maintaining

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.