Skip to content

Instantly share code, notes, and snippets.

@johnmichel
Last active August 29, 2015 14:10
Show Gist options
  • Save johnmichel/e00cbef05ada2d6aaee5 to your computer and use it in GitHub Desktop.
Save johnmichel/e00cbef05ada2d6aaee5 to your computer and use it in GitHub Desktop.

Revisions

  1. johnmichel revised this gist Nov 24, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion config.json
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    {"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true}
    {"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/R4lkR92.png"}
  2. johnmichel revised this gist Nov 24, 2014. 2 changed files with 23 additions and 4 deletions.
    2 changes: 1 addition & 1 deletion config.json
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    {"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true}
    {"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true}
    25 changes: 22 additions & 3 deletions inlet.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,29 @@
    DC = DC || {};

    DC.util = DC.util || {};

    // parse time strings into hours and minutes
    DC.util.parseTime = function (val, type) {
    if (type === 'hour') {
    return DC.util.type(val.split(':')[0]);
    }
    else if (type === 'minute') {
    return DC.util.type(val.split(':')[1]);
    }
    };

    DC.util.type = function(d) {
    d.value = +d.value;
    return d;
    };

    var data = tributary.data;
    var svg = d3.select("svg");
    var gs = svg.selectAll("g").data(data.drinks).enter().append("g");
    var cs = gs.selectAll("circle").data(function(d) { return d.drinks; }).enter().append("circle");
    cs.attr({
    r: 5,
    cx: function(d,i) {return d.amount * 20},
    cy: 40
    r: function(d, i) {return d.amount},
    cx: function(d,i) {return DC.util.parseTime(d.time, 'hour')},
    cy: function(d,i) {return DC.util.parseTime(d.time, 'minute')}
    });
    console.log("asdf",cs);
  3. johnmichel revised this gist Nov 24, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions _.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    [ <a href="http://tributary.io/inlet/e00cbef05ada2d6aaee5">Launch: Tributary inlet</a> ] e00cbef05ada2d6aaee5 by johnmichel<br>
  4. johnmichel created this gist Nov 24, 2014.
    1 change: 1 addition & 0 deletions config.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    {"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true}
    258 changes: 258 additions & 0 deletions data.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,258 @@
    {
    "drinks": [
    {
    "date": "2014-11-01",
    "drinks": [
    {
    "time": "15:07",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "Keystone Blend",
    "method": "Chemex",
    "container": "Dinosaur mug",
    "location": "Apartment"
    }
    ]
    },
    {
    "date": "2014-11-02",
    "drinks": [
    {
    "time": "9:25",
    "amount": 12,
    "roaster": "Toby's Estate",
    "variety": "Guatemala - El Tambor",
    "method": "Pourover",
    "container": "Paper to-go cup",
    "location": "Bean Vault Coffee"
    }
    ]
    },
    {
    "date": "2014-11-03",
    "drinks": [
    {
    "time": "08:09",
    "amount": 11,
    "roaster": "Rival Brothers",
    "variety": "Ethiopia - Limu Natural",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    },
    {
    "time": "10:32",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "El Salvador - Guyabo",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    }
    ]
    },
    {
    "date": "2014-11-04",
    "drinks": [
    {
    "time": "7:41",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "Foundation Blend",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    },
    {
    "time": "9:29",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "El Salvador - Guyabo",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    },
    {
    "time": "10:25",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "El Salvador - Guyabo",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    }
    ]
    },
    {
    "date": "2014-11-05",
    "drinks": [
    {
    "time": "8:19",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "El Salvador - Guyabo",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    },
    {
    "time": "9:45",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "Foundation Blend",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    }
    ]
    },
    {
    "date": "2014-11-06",
    "drinks": [
    {
    "time": "8:24",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "Foundation Blend",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    },
    {
    "time": "10:07",
    "amount": 11,
    "roaster": "ReAnimator",
    "variety": "El Salvador - Guyabo",
    "method": "Drip",
    "container": "CSS Is Awesome mug",
    "location": "Empathy Lab"
    }
    ]
    },
    {
    "date": "2014-11-07",
    "drinks": [
    {
    "time": "8:14",
    "amount": 11,
    "roaster": "Rival Brothers",
    "variety": "Honduras - Guachipilin Blend",
    "method": "Chemex",
    "container": "Dinosaur mug",
    "location": "Apartment"
    }
    ]
    },
    {
    "date": "2014-11-08",
    "drinks": [
    {
    "time": "12:38",
    "amount": 3,
    "roaster": "ReAnimator",
    "variety": "Keystone Blend",
    "method": "Espresso",
    "container": "White ceramic cup",
    "location": "Apartment"
    }
    ]
    },
    {
    "date": "2014-11-15",
    "drinks": [
    {
    "time": "11:44",
    "amount": 12,
    "roaster": "Stumptown",
    "variety": "Ethiopia - Duromina",
    "method": "BeeHouse Pourover",
    "container": "Paper to-go cup",
    "location": "Stumptown W 8th"
    }
    ]
    },
    {
    "date": "2014-11-16",
    "drinks": [
    {
    "time": "10:01",
    "amount": 3,
    "roaster": "Rival Brothers",
    "variety": "Costa Rica - La Acostena",
    "method": "Espresso",
    "container": "White ceramic cup",
    "location": "Apartment"
    },
    {
    "time": "14:49",
    "amount": 12,
    "roaster": "Ocean City Coffee Company",
    "variety": "Ethiopia - Sidamo",
    "method": "Chemex",
    "container": "Sutro Bears mug",
    "location": "House"
    }
    ]
    },
    {
    "date": "2014-11-22",
    "drinks": [
    {
    "time": "11:59",
    "amount": 18,
    "roaster": "Rival Brothers",
    "variety": "Whistle & Cuss",
    "method": "Chemex",
    "container": "Coffee Methods mug",
    "location": "Apartment"
    },
    {
    "time": "13:42",
    "amount": 18,
    "roaster": "Rival Brothers",
    "variety": "Costa Rica - La Acostena",
    "method": "Chemex",
    "container": "Coffee Methods mug",
    "location": "Apartment"
    }
    ]
    },
    {
    "date": "2014-11-23",
    "drinks": [
    {
    "time": "10:36",
    "amount": 18,
    "roaster": "Rival Brothers",
    "variety": "Sumatra - ",
    "method": "Chemex",
    "container": "Coffee Methods mug",
    "location": "Apartment"
    }
    ]
    },
    {
    "date": "2014-11-24",
    "drinks": [
    {
    "time": "9:07",
    "amount": 18,
    "roaster": "Tonx",
    "variety": " - ",
    "method": "Chemex",
    "container": "Coffee Methods mug",
    "location": "Apartment"
    },
    {
    "time": "13:09",
    "amount": 12,
    "roaster": "Stumptown",
    "variety": "Ethiopia - Duromina",
    "method": "Chemex",
    "container": "Dinosaur mug",
    "location": "Apartment"
    }
    ]
    }
    ]
    }
    10 changes: 10 additions & 0 deletions inlet.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    var data = tributary.data;
    var svg = d3.select("svg");
    var gs = svg.selectAll("g").data(data.drinks).enter().append("g");
    var cs = gs.selectAll("circle").data(function(d) { return d.drinks; }).enter().append("circle");
    cs.attr({
    r: 5,
    cx: function(d,i) {return d.amount * 20},
    cy: 40
    });
    console.log("asdf",cs);