Skip to content

Commit

Permalink
merging with v3 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
markmarkoh committed Jan 14, 2013
2 parents e49d90d + b7c7e1f commit 5f9ca3b
Show file tree
Hide file tree
Showing 1,041 changed files with 70,065 additions and 44,739 deletions.
2 changes: 1 addition & 1 deletion dist/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require.config({
appDir: 'app',
paths: {
'd3': 'components/d3/d3.v2',
'd3': 'components/d3/d3',
'underscore': 'components/underscore-amd/underscore',
'jquery': 'components/zepto/dist/zepto',
'backbone': 'components/backbone-amd/backbone'
Expand Down
11 changes: 7 additions & 4 deletions dist/app/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['jquery', 'underscore', 'app/views/MapUsOnly', 'd3'], function ($, _, Map, d3) {
define(['jquery', 'underscore', 'app/views/MapWorldAndUsStates', 'd3'], function ($, _, Map, d3) {

var plots = new Backbone.Collection([
{fillKey: 'DEM', size: 10, longitude: -97.42, latitude: 30.42, text: 'hi'},
Expand Down Expand Up @@ -236,7 +236,7 @@ var bombs = new Backbone.Collection([
bombs.at(idx).set('radius', scale(val.get('yeild')));
});

/* new Map({
new Map({
el: $("#container1"),
scope: 'world',
bubbles: bombs.toJSON(),
Expand Down Expand Up @@ -273,9 +273,12 @@ var bombs = new Backbone.Collection([
'FRA': '#d62728',
'PAK': '#7f7f7f',
defaultFill: '#EDDC4E'
},
}

}).render();

return;

}); //.render(); */
new Map({
el: $('#container1'),
scope: 'usa',
Expand Down
94 changes: 75 additions & 19 deletions dist/app/views/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,20 @@ define([
this.options.projection = 'albersUsa'; //change this default
}

if ( this.options.scope === 'world' ) {
if ( this.options.scope === 'usa' ) {
this._map.set('pathData', _.reject(worldCountries.features, function(val) {
return val.properties.continent === "USA";
return val.properties.continent !== "USA";
}));
}
else if (this.options.scope === 'usa' ) {
else {
this._map.set('pathData', _.reject(worldCountries.features, function(val) {
return val.properties.continent !== "USA";
return val.properties.continent === "USA";
}));

this.options.projection = 'albersUsa'; //override them
}

//set defaults(for complex/nested objects, which backbone doesn't handle too well)
this.options.geography_config = _.defaults(this.options.geography_config || {}, this.options._geography_config);
this.options.bubble_config = _.defaults(this.options.bubble_config || {}, this.options._bubble_config);

this._map.set('projection', d3.geo[this.options.projection]());
this._map.set('path', d3.geo.path().projection( this._map.get('projection')) );

this._map.get('projection').scale(10000);
},

mouseoverPath: function(e) {
Expand Down Expand Up @@ -189,21 +182,84 @@ define([
render: function() {
var self = this;
var width, height;

width = this.$el.width();
height = this.$el.height();

//add inner wrapper div so we can position:relative it
var div = $('<div/>').css({position:'relative'});
var div = $('<div/>').css({width: '100%', height: '100%', position:'relative'});
this.$el.append( div );
this.setElement(div);

var projection = this.projection = this._map.get('projection')
.scale(width)
.translate([width / 2, height / 2]);
width = this.$el.width();
height = this.$el.height();

var projection, path;

var scope = this.options.scope.toLowerCase();

//ugh, revisit
switch (scope) {
case 'world':
projection = d3.geo['equirectangular']()
.scale(width / 6.5);
break;

case 'usa':
projection = d3.geo['albersUsa']()
.scale(width);
break;

case 'southamerica':
projection = d3.geo['equirectangular']()
.scale(width * 1.1)
.center([-60.117187, -20.96144]);
break;

case 'africa':
projection = d3.geo['equirectangular']()
.scale(width * 0.75)
.center([17.547656, 2.740675]);
break;

case 'europe':
projection = d3.geo['mercator']()
.scale(2000)
.center([15.996094, 54.95122]);
break;

case 'southeastasia':
projection = d3.geo['equirectangular']()
.scale(width * 0.80)
.center([122.039063, 5.35156]);
break;

case 'middleeast':
projection = d3.geo['equirectangular']()
.scale(width * 0.90)
.center([54.140625, 31.653381]);
break;

case 'asia':
projection = d3.geo['equirectangular']()
.scale(width * 0.45)
.center([88.375, 40.930432]);
break;

case 'australia':
projection = d3.geo['equirectangular']()
.scale(width * 0.45)
.center([134.824219, -25.799891]);
break;

default:
projection = d3.geo['equirectangular']();
}

projection = projection.translate([width / 2, height / 2]);

path = this.path = d3.geo.path().projection( projection );
this.projection = projection;

var path = this.path = this._map.get('path');
this._map.set('projection', projection);
this._map.set('path', path);

var svg = this.svg = d3.select( this.el ).append('svg:svg')
.attr('width', width)
Expand Down
5 changes: 5 additions & 0 deletions dist/app/views/zooms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(['underscore'], function(_) {
return function(projection, name) {

}
});
12 changes: 6 additions & 6 deletions dist/build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ almondLib.js
components/underscore-amd/underscore.js
components/zepto/dist/zepto.js
components/backbone-amd/backbone.js
components/d3/d3.v2.js
components/d3/d3.js
app/views/injector.js
app/views/Map.js
app/views/MapOptions.js
Expand All @@ -15,7 +15,7 @@ app/views/MapCountriesOnly.js
datamaps-stripped-countries-only.js
----------------
almondLib.js
components/d3/d3.v2.js
components/d3/d3.js
app/views/injector.js
app/views/Map.js
app/views/MapOptions.js
Expand All @@ -28,7 +28,7 @@ almondLib.js
components/underscore-amd/underscore.js
components/zepto/dist/zepto.js
components/backbone-amd/backbone.js
components/d3/d3.v2.js
components/d3/d3.js
app/views/injector.js
app/views/Map.js
app/views/MapOptions.js
Expand All @@ -38,7 +38,7 @@ app/views/MapUsOnly.js
datamaps-stripped-us-only.js
----------------
almondLib.js
components/d3/d3.v2.js
components/d3/d3.js
app/views/injector.js
app/views/Map.js
app/views/MapOptions.js
Expand All @@ -51,7 +51,7 @@ almondLib.js
components/underscore-amd/underscore.js
components/zepto/dist/zepto.js
components/backbone-amd/backbone.js
components/d3/d3.v2.js
components/d3/d3.js
app/views/injector.js
app/views/Map.js
app/views/MapOptions.js
Expand All @@ -61,7 +61,7 @@ app/views/MapWorldAndUsStates.js
datamaps-all-stripped.js
----------------
almondLib.js
components/d3/d3.v2.js
components/d3/d3.js
app/views/injector.js
app/views/Map.js
app/views/MapOptions.js
Expand Down

0 comments on commit 5f9ca3b

Please sign in to comment.