5 Replies - 1089 Views - Last Post: 19 April 2013 - 08:12 AM Rate Topic: -----

#1 troyb408  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 18-August 12

Looping or Case statment?

Posted 18 April 2013 - 02:13 PM

Think I've looked at this and have confused myself. But here is what I need help with. I've created a map and in one particular state I've outlined and named all the counties. Each county i have assigned an ID and from the data base i've used that ID to find out various information. In particular the spending total. Now in my function on the page i am trying to figure out a way to find the ID and the spending total and see if that falls in between pre-established break points so I can color the map based on the spending total break points


Any Idea?

Is This A Good Question/Topic? 0
  • +

Replies To: Looping or Case statment?

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 445
  • View blog
  • Posts: 1,501
  • Joined: 28-April 09

Re: Looping or Case statment?

Posted 18 April 2013 - 03:08 PM

code?
Was This Post Helpful? 0
  • +
  • -

#3 troyb408  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 18-August 12

Re: Looping or Case statment?

Posted 18 April 2013 - 04:48 PM

This give me the ID's that are stored the map. How do I attached the ID to the correct spending total?

function findSpend(graphic) 
        {
            var county = graphic.attributes.FIPS;

            console.log(county);            


            if (county == countyData[county][0]) 
            {
                return countyData[county][0];
            } //end if
            else 
            {
                return 0;
            } //end else

        } //end findSpend


Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1057
  • View blog
  • Posts: 4,097
  • Joined: 02-July 08

Re: Looping or Case statment?

Posted 18 April 2013 - 10:04 PM

There is still insufficient data here to help. Please elaborate on what you doing and post all relevant code.
Was This Post Helpful? 0
  • +
  • -

#5 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 282
  • View blog
  • Posts: 1,489
  • Joined: 07-April 08

Re: Looping or Case statment?

Posted 19 April 2013 - 08:03 AM

What I would suggest is storing the data for the counties in a List<Countydata> then itterating over them using either a series of IF statements or a CASE statement to update the coloring
Was This Post Helpful? 0
  • +
  • -

#6 troyb408  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 18-August 12

Re: Looping or Case statment?

Posted 19 April 2013 - 08:12 AM

After playing around it was as simple as the "." notation. In a different function that attached the attributes ID to the map i passed in the whole row and rather than trying to access it by the index value I just tried the "." Thank you for those that attempted to help or asked for more code I appreciate it. I know I can always come here and find some good ideas pointing me in the right way.

function spend(graphic)
{
 var county = graphic.attributes.ID
}

if(county && countyData[county].SpendingTotal)
return countyData[county].SpendingTotal;

else
return 0


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1