{"id":795,"date":"2013-11-26T20:21:33","date_gmt":"2013-11-27T01:21:33","guid":{"rendered":"http:\/\/billdwhite.com\/?p=795"},"modified":"2013-11-26T20:21:33","modified_gmt":"2013-11-27T01:21:33","slug":"d3-minimap-pan-and-zoom-demo","status":"publish","type":"post","link":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/","title":{"rendered":"d3 Minimap Pan and Zoom Demo"},"content":{"rendered":"<p>I put together a little demo to show how to setup a canvas with a corresponding minimap that displays an overview of the contents of the canvas.  You can use the mousewheel on either the main canvas or the minimap to zoom in and out.  You can also drag either the image or the minimap frame to pan around.  Notice how these actions (pan\/zoom) from the canvas update the minimap and vice versa.  I wrote the demo in the reusable coding style put forth in Bostock&#8217;s <a href=\"http:\/\/bost.ocks.org\/mike\/chart\/\" title=\"Towards Reusable Charts\" target=\"_blank\">Towards Reusable Charts<\/a>.  The trickiest part was preventing the two different pan\/zoom handlers (the canvas and the minimap) from getting out of sync with respect to setting the scale and transform values. Prior to getting that worked out, I kept hitting the common problem of trying to use multiple pan\/zoom controls to operate against a single zoom behavior (discussed <a href=\"https:\/\/groups.google.com\/forum\/#!searchin\/d3-js\/zoom$20reset\/d3-js\/-qUd_jcyGTw\/overview\" title=\"d3 google group\" target=\"_blank\">here<\/a>, <a href=\"https:\/\/groups.google.com\/forum\/#!searchin\/d3-js\/zoom$20back\/d3-js\/-qUd_jcyGTw\/ksHIZi7baCsJ\" title=\"d3 google group\" target=\"_blank\">here<\/a> and <a href=\"https:\/\/groups.google.com\/forum\/#!searchin\/d3-js\/zoom$20event$20translate\/d3-js\/LXjS74ghu_k\/plT6D35iipYJ\" title=\"d3 google group\" target=\"_blank\">here<\/a>).  I managed to work it out by updating the transform and scale values on both controls at the correct time and place.  If you have any suggestions for improvements, I&#8217;d love to hear them.<\/p>\n<p data-height=\"590\" data-theme-id=\"2092\" data-slug-hash=\"QwpYZa\" data-user=\"billdwhite\" data-default-tab=\"result\" class='codepen'>See the Pen <a href='http:\/\/codepen.io\/billdwhite\/pen\/QwpYZa'>d3 Minimap Pan and Zoom Demo<\/a> by Bill White (<a href='http:\/\/codepen.io\/billdwhite'>@billdwhite<\/a>) on <a href='http:\/\/codepen.io'>CodePen<\/a><\/p>\n<p><script async src=\"\/\/codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I put together a little demo to show how to setup a canvas with a corresponding minimap that displays an overview of the contents of the canvas. You can use the mousewheel on either the main canvas or the minimap to zoom in and out. You can also drag either the image or the minimap\u2026 <span class=\"read-more\"><a href=\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\">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,1],"tags":[],"class_list":["post-795","post","type-post","status-publish","format-standard","hentry","category-d3","category-html5","category-javascript","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>d3 Minimap Pan and Zoom Demo - 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\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"d3 Minimap Pan and Zoom Demo - Bill White\" \/>\n<meta property=\"og:description\" content=\"I put together a little demo to show how to setup a canvas with a corresponding minimap that displays an overview of the contents of the canvas. You can use the mousewheel on either the main canvas or the minimap to zoom in and out. You can also drag either the image or the minimap\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\" \/>\n<meta property=\"og:site_name\" content=\"Bill White\" \/>\n<meta property=\"article:published_time\" content=\"2013-11-27T01:21:33+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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\"},\"author\":{\"name\":\"Bill White\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\"},\"headline\":\"d3 Minimap Pan and Zoom Demo\",\"datePublished\":\"2013-11-27T01:21:33+00:00\",\"dateModified\":\"2013-11-27T01:21:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\"},\"wordCount\":207,\"commentCount\":29,\"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\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\",\"url\":\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\",\"name\":\"d3 Minimap Pan and Zoom Demo - Bill White\",\"isPartOf\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#website\"},\"datePublished\":\"2013-11-27T01:21:33+00:00\",\"dateModified\":\"2013-11-27T01:21:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/billdwhite.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"d3 Minimap Pan and Zoom Demo\"}]},{\"@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":"d3 Minimap Pan and Zoom Demo - 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\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/","og_locale":"en_US","og_type":"article","og_title":"d3 Minimap Pan and Zoom Demo - Bill White","og_description":"I put together a little demo to show how to setup a canvas with a corresponding minimap that displays an overview of the contents of the canvas. You can use the mousewheel on either the main canvas or the minimap to zoom in and out. You can also drag either the image or the minimap\u2026 Read More &raquo;","og_url":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/","og_site_name":"Bill White","article_published_time":"2013-11-27T01:21:33+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":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/#article","isPartOf":{"@id":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/"},"author":{"name":"Bill White","@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314"},"headline":"d3 Minimap Pan and Zoom Demo","datePublished":"2013-11-27T01:21:33+00:00","dateModified":"2013-11-27T01:21:33+00:00","mainEntityOfPage":{"@id":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/"},"wordCount":207,"commentCount":29,"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\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/","url":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/","name":"d3 Minimap Pan and Zoom Demo - Bill White","isPartOf":{"@id":"https:\/\/billdwhite.com\/wordpress\/#website"},"datePublished":"2013-11-27T01:21:33+00:00","dateModified":"2013-11-27T01:21:33+00:00","breadcrumb":{"@id":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/billdwhite.com\/wordpress\/2013\/11\/26\/d3-minimap-pan-and-zoom-demo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/billdwhite.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"d3 Minimap Pan and Zoom Demo"}]},{"@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\/795","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=795"}],"version-history":[{"count":0,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/posts\/795\/revisions"}],"wp:attachment":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/media?parent=795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/categories?post=795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/tags?post=795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}