{"id":399,"date":"2018-02-23T08:26:55","date_gmt":"2018-02-23T16:26:55","guid":{"rendered":"http:\/\/courses.haigarmen.com\/intd319\/?p=399"},"modified":"2018-02-23T08:26:55","modified_gmt":"2018-02-23T16:26:55","slug":"exercise-02","status":"publish","type":"post","link":"https:\/\/courses.haigarmen.com\/intd319\/exercise-02\/","title":{"rendered":"Exercise 02"},"content":{"rendered":"<p><a href=\"http:\/\/courses.haigarmen.com\/intd319\/files\/2018\/02\/vancouver-temperatures.csv\">Download this small csv file with vancouver-temperatures<\/a><\/p>\n<pre>\/\/Exercise 02 - Plotting temperature on line chart\r\n\/\/Feb 2018 Haig Armen\r\n\r\nsize(900, 200);\r\nTable myTable = loadTable(\"vancouver-temperatures.csv\", \"header\");\r\n\/\/PFont myFont;\r\n\r\nbackground(255);\r\n\r\nint spacing = 40;\r\n\/\/rect(20, 20, (width-40), (height-40));\r\n\r\n\/\/float lastX = 20;\r\n\/\/float lastY = 50;\r\n\r\nfor (int i = 0; i &lt; myTable.getRowCount(); i = i + 1) {\r\n TableRow myRow = myTable.getRow(i);\r\n int temp = myRow.getInt(\"temp\");\r\n String date = myTable.getString(i, \"date\"); \r\n print(temp + \"\\n\");\r\n\r\nnoStroke();\r\n fill(0);\r\n ellipseMode(CENTER);\r\n\r\n\/\/ use the map function to find the right y coordinate to represent temperature\r\n float y = map(temp, 1, 10, 160, 20);\r\n ellipse(i*spacing, y, 5, 5);\r\n\r\nnoFill();\r\n\r\n\/\/ wait a minute, this is showing the temperature upsidedown, highest is at the bottom\r\n \/\/float y = map(temp, 1, 10, 160, 20);\r\n\r\n\/\/ while we're at it, let's calculate the x value too\r\n float x = i*(20+spacing)+80;\r\n\r\n\/\/draw a line to connect the dots\r\n\r\nstroke(180);\r\n fill(0, 150);\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Download this small csv file with vancouver-temperatures \/\/Exercise 02 &#8211; Plotting temperature on line chart \/\/Feb 2018 Haig Armen size(900, 200); Table myTable = loadTable(&#8220;vancouver-temperatures.csv&#8221;, &#8220;header&#8221;); \/\/PFont myFont; background(255); int spacing = 40; \/\/rect(20, 20, (width-40), (height-40)); \/\/float lastX = 20; \/\/float lastY = 50; for (int i = 0; i &lt; myTable.getRowCount(); i = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-399","post","type-post","status-publish","format-standard","hentry","category-assignments"],"_links":{"self":[{"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/posts\/399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/comments?post=399"}],"version-history":[{"count":1,"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/posts\/399\/revisions"}],"predecessor-version":[{"id":401,"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/posts\/399\/revisions\/401"}],"wp:attachment":[{"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/media?parent=399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/categories?post=399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/intd319\/wp-json\/wp\/v2\/tags?post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}