For the first homework, I tried to find some libraries to visualize the immigration data.
I am still using the data in github so I think it is the immigration data of entire US.
For my first 2 charts, I used a library called Chart.js, which I think is a pretty handy api that can do some simple charts with few animations and decorations.
So I tried to make a bar graph and a pie graph. Since there are over a hundred countries, I feel that it will be better to put them into separate graphs in different regions. Fortunately, both of these 2 graphs are using similar arrangement of data, so that I only have to arrange the data once.
Due to the way of specifying data in Chart.js, I have to put all the labels(countries) into one array, and data(estimates and margin errors) in separate arrays.
For the third approach, I found an api made by Google called Treemaps.
The data should be placed like this:
It is pretty different from what Chart.js wants, so I have to do different arrangement to the raw data.
Also, it needs to specify the parent node of every country, so that it will have layers in the map.
The size of the rectangle will be determined by the proportion of total # of immigrations, and the color of each small part will be determined by the error data.
For me, I think the most important thing of doing visualization is to arrange your data that can fit in whatever libraries or whatever approaches you want to do. With proper preparation of your data, other decorations are the minor problems.
The full code is here