Skip to content

Instantly share code, notes, and snippets.

@samselikoff
Created September 5, 2013 07:44
Show Gist options
  • Select an option

  • Save samselikoff/6447128 to your computer and use it in GitHub Desktop.

Select an option

Save samselikoff/6447128 to your computer and use it in GitHub Desktop.

Revisions

  1. samselikoff created this gist Sep 5, 2013.
    30 changes: 30 additions & 0 deletions brush_redraw_vertical_axis.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    function brush() {
    // Use x.domain to filter the data, then find the max and min duration of this new set, and set y.domain to that
    x.domain(brush.empty() ? x2.domain() : brush.extent());
    var dataFiltered = data.filter(function(d, i) {
    if ( (d.date >= x.domain()[0]) && (d.date <= x.domain()[1]) ) {
    return this;
    }
    })
    var buildersFiltered = color.domain().map(function(name) {
    return {
    name: name,
    values: dataFiltered.map(function(d) {
    return {date: d.date, count: +d[name]};
    })
    };
    });

    y.domain([
    d3.min(buildersFiltered, function(c) { return d3.min(c.values, function(v) { return v.count; }); }),
    d3.max(buildersFiltered, function(c) { return d3.max(c.values, function(v) { return v.count; }); })
    ]);

    focus.selectAll(".builder").select("path").attr("d", function(d) { return line(d.values); })
    focus.select(".x.axis").call(xAxis);
    focus.select(".y.axis").call(yAxis);


    // focus.select("path").attr("d", area);
    // focus.select(".x.axis").call(xAxis);
    }