Commit d235c5a7 authored by Christopher Barnett's avatar Christopher Barnett
Browse files

changed so that if an arms deal appears on the sidebar, all countries involved...

changed so that if an arms deal appears on the sidebar, all countries involved appear, whether or not they are direct importers or exporters from the chosen country.
parent ee6c50b9
This diff is collapsed.
......@@ -304,7 +304,7 @@ ConnectionMap = function () {
},
isRelevant: function (link, country_id) {
isDirectConnection: function (link, country_id) {
return link.Sellers == country_id || link.Buyers == country_id;
},
......@@ -352,6 +352,7 @@ ConnectionMap = function () {
return [arrpt[1], arrpt[0]];
},
renderLinks: function (country_id) {
var self = this;
......@@ -362,11 +363,22 @@ ConnectionMap = function () {
self.currentConnections = {};
self.transactionBounds = new L.latLngBounds();
_.each(this.connections, function (links, k) {
var relevantConnections = {};
// get all deals that involved the selected country
_.each(this.connections, function (v, k) {
var rel = _.some(v, function (i) {
return i.Buyers == country_id || i.Sellers == country_id;
});
if (rel) {
relevantConnections[k] = v;
}
});
_.each(relevantConnections, function (links, k) {
_.each(links, function (link) {
if (!self.isRelevant(link, country_id)) {
return;
}
if (_.has(self.currentConnections, k)) {
var deal = self.currentConnections[k];
......@@ -393,25 +405,29 @@ ConnectionMap = function () {
deal.importers = [link.Buyers];
}
var migration = {};
// we don't want to draw arrows for countries not directly connected
if (self.isDirectConnection(link, country_id)) {
// add the polyline from the centroid of the source feature to the centroid of the target feature
var source = self.getCountry(link.Sellers);
var target = self.getCountry(link.Buyers);
self.currentSources.push(link.Sellers);
self.currentTargets.push(link.Buyers);
self.transactionBounds.extend(source.getBounds());
self.transactionBounds.extend(target.getBounds());
var migration = {};
if (_.isUndefined(source) || _.isUndefined(target)) {
return;
}
// add the polyline from the centroid of the source feature to the centroid of the target feature
var source = self.getCountry(link.Sellers);
var target = self.getCountry(link.Buyers);
self.currentSources.push(link.Sellers);
self.currentTargets.push(link.Buyers);
self.transactionBounds.extend(source.getBounds());
self.transactionBounds.extend(target.getBounds());
migration.from = self.getCentroid(source);
migration.to = self.getCentroid(target);
migration.color = "#3690c0";
if (_.isUndefined(source) || _.isUndefined(target)) {
return;
}
migration.from = self.getCentroid(source);
migration.to = self.getCentroid(target);
migration.color = "#3690c0";
migrations.push(migration);
migrations.push(migration);
}
});
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment