Plotting data to acheive Goal 1
 
Here we want to display the percentage of population for each states of US. For this we need to perform following computations:
 
Calculate the total population of state
A state is divided in various counties. In the database strcuture page we have discussed how we divided each county in different groups and subgroups. So to get the total population of a state we need to sum up the values for all the subgroups for the state. Programmatically a state can be identified with Internal_Id.
 
Calculate total US population
Total US population can be calculated by adding populations of all the states.
 
Find out the percentage
Now, for each state, we have to divide state population by total US population and multiply the result with 100.
 
Plotting data to achieve Goal 2
 
Here we want to display the percentages of population of each state that belong to various groups - Business, Service and Unemployed. This can be achieved through following computations.
 
Calculate total population of the state
This can be done by simply adding the population under all the subgroups of the state.
 
Calculate number of people for each Group
To get this value, we have to find out the group wise total population for all the counties of a state, e.g. to find out total number of people doing business in CA, we need to sum up the number of heads for all the subgroups of Business category in CA.
 
Employment percentage
To show the percentage of population for each group we have to divide number of people in a group by the total population of the state and then multiply the result with 100.
 
Now we have to perform the same method for all the groups of to get state-wise record. And the same thing is to be followed for all the states to get employment data of all the states.