Skip to content

Commit 76afc6c

Browse files
committed
a bit of optimization in choropleth/hover - avoid creating the same array multiple times
1 parent 4e1fd5f commit 76afc6c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/traces/choropleth/hover.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ module.exports = function hoverPoints(pointData, xval, yval) {
1919

2020
var pt, i, j, isInside;
2121

22+
var xy = [xval, yval];
23+
var altXy = [xval + 360, yval];
24+
2225
for(i = 0; i < cd.length; i++) {
2326
pt = cd[i];
2427
isInside = false;
2528

2629
if(pt._polygons) {
2730
for(j = 0; j < pt._polygons.length; j++) {
28-
if(pt._polygons[j].contains([xval, yval])) {
31+
if(pt._polygons[j].contains(xy)) {
2932
isInside = !isInside;
3033
}
3134
// for polygons that cross antimeridian as xval is in [-180, 180]
32-
if(pt._polygons[j].contains([xval + 360, yval])) {
35+
if(pt._polygons[j].contains(altXy)) {
3336
isInside = !isInside;
3437
}
3538
}

0 commit comments

Comments
 (0)