MCPcopy
hub / github.com/microsoft/SandDance / facetSelectionPolygons

Function facetSelectionPolygons

packages/sanddance/src/axisSelection.ts:113–131  ·  view source on GitHub ↗
(facetRects: VegaDeckGl.types.FacetRect[])

Source from the content-addressed store, hash-verified

111}
112
113function facetSelectionPolygons(facetRects: VegaDeckGl.types.FacetRect[]) {
114 const polygons: SelectPolygon[] = [];
115 const linesAndSearches: { lines: VegaDeckGl.types.StyledLine[], search: SearchExpressionGroup }[] = facetRects.map(({ datum, lines }, i) => {
116 const group: SearchExpressionGroup = getSearchGroupFromVegaValue(datum[FieldNames.FacetSearch]);
117 return {
118 lines,
119 search: group,
120 };
121 });
122 linesAndSearches.forEach(({ lines, search }, i) => {
123 //take any 2 lines to get a box dimension
124 const [x, y] = minMaxPoints(lines.slice(2));
125 polygons.push({
126 search,
127 polygon: [[x.min, y.min], [x.max, y.min], [x.max, y.max], [x.min, y.max]],
128 });
129 });
130 return polygons;
131}
132
133function minMaxPoints(lines: VegaDeckGl.types.StyledLine[]) {
134 const points: number[][] = [];

Callers 1

axisSelectionLayerFunction · 0.70

Calls 3

minMaxPointsFunction · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected