MCPcopy Index your code
hub / github.com/plotly/plotly.js / getLayoutPolygons

Function getLayoutPolygons

src/components/selections/select.js:1350–1445  ·  view source on GitHub ↗
(gd, onlyActiveOnes)

Source from the content-addressed store, hash-verified

1348}
1349
1350function getLayoutPolygons(gd, onlyActiveOnes) {
1351 var allPolygons = [];
1352
1353 var fullLayout = gd._fullLayout;
1354 var allSelections = fullLayout.selections;
1355 var len = allSelections.length;
1356
1357 for(var i = 0; i < len; i++) {
1358 if(onlyActiveOnes && i !== fullLayout._activeSelectionIndex) continue;
1359
1360 var selection = allSelections[i];
1361 if(!selection) continue;
1362
1363 var xref = selection.xref;
1364 var yref = selection.yref;
1365
1366 var xaxis = getFromId(gd, xref, 'x');
1367 var yaxis = getFromId(gd, yref, 'y');
1368
1369 var xmin, xmax, ymin, ymax;
1370
1371 var polygon;
1372 if(selection.type === 'rect') {
1373 polygon = [];
1374
1375 var x0 = convert(xaxis, selection.x0);
1376 var x1 = convert(xaxis, selection.x1);
1377 var y0 = convert(yaxis, selection.y0);
1378 var y1 = convert(yaxis, selection.y1);
1379 polygon = [[x0, y0], [x0, y1], [x1, y1], [x1, y0]];
1380
1381 xmin = Math.min(x0, x1);
1382 xmax = Math.max(x0, x1);
1383 ymin = Math.min(y0, y1);
1384 ymax = Math.max(y0, y1);
1385
1386 polygon.xmin = xmin;
1387 polygon.xmax = xmax;
1388 polygon.ymin = ymin;
1389 polygon.ymax = ymax;
1390
1391 polygon.xref = xref;
1392 polygon.yref = yref;
1393
1394 polygon.subtract = false;
1395 polygon.isRect = true;
1396
1397 allPolygons.push(polygon);
1398 } else if(selection.type === 'path') {
1399 var segments = selection.path.split('Z');
1400
1401 var multiPolygons = [];
1402 for(var j = 0; j < segments.length; j++) {
1403 var path = segments[j];
1404 if(!path) continue;
1405 path += 'Z';
1406
1407 var allX = shapeHelpers.extractPathCoords(path, shapeConstants.paramIsX, 'raw');

Callers 1

reselectFunction · 0.85

Calls 2

getSubtractFunction · 0.85
convertFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…