rj's workfile for the module 3 exercise (#knightD3 MOOC)



The graph below represents immigrant to Canada, arriving in 2006 from the "source country", their country of origin. As the numbers varied greatly I applied a 0.01 multiplier to all values, making sure the largest values fit the screen. As a result the smaller values basically disappear. Next class I hope to learn how to show only the top 10% of values, or set a cut-off value.
UPDATE: see below, a cut-off was applied for all values of 1,000 or less

One interesting issue I ran into is that my data has immigrantion values per year, and the column headers were named after the years: 2006, 2007, etc. This gave me trouble when using the sort function using a.2006 as it didn't seem to recognize 2006 as a column header. The easy fix was to add a "y" in front of all the year headers, but I am curious how this can be solved if renaming columns is not an option.

UPDATE - Thanks to the help of James Storey, Scott Murray and Flooh Perlot I was able to use a clean solution for the year headers (replacing a.y2006 with a["2006"]) and set a filter on the data being used in the binding to the rectangles (replacing .data(data) with .data(data.filter(function(d) {return d.y2006>1000;})) ). Gents, your help is much appreciated!
Next step is to look into highlighting one country (I think Holland is not inculded in my sub-set anymore) with a different colour!

Source: http://www.cic.gc.ca
Specific source url