@antv/g2 5.0.0-beta.4 → 5.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g2-lite.min.js +5 -2
- package/dist/g2.min.js +5 -2
- package/esm/api/mark/mark.js +0 -2
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +0 -2
- package/esm/component/axis.js +5 -4
- package/esm/component/axis.js.map +1 -1
- package/esm/component/slider.js +2 -4
- package/esm/component/slider.js.map +1 -1
- package/esm/composition/mark.js +2 -1
- package/esm/composition/mark.js.map +1 -1
- package/esm/interaction/builtin/brushHighlight.d.ts +1 -1
- package/esm/interaction/index.d.ts +3 -0
- package/esm/interaction/index.js +3 -0
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/brushHighlight.d.ts +15 -0
- package/esm/interaction/native/brushHighlight.js +283 -0
- package/esm/interaction/native/brushHighlight.js.map +1 -0
- package/esm/interaction/native/brushXHighlight.d.ts +1 -0
- package/esm/interaction/native/brushXHighlight.js +8 -0
- package/esm/interaction/native/brushXHighlight.js.map +1 -0
- package/esm/interaction/native/brushYHighlight.d.ts +1 -0
- package/esm/interaction/native/brushYHighlight.js +8 -0
- package/esm/interaction/native/brushYHighlight.js.map +1 -0
- package/esm/interaction/native/legendFilter.js +3 -12
- package/esm/interaction/native/legendFilter.js.map +1 -1
- package/esm/interaction/native/tooltip.js +96 -28
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/interaction/native/utils.d.ts +4 -0
- package/esm/interaction/native/utils.js +23 -0
- package/esm/interaction/native/utils.js.map +1 -1
- package/esm/label-transform/contrastReverse.d.ts +9 -0
- package/esm/label-transform/contrastReverse.js +48 -0
- package/esm/label-transform/contrastReverse.js.map +1 -0
- package/esm/label-transform/index.d.ts +8 -8
- package/esm/label-transform/index.js +4 -4
- package/esm/label-transform/index.js.map +1 -1
- package/esm/label-transform/overflowHide.d.ts +7 -0
- package/esm/label-transform/overflowHide.js +18 -0
- package/esm/label-transform/overflowHide.js.map +1 -0
- package/esm/label-transform/overlapDodgeY.d.ts +7 -0
- package/esm/label-transform/{dodgeY.js → overlapDodgeY.js} +4 -4
- package/esm/label-transform/overlapDodgeY.js.map +1 -0
- package/esm/label-transform/overlapHide.d.ts +7 -0
- package/esm/label-transform/overlapHide.js +24 -0
- package/esm/label-transform/overlapHide.js.map +1 -0
- package/esm/runtime/plot.js +24 -6
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/scale.js +17 -5
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js +10 -4
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +1 -0
- package/esm/runtime/types/options.d.ts +1 -0
- package/esm/shape/label/label.js +3 -3
- package/esm/shape/label/label.js.map +1 -1
- package/esm/shape/label/position/area.d.ts +13 -0
- package/esm/shape/label/position/area.js +28 -0
- package/esm/shape/label/position/area.js.map +1 -0
- package/esm/shape/label/position/bottom.d.ts +1 -0
- package/esm/shape/label/position/bottom.js +2 -0
- package/esm/shape/label/position/bottom.js.map +1 -0
- package/esm/shape/label/position/bottomLeft.d.ts +1 -0
- package/esm/shape/label/position/bottomLeft.js +2 -0
- package/esm/shape/label/position/bottomLeft.js.map +1 -0
- package/esm/shape/label/position/bottomRight.d.ts +1 -0
- package/esm/shape/label/position/bottomRight.js +2 -0
- package/esm/shape/label/position/bottomRight.js.map +1 -0
- package/esm/shape/label/position/default.d.ts +20 -0
- package/esm/shape/label/{position.js → position/default.js} +9 -45
- package/esm/shape/label/position/default.js.map +1 -0
- package/esm/shape/label/position/index.d.ts +13 -0
- package/esm/shape/label/position/index.js +14 -0
- package/esm/shape/label/position/index.js.map +1 -0
- package/esm/shape/label/position/inside.d.ts +1 -0
- package/esm/shape/label/position/inside.js +2 -0
- package/esm/shape/label/position/inside.js.map +1 -0
- package/esm/shape/label/position/left.d.ts +1 -0
- package/esm/shape/label/position/left.js +2 -0
- package/esm/shape/label/position/left.js.map +1 -0
- package/esm/shape/label/position/outside.d.ts +1 -0
- package/esm/shape/label/position/outside.js +2 -0
- package/esm/shape/label/position/outside.js.map +1 -0
- package/esm/shape/label/position/right.d.ts +1 -0
- package/esm/shape/label/position/right.js +2 -0
- package/esm/shape/label/position/right.js.map +1 -0
- package/esm/shape/label/position/spider.d.ts +7 -0
- package/esm/shape/label/position/spider.js +40 -0
- package/esm/shape/label/position/spider.js.map +1 -0
- package/esm/shape/label/position/surround.d.ts +7 -0
- package/esm/shape/label/position/surround.js +37 -0
- package/esm/shape/label/position/surround.js.map +1 -0
- package/esm/shape/label/position/top.d.ts +1 -0
- package/esm/shape/label/position/top.js +2 -0
- package/esm/shape/label/position/top.js.map +1 -0
- package/esm/shape/label/position/topLeft.d.ts +1 -0
- package/esm/shape/label/position/topLeft.js +2 -0
- package/esm/shape/label/position/topLeft.js.map +1 -0
- package/esm/shape/label/position/topRight.d.ts +1 -0
- package/esm/shape/label/position/topRight.js +2 -0
- package/esm/shape/label/position/topRight.js.map +1 -0
- package/esm/spec/composition.d.ts +2 -0
- package/esm/spec/geometry.d.ts +1 -1
- package/esm/spec/interaction.d.ts +21 -5
- package/esm/spec/labelTransform.d.ts +24 -11
- package/esm/spec/theme.d.ts +5 -2
- package/esm/stdlib/index.js +5 -6
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.d.ts +3 -0
- package/esm/theme/academy.js +402 -0
- package/esm/theme/academy.js.map +1 -0
- package/esm/theme/dark.js +3 -2
- package/esm/theme/dark.js.map +1 -1
- package/esm/theme/index.d.ts +1 -0
- package/esm/theme/index.js +1 -0
- package/esm/theme/index.js.map +1 -1
- package/esm/theme/light.js +4 -3
- package/esm/theme/light.js.map +1 -1
- package/esm/transform/maybeTooltip.js +3 -1
- package/esm/transform/maybeTooltip.js.map +1 -1
- package/esm/utils/bounds.d.ts +26 -0
- package/esm/utils/bounds.js +41 -0
- package/esm/utils/bounds.js.map +1 -0
- package/esm/utils/color.d.ts +6 -0
- package/esm/utils/color.js +7 -0
- package/esm/utils/color.js.map +1 -0
- package/esm/utils/coordinate.d.ts +1 -0
- package/esm/utils/coordinate.js +12 -0
- package/esm/utils/coordinate.js.map +1 -1
- package/esm/utils/helper.d.ts +1 -0
- package/esm/utils/helper.js +3 -0
- package/esm/utils/helper.js.map +1 -1
- package/lib/api/mark/mark.js +0 -2
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +0 -2
- package/lib/component/axis.js +5 -4
- package/lib/component/axis.js.map +1 -1
- package/lib/component/slider.js +2 -4
- package/lib/component/slider.js.map +1 -1
- package/lib/composition/mark.js +2 -1
- package/lib/composition/mark.js.map +1 -1
- package/lib/interaction/builtin/brushHighlight.d.ts +1 -1
- package/lib/interaction/index.d.ts +3 -0
- package/lib/interaction/index.js +7 -1
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/brushHighlight.d.ts +15 -0
- package/lib/interaction/native/brushHighlight.js +289 -0
- package/lib/interaction/native/brushHighlight.js.map +1 -0
- package/lib/interaction/native/brushXHighlight.d.ts +1 -0
- package/lib/interaction/native/brushXHighlight.js +12 -0
- package/lib/interaction/native/brushXHighlight.js.map +1 -0
- package/lib/interaction/native/brushYHighlight.d.ts +1 -0
- package/lib/interaction/native/brushYHighlight.js +12 -0
- package/lib/interaction/native/brushYHighlight.js.map +1 -0
- package/lib/interaction/native/legendFilter.js +4 -13
- package/lib/interaction/native/legendFilter.js.map +1 -1
- package/lib/interaction/native/tooltip.js +93 -25
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/interaction/native/utils.d.ts +4 -0
- package/lib/interaction/native/utils.js +28 -1
- package/lib/interaction/native/utils.js.map +1 -1
- package/lib/label-transform/contrastReverse.d.ts +9 -0
- package/lib/label-transform/contrastReverse.js +52 -0
- package/lib/label-transform/contrastReverse.js.map +1 -0
- package/lib/label-transform/index.d.ts +8 -8
- package/lib/label-transform/index.js +9 -9
- package/lib/label-transform/index.js.map +1 -1
- package/lib/label-transform/overflowHide.d.ts +7 -0
- package/lib/label-transform/overflowHide.js +22 -0
- package/lib/label-transform/overflowHide.js.map +1 -0
- package/lib/label-transform/overlapDodgeY.d.ts +7 -0
- package/lib/label-transform/{dodgeY.js → overlapDodgeY.js} +6 -6
- package/lib/label-transform/overlapDodgeY.js.map +1 -0
- package/lib/label-transform/overlapHide.d.ts +7 -0
- package/lib/label-transform/overlapHide.js +28 -0
- package/lib/label-transform/overlapHide.js.map +1 -0
- package/lib/runtime/plot.js +24 -6
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/scale.js +16 -4
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +10 -4
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +1 -0
- package/lib/runtime/types/options.d.ts +1 -0
- package/lib/shape/label/label.js +3 -3
- package/lib/shape/label/label.js.map +1 -1
- package/lib/shape/label/position/area.d.ts +13 -0
- package/lib/shape/label/position/area.js +32 -0
- package/lib/shape/label/position/area.js.map +1 -0
- package/lib/shape/label/position/bottom.d.ts +1 -0
- package/lib/shape/label/position/bottom.js +6 -0
- package/lib/shape/label/position/bottom.js.map +1 -0
- package/lib/shape/label/position/bottomLeft.d.ts +1 -0
- package/lib/shape/label/position/bottomLeft.js +6 -0
- package/lib/shape/label/position/bottomLeft.js.map +1 -0
- package/lib/shape/label/position/bottomRight.d.ts +1 -0
- package/lib/shape/label/position/bottomRight.js +6 -0
- package/lib/shape/label/position/bottomRight.js.map +1 -0
- package/lib/shape/label/position/default.d.ts +20 -0
- package/lib/shape/label/{position.js → position/default.js} +10 -43
- package/lib/shape/label/position/default.js.map +1 -0
- package/lib/shape/label/position/index.d.ts +13 -0
- package/lib/shape/label/position/index.js +30 -0
- package/lib/shape/label/position/index.js.map +1 -0
- package/lib/shape/label/position/inside.d.ts +1 -0
- package/lib/shape/label/position/inside.js +6 -0
- package/lib/shape/label/position/inside.js.map +1 -0
- package/lib/shape/label/position/left.d.ts +1 -0
- package/lib/shape/label/position/left.js +6 -0
- package/lib/shape/label/position/left.js.map +1 -0
- package/lib/shape/label/position/outside.d.ts +1 -0
- package/lib/shape/label/position/outside.js +6 -0
- package/lib/shape/label/position/outside.js.map +1 -0
- package/lib/shape/label/position/right.d.ts +1 -0
- package/lib/shape/label/position/right.js +6 -0
- package/lib/shape/label/position/right.js.map +1 -0
- package/lib/shape/label/position/spider.d.ts +7 -0
- package/lib/shape/label/position/spider.js +44 -0
- package/lib/shape/label/position/spider.js.map +1 -0
- package/lib/shape/label/position/surround.d.ts +7 -0
- package/lib/shape/label/position/surround.js +41 -0
- package/lib/shape/label/position/surround.js.map +1 -0
- package/lib/shape/label/position/top.d.ts +1 -0
- package/lib/shape/label/position/top.js +6 -0
- package/lib/shape/label/position/top.js.map +1 -0
- package/lib/shape/label/position/topLeft.d.ts +1 -0
- package/lib/shape/label/position/topLeft.js +6 -0
- package/lib/shape/label/position/topLeft.js.map +1 -0
- package/lib/shape/label/position/topRight.d.ts +1 -0
- package/lib/shape/label/position/topRight.js +6 -0
- package/lib/shape/label/position/topRight.js.map +1 -0
- package/lib/spec/composition.d.ts +2 -0
- package/lib/spec/geometry.d.ts +1 -1
- package/lib/spec/interaction.d.ts +21 -5
- package/lib/spec/labelTransform.d.ts +24 -11
- package/lib/spec/theme.d.ts +5 -2
- package/lib/stdlib/index.js +2 -3
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/academy.d.ts +3 -0
- package/lib/theme/academy.js +406 -0
- package/lib/theme/academy.js.map +1 -0
- package/lib/theme/dark.js +3 -2
- package/lib/theme/dark.js.map +1 -1
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +3 -1
- package/lib/theme/index.js.map +1 -1
- package/lib/theme/light.js +4 -3
- package/lib/theme/light.js.map +1 -1
- package/lib/transform/maybeTooltip.js +3 -1
- package/lib/transform/maybeTooltip.js.map +1 -1
- package/lib/utils/bounds.d.ts +26 -0
- package/lib/utils/bounds.js +48 -0
- package/lib/utils/bounds.js.map +1 -0
- package/lib/utils/color.d.ts +6 -0
- package/lib/utils/color.js +11 -0
- package/lib/utils/color.js.map +1 -0
- package/lib/utils/coordinate.d.ts +1 -0
- package/lib/utils/coordinate.js +14 -1
- package/lib/utils/coordinate.js.map +1 -1
- package/lib/utils/helper.d.ts +1 -0
- package/lib/utils/helper.js +5 -1
- package/lib/utils/helper.js.map +1 -1
- package/package.json +2 -2
- package/src/.DS_Store +0 -0
- package/src/api/mark/mark.ts +0 -2
- package/src/api/mark/types.ts +0 -2
- package/src/component/axis.ts +16 -11
- package/src/component/slider.ts +1 -3
- package/src/composition/mark.ts +2 -0
- package/src/data/.DS_Store +0 -0
- package/src/interaction/index.ts +3 -0
- package/src/interaction/native/brushHighlight.ts +346 -0
- package/src/interaction/native/brushXHighlight.ts +11 -0
- package/src/interaction/native/brushYHighlight.ts +11 -0
- package/src/interaction/native/legendFilter.ts +3 -14
- package/src/interaction/native/tooltip.ts +119 -32
- package/src/interaction/native/utils.ts +31 -0
- package/src/label-transform/contrastReverse.ts +56 -0
- package/src/label-transform/index.ts +8 -8
- package/src/label-transform/overflowHide.ts +23 -0
- package/src/label-transform/{dodgeY.ts → overlapDodgeY.ts} +6 -6
- package/src/label-transform/overlapHide.ts +32 -0
- package/src/runtime/plot.ts +35 -6
- package/src/runtime/scale.ts +15 -7
- package/src/runtime/transform.ts +13 -4
- package/src/runtime/types/common.ts +1 -0
- package/src/runtime/types/options.ts +1 -0
- package/src/shape/.DS_Store +0 -0
- package/src/shape/label/label.ts +4 -3
- package/src/shape/label/position/area.ts +39 -0
- package/src/shape/label/position/bottom.ts +1 -0
- package/src/shape/label/position/bottomLeft.ts +1 -0
- package/src/shape/label/position/bottomRight.ts +1 -0
- package/src/shape/label/{position.ts → position/default.ts} +12 -56
- package/src/shape/label/position/index.ts +13 -0
- package/src/shape/label/position/inside.ts +1 -0
- package/src/shape/label/position/left.ts +1 -0
- package/src/shape/label/position/outside.ts +1 -0
- package/src/shape/label/position/right.ts +1 -0
- package/src/shape/label/position/spider.ts +46 -0
- package/src/shape/label/position/surround.ts +42 -0
- package/src/shape/label/position/top.ts +1 -0
- package/src/shape/label/position/topLeft.ts +1 -0
- package/src/shape/label/position/topRight.ts +1 -0
- package/src/spec/composition.ts +2 -0
- package/src/spec/geometry.ts +2 -1
- package/src/spec/interaction.ts +28 -4
- package/src/spec/labelTransform.ts +29 -11
- package/src/spec/theme.ts +6 -2
- package/src/stdlib/index.ts +19 -7
- package/src/theme/academy.ts +408 -0
- package/src/theme/dark.ts +3 -2
- package/src/theme/index.ts +1 -0
- package/src/theme/light.ts +4 -3
- package/src/transform/maybeTooltip.ts +3 -1
- package/src/utils/bounds.ts +52 -0
- package/src/utils/color.ts +12 -0
- package/src/utils/coordinate.ts +12 -0
- package/src/utils/helper.ts +4 -0
- package/esm/label-transform/dodgeY.d.ts +0 -7
- package/esm/label-transform/dodgeY.js.map +0 -1
- package/esm/label-transform/hideOverlap.d.ts +0 -4
- package/esm/label-transform/hideOverlap.js +0 -48
- package/esm/label-transform/hideOverlap.js.map +0 -1
- package/esm/label-transform/spider.d.ts +0 -7
- package/esm/label-transform/spider.js +0 -30
- package/esm/label-transform/spider.js.map +0 -1
- package/esm/label-transform/surround.d.ts +0 -7
- package/esm/label-transform/surround.js +0 -30
- package/esm/label-transform/surround.js.map +0 -1
- package/esm/shape/label/position.d.ts +0 -25
- package/esm/shape/label/position.js.map +0 -1
- package/lib/label-transform/dodgeY.d.ts +0 -7
- package/lib/label-transform/dodgeY.js.map +0 -1
- package/lib/label-transform/hideOverlap.d.ts +0 -4
- package/lib/label-transform/hideOverlap.js +0 -52
- package/lib/label-transform/hideOverlap.js.map +0 -1
- package/lib/label-transform/spider.d.ts +0 -7
- package/lib/label-transform/spider.js +0 -34
- package/lib/label-transform/spider.js.map +0 -1
- package/lib/label-transform/surround.d.ts +0 -7
- package/lib/label-transform/surround.js +0 -34
- package/lib/label-transform/surround.js.map +0 -1
- package/lib/shape/label/position.d.ts +0 -25
- package/lib/shape/label/position.js.map +0 -1
- package/src/label-transform/hideOverlap.ts +0 -62
- package/src/label-transform/spider.ts +0 -37
- package/src/label-transform/surround.ts +0 -37
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOverlap = exports.isOverflow = exports.isInBounds = exports.parseAABB = void 0;
|
|
4
|
+
function parseAABB(min2) {
|
|
5
|
+
const { min, max } = min2;
|
|
6
|
+
return [
|
|
7
|
+
[min[0], min[1]],
|
|
8
|
+
[max[0], max[1]],
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
exports.parseAABB = parseAABB;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the `point` in `bounds`.
|
|
14
|
+
* @param point
|
|
15
|
+
* @param bounds
|
|
16
|
+
*/
|
|
17
|
+
function isInBounds(point, bounds) {
|
|
18
|
+
const [x, y] = point;
|
|
19
|
+
const [min, max] = bounds;
|
|
20
|
+
return x >= min[0] && x <= max[0] && y >= min[1] && y <= max[1];
|
|
21
|
+
}
|
|
22
|
+
exports.isInBounds = isInBounds;
|
|
23
|
+
/**
|
|
24
|
+
* Whether `b1` is overflow from `b2`.
|
|
25
|
+
* @param b1
|
|
26
|
+
* @param b2
|
|
27
|
+
*/
|
|
28
|
+
function isOverflow(b1, b2) {
|
|
29
|
+
const [min, max] = b1;
|
|
30
|
+
return !(isInBounds(min, b2) && isInBounds(max, b2));
|
|
31
|
+
}
|
|
32
|
+
exports.isOverflow = isOverflow;
|
|
33
|
+
/**
|
|
34
|
+
* Whether `b1` is overlap with `b2`.
|
|
35
|
+
* @param b1
|
|
36
|
+
* @param b2
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
function isOverlap(b1, b2) {
|
|
40
|
+
const [min1, max1] = b1;
|
|
41
|
+
const [min2, max2] = b2;
|
|
42
|
+
return (min1[0] < max2[0] &&
|
|
43
|
+
max1[0] > min2[0] &&
|
|
44
|
+
min1[1] < max2[1] &&
|
|
45
|
+
max1[1] > min2[1]);
|
|
46
|
+
}
|
|
47
|
+
exports.isOverlap = isOverlap;
|
|
48
|
+
//# sourceMappingURL=bounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounds.js","sourceRoot":"src/","sources":["utils/bounds.ts"],"names":[],"mappings":";;;AAOA,SAAgB,SAAS,CAAC,IAAU;IAClC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC1B,OAAO;QACL,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;KACjB,CAAC;AACJ,CAAC;AAND,8BAMC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,KAAc,EAAE,MAAc;IACvD,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IAC1B,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAJD,gCAIC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,EAAU,EAAE,EAAU;IAC/C,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;IACtB,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC;AAHD,gCAGC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,EAAU,EAAE,EAAU;IAC9C,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;IACxB,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;IACxB,OAAO,CACL,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACjB,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACjB,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACjB,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAClB,CAAC;AACJ,CAAC;AATD,8BASC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseToRGB = void 0;
|
|
4
|
+
const g_1 = require("@antv/g");
|
|
5
|
+
function parseToRGB(c) {
|
|
6
|
+
if (typeof c === 'object')
|
|
7
|
+
return c;
|
|
8
|
+
return (0, g_1.parseColor)(c);
|
|
9
|
+
}
|
|
10
|
+
exports.parseToRGB = parseToRGB;
|
|
11
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"src/","sources":["utils/color.ts"],"names":[],"mappings":";;;AAAA,+BAAqC;AAQrC,SAAgB,UAAU,CAAC,CAAiB;IAC1C,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACpC,OAAO,IAAA,cAAU,EAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAHD,gCAGC"}
|
|
@@ -7,3 +7,4 @@ export declare function isParallel(coordinate: Coordinate): boolean;
|
|
|
7
7
|
export declare function isFisheye(coordinate: Coordinate): boolean;
|
|
8
8
|
export declare function isCircular(coordinate: Coordinate): boolean;
|
|
9
9
|
export declare function isTheta(coordinate: Coordinate): boolean;
|
|
10
|
+
export declare function getRadius(coordinate: Coordinate): number;
|
package/lib/utils/coordinate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTheta = exports.isCircular = exports.isFisheye = exports.isParallel = exports.isHelix = exports.isRadial = exports.isPolar = exports.isTranspose = void 0;
|
|
3
|
+
exports.getRadius = exports.isTheta = exports.isCircular = exports.isFisheye = exports.isParallel = exports.isHelix = exports.isRadial = exports.isPolar = exports.isTranspose = void 0;
|
|
4
4
|
function isTranspose(coordinate) {
|
|
5
5
|
const { transformations } = coordinate.getOptions();
|
|
6
6
|
const transposes = transformations
|
|
@@ -45,4 +45,17 @@ function isTheta(coordinate) {
|
|
|
45
45
|
return isPolar(coordinate) && isTranspose(coordinate);
|
|
46
46
|
}
|
|
47
47
|
exports.isTheta = isTheta;
|
|
48
|
+
function getRadius(coordinate) {
|
|
49
|
+
if (isCircular(coordinate)) {
|
|
50
|
+
const [width, height] = coordinate.getSize();
|
|
51
|
+
const polar = coordinate
|
|
52
|
+
.getOptions()
|
|
53
|
+
.transformations.find((t) => t[0] === 'polar');
|
|
54
|
+
// coordinate.size * outerRadius.
|
|
55
|
+
if (polar)
|
|
56
|
+
return (Math.max(width, height) / 2) * polar[4];
|
|
57
|
+
}
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
exports.getRadius = getRadius;
|
|
48
61
|
//# sourceMappingURL=coordinate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate.js","sourceRoot":"src/","sources":["utils/coordinate.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,UAAsB;IAChD,MAAM,EAAE,eAAe,EAAE,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC;IACpD,MAAM,UAAU,GAAG,eAAe;SAC/B,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;SACrB,MAAM,CAAC,CA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CAAC;AACxD,CAAC;AAFD,0BAEC;AAED,SAAgB,SAAS,CAAC,UAAsB;IAC9C,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE;QAC1B,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,UAAU;aACrB,UAAU,EAAE;aACZ,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;QACjD,iCAAiC;QACjC,IAAI,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;KAC5D;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,8BAUC"}
|
package/lib/utils/helper.d.ts
CHANGED
|
@@ -19,4 +19,5 @@ export declare function appendTransform(node: DisplayObject, transform: any): vo
|
|
|
19
19
|
export declare function subObject(obj: Record<string, any>, prefix: string): Record<string, any>;
|
|
20
20
|
export declare function maybeSubObject(obj: Record<string, any>, prefix: string): Record<string, any>;
|
|
21
21
|
export declare function maybePercentage(x: number | string, size: number): number;
|
|
22
|
+
export declare function isStrictObject(d: any): boolean;
|
|
22
23
|
export {};
|
package/lib/utils/helper.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.maybePercentage = exports.maybeSubObject = exports.subObject = exports.appendTransform = exports.useMemo = exports.random = exports.defined = exports.copyAttributes = exports.error = exports.capitalizeFirst = exports.composeAsync = exports.compose = exports.identity = void 0;
|
|
12
|
+
exports.isStrictObject = exports.maybePercentage = exports.maybeSubObject = exports.subObject = exports.appendTransform = exports.useMemo = exports.random = exports.defined = exports.copyAttributes = exports.error = exports.capitalizeFirst = exports.composeAsync = exports.compose = exports.identity = void 0;
|
|
13
13
|
const util_1 = require("@antv/util");
|
|
14
14
|
function identity(x) {
|
|
15
15
|
return x;
|
|
@@ -95,4 +95,8 @@ function maybePercentage(x, size) {
|
|
|
95
95
|
return Number.isNaN(px) ? null : (px / 100) * size;
|
|
96
96
|
}
|
|
97
97
|
exports.maybePercentage = maybePercentage;
|
|
98
|
+
function isStrictObject(d) {
|
|
99
|
+
return typeof d === 'object' && !(d instanceof Date) && d !== null;
|
|
100
|
+
}
|
|
101
|
+
exports.isStrictObject = isStrictObject;
|
|
98
102
|
//# sourceMappingURL=helper.js.map
|
package/lib/utils/helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"src/","sources":["utils/helper.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAwC;AAExC,SAAgB,QAAQ,CAAI,CAAI;IAC9B,OAAO,CAAC,CAAC;AACX,CAAC;AAFD,4BAEC;AAGD;;GAEG;AACH,SAAgB,OAAO,CAAI,GAAc;IACvC,OAAO,GAAG,CAAC,MAAM,CACf,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CACf,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,CACb,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EACrC,QAAQ,CACT,CAAC;AACJ,CAAC;AAPD,0BAOC;AAED;;GAEG;AACH,SAAgB,YAAY,CAC1B,GAAiC;IAEjC,OAAO,GAAG,CAAC,MAAM,CACf,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC,CAAO,CAAC,EAAE,EAAE;QAC5B,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAA,EACD,QAAQ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C,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC;AATD,wCASC;AAED,SAAgB,eAAe,CAAC,CAAkB,EAAE,IAAY;IAC9D,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACjC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;AACrD,CAAC;AALD,0CAKC;AAED,SAAgB,cAAc,CAAC,CAAM;IACnC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;AACrE,CAAC;AAFD,wCAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g2",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.5",
|
|
4
4
|
"description": "the Grammar of Graphics in Javascript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -138,4 +138,4 @@
|
|
|
138
138
|
"d3-shape": "^3.1.0",
|
|
139
139
|
"d3-voronoi": "^1.1.4"
|
|
140
140
|
}
|
|
141
|
-
}
|
|
141
|
+
}
|
package/src/.DS_Store
ADDED
|
Binary file
|
package/src/api/mark/mark.ts
CHANGED
|
@@ -140,8 +140,6 @@ export const props: NodePropertyDescriptor[] = [
|
|
|
140
140
|
{ name: 'transform', type: 'array' },
|
|
141
141
|
{ name: 'style', type: 'object' },
|
|
142
142
|
{ name: 'animate', type: 'object' },
|
|
143
|
-
{ name: 'coordinate', type: 'array', key: 'coordinates' },
|
|
144
|
-
{ name: 'interaction', type: 'array', key: 'interactions' },
|
|
145
143
|
{ name: 'label', type: 'array', key: 'labels' },
|
|
146
144
|
{ name: 'axis', type: 'object' },
|
|
147
145
|
{ name: 'legend', type: 'object' },
|
package/src/api/mark/types.ts
CHANGED
|
@@ -12,7 +12,5 @@ export type API<Props extends Geometry, Mark> = {
|
|
|
12
12
|
axis: ObjectAttribute<Props['axis'], Mark>;
|
|
13
13
|
slider: ObjectAttribute<Props['slider'], Mark>;
|
|
14
14
|
legend: ObjectAttribute<Props['legend'], Mark>;
|
|
15
|
-
coordinate: ArrayAttribute<Props['coordinates'], Mark>;
|
|
16
|
-
interaction: ArrayAttribute<Props['interactions'], Mark>;
|
|
17
15
|
layout: ValueAttribute<Props['layout'], Mark>;
|
|
18
16
|
};
|
package/src/component/axis.ts
CHANGED
|
@@ -364,6 +364,7 @@ function inferDefaultStyle(scale, theme, position, direction) {
|
|
|
364
364
|
labelTransform: direction === 'center' ? 'translate(50%, 0)' : '',
|
|
365
365
|
tickDirection: direction === 'right' ? 'negative' : 'positive',
|
|
366
366
|
labelSpacing: direction === 'center' ? 0 : 4,
|
|
367
|
+
tick: direction === 'center' ? false : undefined,
|
|
367
368
|
};
|
|
368
369
|
}
|
|
369
370
|
|
|
@@ -382,11 +383,6 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
|
382
383
|
tickCount,
|
|
383
384
|
tickFilter,
|
|
384
385
|
tickMethod,
|
|
385
|
-
labelAutoHide = false,
|
|
386
|
-
labelAutoRotate = true,
|
|
387
|
-
grid,
|
|
388
|
-
label: showLabel = true,
|
|
389
|
-
tick: showTick = true,
|
|
390
386
|
...userDefinitions
|
|
391
387
|
} = options;
|
|
392
388
|
|
|
@@ -404,15 +400,24 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
|
404
400
|
coordinate,
|
|
405
401
|
);
|
|
406
402
|
|
|
403
|
+
const defaultStyle = inferDefaultStyle(scale, theme, position, direction);
|
|
404
|
+
const {
|
|
405
|
+
labelAutoRotate = true,
|
|
406
|
+
labelAutoHide = false,
|
|
407
|
+
label: showLabel = true,
|
|
408
|
+
tick: showTick = true,
|
|
409
|
+
line = false,
|
|
410
|
+
grid,
|
|
411
|
+
} = Object.assign({}, defaultStyle, userDefinitions);
|
|
412
|
+
|
|
407
413
|
const showGrid = inferGrid(grid, coordinate, scale);
|
|
408
414
|
const gridLength = getGridLength(position, coordinate);
|
|
409
415
|
|
|
410
|
-
const {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const defaultStyle = inferDefaultStyle(scale, theme, position, direction);
|
|
416
|
+
const { showLine = line, ...overrideStyle } = inferOverrideStyle(
|
|
417
|
+
position,
|
|
418
|
+
bbox,
|
|
419
|
+
coordinate,
|
|
420
|
+
);
|
|
416
421
|
|
|
417
422
|
const axisStyle = {
|
|
418
423
|
...defaultStyle,
|
package/src/component/slider.ts
CHANGED
|
@@ -30,15 +30,13 @@ export const Slider: GCC<SliderOptions> = (options) => {
|
|
|
30
30
|
style: Object.assign({}, sliderTheme, {
|
|
31
31
|
x,
|
|
32
32
|
y,
|
|
33
|
-
|
|
33
|
+
trackLength: orient === 'horizontal' ? width : height,
|
|
34
34
|
orient,
|
|
35
35
|
formatter: (v) => {
|
|
36
36
|
const f = formatter || defaultFormatter;
|
|
37
37
|
const tick = invertTick(scale, v);
|
|
38
38
|
return f(tick);
|
|
39
39
|
},
|
|
40
|
-
// @todo GUI should rename size to railSize
|
|
41
|
-
size: sliderTheme.railSize,
|
|
42
40
|
...rest,
|
|
43
41
|
}),
|
|
44
42
|
});
|
package/src/composition/mark.ts
CHANGED
|
@@ -36,6 +36,7 @@ export const Mark: CC<MarkOptions> = () => {
|
|
|
36
36
|
title,
|
|
37
37
|
labelTransform,
|
|
38
38
|
parentKey,
|
|
39
|
+
clip,
|
|
39
40
|
...mark
|
|
40
41
|
} = options;
|
|
41
42
|
|
|
@@ -70,6 +71,7 @@ export const Mark: CC<MarkOptions> = () => {
|
|
|
70
71
|
marginTop,
|
|
71
72
|
marginRight,
|
|
72
73
|
parentKey,
|
|
74
|
+
clip,
|
|
73
75
|
marks: [{ ...mark, key: `${key}-0`, data }],
|
|
74
76
|
},
|
|
75
77
|
];
|
|
Binary file
|
package/src/interaction/index.ts
CHANGED
|
@@ -10,6 +10,9 @@ export { ChartIndex } from './native/chartIndex';
|
|
|
10
10
|
export { Fisheye } from './native/fisheye';
|
|
11
11
|
export { Tooltip } from './native/tooltip';
|
|
12
12
|
export { LegendFilter } from './native/legendFilter';
|
|
13
|
+
export { BrushHighlight } from './native/brushHighlight';
|
|
14
|
+
export { BrushXHighlight } from './native/brushXHighlight';
|
|
15
|
+
export { BrushYHighlight } from './native/brushYHighlight';
|
|
13
16
|
|
|
14
17
|
export { LEGEND_ITEMS_CLASS_NAME } from './native/legendFilter';
|
|
15
18
|
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { DisplayObject, Rect, Path } from '@antv/g';
|
|
2
|
+
import { subObject } from '../../utils/helper';
|
|
3
|
+
import {
|
|
4
|
+
selectG2Elements,
|
|
5
|
+
selectPlotArea,
|
|
6
|
+
createDatumof,
|
|
7
|
+
useState,
|
|
8
|
+
createValueof,
|
|
9
|
+
setCursor,
|
|
10
|
+
mousePositionClamp,
|
|
11
|
+
selectFacetG2Elements,
|
|
12
|
+
} from './utils';
|
|
13
|
+
|
|
14
|
+
function intersect(bbox1: any, bbox2: any) {
|
|
15
|
+
const [minX1, minY1, maxX1, maxY1] = bbox1;
|
|
16
|
+
const [minX2, minY2, maxX2, maxY2] = bbox2;
|
|
17
|
+
return !(minX2 > maxX1 || maxX2 < minX1 || minY2 > maxY1 || maxY2 < minY1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function normalizeBounds(x, y, x1, y1, extent) {
|
|
21
|
+
const [minX, minY, maxX, maxY] = extent;
|
|
22
|
+
return [
|
|
23
|
+
Math.max(minX, Math.min(x, x1)),
|
|
24
|
+
Math.max(minY, Math.min(y, y1)),
|
|
25
|
+
Math.min(maxX, Math.max(x, x1)),
|
|
26
|
+
Math.min(maxY, Math.max(y, y1)),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function brush(
|
|
31
|
+
root: DisplayObject,
|
|
32
|
+
{
|
|
33
|
+
brushed,
|
|
34
|
+
brushend,
|
|
35
|
+
brushRegion,
|
|
36
|
+
extent,
|
|
37
|
+
reverse = false,
|
|
38
|
+
...style
|
|
39
|
+
}: Record<string, any>,
|
|
40
|
+
) {
|
|
41
|
+
let start = null; // Start point of mask.
|
|
42
|
+
let end = null; // End point of mask.
|
|
43
|
+
let moveStart = null; // Start point of moving mask.
|
|
44
|
+
let mask = null; // Mask instance.
|
|
45
|
+
let background = null;
|
|
46
|
+
let resizing = false;
|
|
47
|
+
|
|
48
|
+
const [originX, originY, width, height] = extent;
|
|
49
|
+
|
|
50
|
+
setCursor(root, 'crosshair');
|
|
51
|
+
root.style.draggable = true; // Make it response to drag event.
|
|
52
|
+
|
|
53
|
+
// Remove old mask and init new mask.
|
|
54
|
+
const initMask = (x, y) => {
|
|
55
|
+
if (mask) mask.remove();
|
|
56
|
+
if (background) background.remove();
|
|
57
|
+
start = [x, y];
|
|
58
|
+
if (reverse) return initReverseMask();
|
|
59
|
+
initNormalMask();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const initReverseMask = () => {
|
|
63
|
+
background = new Path({
|
|
64
|
+
style: {
|
|
65
|
+
...style,
|
|
66
|
+
pointerEvents: 'none',
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
mask = new Rect({
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
style: {
|
|
72
|
+
draggable: true,
|
|
73
|
+
fill: 'transparent',
|
|
74
|
+
},
|
|
75
|
+
className: 'mask',
|
|
76
|
+
});
|
|
77
|
+
root.appendChild(background);
|
|
78
|
+
root.appendChild(mask);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const initNormalMask = () => {
|
|
82
|
+
mask = new Rect({
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
style: {
|
|
85
|
+
...style,
|
|
86
|
+
draggable: true, // Make it response to drag event.
|
|
87
|
+
},
|
|
88
|
+
className: 'mask',
|
|
89
|
+
});
|
|
90
|
+
root.appendChild(mask);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Remove mask and reset states.
|
|
94
|
+
const removeMask = () => {
|
|
95
|
+
if (mask) mask.remove();
|
|
96
|
+
if (background) background.remove();
|
|
97
|
+
start = null;
|
|
98
|
+
end = null;
|
|
99
|
+
moveStart = null;
|
|
100
|
+
resizing = false;
|
|
101
|
+
mask = null;
|
|
102
|
+
background = null;
|
|
103
|
+
brushend();
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Update mask and invoke brushend callback.
|
|
107
|
+
const updateMask = (start, end) => {
|
|
108
|
+
const [x, y, x1, y1] = normalizeBounds(
|
|
109
|
+
start[0],
|
|
110
|
+
start[1],
|
|
111
|
+
end[0],
|
|
112
|
+
end[1],
|
|
113
|
+
extent,
|
|
114
|
+
);
|
|
115
|
+
const [fx, fy, fx1, fy1] = brushRegion(x, y, x1, y1, extent);
|
|
116
|
+
if (reverse) updateReverseMask(fx, fy, fx1, fy1);
|
|
117
|
+
else updateNormalMask(fx, fy, fx1, fy1);
|
|
118
|
+
brushed(fx, fy, fx1, fy1);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const updateNormalMask = (x, y, x1, y1) => {
|
|
122
|
+
mask.style.x = x;
|
|
123
|
+
mask.style.y = y;
|
|
124
|
+
mask.style.width = x1 - x;
|
|
125
|
+
mask.style.height = y1 - y;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const updateReverseMask = (x, y, x1, y1) => {
|
|
129
|
+
background.style.d = `
|
|
130
|
+
M${originX},${originY}L${width},${originY}L${width},${height}L${originX},${height}Z
|
|
131
|
+
M${x},${y}L${x},${y1}L${x1},${y1}L${x1},${y}Z
|
|
132
|
+
`;
|
|
133
|
+
mask.style.x = x;
|
|
134
|
+
mask.style.y = y;
|
|
135
|
+
mask.style.width = x1 - x;
|
|
136
|
+
mask.style.height = y1 - y;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// Move and update mask.
|
|
140
|
+
const moveMask = (current) => {
|
|
141
|
+
const clip = (dt, start, end, min, max) => {
|
|
142
|
+
if (dt + start < min) return min - start;
|
|
143
|
+
if (dt + end > max) return max - end;
|
|
144
|
+
return dt;
|
|
145
|
+
};
|
|
146
|
+
const dx = current[0] - moveStart[0];
|
|
147
|
+
const dy = current[1] - moveStart[1];
|
|
148
|
+
const dx1 = clip(dx, start[0], end[0], originX, width);
|
|
149
|
+
const dy1 = clip(dy, start[1], end[1], originY, height);
|
|
150
|
+
const currentStart = [start[0] + dx1, start[1] + dy1];
|
|
151
|
+
const currentEnd = [end[0] + dx1, end[1] + dy1];
|
|
152
|
+
updateMask(currentStart, currentEnd);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// If target is plot area, create mask.
|
|
156
|
+
// If target is mask, about to update position.
|
|
157
|
+
const dragstart = (event) => {
|
|
158
|
+
const { target } = event;
|
|
159
|
+
const [offsetX, offsetY] = mousePositionClamp(root, event);
|
|
160
|
+
if (target === mask) {
|
|
161
|
+
moveStart = [offsetX, offsetY];
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
initMask(offsetX, offsetY);
|
|
165
|
+
resizing = true;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// If target is plot area, resize mask.
|
|
169
|
+
// If target is mask, move mask.
|
|
170
|
+
const drag = (event) => {
|
|
171
|
+
const mouse = mousePositionClamp(root, event);
|
|
172
|
+
if (!start) return;
|
|
173
|
+
if (moveStart) return moveMask(mouse);
|
|
174
|
+
updateMask(start, mouse);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// If target is plot area, finish resizing.
|
|
178
|
+
// If target is mask, finish moving mask.
|
|
179
|
+
const dragend = (event) => {
|
|
180
|
+
if (moveStart) {
|
|
181
|
+
moveStart = null;
|
|
182
|
+
// Update start and end;
|
|
183
|
+
const { x, y, width, height } = mask.style;
|
|
184
|
+
start = [x, y];
|
|
185
|
+
end = [x + width, y + height];
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
end = mousePositionClamp(root, event);
|
|
189
|
+
updateMask(start, end);
|
|
190
|
+
resizing = false;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// Hide mask.
|
|
194
|
+
const click = (event) => {
|
|
195
|
+
const { target } = event;
|
|
196
|
+
if (mask && target !== mask) removeMask();
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Update cursor depends on hovered element.
|
|
200
|
+
const pointermove = (event) => {
|
|
201
|
+
const { target } = event;
|
|
202
|
+
if (target === mask && !resizing) setCursor(root, 'move');
|
|
203
|
+
else setCursor(root, 'crosshair');
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
root.addEventListener('dragstart', dragstart);
|
|
207
|
+
root.addEventListener('drag', drag);
|
|
208
|
+
root.addEventListener('dragend', dragend);
|
|
209
|
+
root.addEventListener('click', click);
|
|
210
|
+
root.addEventListener('pointermove', pointermove);
|
|
211
|
+
|
|
212
|
+
return () => {
|
|
213
|
+
if (mask) mask.remove();
|
|
214
|
+
if (background) background.remove();
|
|
215
|
+
root.removeEventListener('dragstart', dragstart);
|
|
216
|
+
root.removeEventListener('drag', drag);
|
|
217
|
+
root.removeEventListener('dragend', dragend);
|
|
218
|
+
root.removeEventListener('click', click);
|
|
219
|
+
root.removeEventListener('pointermove', pointermove);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function brushHighlight(
|
|
224
|
+
root,
|
|
225
|
+
{
|
|
226
|
+
elements: elementof,
|
|
227
|
+
datum,
|
|
228
|
+
brushRegion,
|
|
229
|
+
extent: optionalExtent,
|
|
230
|
+
reverse,
|
|
231
|
+
series = false,
|
|
232
|
+
...rest
|
|
233
|
+
},
|
|
234
|
+
) {
|
|
235
|
+
const elements = elementof(root);
|
|
236
|
+
const valueof = createValueof(elements, datum);
|
|
237
|
+
const brushStyle = subObject(rest, 'mask');
|
|
238
|
+
const { setState, removeState } = useState(rest, valueof);
|
|
239
|
+
const clonedElement = new Map();
|
|
240
|
+
const {
|
|
241
|
+
width: rootWidth,
|
|
242
|
+
height: rootHeight,
|
|
243
|
+
x: ordinalX,
|
|
244
|
+
y: ordinalY,
|
|
245
|
+
} = root.getBBox();
|
|
246
|
+
const extent = optionalExtent
|
|
247
|
+
? optionalExtent
|
|
248
|
+
: [0, 0, rootWidth, rootHeight];
|
|
249
|
+
|
|
250
|
+
const seriesBrushend = () => {
|
|
251
|
+
for (const element of elements) removeState(element, 'unhighlighted');
|
|
252
|
+
for (const cloned of clonedElement.values()) cloned.remove();
|
|
253
|
+
clonedElement.clear();
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const brushend = () => {
|
|
257
|
+
for (const element of elements) {
|
|
258
|
+
removeState(element, 'highlighted', 'unhighlighted');
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const brushed = (x, y, x1, y1) => {
|
|
263
|
+
for (const element of elements) {
|
|
264
|
+
const { min, max } = element.getLocalBounds();
|
|
265
|
+
const [ex, ey] = min;
|
|
266
|
+
const [ex1, ey1] = max;
|
|
267
|
+
if (!intersect([ex, ey, ex1, ey1], [x, y, x1, y1])) {
|
|
268
|
+
setState(element, 'unhighlighted');
|
|
269
|
+
} else {
|
|
270
|
+
setState(element, 'highlighted');
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const seriesBrushed = (x, y, x1, y1) => {
|
|
276
|
+
const clone = (element) => {
|
|
277
|
+
const cloned = element.cloneNode();
|
|
278
|
+
element.parentNode.appendChild(cloned);
|
|
279
|
+
clonedElement.set(element, cloned);
|
|
280
|
+
return cloned;
|
|
281
|
+
};
|
|
282
|
+
for (const element of elements) {
|
|
283
|
+
const cloned = clonedElement.get(element) || clone(element);
|
|
284
|
+
cloned.style.clipPath = new Rect({
|
|
285
|
+
style: {
|
|
286
|
+
x: x + ordinalX,
|
|
287
|
+
y: y + ordinalY,
|
|
288
|
+
width: x1 - x,
|
|
289
|
+
height: y1 - y,
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
setState(element, 'unhighlighted');
|
|
293
|
+
setState(cloned, 'highlighted');
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
return brush(root, {
|
|
298
|
+
...brushStyle,
|
|
299
|
+
extent,
|
|
300
|
+
brushRegion,
|
|
301
|
+
reverse,
|
|
302
|
+
brushend: series ? seriesBrushend : brushend,
|
|
303
|
+
brushed: series ? seriesBrushed : brushed,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function BrushHighlight({ facet, ...rest }) {
|
|
308
|
+
return (target, viewInstances) => {
|
|
309
|
+
const { container, view } = target;
|
|
310
|
+
const plotArea = selectPlotArea(container);
|
|
311
|
+
const defaultOptions = {
|
|
312
|
+
maskFill: '#777',
|
|
313
|
+
maskFillOpacity: '0.3',
|
|
314
|
+
maskStroke: '#fff',
|
|
315
|
+
unhighlightedOpacity: 0.5,
|
|
316
|
+
reverse: false,
|
|
317
|
+
};
|
|
318
|
+
if (facet) {
|
|
319
|
+
const bbox = plotArea.getBounds();
|
|
320
|
+
const x = bbox.min[0];
|
|
321
|
+
const y = bbox.min[1];
|
|
322
|
+
const x1 = bbox.max[0];
|
|
323
|
+
const y1 = bbox.max[1];
|
|
324
|
+
return brushHighlight(plotArea.parentNode.parentNode, {
|
|
325
|
+
elements: () => selectFacetG2Elements(target, viewInstances),
|
|
326
|
+
datum: createDatumof(view),
|
|
327
|
+
brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
|
|
328
|
+
maskFill: '#777',
|
|
329
|
+
maskFillOpacity: '0.3',
|
|
330
|
+
maskStroke: '#fff',
|
|
331
|
+
unhighlightedOpacity: 0.5,
|
|
332
|
+
extent: [x, y, x1, y1],
|
|
333
|
+
...defaultOptions,
|
|
334
|
+
...rest,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
return brushHighlight(plotArea, {
|
|
338
|
+
elements: selectG2Elements,
|
|
339
|
+
datum: createDatumof(view),
|
|
340
|
+
brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
|
|
341
|
+
extent: undefined,
|
|
342
|
+
...defaultOptions,
|
|
343
|
+
...rest,
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BrushHighlight } from './brushHighlight';
|
|
2
|
+
|
|
3
|
+
export function BrushXHighlight(options) {
|
|
4
|
+
return BrushHighlight({
|
|
5
|
+
...options,
|
|
6
|
+
brushRegion: (x, y, x1, y1, extent) => {
|
|
7
|
+
const [, minY, , maxY] = extent;
|
|
8
|
+
return [x, minY, x1, maxY];
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BrushHighlight } from './brushHighlight';
|
|
2
|
+
|
|
3
|
+
export function BrushYHighlight(options) {
|
|
4
|
+
return BrushHighlight({
|
|
5
|
+
...options,
|
|
6
|
+
brushRegion: (x, y, x1, y1, extent) => {
|
|
7
|
+
const [minX, , maxX] = extent;
|
|
8
|
+
return [minX, y, maxX, y1];
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
}
|