@antv/g2 5.0.4 → 5.0.6
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 +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/api/chart.d.ts +10 -6
- package/esm/api/chart.js +56 -28
- package/esm/api/chart.js.map +1 -1
- package/esm/api/composition/base.d.ts +1 -0
- package/esm/api/composition/base.js +2 -2
- package/esm/api/composition/base.js.map +1 -1
- package/esm/component/axis.js +9 -7
- package/esm/component/axis.js.map +1 -1
- package/esm/component/slider.js +8 -5
- package/esm/component/slider.js.map +1 -1
- package/esm/interaction/brushFilter.d.ts +6 -2
- package/esm/interaction/brushFilter.js +42 -21
- package/esm/interaction/brushFilter.js.map +1 -1
- package/esm/interaction/brushHighlight.d.ts +8 -2
- package/esm/interaction/brushHighlight.js +51 -10
- package/esm/interaction/brushHighlight.js.map +1 -1
- package/esm/interaction/brushXFilter.d.ts +1 -1
- package/esm/interaction/brushXHighlight.d.ts +2 -1
- package/esm/interaction/brushYFilter.d.ts +1 -1
- package/esm/interaction/brushYHighlight.d.ts +2 -1
- package/esm/interaction/sliderFilter.js +16 -7
- package/esm/interaction/sliderFilter.js.map +1 -1
- package/esm/runtime/render.js +3 -1
- package/esm/runtime/render.js.map +1 -1
- package/esm/transform/sort.js +13 -3
- package/esm/transform/sort.js.map +1 -1
- package/esm/utils/scale.d.ts +2 -0
- package/esm/utils/scale.js +21 -0
- package/esm/utils/scale.js.map +1 -1
- package/esm/utils/size.d.ts +0 -10
- package/esm/utils/size.js +0 -23
- package/esm/utils/size.js.map +1 -1
- package/lib/api/chart.d.ts +10 -6
- package/lib/api/chart.js +55 -27
- package/lib/api/chart.js.map +1 -1
- package/lib/api/composition/base.d.ts +1 -0
- package/lib/api/composition/base.js +2 -2
- package/lib/api/composition/base.js.map +1 -1
- package/lib/component/axis.js +9 -7
- package/lib/component/axis.js.map +1 -1
- package/lib/component/slider.js +8 -5
- package/lib/component/slider.js.map +1 -1
- package/lib/interaction/brushFilter.d.ts +6 -2
- package/lib/interaction/brushFilter.js +41 -20
- package/lib/interaction/brushFilter.js.map +1 -1
- package/lib/interaction/brushHighlight.d.ts +8 -2
- package/lib/interaction/brushHighlight.js +51 -10
- package/lib/interaction/brushHighlight.js.map +1 -1
- package/lib/interaction/brushXFilter.d.ts +1 -1
- package/lib/interaction/brushXHighlight.d.ts +2 -1
- package/lib/interaction/brushYFilter.d.ts +1 -1
- package/lib/interaction/brushYHighlight.d.ts +2 -1
- package/lib/interaction/sliderFilter.js +16 -7
- package/lib/interaction/sliderFilter.js.map +1 -1
- package/lib/runtime/render.js +3 -1
- package/lib/runtime/render.js.map +1 -1
- package/lib/transform/sort.js +13 -3
- package/lib/transform/sort.js.map +1 -1
- package/lib/utils/scale.d.ts +2 -0
- package/lib/utils/scale.js +24 -1
- package/lib/utils/scale.js.map +1 -1
- package/lib/utils/size.d.ts +0 -10
- package/lib/utils/size.js +1 -25
- package/lib/utils/size.js.map +1 -1
- package/package.json +5 -5
- package/src/api/chart.ts +70 -46
- package/src/api/composition/base.ts +4 -2
- package/src/component/axis.ts +12 -7
- package/src/component/slider.ts +10 -5
- package/src/interaction/brushFilter.ts +49 -19
- package/src/interaction/brushHighlight.ts +55 -6
- package/src/interaction/sliderFilter.ts +21 -7
- package/src/runtime/render.ts +3 -1
- package/src/transform/sort.ts +12 -3
- package/src/utils/scale.ts +23 -0
- package/src/utils/size.ts +0 -31
package/src/utils/scale.ts
CHANGED
|
@@ -29,3 +29,26 @@ export function domainOf(scale, values) {
|
|
|
29
29
|
const end = domain.indexOf(v2);
|
|
30
30
|
return domain.slice(start, end + 1);
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
export function selectionOf(x, y, x1, y1, scale, coordinate) {
|
|
34
|
+
const { x: scaleX, y: scaleY } = scale;
|
|
35
|
+
const abstractDomain = (point, start) => {
|
|
36
|
+
const [x, y] = coordinate.invert(point);
|
|
37
|
+
return [invert(scaleX, x, start), invert(scaleY, y, start)];
|
|
38
|
+
};
|
|
39
|
+
const p0 = abstractDomain([x, y], true);
|
|
40
|
+
const p1 = abstractDomain([x1, y1], false);
|
|
41
|
+
const domainX = domainOf(scaleX, [p0[0], p1[0]]);
|
|
42
|
+
const domainY = domainOf(scaleY, [p0[1], p1[1]]);
|
|
43
|
+
return [domainX, domainY];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function pixelsOf(selection, scale, coordinate) {
|
|
47
|
+
const [[minX, maxX], [minY, maxY]] = selection;
|
|
48
|
+
const { x: scaleX, y: scaleY } = scale;
|
|
49
|
+
const p0 = [scaleX.map(minX), scaleY.map(minY)];
|
|
50
|
+
const p1 = [scaleX.map(maxX), scaleY.map(maxY)];
|
|
51
|
+
const [x, y] = coordinate.map(p0);
|
|
52
|
+
const [x1, y1] = coordinate.map(p1);
|
|
53
|
+
return [x, y, x1, y1];
|
|
54
|
+
}
|
package/src/utils/size.ts
CHANGED
|
@@ -31,37 +31,6 @@ export function getContainerSize(container: HTMLElement): Size {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @description Calculate the chart size.
|
|
37
|
-
* @param container DOM container element.
|
|
38
|
-
* @param autoFit Should auto fit.
|
|
39
|
-
* @param width Chart width which is set by user.
|
|
40
|
-
* @param height Chart height which is set by user.
|
|
41
|
-
* @returns chart width and height.
|
|
42
|
-
*/
|
|
43
|
-
export function getChartSize(
|
|
44
|
-
container: HTMLElement,
|
|
45
|
-
autoFit: boolean,
|
|
46
|
-
width: number,
|
|
47
|
-
height: number,
|
|
48
|
-
): Size {
|
|
49
|
-
if (!autoFit) {
|
|
50
|
-
return {
|
|
51
|
-
width,
|
|
52
|
-
height,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Get size from wrapper container.
|
|
57
|
-
const size = getContainerSize(container);
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
width: size.width,
|
|
61
|
-
height: size.height,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
34
|
/**
|
|
66
35
|
* @description Calculate the real canvas size by view options.
|
|
67
36
|
*/
|