{"id":1105,"date":"2015-02-24T15:11:29","date_gmt":"2015-02-24T21:11:29","guid":{"rendered":"http:\/\/billdwhite.com\/?p=1105"},"modified":"2015-02-24T15:11:29","modified_gmt":"2015-02-24T21:11:29","slug":"book-review-learning-d3-js-mapping","status":"publish","type":"post","link":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/","title":{"rendered":"Book Review: Learning D3.js Mapping"},"content":{"rendered":"<p>I was recently asked to review a copy of <a href=\"http:\/\/www.packtpub.com\" title=\"Packt Publishing\" target=\"_blank\">PacktPub&#8217;s<\/a> <a href=\"https:\/\/www.packtpub.com\/web-development\/learning-d3js-mapping\" title=\"Learning D3.js Mapping\" target=\"_blank\">&#8220;Learning D3.js Mapping&#8221;<\/a> by Thomas Newton and Oscar Villarreal.  I&#8217;ve done a good deal of d3 development, but the mapping portion of the library has not received much of my attention until now.  A fellow d3 developer and leader of our <a href=\"http:\/\/www.meetup.com\/Austin-d3-js-Meetup\/\" title=\"d3 Meetup Austin\" target=\"_blank\">local d3 Meetup group<\/a>, <a href=\"http:\/\/encodingpixels.com\/\" title=\"Andrew Thornton\" target=\"_blank\">Andrew Thornton<\/a>, has done considerable work with d3-driven mapping applications and it is something I&#8217;ve always wanted to delve into but never really had the chance.  This book served as that motivation and while it is relatively short, it provides as a great introduction to generating maps in d3 and demonstrates just how powerful the library truly is for creating geographic visualizations.<\/p>\n<p>The book starts by laying out the basic setup for running the provided code samples.  They suggest running with the code using a local nodejs http-server, but you can just as easily run the examples directly from the downloaded code samples folder, or using an online IDE such as <a href=\"http:\/\/www.codepen.io\" title=\"CodePen\" target=\"_blank\">CodePen<\/a> or <a href=\"http:\/\/jsbin.com\/\" title=\"JSBin\" target=\"_blank\">JSBin<\/a>, although you will need to have access to the hosted sample JSON data files used in the examples.  A basic foundation of SVG fundamentals is also provided, which can be useful for those just getting started with SVG-based data visualizations.  While the more seasoned d3 developers will be inclined to skip this section, the authors focus a good deal on SVG elements such as paths, which foreshadows their importance in creating maps later in the book.  The third chapter is a d3 primer, providing some history behind the library itself.  The <a href=\"https:\/\/medium.com\/@c_behrens\/enter-update-exit-6cafc6014c36\" title=\"d3 Enter Update Exit\" target=\"_blank\">enter\/update\/exit<\/a> lifecycle is described although novice readers will want to read further about this before attempting the more advanced d3 code samples.<\/p>\n<p>The meat of the book is found starting with chapter 4 where you create your first map.  The reader is introduced to projections which handle the conversion of coordinates from one space to another. The authors do a good job of covering supporting topics such as scaling and translations which may be new to some readers.  Later on in the chapter, an approach to creating choropleths (a fancy way of saying &#8220;color-filled maps&#8221;) is discussed which introduces the beginners to the use of d3 scales for mapping colors to values, handling click events and adding transitions to spruce up the user interaction.  Again, nothing new for most d3 experts, but the authors are clearly trying not to leave anyone out with respect to programming backgrounds. Below is an example of one of the code samples discussed in Chapter 4:<\/p>\n<p data-height=\"600\" data-theme-id=\"2092\" data-slug-hash=\"pxpGJB\" data-default-tab=\"js,result\" data-user=\"billdwhite\" data-pen-title=\"d3 Mapping demo 1\" class=\"codepen\">See the Pen <a href=\"https:\/\/codepen.io\/billdwhite\/pen\/pxpGJB\/\">d3 Mapping demo 1<\/a> by Bill White (<a href=\"https:\/\/codepen.io\/billdwhite\">@billdwhite<\/a>) on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/static.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<p>Chapter 5 is where the book really hits its stride.  Starting with the addition of tooltips and then diving into the use of pan and zoom (<a href=\"http:\/\/billdwhite.com\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\" title=\"d3 Pan and Zoom\" target=\"_blank\">one my personal favorites<\/a>), this chapter takes a basic d3-generated map and turns it into a functional data visualization.  The reader learns about orthographic projections (representing three-dimensions in a two-dimensional format) such as this:<\/p>\n<p data-height=\"600\" data-theme-id=\"2092\" data-slug-hash=\"PyEVZe\" data-default-tab=\"result\" data-user=\"billdwhite\" data-pen-title=\"d3 Mapping demo 2\" class=\"codepen\">See the Pen <a href=\"https:\/\/codepen.io\/billdwhite\/pen\/PyEVZe\/\">d3 Mapping demo 2<\/a> by Bill White (<a href=\"https:\/\/codepen.io\/billdwhite\">@billdwhite<\/a>) on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/static.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<p>Of course, maps are cool to display using d3, but a big piece of the puzzle is obtaining the mapping data to drive the visualization.  Chapter 6 discusses the difference between <a href=\"http:\/\/diva-gis.org\" title=\"Shape Files from diva-gis.org\" target=\"_blank\">shapefiles<\/a>, <a href=\"http:\/\/geojson.org\" title=\"GeoJSON files\" target=\"_blank\">GeoJSON<\/a> and <a href=\"https:\/\/github.com\/mbostock\/topojson\" title=\"TopoJSON\" target=\"_blank\">TopoJSON<\/a> file types and even shows you where to get free shapefiles, albeit they are the largest and most inefficient of the three types.  I found this chapter to be very useful since understanding the mapping source data is key to creating solid mapping visualizations.  Up to this point, I had never really understood the difference between these types, nor was I aware that <a href=\"http:\/\/bost.ocks.org\/mike\/\" title=\"Mike Bostock\" target=\"_blank\">Mike Bostock<\/a>, the creator of <a href=\"http:\/\/d3js.org\" title=\"d3\" target=\"_blank\">d3<\/a>, was also <a href=\"https:\/\/github.com\/mbostock\/topojson\/compare\/v1.0.0...master\" title=\"TopoJSON GitHub Repo\" target=\"_blank\">behind the TopoJSON project<\/a>.  (It is amazing how much code developers rely upon every day without knowing the names of the key contributors or understanding the motivation for it&#8217;s initial creation.  This is yet further proof that open source software makes the world go &#8217;round).<\/p>\n<p>The final chapter review unit testing techniques, which seems a bit out of place, but is helpful and informative nonetheless.  Unit testing is clearly an important aspect of writing good code.  However I cannot help but think that, if what we want is more scalable, maintainable and testable code, then getting away from a weakly-typed, inconsistently-implemented, functional language such as Javascript would be a good first step.  But since Javascript is really the only viable option we have these days, we have to make the best of it and the techniques the authors discuss here are certainly worth considering.<\/p>\n<p>Overall, I enjoyed the book and would certainly recommend it to anyone looking to create maps using d3.  The d3 library itself is quite challenging in its own right, but this book gives you enough background that you can get some geographic visualizations up and running in very little time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was recently asked to review a copy of PacktPub&#8217;s &#8220;Learning D3.js Mapping&#8221; by Thomas Newton and Oscar Villarreal. I&#8217;ve done a good deal of d3 development, but the mapping portion of the library has not received much of my attention until now. A fellow d3 developer and leader of our local d3 Meetup group,\u2026 <span class=\"read-more\"><a href=\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4,7,9],"tags":[],"class_list":["post-1105","post","type-post","status-publish","format-standard","hentry","category-d3","category-html5","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Book Review: Learning D3.js Mapping - Bill White<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Book Review: Learning D3.js Mapping - Bill White\" \/>\n<meta property=\"og:description\" content=\"I was recently asked to review a copy of PacktPub&#8217;s &#8220;Learning D3.js Mapping&#8221; by Thomas Newton and Oscar Villarreal. I&#8217;ve done a good deal of d3 development, but the mapping portion of the library has not received much of my attention until now. A fellow d3 developer and leader of our local d3 Meetup group,\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/\" \/>\n<meta property=\"og:site_name\" content=\"Bill White\" \/>\n<meta property=\"article:published_time\" content=\"2015-02-24T21:11:29+00:00\" \/>\n<meta name=\"author\" content=\"Bill White\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bill_d_white\" \/>\n<meta name=\"twitter:site\" content=\"@bill_d_white\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bill White\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/\"},\"author\":{\"name\":\"Bill White\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\"},\"headline\":\"Book Review: Learning D3.js Mapping\",\"datePublished\":\"2015-02-24T21:11:29+00:00\",\"dateModified\":\"2015-02-24T21:11:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/\"},\"wordCount\":812,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\"},\"articleSection\":[\"d3\",\"HTML5\",\"Javascript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/\",\"url\":\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/\",\"name\":\"Book Review: Learning D3.js Mapping - Bill White\",\"isPartOf\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#website\"},\"datePublished\":\"2015-02-24T21:11:29+00:00\",\"dateModified\":\"2015-02-24T21:11:29+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/billdwhite.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Book Review: Learning D3.js Mapping\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#website\",\"url\":\"https:\/\/billdwhite.com\/wordpress\/\",\"name\":\"Bill White's Blog\",\"description\":\"UI Development and Data Visualization:  Angular \/ React \/ D3 \/ Typescript \/ Javascript \/ UI \/ UX \/ Etc\",\"publisher\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/billdwhite.com\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\",\"name\":\"Bill White\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3c3595ee8305a186eea4ea5286143893?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3c3595ee8305a186eea4ea5286143893?s=96&d=mm&r=g\",\"caption\":\"Bill White\"},\"logo\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.billdwhite.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Book Review: Learning D3.js Mapping - Bill White","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/","og_locale":"en_US","og_type":"article","og_title":"Book Review: Learning D3.js Mapping - Bill White","og_description":"I was recently asked to review a copy of PacktPub&#8217;s &#8220;Learning D3.js Mapping&#8221; by Thomas Newton and Oscar Villarreal. I&#8217;ve done a good deal of d3 development, but the mapping portion of the library has not received much of my attention until now. A fellow d3 developer and leader of our local d3 Meetup group,\u2026 Read More &raquo;","og_url":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/","og_site_name":"Bill White","article_published_time":"2015-02-24T21:11:29+00:00","author":"Bill White","twitter_card":"summary_large_image","twitter_creator":"@bill_d_white","twitter_site":"@bill_d_white","twitter_misc":{"Written by":"Bill White","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/#article","isPartOf":{"@id":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/"},"author":{"name":"Bill White","@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314"},"headline":"Book Review: Learning D3.js Mapping","datePublished":"2015-02-24T21:11:29+00:00","dateModified":"2015-02-24T21:11:29+00:00","mainEntityOfPage":{"@id":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/"},"wordCount":812,"commentCount":1,"publisher":{"@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314"},"articleSection":["d3","HTML5","Javascript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/","url":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/","name":"Book Review: Learning D3.js Mapping - Bill White","isPartOf":{"@id":"https:\/\/billdwhite.com\/wordpress\/#website"},"datePublished":"2015-02-24T21:11:29+00:00","dateModified":"2015-02-24T21:11:29+00:00","breadcrumb":{"@id":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/billdwhite.com\/wordpress\/2015\/02\/24\/book-review-learning-d3-js-mapping\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/billdwhite.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Book Review: Learning D3.js Mapping"}]},{"@type":"WebSite","@id":"https:\/\/billdwhite.com\/wordpress\/#website","url":"https:\/\/billdwhite.com\/wordpress\/","name":"Bill White's Blog","description":"UI Development and Data Visualization:  Angular \/ React \/ D3 \/ Typescript \/ Javascript \/ UI \/ UX \/ Etc","publisher":{"@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/billdwhite.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314","name":"Bill White","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3c3595ee8305a186eea4ea5286143893?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3c3595ee8305a186eea4ea5286143893?s=96&d=mm&r=g","caption":"Bill White"},"logo":{"@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.billdwhite.com"]}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/posts\/1105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1105"}],"version-history":[{"count":0,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/posts\/1105\/revisions"}],"wp:attachment":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}