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

Function axisSelectionLayer

docs/tests/v2/es6/js/sanddance.js:148934–148986  ·  view source on GitHub ↗
(presenter, specCapabilities, columns, stage, clickHandler, highlightColor, polygonZ)

Source from the content-addressed store, hash-verified

148932// Copyright (c) Microsoft Corporation. All rights reserved.
148933// Licensed under the MIT license.
148934function axisSelectionLayer(presenter, specCapabilities, columns, stage, clickHandler, highlightColor, polygonZ) {
148935 const polygons = [];
148936 const xRole = specCapabilities.roles.filter(r => r.role === 'x')[0];
148937
148938 if (xRole && xRole.axisSelection) {
148939 stage.axes.x.filter(axis => axis.tickText.length).forEach(axis => {
148940 polygons.push.apply(polygons, axisSelectionPolygons(axis, false, xRole.axisSelection, columns.x));
148941 });
148942 }
148943
148944 const yRole = specCapabilities.roles.filter(r => r.role === 'y')[0];
148945
148946 if (yRole && yRole.axisSelection) {
148947 stage.axes.y.filter(axis => axis.tickText.length).forEach(axis => {
148948 polygons.push.apply(polygons, axisSelectionPolygons(axis, true, yRole.axisSelection, columns.y));
148949 });
148950 }
148951
148952 if (stage.facets) {
148953 polygons.push.apply(polygons, facetSelectionPolygons(stage.facets, columns.facet));
148954 } //move polygons to Z
148955
148956
148957 polygons.forEach(datum => {
148958 datum.polygon.forEach(p => {
148959 p[2] = polygonZ;
148960 });
148961 });
148962
148963 const onClick = (o, e) => clickHandler(e.srcEvent, o.object.search);
148964
148965 const polygonLayer = new VegaDeckGl.base.layers.PolygonLayer({
148966 autoHighlight: true,
148967 coordinateSystem: VegaDeckGl.base.deck.COORDINATE_SYSTEM.IDENTITY,
148968 data: polygons,
148969 extruded: false,
148970 highlightColor,
148971 id: 'selections',
148972 onHover: (o, e) => {
148973 if (o.index === -1) {
148974 presenter.deckgl.interactiveState.onAxisSelection = false;
148975 } else {
148976 presenter.deckgl.interactiveState.onAxisSelection = true;
148977 }
148978 },
148979 onClick,
148980 getElevation: () => 0,
148981 getFillColor: () => [0, 0, 0, 0],
148982 pickable: true,
148983 stroked: false
148984 });
148985 return polygonLayer;
148986}
148987
148988function axisSelectionPolygons(axis, vertical, axisSelectionType, column) {
148989 const polygons = [];

Callers

nothing calls this directly

Calls 4

axisSelectionPolygonsFunction · 0.70
facetSelectionPolygonsFunction · 0.70
filterMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected