Sha256: 8d7ec6bb7a966d3c7cf15ac21717035c82812556d994dd1ee3550cd08a649c91

Contents?: true

Size: 1.6 KB

Versions: 60

Compression:

Stored size: 1.6 KB

Contents

$.fn.initMap = function() {
  if (!this || this.length == 0) {
    return;
  }

  var width = 950,
  height = 600;

  var appsById = d3.map();

  var formatNumber = d3.format(",.0f");

  var path = d3.geo.path()
      .projection(null);

  var radius = d3.scale.sqrt()
      .domain([0, 50])
      .range([0, 1]);

  var svg = d3.select(this[0]).append("svg:svg")
      .attr("width", width)
      .attr("height", height);

  queue()
      .defer(d3.json, "/hackathon_manager/us.json")
      .defer(d3.tsv, "/manage/dashboard/map_data.tsv", function(d) { appsById.set(d.id, +d.apps); })
      .await(ready);

  function ready(error, us) {
    if (error) return console.error(error);

    svg.append("path")
        .datum(topojson.feature(us, us.objects.nation))
        .attr("class", "land")
        .attr("d", path);

    svg.append("path")
        .datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; }))
        .attr("class", "border border--state")
        .attr("d", path);

    svg.append("g")
        .attr("class", "county")
      .selectAll("path")
        .data(topojson.feature(us, us.objects.counties).features
          .sort(function(a, b) { return (appsById.get(b.id) || 0) - (appsById.get(a.id) || 0); }))
      .enter().append("path")
        .attr("d", path)
        .attr("fill-opacity", function(d) { return radius(appsById.get(d.id) || 0); })
      .append("title")
        .text(function(d) {
          return d.properties.name
              + "\nApplications: " + formatNumber(appsById.get(d.id) || 0);
        });
  };

  d3.select(self.frameElement).style("height", height + "px");
};

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
hackathon_manager-0.14.1 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.14.0 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.12 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.11 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.10 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.9 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.8 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.7 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.6 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.5 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.4 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.3 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.2 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.1 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.13.0 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.12.2 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.12.1 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.12.0 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.11.2 app/assets/javascripts/hackathon_manager/manage/map.js
hackathon_manager-0.11.1 app/assets/javascripts/hackathon_manager/manage/map.js