@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.
Files changed (68) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/g2-lite.min.js +3 -3
  3. package/dist/g2.min.js +3 -3
  4. package/esm/api/utils.js +2 -2
  5. package/esm/api/utils.js.map +1 -1
  6. package/esm/composition/facetRect.js +1 -1
  7. package/esm/composition/facetRect.js.map +1 -1
  8. package/esm/interaction/tooltip.d.ts +2 -2
  9. package/esm/interaction/tooltip.js +40 -30
  10. package/esm/interaction/tooltip.js.map +1 -1
  11. package/esm/mark/line.js +1 -1
  12. package/esm/mark/line.js.map +1 -1
  13. package/esm/mark/utils.js +3 -3
  14. package/esm/mark/utils.js.map +1 -1
  15. package/esm/runtime/component.d.ts +1 -1
  16. package/esm/runtime/component.js +24 -19
  17. package/esm/runtime/component.js.map +1 -1
  18. package/esm/runtime/layout.js +6 -4
  19. package/esm/runtime/layout.js.map +1 -1
  20. package/esm/shape/area/curve.js +1 -1
  21. package/esm/shape/area/curve.js.map +1 -1
  22. package/esm/shape/line/trail.js +4 -1
  23. package/esm/shape/line/trail.js.map +1 -1
  24. package/esm/spec/mark.d.ts +1 -0
  25. package/esm/transform/maybeGradient.js +3 -2
  26. package/esm/transform/maybeGradient.js.map +1 -1
  27. package/esm/utils/helper.d.ts +1 -0
  28. package/esm/utils/helper.js +15 -1
  29. package/esm/utils/helper.js.map +1 -1
  30. package/lib/api/utils.js +2 -2
  31. package/lib/api/utils.js.map +1 -1
  32. package/lib/composition/facetRect.js +1 -1
  33. package/lib/composition/facetRect.js.map +1 -1
  34. package/lib/interaction/tooltip.d.ts +2 -2
  35. package/lib/interaction/tooltip.js +40 -30
  36. package/lib/interaction/tooltip.js.map +1 -1
  37. package/lib/mark/line.js +1 -1
  38. package/lib/mark/line.js.map +1 -1
  39. package/lib/mark/utils.js +3 -3
  40. package/lib/mark/utils.js.map +1 -1
  41. package/lib/runtime/component.d.ts +1 -1
  42. package/lib/runtime/component.js +24 -19
  43. package/lib/runtime/component.js.map +1 -1
  44. package/lib/runtime/layout.js +5 -3
  45. package/lib/runtime/layout.js.map +1 -1
  46. package/lib/shape/area/curve.js +1 -1
  47. package/lib/shape/area/curve.js.map +1 -1
  48. package/lib/shape/line/trail.js +4 -1
  49. package/lib/shape/line/trail.js.map +1 -1
  50. package/lib/spec/mark.d.ts +1 -0
  51. package/lib/transform/maybeGradient.js +3 -2
  52. package/lib/transform/maybeGradient.js.map +1 -1
  53. package/lib/utils/helper.d.ts +1 -0
  54. package/lib/utils/helper.js +16 -1
  55. package/lib/utils/helper.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/api/utils.ts +2 -2
  58. package/src/composition/facetRect.ts +1 -1
  59. package/src/interaction/tooltip.ts +42 -28
  60. package/src/mark/line.ts +1 -1
  61. package/src/mark/utils.ts +3 -3
  62. package/src/runtime/component.ts +32 -27
  63. package/src/runtime/layout.ts +10 -7
  64. package/src/shape/area/curve.ts +1 -1
  65. package/src/shape/line/trail.ts +3 -1
  66. package/src/spec/mark.ts +1 -0
  67. package/src/transform/maybeGradient.ts +4 -3
  68. package/src/utils/helper.ts +24 -1
@@ -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 { column, columnOf, constant, visualColumn } from './utils/helper';
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, {
@@ -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
+ }