@antv/g2 5.1.6 → 5.1.8-beta.1
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/README.md +2 -2
- package/README.zh-CN.md +1 -1
- package/dist/g2.full.min.js +1 -1
- package/dist/g2.lite.min.js +1 -1
- package/dist/g2.min.js +1 -1
- package/esm/animation/growInX.js +0 -4
- package/esm/animation/growInX.js.map +1 -1
- package/esm/animation/growInY.js +0 -4
- package/esm/animation/growInY.js.map +1 -1
- package/esm/animation/scaleInX.js +5 -7
- package/esm/animation/scaleInX.js.map +1 -1
- package/esm/animation/scaleInY.js +5 -7
- package/esm/animation/scaleInY.js.map +1 -1
- package/esm/animation/scaleOutX.js +5 -7
- package/esm/animation/scaleOutX.js.map +1 -1
- package/esm/animation/scaleOutY.js +5 -7
- package/esm/animation/scaleOutY.js.map +1 -1
- package/esm/animation/zoomIn.js +4 -5
- package/esm/animation/zoomIn.js.map +1 -1
- package/esm/animation/zoomOut.js +4 -6
- package/esm/animation/zoomOut.js.map +1 -1
- package/esm/component/axis.js +1 -5
- package/esm/component/axis.js.map +1 -1
- package/esm/component/index.d.ts +0 -1
- package/esm/component/index.js +0 -1
- package/esm/component/index.js.map +1 -1
- package/esm/component/legendContinuous.js +1 -1
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/coordinate/index.d.ts +0 -2
- package/esm/coordinate/index.js +0 -1
- package/esm/coordinate/index.js.map +1 -1
- package/esm/exports.d.ts +6 -1
- package/esm/exports.js +4 -0
- package/esm/exports.js.map +1 -1
- package/esm/index.d.ts +114 -114
- package/esm/index.js +2 -2
- package/esm/index.js.map +1 -1
- package/esm/lib/builtinlib.d.ts +7 -7
- package/esm/lib/core.d.ts +32 -32
- package/esm/lib/index.d.ts +0 -2
- package/esm/lib/index.js +0 -2
- package/esm/lib/index.js.map +1 -1
- package/esm/lib/lite.d.ts +18 -18
- package/esm/lib/std.d.ts +56 -56
- package/esm/mark/index.d.ts +0 -4
- package/esm/mark/index.js +0 -4
- package/esm/mark/index.js.map +1 -1
- package/esm/mark/liquid.js +2 -1
- package/esm/mark/liquid.js.map +1 -1
- package/esm/runtime/component.js +1 -3
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/types/component.d.ts +1 -6
- package/esm/shape/index.d.ts +0 -4
- package/esm/shape/index.js +0 -4
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/interval/color.d.ts +4 -0
- package/esm/shape/interval/color.js +10 -7
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/interval/rect.d.ts +4 -0
- package/esm/shape/interval/rect.js.map +1 -1
- package/esm/shape/line/smooth.js +8 -4
- package/esm/shape/line/smooth.js.map +1 -1
- package/esm/spec/coordinate.d.ts +1 -4
- package/esm/spec/mark.d.ts +1 -3
- package/esm/theme/create.d.ts +1 -0
- package/esm/theme/create.js +1 -0
- package/esm/theme/create.js.map +1 -1
- package/esm/transform/filter.js +3 -1
- package/esm/transform/filter.js.map +1 -1
- package/esm/transform/maybeTitle.js +6 -1
- package/esm/transform/maybeTitle.js.map +1 -1
- package/esm/utils/dateFormat.d.ts +1 -0
- package/esm/utils/dateFormat.js +18 -0
- package/esm/utils/dateFormat.js.map +1 -0
- package/esm/utils/number.d.ts +4 -0
- package/esm/utils/number.js +8 -0
- package/esm/utils/number.js.map +1 -1
- package/lib/animation/growInX.js +0 -4
- package/lib/animation/growInX.js.map +1 -1
- package/lib/animation/growInY.js +0 -4
- package/lib/animation/growInY.js.map +1 -1
- package/lib/animation/scaleInX.js +5 -7
- package/lib/animation/scaleInX.js.map +1 -1
- package/lib/animation/scaleInY.js +5 -7
- package/lib/animation/scaleInY.js.map +1 -1
- package/lib/animation/scaleOutX.js +5 -7
- package/lib/animation/scaleOutX.js.map +1 -1
- package/lib/animation/scaleOutY.js +5 -7
- package/lib/animation/scaleOutY.js.map +1 -1
- package/lib/animation/zoomIn.js +4 -5
- package/lib/animation/zoomIn.js.map +1 -1
- package/lib/animation/zoomOut.js +4 -6
- package/lib/animation/zoomOut.js.map +1 -1
- package/lib/component/axis.js +3 -7
- package/lib/component/axis.js.map +1 -1
- package/lib/component/index.d.ts +0 -1
- package/lib/component/index.js +1 -3
- package/lib/component/index.js.map +1 -1
- package/lib/component/legendContinuous.js +1 -1
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/coordinate/index.d.ts +0 -2
- package/lib/coordinate/index.js +1 -3
- package/lib/coordinate/index.js.map +1 -1
- package/lib/exports.d.ts +6 -1
- package/lib/exports.js +13 -1
- package/lib/exports.js.map +1 -1
- package/lib/index.d.ts +114 -114
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/lib/builtinlib.d.ts +7 -7
- package/lib/lib/core.d.ts +32 -32
- package/lib/lib/index.d.ts +0 -2
- package/lib/lib/index.js +1 -5
- package/lib/lib/index.js.map +1 -1
- package/lib/lib/lite.d.ts +18 -18
- package/lib/lib/std.d.ts +56 -56
- package/lib/mark/index.d.ts +0 -4
- package/lib/mark/index.js +1 -9
- package/lib/mark/index.js.map +1 -1
- package/lib/mark/liquid.js +2 -1
- package/lib/mark/liquid.js.map +1 -1
- package/lib/runtime/component.js +2 -4
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/types/component.d.ts +1 -6
- package/lib/shape/index.d.ts +0 -4
- package/lib/shape/index.js +6 -14
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/interval/color.d.ts +4 -0
- package/lib/shape/interval/color.js +10 -7
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/interval/rect.d.ts +4 -0
- package/lib/shape/interval/rect.js.map +1 -1
- package/lib/shape/line/smooth.js +6 -2
- package/lib/shape/line/smooth.js.map +1 -1
- package/lib/spec/coordinate.d.ts +1 -4
- package/lib/spec/mark.d.ts +1 -3
- package/lib/theme/create.d.ts +1 -0
- package/lib/theme/create.js +1 -0
- package/lib/theme/create.js.map +1 -1
- package/lib/transform/filter.js +3 -1
- package/lib/transform/filter.js.map +1 -1
- package/lib/transform/maybeTitle.js +6 -1
- package/lib/transform/maybeTitle.js.map +1 -1
- package/lib/utils/dateFormat.d.ts +1 -0
- package/lib/utils/dateFormat.js +22 -0
- package/lib/utils/dateFormat.js.map +1 -0
- package/lib/utils/number.d.ts +4 -0
- package/lib/utils/number.js +10 -1
- package/lib/utils/number.js.map +1 -1
- package/package.json +10 -17
- package/src/animation/growInX.ts +1 -6
- package/src/animation/growInY.ts +1 -6
- package/src/animation/scaleInX.ts +8 -11
- package/src/animation/scaleInY.ts +8 -11
- package/src/animation/scaleOutX.ts +8 -11
- package/src/animation/scaleOutY.ts +8 -11
- package/src/animation/zoomIn.ts +4 -6
- package/src/animation/zoomOut.ts +4 -7
- package/src/component/axis.ts +1 -5
- package/src/component/index.ts +0 -1
- package/src/component/legendContinuous.ts +1 -1
- package/src/coordinate/index.ts +0 -2
- package/src/exports.ts +18 -2
- package/src/index.ts +2 -2
- package/src/lib/index.ts +0 -2
- package/src/mark/index.ts +0 -4
- package/src/mark/liquid.ts +2 -1
- package/src/runtime/component.ts +1 -4
- package/src/runtime/types/component.ts +2 -9
- package/src/shape/index.ts +0 -4
- package/src/shape/interval/color.ts +16 -4
- package/src/shape/interval/rect.ts +5 -0
- package/src/shape/line/smooth.ts +12 -4
- package/src/spec/coordinate.ts +0 -5
- package/src/spec/mark.ts +0 -3
- package/src/theme/create.ts +1 -0
- package/src/transform/filter.ts +3 -1
- package/src/transform/maybeTitle.ts +8 -1
- package/src/utils/dateFormat.ts +22 -0
- package/src/utils/number.ts +8 -0
- package/CHANGELOG.md +0 -417
- package/esm/component/axisZ.d.ts +0 -8
- package/esm/component/axisZ.js +0 -14
- package/esm/component/axisZ.js.map +0 -1
- package/esm/coordinate/cartesian3D.d.ts +0 -7
- package/esm/coordinate/cartesian3D.js +0 -6
- package/esm/coordinate/cartesian3D.js.map +0 -1
- package/esm/lib/auto.d.ts +0 -3
- package/esm/lib/auto.js +0 -7
- package/esm/lib/auto.js.map +0 -1
- package/esm/lib/threed.d.ts +0 -7
- package/esm/lib/threed.js +0 -13
- package/esm/lib/threed.js.map +0 -1
- package/esm/mark/auto.d.ts +0 -1
- package/esm/mark/auto.js +0 -26
- package/esm/mark/auto.js.map +0 -1
- package/esm/mark/interval3D.d.ts +0 -8
- package/esm/mark/interval3D.js +0 -65
- package/esm/mark/interval3D.js.map +0 -1
- package/esm/mark/line3D.d.ts +0 -7
- package/esm/mark/line3D.js +0 -65
- package/esm/mark/line3D.js.map +0 -1
- package/esm/mark/point3D.d.ts +0 -9
- package/esm/mark/point3D.js +0 -76
- package/esm/mark/point3D.js.map +0 -1
- package/esm/shape/interval3D/cube.d.ts +0 -6
- package/esm/shape/interval3D/cube.js +0 -71
- package/esm/shape/interval3D/cube.js.map +0 -1
- package/esm/shape/line3D/line.d.ts +0 -3
- package/esm/shape/line3D/line.js +0 -30
- package/esm/shape/line3D/line.js.map +0 -1
- package/esm/shape/point3D/cube.d.ts +0 -6
- package/esm/shape/point3D/cube.js +0 -70
- package/esm/shape/point3D/cube.js.map +0 -1
- package/esm/shape/point3D/sphere.d.ts +0 -6
- package/esm/shape/point3D/sphere.js +0 -70
- package/esm/shape/point3D/sphere.js.map +0 -1
- package/lib/component/axisZ.d.ts +0 -8
- package/lib/component/axisZ.js +0 -19
- package/lib/component/axisZ.js.map +0 -1
- package/lib/coordinate/cartesian3D.d.ts +0 -7
- package/lib/coordinate/cartesian3D.js +0 -10
- package/lib/coordinate/cartesian3D.js.map +0 -1
- package/lib/lib/auto.d.ts +0 -3
- package/lib/lib/auto.js +0 -11
- package/lib/lib/auto.js.map +0 -1
- package/lib/lib/threed.d.ts +0 -7
- package/lib/lib/threed.js +0 -17
- package/lib/lib/threed.js.map +0 -1
- package/lib/mark/auto.d.ts +0 -1
- package/lib/mark/auto.js +0 -30
- package/lib/mark/auto.js.map +0 -1
- package/lib/mark/interval3D.d.ts +0 -8
- package/lib/mark/interval3D.js +0 -69
- package/lib/mark/interval3D.js.map +0 -1
- package/lib/mark/line3D.d.ts +0 -7
- package/lib/mark/line3D.js +0 -69
- package/lib/mark/line3D.js.map +0 -1
- package/lib/mark/point3D.d.ts +0 -9
- package/lib/mark/point3D.js +0 -80
- package/lib/mark/point3D.js.map +0 -1
- package/lib/shape/interval3D/cube.d.ts +0 -6
- package/lib/shape/interval3D/cube.js +0 -75
- package/lib/shape/interval3D/cube.js.map +0 -1
- package/lib/shape/line3D/line.d.ts +0 -3
- package/lib/shape/line3D/line.js +0 -34
- package/lib/shape/line3D/line.js.map +0 -1
- package/lib/shape/point3D/cube.d.ts +0 -6
- package/lib/shape/point3D/cube.js +0 -74
- package/lib/shape/point3D/cube.js.map +0 -1
- package/lib/shape/point3D/sphere.d.ts +0 -6
- package/lib/shape/point3D/sphere.js +0 -74
- package/lib/shape/point3D/sphere.js.map +0 -1
- package/src/component/axisZ.ts +0 -25
- package/src/coordinate/cartesian3D.ts +0 -11
- package/src/lib/auto.ts +0 -7
- package/src/lib/threed.ts +0 -13
- package/src/mark/auto.ts +0 -22
- package/src/mark/interval3D.ts +0 -100
- package/src/mark/line3D.ts +0 -81
- package/src/mark/point3D.ts +0 -90
- package/src/shape/interval3D/cube.ts +0 -69
- package/src/shape/line3D/line.ts +0 -29
- package/src/shape/point3D/cube.ts +0 -68
- package/src/shape/point3D/sphere.ts +0 -68
|
@@ -16,6 +16,12 @@ export type ColorOptions = {
|
|
|
16
16
|
* Maximum width of each interval.
|
|
17
17
|
*/
|
|
18
18
|
maxWidth?: number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Minimum height of each interval.
|
|
22
|
+
*/
|
|
23
|
+
minHeight?: number;
|
|
24
|
+
|
|
19
25
|
[key: string]: any;
|
|
20
26
|
};
|
|
21
27
|
|
|
@@ -40,6 +46,7 @@ export function rect(
|
|
|
40
46
|
radiusTopRight = radius,
|
|
41
47
|
minWidth = -Infinity,
|
|
42
48
|
maxWidth = Infinity,
|
|
49
|
+
minHeight = -Infinity,
|
|
43
50
|
...rest
|
|
44
51
|
} = style;
|
|
45
52
|
if (!isPolar(coordinate) && !isHelix(coordinate)) {
|
|
@@ -51,6 +58,7 @@ export function rect(
|
|
|
51
58
|
// Deal with width or height is negative.
|
|
52
59
|
const absX = width > 0 ? x : x + width;
|
|
53
60
|
const absY = height > 0 ? y : y + height;
|
|
61
|
+
|
|
54
62
|
const absWidth = Math.abs(width);
|
|
55
63
|
const absHeight = Math.abs(height);
|
|
56
64
|
const finalX = absX + insetLeft;
|
|
@@ -59,13 +67,15 @@ export function rect(
|
|
|
59
67
|
const finalHeight = absHeight - (insetTop + insetBottom);
|
|
60
68
|
|
|
61
69
|
const clampWidth = tpShape
|
|
62
|
-
? finalWidth
|
|
70
|
+
? clamp(finalWidth, minHeight, Infinity)
|
|
63
71
|
: clamp(finalWidth, minWidth, maxWidth);
|
|
64
72
|
const clampHeight = tpShape
|
|
65
73
|
? clamp(finalHeight, minWidth, maxWidth)
|
|
66
|
-
: finalHeight;
|
|
67
|
-
const clampX = finalX - (clampWidth - finalWidth) / 2;
|
|
68
|
-
const clampY =
|
|
74
|
+
: clamp(finalHeight, minHeight, Infinity);
|
|
75
|
+
const clampX = tpShape ? finalX : finalX - (clampWidth - finalWidth) / 2;
|
|
76
|
+
const clampY = tpShape
|
|
77
|
+
? finalY - (clampHeight - finalHeight) / 2
|
|
78
|
+
: finalY - (clampHeight - finalHeight);
|
|
69
79
|
|
|
70
80
|
return select(document.createElement('rect', {}))
|
|
71
81
|
.style('x', clampX)
|
|
@@ -145,6 +155,7 @@ export const Color: SC<ColorOptions> = (options, context) => {
|
|
|
145
155
|
insetTop = inset,
|
|
146
156
|
minWidth,
|
|
147
157
|
maxWidth,
|
|
158
|
+
minHeight,
|
|
148
159
|
...rest
|
|
149
160
|
} = style;
|
|
150
161
|
const { color = defaultColor, opacity } = value;
|
|
@@ -179,6 +190,7 @@ export const Color: SC<ColorOptions> = (options, context) => {
|
|
|
179
190
|
insetTop,
|
|
180
191
|
minWidth,
|
|
181
192
|
maxWidth,
|
|
193
|
+
minHeight,
|
|
182
194
|
};
|
|
183
195
|
|
|
184
196
|
return (
|
package/src/shape/line/smooth.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
curveMonotoneX,
|
|
3
|
+
curveMonotoneY,
|
|
4
|
+
curveCatmullRomClosed,
|
|
5
|
+
} from 'd3-shape';
|
|
6
|
+
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
3
7
|
import { ShapeComponent as SC } from '../../runtime';
|
|
4
8
|
import { Curve } from './curve';
|
|
5
9
|
|
|
@@ -11,8 +15,12 @@ export const Smooth: SC<SmoothOptions> = (options, context) => {
|
|
|
11
15
|
const { alpha = 0.5, ...rest } = options;
|
|
12
16
|
const { coordinate } = context;
|
|
13
17
|
return (...params) => {
|
|
14
|
-
const curve = isPolar(coordinate)
|
|
15
|
-
|
|
18
|
+
const curve = isPolar(coordinate)
|
|
19
|
+
? curveCatmullRomClosed
|
|
20
|
+
: isTranspose(coordinate)
|
|
21
|
+
? curveMonotoneY
|
|
22
|
+
: curveMonotoneX;
|
|
23
|
+
return Curve({ curve: curve, ...rest }, context)(...params);
|
|
16
24
|
};
|
|
17
25
|
};
|
|
18
26
|
|
package/src/spec/coordinate.ts
CHANGED
|
@@ -7,7 +7,6 @@ export type Coordinate =
|
|
|
7
7
|
| ThetaCoordinate
|
|
8
8
|
| CustomCoordinate
|
|
9
9
|
| CartesianCoordinate
|
|
10
|
-
| Cartesian3DCoordinate
|
|
11
10
|
| ParallelCoordinate
|
|
12
11
|
| RadialCoordinate
|
|
13
12
|
| RadarCoordinate
|
|
@@ -72,10 +71,6 @@ export type CartesianCoordinate = BaseCoordinate<{
|
|
|
72
71
|
type?: 'cartesian';
|
|
73
72
|
}>;
|
|
74
73
|
|
|
75
|
-
export type Cartesian3DCoordinate = BaseCoordinate<{
|
|
76
|
-
type?: 'cartesian3D';
|
|
77
|
-
}>;
|
|
78
|
-
|
|
79
74
|
export type ParallelCoordinate = BaseCoordinate<{
|
|
80
75
|
type?: 'parallel';
|
|
81
76
|
}>;
|
package/src/spec/mark.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AdviseParams } from '@antv/ava';
|
|
2
1
|
import { MarkComponent } from '../runtime';
|
|
3
2
|
import { Encode } from './encode';
|
|
4
3
|
import { Transform } from './transform';
|
|
@@ -19,7 +18,6 @@ import {
|
|
|
19
18
|
import { Closeable, Literal2Object, Padding } from './utils';
|
|
20
19
|
|
|
21
20
|
export type Mark =
|
|
22
|
-
| AutoMark
|
|
23
21
|
| IntervalMark
|
|
24
22
|
| RectMark
|
|
25
23
|
| LineMark
|
|
@@ -394,4 +392,3 @@ export type HeatmapMark = BaseMark<'heatmap'>;
|
|
|
394
392
|
export type LiquidMark = BaseMark<'liquid'>;
|
|
395
393
|
|
|
396
394
|
export type CustomMark = BaseMark<MarkComponent, ChannelTypes>;
|
|
397
|
-
export type AutoMark = BaseMark<'auto'> & AdviseParams;
|
package/src/theme/create.ts
CHANGED
package/src/transform/filter.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
2
|
import { isUnset } from '../utils/helper';
|
|
3
3
|
import { TransformComponent as TC } from '../runtime';
|
|
4
|
+
import { dynamicFormatDateTime } from '../utils/dateFormat';
|
|
4
5
|
import { columnOf } from './utils/helper';
|
|
5
6
|
|
|
6
7
|
export type MaybeTitleOptions = {
|
|
@@ -27,7 +28,13 @@ export const MaybeTitle: TC<MaybeTitleOptions> = (options = {}) => {
|
|
|
27
28
|
if (titles.length === 0) return [I, mark];
|
|
28
29
|
const T = [];
|
|
29
30
|
for (const i of I) {
|
|
30
|
-
T[i] = {
|
|
31
|
+
T[i] = {
|
|
32
|
+
value: titles
|
|
33
|
+
.map((t) =>
|
|
34
|
+
t[i] instanceof Date ? dynamicFormatDateTime(t[i] as Date) : t[i],
|
|
35
|
+
)
|
|
36
|
+
.join(', '),
|
|
37
|
+
};
|
|
31
38
|
}
|
|
32
39
|
return [
|
|
33
40
|
I,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function fillZero(digit: number) {
|
|
2
|
+
if (Math.abs(digit) > 10) return String(digit);
|
|
3
|
+
return digit.toString().padStart(2, '0');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function dynamicFormatDateTime(date: Date) {
|
|
7
|
+
const year = date.getFullYear();
|
|
8
|
+
const month = fillZero(date.getMonth() + 1);
|
|
9
|
+
const day = fillZero(date.getDate());
|
|
10
|
+
|
|
11
|
+
const yyyyMMDD = `${year}-${month}-${day}`;
|
|
12
|
+
|
|
13
|
+
const hour = date.getHours();
|
|
14
|
+
const minutes = date.getMinutes();
|
|
15
|
+
const seconds = date.getSeconds();
|
|
16
|
+
|
|
17
|
+
if (hour || minutes || seconds)
|
|
18
|
+
return `${yyyyMMDD} ${fillZero(hour)}:${fillZero(minutes)}:${fillZero(
|
|
19
|
+
seconds,
|
|
20
|
+
)}`;
|
|
21
|
+
return yyyyMMDD;
|
|
22
|
+
}
|
package/src/utils/number.ts
CHANGED
|
@@ -4,3 +4,11 @@
|
|
|
4
4
|
export function clamp(v: number, lower: number, upper: number): number {
|
|
5
5
|
return Math.max(lower, Math.min(v, upper));
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Precision conversion
|
|
10
|
+
*/
|
|
11
|
+
export function prettyNumber(n: number, precision = 10) {
|
|
12
|
+
if (typeof n !== 'number') return n;
|
|
13
|
+
return Math.abs(n) < 1e-15 ? n : parseFloat(n.toFixed(precision));
|
|
14
|
+
}
|