@antv/g2 5.0.1 → 5.0.3

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 (52) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/g2-lite.min.js +3 -3
  3. package/dist/g2.min.js +3 -3
  4. package/esm/animation/morphing.js +4 -2
  5. package/esm/animation/morphing.js.map +1 -1
  6. package/esm/api/chart.d.ts +1 -2
  7. package/esm/api/chart.js.map +1 -1
  8. package/esm/component/axis.js +1 -1
  9. package/esm/component/axis.js.map +1 -1
  10. package/esm/interaction/fisheye.js +3 -1
  11. package/esm/interaction/fisheye.js.map +1 -1
  12. package/esm/interaction/tooltip.js +3 -1
  13. package/esm/interaction/tooltip.js.map +1 -1
  14. package/esm/runtime/render.d.ts +1 -1
  15. package/esm/runtime/render.js +16 -6
  16. package/esm/runtime/render.js.map +1 -1
  17. package/esm/shape/interval/funnel.js +20 -4
  18. package/esm/shape/interval/funnel.js.map +1 -1
  19. package/esm/shape/interval/pyramid.js +3 -2
  20. package/esm/shape/interval/pyramid.js.map +1 -1
  21. package/esm/spec/composition.d.ts +7 -6
  22. package/lib/animation/morphing.js +4 -2
  23. package/lib/animation/morphing.js.map +1 -1
  24. package/lib/api/chart.d.ts +1 -2
  25. package/lib/api/chart.js.map +1 -1
  26. package/lib/component/axis.js +1 -1
  27. package/lib/component/axis.js.map +1 -1
  28. package/lib/interaction/fisheye.js +3 -1
  29. package/lib/interaction/fisheye.js.map +1 -1
  30. package/lib/interaction/tooltip.js +3 -1
  31. package/lib/interaction/tooltip.js.map +1 -1
  32. package/lib/runtime/render.d.ts +1 -1
  33. package/lib/runtime/render.js +16 -6
  34. package/lib/runtime/render.js.map +1 -1
  35. package/lib/shape/interval/funnel.js +20 -4
  36. package/lib/shape/interval/funnel.js.map +1 -1
  37. package/lib/shape/interval/pyramid.js +3 -2
  38. package/lib/shape/interval/pyramid.js.map +1 -1
  39. package/lib/spec/composition.d.ts +7 -6
  40. package/package.json +3 -3
  41. package/src/animation/morphing.ts +8 -2
  42. package/src/api/chart.ts +0 -2
  43. package/src/component/axis.ts +1 -1
  44. package/src/interaction/fisheye.ts +4 -1
  45. package/src/interaction/tooltip.ts +4 -1
  46. package/src/runtime/render.ts +18 -7
  47. package/src/shape/interval/funnel.ts +23 -12
  48. package/src/shape/interval/pyramid.ts +0 -2
  49. package/src/spec/composition.ts +7 -6
  50. package/src/.DS_Store +0 -0
  51. package/src/data/.DS_Store +0 -0
  52. package/src/shape/.DS_Store +0 -0
@@ -1,7 +1,10 @@
1
+ import { Path } from '@antv/g';
2
+ import { line, curveLinearClosed } from 'd3-shape';
1
3
  import { Coordinate } from '@antv/coord';
2
4
  import { isTranspose } from '../../utils/coordinate';
3
5
  import { ShapeComponent as SC, Vector2 } from '../../runtime';
4
- import { Color } from './color';
6
+ import { select } from '../../utils/selection';
7
+ import { applyStyle, getShapeTheme, reorder, toOpacityKey } from '../utils';
5
8
 
6
9
  export type FunnelOptions = {
7
10
  adjustPoints?: (
@@ -38,22 +41,30 @@ function getFunnelPoints(
38
41
  export const Funnel: SC<FunnelOptions> = (options) => {
39
42
  const { adjustPoints = getFunnelPoints, ...style } = options;
40
43
  return (points, value, coordinate, theme, point2d, ...args) => {
41
- const { index } = value;
44
+ const { index, mark, shape, defaultShape } = value;
45
+ const { defaultColor, ...defaults } = getShapeTheme(
46
+ theme,
47
+ mark,
48
+ shape,
49
+ defaultShape,
50
+ );
42
51
  const nextPoints = point2d[index + 1];
43
52
  const funnelPoints = adjustPoints(points, nextPoints, coordinate);
53
+ const tpShape = !!isTranspose(coordinate);
44
54
 
45
- return Color({ colorAttribute: 'fill', ...style })(
46
- funnelPoints,
47
- value,
48
- coordinate,
49
- theme,
50
- point2d,
51
- ...args,
52
- );
55
+ const [p0, p1, p2, p3] = tpShape ? reorder(funnelPoints) : funnelPoints;
56
+ const { color = defaultColor, opacity } = value;
57
+ const b = line().curve(curveLinearClosed)([p0, p1, p2, p3]);
58
+ return select(new Path({}))
59
+ .call(applyStyle, defaults)
60
+ .style('path', b)
61
+ .style('fill', color)
62
+ .style('fillOpacity', opacity)
63
+ .call(applyStyle, style)
64
+ .node();
53
65
  };
54
66
  };
55
67
 
56
68
  Funnel.props = {
57
- ...Color.props,
58
- defaultMarker: 'funnel',
69
+ defaultMarker: 'square',
59
70
  };
@@ -1,7 +1,6 @@
1
1
  import { Coordinate } from '@antv/coord';
2
2
  import { isTranspose } from '../../utils/coordinate';
3
3
  import { ShapeComponent as SC, Vector2 } from '../../runtime';
4
- import { Color } from './color';
5
4
  import { Funnel } from './funnel';
6
5
 
7
6
  export type PyramidOptions = Record<string, any>;
@@ -46,6 +45,5 @@ export const Pyramid: SC<PyramidOptions> = (options) => {
46
45
  };
47
46
 
48
47
  Pyramid.props = {
49
- ...Color.props,
50
48
  defaultMarker: 'square',
51
49
  };
@@ -62,6 +62,7 @@ export type ViewComposition = {
62
62
  theme?: Theme;
63
63
  children?: Mark[];
64
64
  scale?: Record<string, Scale>;
65
+ frame?: boolean;
65
66
  labelTransform?: LabelTransform[];
66
67
  // @todo
67
68
  axis?: Record<string, any>;
@@ -141,9 +142,9 @@ export type FacetRectComposition = {
141
142
  shareSize?: boolean;
142
143
  children?: Node[] | ((facet: FacetContext) => Node);
143
144
  // @todo
144
- axis?: Record<string, any>;
145
+ axis?: Record<string, any> | boolean;
145
146
  // @todo
146
- legend?: Record<string, any>;
147
+ legend?: Record<string, any> | boolean;
147
148
  };
148
149
 
149
150
  export type RepeatMatrixComposition = {
@@ -172,9 +173,9 @@ export type RepeatMatrixComposition = {
172
173
  color?: Scale;
173
174
  };
174
175
  // @todo
175
- axis?: Record<string, any>;
176
+ axis?: Record<string, any> | boolean;
176
177
  // @todo
177
- legend?: Record<string, any>;
178
+ legend?: Record<string, any> | boolean;
178
179
  children?: Node[] | ((facet: FacetContext) => Node);
179
180
  };
180
181
 
@@ -203,9 +204,9 @@ export type FacetCircleComposition = {
203
204
  };
204
205
  children?: Node[] | ((facet: FacetContext) => Node);
205
206
  // @todo
206
- axis?: Record<string, any>;
207
+ axis?: Record<string, any> | boolean;
207
208
  // @todo
208
- legend?: Record<string, any>;
209
+ legend?: Record<string, any> | boolean;
209
210
  };
210
211
 
211
212
  export type TimingKeyframeComposition = {
package/src/.DS_Store DELETED
Binary file
Binary file
Binary file