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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:11:34+00:00 2026-05-26T15:11:34+00:00

I am working with achartengine in my app. They have added a feature to

  • 0

I am working with achartengine in my app. They have added a feature to handle null values but in order to handle them properly you need MathHelper.NULL_VALUE to be in the place of a null value. The graph needs a List Double[] (list of double arrays) in order to properly display the data. My code loops through a cursor, populates a list of doubles, converts the list of doubles into a Double[] then finally adds the Double[] to my List Double[].

I tried putting an if/else statement in the loop saying if column_TEMP is null then cvalue=MathHelper.NULL_VALUE but it does the calculations before it is needed and the results were quite catastrophic (it failed). The graph did not populate properly having a single small line on the very bottom of the screen and only showed 2 points instead of 10. It cannot do the calculations for MathHelper.NULL_VALUE until after it is in the List Double[]. I am trying to figure out a way to change null values when it goes from Double[] to List Double[]. Here is the code I am currently using. As-is it makes null values show as 0 on the graph. Graphs using larger numbers can be quite messed up if one null value is there. You could go from several hundred all the way across to 0 out of nowhere then back to several hundred again. Any suggestions are very appreciated.

private List<Double[]> values;
private List<Double> cValue;
private Double[] Dvalue;

        while (cursor.moveToNext()) {
            try {
                String cdate=null;
                Double cvalue=null;
                column_date = cursor.getColumnIndex(Provider.DATE);
                column_value = cursor.getColumnIndex(Provider.TEMP);
                cdate = cursor.getString(column_date);
                cvalue = cursor.getDouble(column_value);
                };
                SimpleDateFormat curFormater = new SimpleDateFormat("yyyy/MM/dd");
                Date dateObj = curFormater.parse(cdate);
                if (dateObj.getTime() >= startDate.getTime() && 
                        dateObj.getTime() <= endDate.getTime())  {
                    SimpleDateFormat postFormater = new SimpleDateFormat("yyyy,MM,dd");
                    String dateObj1 = postFormater.format(dateObj);
                    SimpleDateFormat finalFormater = new SimpleDateFormat("yyyy,MM,dd");
                    Date dateObj2 = finalFormater.parse(dateObj1);
                    cDates.add(dateObj2);
                    cValue.add(cvalue);
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }

    dateValues = cDates.toArray(new Date[0]);
    dates.add(dateValues);

    Dvalue = (Double[]) cValue.toArray(new Double[0]);
    values.add(Dvalue);

In theory this is what the array should look like but I have no clue how to input the MathHelper.NULL_VALUE into the existing array.

values.add(new double[] { 21.2, 21.5, 21.7, 21.5, 21.4, 21.4, 21.3, 21.1, 20.6, 20.3, 20.2,
    19.9, 19.7, 19.6, 19.9, 20.3, 20.6, 20.9, 21.2, 21.6, 21.9, 22.1, 21.7, 21.5 });
values.add(new double[] { 1.9, 1.2, 0.9, 0.5, 0.1, -0.5, -0.6, MathHelper.NULL_VALUE,
    MathHelper.NULL_VALUE, -1.8, -0.3, 1.4, 3.4, 4.9, 7.0, 6.4, 3.4, 2.0, 1.5, 0.9, -0.5,
    MathHelper.NULL_VALUE, -1.9, -2.5, -4.3 });

Edit:

I figured out one issue. In my while loop I put this code

            Double d=MathHelper.NULL_VALUE; 
            String s=Double.toString(d); 
            Log.i(getClass().getSimpleName(), s);

and it logs 0.0 but lower down by my chartfactory settings (outside the loop) I put the
same code and it returned 1.7976931348623157E308 as expected. Why
would the while loop cause it to return 0.0?

  • 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-26T15:11:35+00:00Added an answer on May 26, 2026 at 3:11 pm

    Ok the value showing as 0.0 was an ID10T error. stupid me had string = instead of string.equals. The main problem though was it didn’t like passing the MathHelper.NULL_VALUE in the original list as a Double. What I had to do was pass everything as a String to the list of strings then add that to the string array and finally I passed that to the list of string arrays. Once I had everything in the list of string arrays I had to come up with new code to convert the list of string arrays into a list of Double arrays and it worked perfect.

    Thanks for the help Laurence 🙂

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

Sidebar

Related Questions

I am working with achartengine for displaying some graphs. In my app I show
Working on a multi-tenant app where most of my models will have a tenant_id
Working on a new app and using restful-authentication. I was trying to make it
Working in an app where a page_title method was defined in application_helper.rb as such:
I have a problem. I'm making a graph with AChartEngine and I would like
Working with an API where I need to send a value over in an
Working example: http://alpha.jsfiddle.net/gTpWv/ Both of the methods work separately, but once regexp for smilies
Working with a Lucene index, I have a standard document format that looks something
Working with SSRS and a SQL 2000 source, I have a stored procedure that
Working with one of our partners, we have developed now two separate sets of

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.