(axis: VegaDeckGl.types.Axis, vertical: boolean, axisSelectionType: AxisSelectionType, column: Column)
| 70 | } |
| 71 | |
| 72 | function axisSelectionPolygons(axis: VegaDeckGl.types.Axis, vertical: boolean, axisSelectionType: AxisSelectionType, column: Column) { |
| 73 | const polygons: SelectPolygon[] = []; |
| 74 | const size = 50; |
| 75 | const getSearch: { (a, c, i): SearchExpressionGroup } = |
| 76 | axisSelectionType === 'exact' ? |
| 77 | (a, c, i) => ({ expressions: [selectExactAxis(a, c, i)] }) |
| 78 | : |
| 79 | selectBetweenAxis; |
| 80 | const { domain, ticks } = axis; |
| 81 | if (ticks.length > 0 && domain) { |
| 82 | const dim = vertical ? 1 : 0; |
| 83 | const between = Math.abs(ticks[0].sourcePosition[dim] - domain.sourcePosition[dim]) > 1; |
| 84 | let divisions: number[]; |
| 85 | if (between) { |
| 86 | divisions = []; |
| 87 | for (let i = 1; i < ticks.length; i++) { |
| 88 | divisions.push((ticks[i].sourcePosition[dim] + ticks[i - 1].sourcePosition[dim]) / 2); |
| 89 | } |
| 90 | } else { |
| 91 | divisions = ticks.slice(1, -1).map(tick => tick.sourcePosition[dim]); |
| 92 | } |
| 93 | |
| 94 | const add = (p2: number, i: number) => { |
| 95 | const coords: VegaDeckGl.Position[] = [[p1, q1], [p2, q1], [p2, q2], [p1, q2]]; |
| 96 | polygons.push({ |
| 97 | search: getSearch(axis, column, i), |
| 98 | polygon: vertical ? coords.map(xy => xy.reverse() as VegaDeckGl.Position) : coords, |
| 99 | }); |
| 100 | p1 = p2; |
| 101 | }; |
| 102 | |
| 103 | let p1 = domain.sourcePosition[dim]; |
| 104 | const q1 = domain.sourcePosition[vertical ? 0 : 1]; |
| 105 | const q2 = q1 - size; |
| 106 | |
| 107 | divisions.forEach(add); |
| 108 | add(domain.targetPosition[dim], ticks.length - (between ? 1 : 2)); |
| 109 | } |
| 110 | return polygons; |
| 111 | } |
| 112 | |
| 113 | function facetSelectionPolygons(facetRects: VegaDeckGl.types.FacetRect[]) { |
| 114 | const polygons: SelectPolygon[] = []; |
no test coverage detected