{"id":932,"date":"2012-08-30T12:00:35","date_gmt":"2012-08-30T10:00:35","guid":{"rendered":"http:\/\/visurus.wordpress.com\/?p=932"},"modified":"2013-12-10T11:03:37","modified_gmt":"2013-12-10T11:03:37","slug":"visualizing-swiss-politicians-on-twitter-using-d3-js","status":"publish","type":"post","link":"https:\/\/www.ralphstraumann.ch\/blog\/2012\/08\/visualizing-swiss-politicians-on-twitter-using-d3-js\/","title":{"rendered":"Visualizing Swiss politicians on Twitter using D3.js"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" title=\"SoMePolis\" alt=\"\" src=\"http:\/\/somepolis.ch\/wordpress\/wp-content\/uploads\/2012\/03\/SMP_Logo_farbig-e1331932841668-300x139.png\" width=\"300\" height=\"139\" \/>I&#8217;ve recently been playing with D3.js, mainly for my side-project, <a href=\"http:\/\/www.somepolis.ch\">SoMePolis<\/a>, which investigates social media usage by Swiss MPs.<\/p>\n<p><a href=\"http:\/\/d3js.org\/\">D3.js<\/a> (D3:\u00a0<strong>d<\/strong>ata-<strong>d<\/strong>riven <strong>d<\/strong>ocuments) is a Javascript library for creating complex, static or animated\/interactive web graphics using HTML, SVG and CSS. The main site has a <a href=\"http:\/\/d3js.org\/\">short tutorial<\/a>\u00a0and <a href=\"https:\/\/github.com\/mbostock\/d3\/wiki\/Gallery\">lots of example implementations<\/a>. A well-known solid introduction to D3.js is <a href=\"http:\/\/alignedleft.com\/tutorials\/d3\/\">the one by Scott Murray from alignedleft.com<\/a>. Small tutorials also come from <a href=\"http:\/\/bost.ocks.org\/mike\/d3\/workshop\/\">Mike Bostocks<\/a>\u00a0(developer of D3.js), <a href=\"http:\/\/www.janwillemtulp.com\/2011\/03\/20\/tutorial-introduction-to-d3\/\">Jan Willem Tulp<\/a>\u00a0and <a href=\"http:\/\/christopheviau.com\/d3_tutorial\/\">Christophe Viau<\/a>.<\/p>\n<p>D3.js is not exactly easy to use to build something from scratch, especially if you are not <em>that<\/em> experienced a Javascript developer. But it&#8217;s easily understandable enough to take an existing visualization and tweak it to fit your purpose. Guess what? That&#8217;s exactly what I did.<\/p>\n<figure style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/somepolis.ch\/2012\/06\/eine-reichhaltige-infografik-twitternde-parlamentsmitglieder\/\"><img loading=\"lazy\" decoding=\"async\" title=\"SoMePolis infographic\" alt=\"\" src=\"http:\/\/somepolis.ch\/wordpress\/wp-content\/uploads\/2012\/06\/parsets_large-300x238.png\" width=\"300\" height=\"238\" \/><\/a><figcaption class=\"wp-caption-text\">SoMePolis infographic of tweeting Swiss politicians<\/figcaption><\/figure>\n<p>Our first <a href=\"http:\/\/somepolis.ch\/infographics\/twitterer-nutzer-inn-en\/\">infographic<\/a>\u00a0(German, but English-speakers should still be fine looking at it; find the\u00a0<a href=\"http:\/\/somepolis.ch\/infographics\/les-twittos-federaux\/\">French version here<\/a>)\u00a0details the membership of tweeting MPs to a range of classes in the dimensions &#8220;political party&#8221;, &#8220;sex&#8221;, &#8220;chamber&#8221;, &#8220;status in parliament&#8221;, &#8220;age&#8221; and &#8220;year of account creation&#8221;.<\/p>\n<p>The visualization, called <em>Par(allel)Sets<\/em>, thus allows you to explore a six-dimensional attribute space with relative ease. All the dimensions can be (vertically) re-ordered using drag-and-drop.<br \/>\nSimilarly, the classes on each dimension can be (horizontally) re-ordered using either drag-and-drop, alphabetic sorting or sorting according to class size (in terms of number of politicians in each class). The latter two support ascending and descending sorting.<br \/>\nDistilling insight from the graphic is facilitated by informative captions that show when you hover over a class or a portion of the coloured bands.<\/p>\n<p>The adaptation of the D3.js code was actually not as much work as making the graphic in an iframe work seamlessly within our WordPress template and compiling a <a href=\"http:\/\/www.youtube.com\/watch?v=ChzoQZ1epvI&amp;rel=0\">concise introduction video<\/a> using <a href=\"http:\/\/www.screenr.com\/\">in-browser screencasting tool Screenr<\/a> (thumbs up!) and YouTube annotations (thumbs down).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve recently been playing with D3.js, mainly for my side-project, SoMePolis, which investigates social media usage by Swiss MPs. D3.js (D3:\u00a0data-driven documents) is a Javascript library for creating complex, static or animated\/interactive web graphics using HTML, SVG and CSS. The main site has a short tutorial\u00a0and lots of example implementations. A well-known solid introduction to &hellip; <a href=\"https:\/\/www.ralphstraumann.ch\/blog\/2012\/08\/visualizing-swiss-politicians-on-twitter-using-d3-js\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visualizing Swiss politicians on Twitter using D3.js<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1482,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Visualizing Swiss politicians on Twitter in the browser using D3.js http:\/\/wp.me\/p1qYOj-f2","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[24,31,87,101,117,125],"class_list":["post-932","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-piece","tag-chart","tag-d3-js","tag-politics","tag-social-media","tag-twitter","tag-visualization"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ralphstraumann.ch\/blog\/wp-content\/uploads\/2012\/08\/SoMePolis.png","jetpack_shortlink":"https:\/\/wp.me\/p3pPwF-f2","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/posts\/932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/comments?post=932"}],"version-history":[{"count":2,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/posts\/932\/revisions"}],"predecessor-version":[{"id":1483,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/posts\/932\/revisions\/1483"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/media\/1482"}],"wp:attachment":[{"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/media?parent=932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/categories?post=932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/tags?post=932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}