@antv/g2 4.2.1 → 4.2.4

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 (49) hide show
  1. package/dist/g2.min.js +2 -16
  2. package/dist/g2.min.js.map +1 -1
  3. package/esm/animate/animation/sector-path-update.d.ts +17 -1
  4. package/esm/animate/animation/sector-path-update.js +3 -3
  5. package/esm/animate/animation/sector-path-update.js.map +1 -1
  6. package/esm/animate/animation/wave-in.js +5 -1
  7. package/esm/animate/animation/wave-in.js.map +1 -1
  8. package/esm/chart/view.js +3 -0
  9. package/esm/chart/view.js.map +1 -1
  10. package/esm/component/update-label.js +1 -1
  11. package/esm/component/update-label.js.map +1 -1
  12. package/esm/core.d.ts +1 -1
  13. package/esm/core.js +1 -1
  14. package/esm/core.js.map +1 -1
  15. package/esm/geometry/shape/interval/util.js +10 -6
  16. package/esm/geometry/shape/interval/util.js.map +1 -1
  17. package/esm/index.js +1 -0
  18. package/esm/index.js.map +1 -1
  19. package/esm/interaction/action/component/axis/axis-description.d.ts +1 -1
  20. package/esm/interaction/action/component/axis/axis-description.js +13 -17
  21. package/esm/interaction/action/component/axis/axis-description.js.map +1 -1
  22. package/lib/animate/animation/sector-path-update.d.ts +17 -1
  23. package/lib/animate/animation/sector-path-update.js +4 -3
  24. package/lib/animate/animation/sector-path-update.js.map +1 -1
  25. package/lib/animate/animation/wave-in.js +5 -1
  26. package/lib/animate/animation/wave-in.js.map +1 -1
  27. package/lib/chart/view.js +3 -0
  28. package/lib/chart/view.js.map +1 -1
  29. package/lib/component/update-label.js +1 -1
  30. package/lib/component/update-label.js.map +1 -1
  31. package/lib/core.d.ts +1 -1
  32. package/lib/core.js +1 -1
  33. package/lib/core.js.map +1 -1
  34. package/lib/geometry/shape/interval/util.js +10 -6
  35. package/lib/geometry/shape/interval/util.js.map +1 -1
  36. package/lib/index.js +1 -0
  37. package/lib/index.js.map +1 -1
  38. package/lib/interaction/action/component/axis/axis-description.d.ts +1 -1
  39. package/lib/interaction/action/component/axis/axis-description.js +8 -12
  40. package/lib/interaction/action/component/axis/axis-description.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/animate/animation/sector-path-update.ts +3 -3
  43. package/src/animate/animation/wave-in.ts +6 -1
  44. package/src/chart/view.ts +4 -0
  45. package/src/component/update-label.ts +1 -1
  46. package/src/core.ts +1 -1
  47. package/src/geometry/shape/interval/util.ts +11 -6
  48. package/src/index.ts +1 -0
  49. package/src/interaction/action/component/axis/axis-description.ts +36 -38
@@ -8,7 +8,7 @@ import { AnimateExtraCfg } from '../interface';
8
8
  import { getArcPath, getSectorPath } from '../../util/graphics';
9
9
 
10
10
  function getAngle(startPoint: number[], arcPath: PathCommand) {
11
- let { startAngle, endAngle } = getArcParams(startPoint, arcPath);
11
+ let { startAngle, endAngle, arcFlag } = getArcParams(startPoint, arcPath);
12
12
 
13
13
  if (!isNumberEqual(startAngle, -Math.PI * 0.5) && startAngle < -Math.PI * 0.5) {
14
14
  startAngle += Math.PI * 2;
@@ -26,7 +26,7 @@ function getAngle(startPoint: number[], arcPath: PathCommand) {
26
26
  startAngle = Math.PI * -0.5;
27
27
  }
28
28
 
29
- if (isNumberEqual(endAngle, Math.PI * -0.5)) {
29
+ if (isNumberEqual(endAngle, Math.PI * -0.5) && arcFlag) {
30
30
  endAngle = Math.PI * 1.5;
31
31
  }
32
32
 
@@ -57,7 +57,7 @@ function getArcStartPoint(path: PathCommand) {
57
57
  * 6. radial-line, 为整圆时的 path,命令为 M, A, A, A, A, Z
58
58
  * @param path theta 坐标系下圆弧的 path 命令
59
59
  */
60
- function getArcInfo(path: PathCommand[]) {
60
+ export function getArcInfo(path: PathCommand[]) {
61
61
  let startAngle;
62
62
  let endAngle;
63
63
 
@@ -19,7 +19,12 @@ export function waveIn(element: IShape | IGroup, animateCfg: GAnimateCfg, cfg: A
19
19
  attrs: startState,
20
20
  }) as IShape; // 为 shape 设置剪切区域
21
21
 
22
- // 对剪切图形做动画
22
+ // 更新 动画 获取了 toAttrs 需要重新更新上去
23
+ if (cfg.toAttrs) {
24
+ element.attr(cfg.toAttrs);
25
+ }
26
+
27
+ // 对剪切图形做动画
23
28
  clipShape.animate(endState, {
24
29
  ...animateCfg,
25
30
  callback: () => {
package/src/chart/view.ts CHANGED
@@ -1427,6 +1427,10 @@ export class View extends Base {
1427
1427
  this.coordinateBBox = this.viewBBox.shrink(this.autoPadding.getPadding());
1428
1428
  this.adjustCoordinate();
1429
1429
 
1430
+ // 刷新 tooltip (tooltip crosshairs 依赖 coordinate 位置)
1431
+ const tooltipController = this.controllers.find((c) => c.name === 'tooltip');
1432
+ tooltipController.update();
1433
+
1430
1434
  // 同样递归处理子 views
1431
1435
  const views = this.views;
1432
1436
  for (let i = 0, len = views.length; i < len; i++) {
@@ -32,7 +32,7 @@ export function updateLabel(fromShape: IGroup, toShape: IGroup, cfg: Cfg): void
32
32
  fromShape.set('coordinate', coordinate);
33
33
  fromShape.set('visible', toShape.get('visible'));
34
34
 
35
- fromShape.getChildren().forEach((fromChild, idx) => {
35
+ (fromShape.getChildren() || []).forEach((fromChild, idx) => {
36
36
  const toChild = toShape.getChildByIndex(idx) as IShape;
37
37
  if (!toChild) {
38
38
  fromShape.removeChild(fromChild);
package/src/core.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /* G2 的一个壳子,不包含 Geometry,由开发者自己定义和引入 */
2
2
 
3
- export const VERSION = '4.2.1';
3
+ export const VERSION = '4.2.4';
4
4
 
5
5
  // 核心基类导出
6
6
  export { Chart, View, Event } from './chart'; // Chart, View 类
@@ -139,14 +139,19 @@ export function getBackgroundRectPath(cfg: ShapeInfo, points: Point[], coordinat
139
139
  const height = coordinate.isTransposed ? coordinate.getWidth() : coordinate.getHeight();
140
140
  const [r1, r2, r3, r4] = parseRadius(radius, Math.min(width, height));
141
141
 
142
- path.push(['M', p0.x, p1.y + r1]);
143
- r1 !== 0 && path.push(['A', r1, r1, 0, 0, 1, p0.x + r1, p1.y]);
142
+ // 同时存在 坐标系是否发生转置 和 y 镜像的时候
143
+ const isReflectYTransposed = (coordinate.isTransposed && coordinate.isReflect('y'));
144
+ const bump = isReflectYTransposed ? 0 : 1;
145
+ const opposite = (r: number) => isReflectYTransposed ? -r : r;
146
+
147
+ path.push(['M', p0.x, p1.y + opposite(r1)]);
148
+ r1 !== 0 && path.push(['A', r1, r1, 0, 0, bump, p0.x + r1, p1.y]);
144
149
  path.push(['L', p1.x - r2, p1.y]);
145
- r2 !== 0 && path.push(['A', r2, r2, 0, 0, 1, p1.x, p1.y + r2]);
146
- path.push(['L', p1.x, p0.y - r3]);
147
- r3 !== 0 && path.push(['A', r3, r3, 0, 0, 1, p1.x - r3, p0.y]);
150
+ r2 !== 0 && path.push(['A', r2, r2, 0, 0, bump, p1.x, p1.y + opposite(r2)]);
151
+ path.push(['L', p1.x, p0.y - opposite(r3)]);
152
+ r3 !== 0 && path.push(['A', r3, r3, 0, 0, bump, p1.x - r3, p0.y]);
148
153
  path.push(['L', p0.x + r4, p0.y]);
149
- r4 !== 0 && path.push(['A', r4, r4, 0, 0, 1, p0.x, p0.y - r4]);
154
+ r4 !== 0 && path.push(['A', r4, r4, 0, 0, bump, p0.x, p0.y - opposite(r4)]);
150
155
  } else {
151
156
  path.push(['M', p0.x, p0.y]);
152
157
  path.push(['L', p1.x, p0.y]);
package/src/index.ts CHANGED
@@ -343,6 +343,7 @@ registerInteraction('ellipsis-text', {
343
343
  { trigger: 'legend-item-name:mouseleave', action: 'ellipsis-text:hide' },
344
344
  { trigger: 'legend-item-name:touchend', action: 'ellipsis-text:hide' },
345
345
  { trigger: 'axis-label:mouseleave', action: 'ellipsis-text:hide' },
346
+ { trigger: 'axis-label:mouseout', action: 'ellipsis-text:hide' },
346
347
  { trigger: 'axis-label:touchend', action: 'ellipsis-text:hide' },
347
348
  ],
348
349
  });
@@ -1,10 +1,11 @@
1
- import { TOOLTIP_CSS_CONST } from "@antv/component";
2
- import { deepMix } from "@antv/util";
3
- import { HtmlTooltip } from "../../../../dependents";
4
- import Action from "../../base";
5
- import { getDelegationObject } from "../../util";
1
+ import { TOOLTIP_CSS_CONST } from '@antv/component';
2
+ import { deepMix } from '@antv/util';
3
+ import { HtmlTooltip } from '../../../../dependents';
4
+ import Action from '../../base';
5
+ import { getDelegationObject } from '../../util';
6
+ import cx from 'classnames';
6
7
 
7
- const AXIS_DESCRIPTION_TOOLTIP = 'aixs-description-tooltip'
8
+ const AXIS_DESCRIPTION_TOOLTIP = 'aixs-description-tooltip';
8
9
 
9
10
  class AxisDescription extends Action {
10
11
  private tooltip;
@@ -12,29 +13,26 @@ class AxisDescription extends Action {
12
13
  public show() {
13
14
  const context = this.context;
14
15
  const { axis } = getDelegationObject(context);
15
- const { description, text } = axis.cfg.title;
16
+ const { description, text, descriptionTooltipStyle } = axis.cfg.title;
16
17
  const { x, y } = context.event;
17
- if(!this.tooltip) {
18
- this.renderTooltip()
19
- };
18
+ if (!this.tooltip) {
19
+ this.renderTooltip();
20
+ }
20
21
  this.tooltip.update({
21
22
  title: text || '',
22
23
  customContent: () => {
23
- return (`
24
- <div class="${TOOLTIP_CSS_CONST.CONTAINER_CLASS}">
24
+ return `
25
+ <div class="${TOOLTIP_CSS_CONST.CONTAINER_CLASS}" style={${descriptionTooltipStyle}}>
25
26
  <div class="${TOOLTIP_CSS_CONST.TITLE_CLASS}">
26
- ${text}
27
- </div>
28
- <div class="${TOOLTIP_CSS_CONST.LIST_CLASS}">
29
- ${description}
27
+ 字段说明:${description}
30
28
  </div>
31
29
  </div>
32
- `)
30
+ `;
33
31
  },
34
32
  x,
35
- y
33
+ y,
36
34
  });
37
- this.tooltip.show()
35
+ this.tooltip.show();
38
36
  }
39
37
 
40
38
  public destroy() {
@@ -43,7 +41,7 @@ class AxisDescription extends Action {
43
41
  }
44
42
 
45
43
  public hide() {
46
- this.tooltip && this.tooltip.hide()
44
+ this.tooltip && this.tooltip.hide();
47
45
  }
48
46
 
49
47
  public renderTooltip() {
@@ -59,28 +57,28 @@ class AxisDescription extends Action {
59
57
  visible: false,
60
58
  containerId: AXIS_DESCRIPTION_TOOLTIP,
61
59
  domStyles: {
62
- ...deepMix({}, {
63
- // 超长的时候,tooltip tip 最大宽度为 50%,然后可以换行
64
- [TOOLTIP_CSS_CONST.CONTAINER_CLASS]: {
65
- 'max-width': '50%',
66
- 'padding': '5px',
67
- 'line-height': '15px'
68
- },
69
- [TOOLTIP_CSS_CONST.TITLE_CLASS]: {
70
- 'word-break': 'break-all',
71
- 'font-size': '14px',
72
- 'margin-bottom': '3px'
73
- },
74
- [TOOLTIP_CSS_CONST.LIST_CLASS]: {
75
- 'word-break': 'break-all',
76
- 'opacity': '.5'
60
+ ...deepMix(
61
+ {},
62
+ {
63
+ // 超长的时候,tooltip tip 最大宽度为 50%,然后可以换行
64
+ [TOOLTIP_CSS_CONST.CONTAINER_CLASS]: {
65
+ 'max-width': '50%',
66
+ padding: '10px',
67
+ 'line-height': '15px',
68
+ 'font-size': '12px',
69
+ color: 'rgba(0, 0, 0, .65)',
70
+ },
71
+ [TOOLTIP_CSS_CONST.TITLE_CLASS]: {
72
+ 'word-break': 'break-all',
73
+ 'margin-bottom': '3px',
74
+ },
77
75
  }
78
- }),
76
+ ),
79
77
  },
80
78
  });
81
79
  tooltip.init();
82
80
  tooltip.setCapture(false);
83
- this.tooltip = tooltip
81
+ this.tooltip = tooltip;
84
82
  }
85
83
  }
86
- export default AxisDescription
84
+ export default AxisDescription;