Skip to content

Instantly share code, notes, and snippets.

View alansmithy's full-sized avatar

Alan Smith alansmithy

View GitHub Profile
@alansmithy
alansmithy / README.md
Last active August 29, 2015 14:19
Using Pym.js to create a dynamic, responsive graphic

Pym.js

Pym.js by NPR is a really useful tool for deploying responsive SVG graphics.

Pym.js works by creating dynamic iframes on a (parent) page which can transmit window-size changes to an embedded (child) page. The child can also send changes back to the parent if interaction causes the embedded item to change in height. Crucially, the child page can be set to redraw its content when a window is resized, allowing different content to be generated depending on the size of the iframe.

This playful (and artistically inept) example illustrates the concept by using d3 to draw different images (a 'landscape' landscape and a 'portrait' portrait) depending on the window width. To see it properly using bl.ocks.org, you'll need to launch into the new window view - then just resize the window by dragging the window in and out (the switch happens at 600px).

You can read more about using pym.js on the NPR Blog

@alansmithy
alansmithy / index.html
Last active November 1, 2015 19:14
The Costner Effect
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>The Costner Effect</title>
<style>
body{font-family:sans-serif;background-color:#dedede}
#container {
width: 800px;
margin-left: auto;
@alansmithy
alansmithy / index.html
Last active November 5, 2015 18:31
'Squeezed'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tax credit changes and the low income family</title>
<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style type="text/css">
body, text{font-family:metric,sans-serif;}
h2{font-weight:500;font-size:21px;margin-bottom:-10px;}
@alansmithy
alansmithy / .block
Last active May 9, 2017 01:41
d3-annotation
license: mit
@alansmithy
alansmithy / .block
Last active May 9, 2017 01:52
A Europe of Two Halves
license: mit
@alansmithy
alansmithy / .block
Last active May 9, 2017 01:52
European map
license: mit
@alansmithy
alansmithy / .block
Last active May 12, 2017 08:29
Table
license: mit
@alansmithy
alansmithy / .block
Last active May 13, 2017 02:26
animated radar plot
license: mit
@alansmithy
alansmithy / .block
Last active May 15, 2017 03:08
Radar
license: mit
@alansmithy
alansmithy / .block
Last active May 22, 2017 03:00
Illustrator artwork
license: mit