dmn-elex-texas-choropleth
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "dmn-elex-texas-choropleth", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "State choropleth module for DMN elections project.", | ||
@@ -9,3 +9,3 @@ "main": "src/js/chart.js", | ||
}, | ||
"author": "Ariana Giorgi", | ||
"author": "Ariana Giorgi and Allan James Vestal, The Dallas Morning News", | ||
"license": "ISC", | ||
@@ -38,4 +38,13 @@ "devDependencies": { | ||
"browserify": { | ||
"transform": [["babelify", { "presets": ["es2015"] }]] | ||
"transform": [ | ||
[ | ||
"babelify", | ||
{ | ||
"presets": [ | ||
"es2015" | ||
] | ||
} | ||
] | ||
] | ||
} | ||
} |
@@ -15,2 +15,3 @@ import * as d3 from "d3"; | ||
var geoData = []; | ||
var labelingFn; | ||
@@ -64,6 +65,6 @@ // Inner chart function | ||
.attr('d', path) | ||
.attr('class', function(d){ | ||
return 'county ' + classCounty(data.results.countyResults[d.id], data.candidates); | ||
.attr('class', function(d) { | ||
var result = data.results.countyResults[d.id]; | ||
return ['county', labelingFn(result, data.candidates)].join(' '); | ||
}); | ||
}); | ||
@@ -79,2 +80,8 @@ } | ||
chart.labelingFn = function(_){ | ||
if (!arguments.length) return labelingFn; | ||
labelingFn = _; | ||
return chart; | ||
} | ||
return chart; | ||
@@ -88,3 +95,4 @@ }, | ||
var chart = this.init() | ||
.geoData(this._geoData); | ||
.geoData(this._geoData) | ||
.labelingFn(this._labelingFn); | ||
@@ -98,3 +106,7 @@ d3.select(this._selection) | ||
// It appends data, geoData and the selection to "this" and calls draw. | ||
create: function(selection, data, geoData){ | ||
create: function(selection, data, geoData, customLabelingFn) { | ||
this._labelingFn = (typeof customLabelingFn !== 'undefined') | ||
? customLabelingFn | ||
: classCounty; | ||
this._selection = selection; | ||
@@ -113,3 +125,3 @@ this._data = data; | ||
}, | ||
//resize | ||
@@ -116,0 +128,0 @@ resize: function(selection){ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
4418237
59598
23