Skip to content

Commit 43c568f

Browse files
committed
improve Choropleth.calc
- 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
1 parent 23ffe4f commit 43c568f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Diff for: src/traces/choropleth/calc.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

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

28-
calcPt.loc = typeof loc === 'string' ? loc : null;
29-
calcPt.z = isNumeric(z) ? z : BADNUM;
27+
if(typeof loc === 'string' && isNumeric(z)) {
28+
calcPt.loc = loc;
29+
calcPt.z = z;
30+
} else {
31+
calcPt.loc = null;
32+
calcPt.z = BADNUM;
33+
}
34+
35+
calcPt.index = i;
3036
}
3137

3238
arraysToCalcdata(calcTrace, trace);

Diff for: src/traces/choropleth/plot.js

-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ function calcGeoJSON(calcTrace, topojson) {
5353
continue;
5454
}
5555

56-
5756
calcPt.geojson = feature;
5857
calcPt.ct = feature.properties.ct;
59-
calcPt.index = i;
6058
calcPt._polygons = feature2polygons(feature);
6159
}
6260
}

0 commit comments

Comments
 (0)