@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.
- package/dist/g2.min.js +2 -16
- package/dist/g2.min.js.map +1 -1
- package/esm/animate/animation/sector-path-update.d.ts +17 -1
- package/esm/animate/animation/sector-path-update.js +3 -2
- package/esm/animate/animation/sector-path-update.js.map +1 -1
- package/esm/animate/animation/wave-in.js +5 -1
- package/esm/animate/animation/wave-in.js.map +1 -1
- package/esm/chart/controller/annotation.js +0 -1
- package/esm/chart/controller/annotation.js.map +1 -1
- package/esm/chart/controller/slider.js +4 -4
- package/esm/chart/controller/slider.js.map +1 -1
- package/esm/chart/controller/tooltip.js +1 -7
- package/esm/chart/controller/tooltip.js.map +1 -1
- package/esm/chart/view.js +3 -0
- package/esm/chart/view.js.map +1 -1
- package/esm/component/update-label.js +1 -1
- package/esm/component/update-label.js.map +1 -1
- package/esm/core.d.ts +1 -1
- package/esm/core.js +1 -1
- package/esm/core.js.map +1 -1
- package/esm/geometry/shape/area/index.js +1 -0
- package/esm/geometry/shape/area/index.js.map +1 -1
- package/esm/geometry/shape/area/smooth.js +1 -0
- package/esm/geometry/shape/area/smooth.js.map +1 -1
- package/esm/geometry/shape/interval/index.js +3 -1
- package/esm/geometry/shape/interval/index.js.map +1 -1
- package/esm/geometry/shape/interval/util.js +10 -6
- package/esm/geometry/shape/interval/util.js.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/util/coordinate.js.map +1 -1
- package/lib/animate/animation/sector-path-update.d.ts +17 -1
- package/lib/animate/animation/sector-path-update.js +4 -2
- package/lib/animate/animation/sector-path-update.js.map +1 -1
- package/lib/animate/animation/wave-in.js +5 -1
- package/lib/animate/animation/wave-in.js.map +1 -1
- package/lib/chart/controller/annotation.js +0 -1
- package/lib/chart/controller/annotation.js.map +1 -1
- package/lib/chart/controller/slider.js +4 -4
- package/lib/chart/controller/slider.js.map +1 -1
- package/lib/chart/controller/tooltip.js +0 -6
- package/lib/chart/controller/tooltip.js.map +1 -1
- package/lib/chart/view.js +3 -0
- package/lib/chart/view.js.map +1 -1
- package/lib/component/update-label.js +1 -1
- package/lib/component/update-label.js.map +1 -1
- package/lib/core.d.ts +1 -1
- package/lib/core.js +1 -1
- package/lib/core.js.map +1 -1
- package/lib/geometry/shape/area/index.js +1 -0
- package/lib/geometry/shape/area/index.js.map +1 -1
- package/lib/geometry/shape/area/smooth.js +1 -0
- package/lib/geometry/shape/area/smooth.js.map +1 -1
- package/lib/geometry/shape/interval/index.js +3 -1
- package/lib/geometry/shape/interval/index.js.map +1 -1
- package/lib/geometry/shape/interval/util.js +10 -6
- package/lib/geometry/shape/interval/util.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/util/coordinate.js.map +1 -1
- package/package.json +1 -1
- package/src/animate/animation/sector-path-update.ts +3 -2
- package/src/animate/animation/wave-in.ts +6 -1
- package/src/chart/controller/annotation.ts +1 -1
- package/src/chart/controller/slider.ts +4 -4
- package/src/chart/controller/tooltip.ts +1 -7
- package/src/chart/view.ts +4 -0
- package/src/component/update-label.ts +1 -1
- package/src/core.ts +1 -1
- package/src/geometry/shape/area/index.ts +1 -0
- package/src/geometry/shape/area/smooth.ts +1 -0
- package/src/geometry/shape/interval/index.ts +3 -1
- package/src/geometry/shape/interval/util.ts +11 -6
- package/src/index.ts +1 -0
- 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.
|
|
292
|
-
const maxIndex = Math.
|
|
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.
|
|
331
|
-
const maxIndex = Math.
|
|
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,
|
|
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
|
@@ -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
|
-
|
|
143
|
-
|
|
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,
|
|
146
|
-
path.push(['L', p1.x, p0.y - r3]);
|
|
147
|
-
r3 !== 0 && path.push(['A', r3, r3, 0, 0,
|
|
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,
|
|
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
|
});
|
package/src/util/coordinate.ts
CHANGED
|
@@ -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
|
}
|