~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-proposed

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/examples/mercator/mercator-zoom-constrained.html

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-10 14:28:58 UTC
  • Revision ID: package-import@ubuntu.com-20120410142858-nk453o1z7t7py3bs
Tags: 0.1.26
* Take ownership of the NetworkManager state variant on setup and
  unref it, plugging a memory leak.
* Log the reason the server rejected the submitted crash report.
* Send the Whoopsie version with each crash submission.
* Delete both .upload and .uploaded files after 14 days. Thanks
  Marc Deslauriers (LP: #973687).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html>
 
2
<meta charset="utf-8">
 
3
<style>
 
4
 
 
5
.frame {
 
6
  stroke: #000;
 
7
  fill: none;
 
8
  pointer-events: all;
 
9
}
 
10
 
 
11
.feature {
 
12
  fill: #eee;
 
13
  stroke: #ccc;
 
14
}
 
15
 
 
16
</style>
 
17
<script src="../../d3.v2.js"></script>
 
18
<body>
 
19
<script>
 
20
 
 
21
var margin = {top: 0, right: 0, bottom: 0, left: 0},
 
22
    width = 960 - margin.left - margin.right,
 
23
    height = 500 - margin.top - margin.bottom;
 
24
 
 
25
var projection = d3.geo.mercator()
 
26
    .scale(width)
 
27
    .translate([width / 2, height / 2]);
 
28
 
 
29
var path = d3.geo.path()
 
30
    .projection(projection);
 
31
 
 
32
var zoom = d3.behavior.zoom()
 
33
    .translate(projection.translate())
 
34
    .scale(projection.scale())
 
35
    .scaleExtent([height, 8 * height])
 
36
    .on("zoom", move);
 
37
 
 
38
var svg = d3.select("body").append("svg")
 
39
    .attr("width", width + margin.left + margin.right)
 
40
    .attr("height", height + margin.top + margin.bottom)
 
41
  .append("g")
 
42
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")")
 
43
    .call(zoom);
 
44
 
 
45
var g = svg.append("g"),
 
46
    feature = g.selectAll(".feature");
 
47
 
 
48
svg.append("rect")
 
49
    .attr("class", "frame")
 
50
    .attr("width", width)
 
51
    .attr("height", height);
 
52
 
 
53
d3.json("../data/world-countries.json", function(collection) {
 
54
  feature = feature
 
55
      .data(collection.features)
 
56
    .enter().append("path")
 
57
      .attr("class", "feature")
 
58
      .attr("d", path);
 
59
});
 
60
 
 
61
function move() {
 
62
  var t = d3.event.translate,
 
63
      s = d3.event.scale;
 
64
  t[0] = Math.max(-s / 2, Math.min(width + s / 2, t[0]));
 
65
  t[1] = Math.max(-s / 2, Math.min(height + s / 2, t[1]));
 
66
  zoom.translate(t);
 
67
  projection.translate(t).scale(s);
 
68
  feature.attr("d", path);
 
69
}
 
70
 
 
71
</script>