├── .gitignore ├── README.md ├── data ├── .DS_Store ├── test1.geojson └── test10.geojson ├── example1.html ├── example2.html ├── example3.html ├── images ├── Screen Shot 2015-03-23 at 5.12.53 PM.png ├── Screen Shot 2015-03-23 at 5.15.40 PM.png ├── Screen Shot 2015-03-23 at 5.15.48 PM.png ├── Screen Shot 2015-03-23 at 5.16.14 PM.png ├── Screen Shot 2015-03-23 at 5.20.01 PM.png └── Screen Shot 2015-03-23 at 5.21.08 PM.png ├── stroke-dash-array.key └── stroke-dash-array.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/polyline -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # stroke-dash-interpolation-talk 2 | Slides from March d3.js talk at Pivotal Labs are in the .key and .pdf files 3 | 4 | This talk teaches how to make [this type](http://www.nytimes.com/newsgraphics/2013/10/13/russia/) of long-form interactive created by the New York Times. 5 | 6 | Three key concepts: 7 | 8 | 1. `getPointAtLength()` (example1.html / example2.html / example3.html) 9 | 1. `Stroke-dasharray` (example2.html / example3.html) 10 | 2. `getTotalLength()` (example1.html / example2.html / example3.html) 11 | 12 | An additional explainer [can be found in this gist](https://gist.github.com/petulla/2525ffad1705c99ae7d2). 13 | 14 | 15 | ### Links from the talk 16 | 17 | [Example of an interpolation] (http://jsfiddle.net/c5YVX/8/) 18 | 19 | [Explainer on stroke-dasharray] (https://source.opennews.org/en-US/articles/animating-maps-d3-and-topojson/) 20 | 21 | 22 | [Example of animating a circle along a path](example1.html) 23 | 24 | [Airplanes example] (http://www.tnoda.com/blog/2014-04-02) 25 | 26 | 27 | [Projection of the line on a basemap](http://zevross.com/blog/2014/09/30/use-the-amazing-d3-library-to-animate-a-path-on-a-leaflet-map/) 28 | 29 | [Tween between paths] (http://bl.ocks.org/mbostock/3916621) 30 | 31 | [getPointAtLength for mouse interactions](http://bl.ocks.org/duopixel/3824661) 32 | 33 | [Using to animate Citibike paths](https://citibike-explorer.herokuapp.com) 34 | 35 | [Example of getting the point on a line from any position] (http://bl.ocks.org/mbostock/8027835) 36 | 37 | [Convert Google Maps directions to a Linestring](http://zevross.com/blog/2014/09/23/convert-google-directions-to-geojson-points-or-polylines/) 38 | 39 | [Change the point on a path relative to another window event](http://www.nytimes.com/interactive/2014/12/09/science/space/curiosity-rover-28-months-on-mars.html) 40 | 41 | -------------------------------------------------------------------------------- /data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/petulla/stroke-dasharray-interpolation-talk/d9e20dddfd28ec1eede1ed5fc83f173bbcff5420/data/.DS_Store -------------------------------------------------------------------------------- /data/test1.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, 4 | 5 | "features": [ 6 | { "type": "Feature", "properties": { "latitude": 40.722390, "longitude": -73.995170, "time": 1, "id": "route1", "name":"Gimme" }, "geometry": { "type": "Point", "coordinates": [ -73.99517, 40.72239 ] } }, 7 | { "type": "Feature", "properties": { "latitude": 40.721580, "longitude": -73.995480, "time": 2, "id": "route1", "name":"Along route" }, "geometry": { "type": "Point", "coordinates": [ -73.99548, 40.72158 ] } }} -------------------------------------------------------------------------------- /data/test10.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, 4 | 5 | "features": [ 6 | { "type": "Feature", "properties": { "id": 0 }, "geometry": { "type": "LineString", "coordinates": [ [ -73.996417800798241, 40.712589073717979 ], [ -73.98372686750406, 40.71896699034825 ], [ -73.99586602108981, 40.721894354036948 ], [ -73.980830024034702, 40.726494236867744 ], [ -73.997383415288027, 40.728375915486041 ], [ -73.979588519690736, 40.732557233036481 ], [ -74.001797652955574, 40.737260901212267 ], [ -73.981657693597384, 40.743949989807057 ], [ -73.993520957328911, 40.745308628732268 ], [ -73.974484557387612, 40.753668872715252 ], [ -73.991037948640908, 40.755340795379475 ], [ -73.975036337096071, 40.760983223958874 ] ] } } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /example1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |