@antv/g2 4.2.2 → 4.2.5

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 (75) 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 -2
  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/controller/annotation.js +0 -1
  9. package/esm/chart/controller/annotation.js.map +1 -1
  10. package/esm/chart/controller/slider.js +4 -4
  11. package/esm/chart/controller/slider.js.map +1 -1
  12. package/esm/chart/controller/tooltip.js +1 -7
  13. package/esm/chart/controller/tooltip.js.map +1 -1
  14. package/esm/chart/view.js +3 -0
  15. package/esm/chart/view.js.map +1 -1
  16. package/esm/component/update-label.js +1 -1
  17. package/esm/component/update-label.js.map +1 -1
  18. package/esm/core.d.ts +1 -1
  19. package/esm/core.js +1 -1
  20. package/esm/core.js.map +1 -1
  21. package/esm/geometry/shape/area/index.js +1 -0
  22. package/esm/geometry/shape/area/index.js.map +1 -1
  23. package/esm/geometry/shape/area/smooth.js +1 -0
  24. package/esm/geometry/shape/area/smooth.js.map +1 -1
  25. package/esm/geometry/shape/interval/index.js +3 -1
  26. package/esm/geometry/shape/interval/index.js.map +1 -1
  27. package/esm/geometry/shape/interval/util.js +10 -6
  28. package/esm/geometry/shape/interval/util.js.map +1 -1
  29. package/esm/index.js +1 -0
  30. package/esm/index.js.map +1 -1
  31. package/esm/util/coordinate.js.map +1 -1
  32. package/lib/animate/animation/sector-path-update.d.ts +17 -1
  33. package/lib/animate/animation/sector-path-update.js +4 -2
  34. package/lib/animate/animation/sector-path-update.js.map +1 -1
  35. package/lib/animate/animation/wave-in.js +5 -1
  36. package/lib/animate/animation/wave-in.js.map +1 -1
  37. package/lib/chart/controller/annotation.js +0 -1
  38. package/lib/chart/controller/annotation.js.map +1 -1
  39. package/lib/chart/controller/slider.js +4 -4
  40. package/lib/chart/controller/slider.js.map +1 -1
  41. package/lib/chart/controller/tooltip.js +0 -6
  42. package/lib/chart/controller/tooltip.js.map +1 -1
  43. package/lib/chart/view.js +3 -0
  44. package/lib/chart/view.js.map +1 -1
  45. package/lib/component/update-label.js +1 -1
  46. package/lib/component/update-label.js.map +1 -1
  47. package/lib/core.d.ts +1 -1
  48. package/lib/core.js +1 -1
  49. package/lib/core.js.map +1 -1
  50. package/lib/geometry/shape/area/index.js +1 -0
  51. package/lib/geometry/shape/area/index.js.map +1 -1
  52. package/lib/geometry/shape/area/smooth.js +1 -0
  53. package/lib/geometry/shape/area/smooth.js.map +1 -1
  54. package/lib/geometry/shape/interval/index.js +3 -1
  55. package/lib/geometry/shape/interval/index.js.map +1 -1
  56. package/lib/geometry/shape/interval/util.js +10 -6
  57. package/lib/geometry/shape/interval/util.js.map +1 -1
  58. package/lib/index.js +1 -0
  59. package/lib/index.js.map +1 -1
  60. package/lib/util/coordinate.js.map +1 -1
  61. package/package.json +1 -1
  62. package/src/animate/animation/sector-path-update.ts +3 -2
  63. package/src/animate/animation/wave-in.ts +6 -1
  64. package/src/chart/controller/annotation.ts +1 -1
  65. package/src/chart/controller/slider.ts +4 -4
  66. package/src/chart/controller/tooltip.ts +1 -7
  67. package/src/chart/view.ts +4 -0
  68. package/src/component/update-label.ts +1 -1
  69. package/src/core.ts +1 -1
  70. package/src/geometry/shape/area/index.ts +1 -0
  71. package/src/geometry/shape/area/smooth.ts +1 -0
  72. package/src/geometry/shape/interval/index.ts +3 -1
  73. package/src/geometry/shape/interval/util.ts +11 -6
  74. package/src/index.ts +1 -0
  75. package/src/util/coordinate.ts +1 -1
@@ -496,7 +496,7 @@ export default class Annotation extends Controller<BaseOption[]> {
496
496
  if (isNil(option)) {
497
497
  return null;
498
498
  }
499
- const { start, end, position } = option;;
499
+ const { start, end, position } = option;
500
500
  const sp = this.parsePosition(start);
501
501
  const ep = this.parsePosition(end);
502
502
  const textPoint = this.parsePosition(position);
@@ -288,8 +288,8 @@ export default class Slider extends Controller<SliderOption> {
288
288
 
289
289
  const xTickCount = size(xValues);
290
290
 
291
- const minIndex = Math.floor(min * (xTickCount - 1));
292
- const maxIndex = Math.floor(max * (xTickCount - 1));
291
+ const minIndex = Math.round(min * (xTickCount - 1));
292
+ const maxIndex = Math.round(max * (xTickCount - 1));
293
293
 
294
294
  let minText = get(xValues, [minIndex]);
295
295
  let maxText = get(xValues, [maxIndex]);
@@ -327,8 +327,8 @@ export default class Slider extends Controller<SliderOption> {
327
327
  const xValues = isHorizontal ? xScaleValues : xScaleValues.reverse();
328
328
  const xTickCount = size(xValues);
329
329
 
330
- const minIndex = Math.floor(min * (xTickCount - 1));
331
- const maxIndex = Math.floor(max * (xTickCount - 1));
330
+ const minIndex = Math.round(min * (xTickCount - 1));
331
+ const maxIndex = Math.round(max * (xTickCount - 1));
332
332
 
333
333
  // 增加 x 轴的过滤器
334
334
  this.view.filter(xScale.field, (value: any, datum: Datum) => {
@@ -1,7 +1,7 @@
1
1
  import { deepMix, find, get, isEqual, isFunction, mix, isString, isBoolean, flatten, isArray } from '@antv/util';
2
2
  import { Crosshair, HtmlTooltip, IGroup } from '../../dependents';
3
3
  import { Point, TooltipItem, TooltipOption } from '../../interface';
4
- import { getAngleByPoint, getDistanceToCenter, isPointInCoordinate, getCoordinateClipCfg } from '../../util/coordinate';
4
+ import { getAngleByPoint, getDistanceToCenter, getCoordinateClipCfg } from '../../util/coordinate';
5
5
  import { polarToCartesian } from '../../util/graphics';
6
6
  import { findItemsFromView } from '../../util/tooltip';
7
7
  import { BBox } from '../../util/bbox';
@@ -492,9 +492,6 @@ export default class Tooltip extends Controller<TooltipOption> {
492
492
  // 渲染 x 轴上的 tooltip 辅助线
493
493
  private renderXCrosshairs(point: Point, tooltipCfg) {
494
494
  const coordinate = this.getViewWithGeometry(this.view).getCoordinate();
495
- if (!isPointInCoordinate(coordinate, point)) {
496
- return;
497
- }
498
495
  let start;
499
496
  let end;
500
497
  if (coordinate.isRect) {
@@ -552,9 +549,6 @@ export default class Tooltip extends Controller<TooltipOption> {
552
549
  // 渲染 y 轴上的辅助线
553
550
  private renderYCrosshairs(point: Point, tooltipCfg) {
554
551
  const coordinate = this.getViewWithGeometry(this.view).getCoordinate();
555
- if (!isPointInCoordinate(coordinate, point)) {
556
- return;
557
- }
558
552
  let cfg;
559
553
  let type;
560
554
  if (coordinate.isRect) {
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.2';
3
+ export const VERSION = '4.2.5';
4
4
 
5
5
  // 核心基类导出
6
6
  export { Chart, View, Event } from './chart'; // Chart, View 类
@@ -41,6 +41,7 @@ registerShape('area', 'area', {
41
41
  style: {
42
42
  r: 5,
43
43
  fill: color,
44
+ fillOpacity: 1,
44
45
  },
45
46
  };
46
47
  },
@@ -28,6 +28,7 @@ registerShape('area', 'smooth', {
28
28
  style: {
29
29
  r: 5,
30
30
  fill: color,
31
+ fillOpacity: 1,
31
32
  },
32
33
  };
33
34
  },
@@ -22,7 +22,9 @@ registerShape('interval', 'rect', {
22
22
 
23
23
  const backgroundCfg = cfg?.background;
24
24
  if (backgroundCfg) {
25
- group = container.addGroup();
25
+ group = container.addGroup({
26
+ name: 'interval-group',
27
+ });
26
28
  const backgroundStyle = getBackgroundRectStyle(cfg);
27
29
  const backgroundPath = getBackgroundRectPath(cfg, this.parsePoints(cfg.points) as Point[], this.coordinate);
28
30
  group.addShape('path', {
@@ -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
  });
@@ -64,7 +64,7 @@ export function isPointInCoordinate(coordinate: Coordinate, point: Point) {
64
64
  result = isBetween(point.x, start.x, end.x) && isBetween(point.y, start.y, end.y);
65
65
  } else {
66
66
  const invertPoint = coordinate.invert(point);
67
-
67
+
68
68
  result = isBetween(invertPoint.x, 0, 1) && isBetween(invertPoint.y, 0, 1);
69
69
  }
70
70
  }