Skip to content

Commit

Permalink
improve Choropleth.calc
Browse files Browse the repository at this point in the history
- valid choropleth datum must have a valid location AND `z` value
- set calcdata[i][j].index during calc
  so that choroplethmapbox can use it in its convert.js
  • Loading branch information
etpinard committed Jun 26, 2019
1 parent 23ffe4f commit 43c568f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/traces/choropleth/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var isNumeric = require('fast-isnumeric');
Expand All @@ -25,8 +24,15 @@ module.exports = function calc(gd, trace) {
var loc = trace.locations[i];
var z = trace.z[i];

calcPt.loc = typeof loc === 'string' ? loc : null;
calcPt.z = isNumeric(z) ? z : BADNUM;
if(typeof loc === 'string' && isNumeric(z)) {
calcPt.loc = loc;
calcPt.z = z;
} else {
calcPt.loc = null;
calcPt.z = BADNUM;
}

calcPt.index = i;
}

arraysToCalcdata(calcTrace, trace);
Expand Down
2 changes: 0 additions & 2 deletions src/traces/choropleth/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ function calcGeoJSON(calcTrace, topojson) {
continue;
}


calcPt.geojson = feature;
calcPt.ct = feature.properties.ct;
calcPt.index = i;
calcPt._polygons = feature2polygons(feature);
}
}
Expand Down

0 comments on commit 43c568f

Please sign in to comment.