@antv/g2 5.0.13 → 5.0.14
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/CHANGELOG.md +17 -0
- package/dist/g2-lite.min.js +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/api/utils.js +2 -2
- package/esm/api/utils.js.map +1 -1
- package/esm/composition/facetRect.js +1 -1
- package/esm/composition/facetRect.js.map +1 -1
- package/esm/interaction/tooltip.d.ts +2 -2
- package/esm/interaction/tooltip.js +40 -30
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/mark/line.js +1 -1
- package/esm/mark/line.js.map +1 -1
- package/esm/mark/utils.js +3 -3
- package/esm/mark/utils.js.map +1 -1
- package/esm/runtime/component.d.ts +1 -1
- package/esm/runtime/component.js +24 -19
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +6 -4
- package/esm/runtime/layout.js.map +1 -1
- package/esm/shape/area/curve.js +1 -1
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/line/trail.js +4 -1
- package/esm/shape/line/trail.js.map +1 -1
- package/esm/spec/mark.d.ts +1 -0
- package/esm/transform/maybeGradient.js +3 -2
- package/esm/transform/maybeGradient.js.map +1 -1
- package/esm/utils/helper.d.ts +1 -0
- package/esm/utils/helper.js +15 -1
- package/esm/utils/helper.js.map +1 -1
- package/lib/api/utils.js +2 -2
- package/lib/api/utils.js.map +1 -1
- package/lib/composition/facetRect.js +1 -1
- package/lib/composition/facetRect.js.map +1 -1
- package/lib/interaction/tooltip.d.ts +2 -2
- package/lib/interaction/tooltip.js +40 -30
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/mark/line.js +1 -1
- package/lib/mark/line.js.map +1 -1
- package/lib/mark/utils.js +3 -3
- package/lib/mark/utils.js.map +1 -1
- package/lib/runtime/component.d.ts +1 -1
- package/lib/runtime/component.js +24 -19
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +5 -3
- package/lib/runtime/layout.js.map +1 -1
- package/lib/shape/area/curve.js +1 -1
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/line/trail.js +4 -1
- package/lib/shape/line/trail.js.map +1 -1
- package/lib/spec/mark.d.ts +1 -0
- package/lib/transform/maybeGradient.js +3 -2
- package/lib/transform/maybeGradient.js.map +1 -1
- package/lib/utils/helper.d.ts +1 -0
- package/lib/utils/helper.js +16 -1
- package/lib/utils/helper.js.map +1 -1
- package/package.json +1 -1
- package/src/api/utils.ts +2 -2
- package/src/composition/facetRect.ts +1 -1
- package/src/interaction/tooltip.ts +42 -28
- package/src/mark/line.ts +1 -1
- package/src/mark/utils.ts +3 -3
- package/src/runtime/component.ts +32 -27
- package/src/runtime/layout.ts +10 -7
- package/src/shape/area/curve.ts +1 -1
- package/src/shape/line/trail.ts +3 -1
- package/src/spec/mark.ts +1 -0
- package/src/transform/maybeGradient.ts +4 -3
- package/src/utils/helper.ts +24 -1
package/src/shape/line/trail.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ShapeComponent as SC } from '../../runtime';
|
|
|
3
3
|
import { select } from '../../utils/selection';
|
|
4
4
|
import { applyStyle } from '../utils';
|
|
5
5
|
import { angle, sub, add, Vector2 } from '../../utils/vector';
|
|
6
|
+
import { defined } from '../../utils/helper';
|
|
6
7
|
import { Curve } from './curve';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -44,6 +45,7 @@ function stroke(path, p0, p1, s0, s1) {
|
|
|
44
45
|
|
|
45
46
|
export type TrailOptions = Record<string, any>;
|
|
46
47
|
|
|
48
|
+
// @todo Support connect and connectStyle.
|
|
47
49
|
export const Trail: SC<TrailOptions> = (options, context) => {
|
|
48
50
|
const { document } = context;
|
|
49
51
|
return (P, value, defaults) => {
|
|
@@ -55,7 +57,7 @@ export const Trail: SC<TrailOptions> = (options, context) => {
|
|
|
55
57
|
const p1 = P[i + 1];
|
|
56
58
|
const s0 = seriesSize[i];
|
|
57
59
|
const s1 = seriesSize[i + 1];
|
|
58
|
-
stroke(path, p0, p1, s0, s1);
|
|
60
|
+
if ([...p0, ...p1].every(defined)) stroke(path, p0, p1, s0, s1);
|
|
59
61
|
}
|
|
60
62
|
return select(document.createElement('path', {}))
|
|
61
63
|
.call(applyStyle, rest)
|
package/src/spec/mark.ts
CHANGED
|
@@ -153,6 +153,7 @@ export type BaseMark<T extends MarkTypes, C extends string = ChannelTypes> = {
|
|
|
153
153
|
scale?: Partial<Record<C, Scale>>;
|
|
154
154
|
coordinate?: Coordinate;
|
|
155
155
|
style?: Record<string, any>;
|
|
156
|
+
viewStyle?: Record<string, any>;
|
|
156
157
|
state?: Partial<
|
|
157
158
|
Record<
|
|
158
159
|
'active' | 'selected' | 'inactive' | 'unselected',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
2
|
import { TransformComponent as TC } from '../runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { constant, visualColumn } from './utils/helper';
|
|
4
4
|
|
|
5
5
|
export type MaybeGradientOptions = Record<string, never>;
|
|
6
6
|
|
|
@@ -10,9 +10,10 @@ export type MaybeGradientOptions = Record<string, never>;
|
|
|
10
10
|
*/
|
|
11
11
|
export const MaybeGradient: TC<MaybeGradientOptions> = () => {
|
|
12
12
|
return (I, mark) => {
|
|
13
|
-
const { style = {} } = mark;
|
|
13
|
+
const { style = {}, encode } = mark;
|
|
14
|
+
const { series } = encode;
|
|
14
15
|
const { gradient } = style;
|
|
15
|
-
if (!gradient) return [I, mark];
|
|
16
|
+
if (!gradient || series) return [I, mark];
|
|
16
17
|
return [
|
|
17
18
|
I,
|
|
18
19
|
deepMix({}, mark, {
|
package/src/utils/helper.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
|
-
import { lowerFirst, upperFirst } from '@antv/util';
|
|
2
|
+
import { lowerFirst, upperFirst, isPlainObject } from '@antv/util';
|
|
3
3
|
|
|
4
4
|
export function identity<T>(x: T): T {
|
|
5
5
|
return x;
|
|
@@ -146,3 +146,26 @@ export function isStrictObject(d: any): boolean {
|
|
|
146
146
|
export function isUnset(value) {
|
|
147
147
|
return value === null || value === false;
|
|
148
148
|
}
|
|
149
|
+
|
|
150
|
+
export function deepAssign(
|
|
151
|
+
dist: Record<string, unknown>,
|
|
152
|
+
src: Record<string, unknown>,
|
|
153
|
+
maxLevel = 5,
|
|
154
|
+
level = 0,
|
|
155
|
+
): Record<string, unknown> {
|
|
156
|
+
if (level >= maxLevel) return;
|
|
157
|
+
for (const key of Object.keys(src)) {
|
|
158
|
+
const value = src[key];
|
|
159
|
+
if (!isPlainObject(value) || !isPlainObject(dist[key])) {
|
|
160
|
+
dist[key] = value;
|
|
161
|
+
} else {
|
|
162
|
+
deepAssign(
|
|
163
|
+
dist[key] as Record<string, unknown>,
|
|
164
|
+
value as Record<string, unknown>,
|
|
165
|
+
maxLevel,
|
|
166
|
+
level + 1,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return dist;
|
|
171
|
+
}
|