@antv/g2 5.1.16 → 5.1.18
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.lite.min.js +1 -1
- package/dist/g2.min.js +1 -1
- package/esm/animation/growInX.js +4 -2
- package/esm/animation/growInX.js.map +1 -1
- package/esm/animation/growInY.js +4 -2
- package/esm/animation/growInY.js.map +1 -1
- package/esm/animation/morphing.js +35 -18
- package/esm/animation/morphing.js.map +1 -1
- package/esm/animation/scaleInY.js +2 -5
- package/esm/animation/scaleInY.js.map +1 -1
- package/esm/animation/utils.d.ts +10 -1
- package/esm/animation/utils.js +29 -3
- package/esm/animation/utils.js.map +1 -1
- package/esm/animation/waveIn.js +3 -14
- package/esm/animation/waveIn.js.map +1 -1
- package/esm/component/title.js +2 -1
- package/esm/component/title.js.map +1 -1
- package/esm/exports.js +0 -2
- package/esm/exports.js.map +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/interaction/brushAxisHighlight.js +3 -3
- package/esm/interaction/brushAxisHighlight.js.map +1 -1
- package/esm/interaction/brushHighlight.js +4 -5
- package/esm/interaction/brushHighlight.js.map +1 -1
- package/esm/interaction/elementPointMove.d.ts +9 -0
- package/esm/interaction/elementPointMove.js +506 -0
- package/esm/interaction/elementPointMove.js.map +1 -0
- package/esm/interaction/event.js +1 -8
- package/esm/interaction/event.js.map +1 -1
- package/esm/interaction/index.d.ts +1 -0
- package/esm/interaction/index.js +1 -0
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/tooltip.js +15 -5
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/interaction/treemapDrillDown.js +1 -4
- package/esm/interaction/treemapDrillDown.js.map +1 -1
- package/esm/interaction/utils.d.ts +8 -2
- package/esm/interaction/utils.js +51 -8
- package/esm/interaction/utils.js.map +1 -1
- package/esm/lib/core.d.ts +2 -1
- package/esm/lib/core.js +2 -1
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/std.d.ts +1 -0
- package/esm/mark/chord.js +0 -1
- package/esm/mark/chord.js.map +1 -1
- package/esm/mark/point.js +3 -1
- package/esm/mark/point.js.map +1 -1
- package/esm/mark/sankey.js +1 -1
- package/esm/mark/sankey.js.map +1 -1
- package/esm/runtime/plot.js +4 -7
- package/esm/runtime/plot.js.map +1 -1
- package/esm/shape/connector/connector.js +1 -1
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/gauge/round.js +1 -1
- package/esm/shape/gauge/round.js.map +1 -1
- package/esm/shape/image/image.js +1 -1
- package/esm/shape/index.d.ts +2 -0
- package/esm/shape/index.js +2 -0
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/interval/color.js +1 -1
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/interval/funnel.js +1 -1
- package/esm/shape/interval/funnel.js.map +1 -1
- package/esm/shape/label/position/default.js +9 -9
- package/esm/shape/label/position/default.js.map +1 -1
- package/esm/shape/lineXY/line.js +1 -1
- package/esm/shape/lineXY/line.js.map +1 -1
- package/esm/shape/liquid/liquid.js +4 -4
- package/esm/shape/liquid/liquid.js.map +1 -1
- package/esm/shape/liquid/wave.js +2 -2
- package/esm/shape/liquid/wave.js.map +1 -1
- package/esm/shape/point/circle.d.ts +16 -0
- package/esm/shape/point/circle.js +56 -0
- package/esm/shape/point/circle.js.map +1 -0
- package/esm/shape/point/color.d.ts +2 -0
- package/esm/shape/point/color.js +2 -1
- package/esm/shape/point/color.js.map +1 -1
- package/esm/shape/point/hollowCircle.d.ts +6 -0
- package/esm/shape/point/hollowCircle.js +9 -0
- package/esm/shape/point/hollowCircle.js.map +1 -0
- package/esm/shape/text/advance.js +2 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/text/badge.js +2 -3
- package/esm/shape/text/badge.js.map +1 -1
- package/esm/theme/create.d.ts +4 -2
- package/esm/theme/create.js +4 -2
- package/esm/theme/create.js.map +1 -1
- package/esm/utils/helper.js +1 -8
- package/esm/utils/helper.js.map +1 -1
- package/esm/utils/marker.d.ts +1 -1
- package/esm/utils/marker.js +2 -2
- package/esm/utils/marker.js.map +1 -1
- package/lib/animation/growInX.js +4 -2
- package/lib/animation/growInX.js.map +1 -1
- package/lib/animation/growInY.js +4 -2
- package/lib/animation/growInY.js.map +1 -1
- package/lib/animation/morphing.js +33 -16
- package/lib/animation/morphing.js.map +1 -1
- package/lib/animation/scaleInY.js +2 -5
- package/lib/animation/scaleInY.js.map +1 -1
- package/lib/animation/utils.d.ts +10 -1
- package/lib/animation/utils.js +30 -4
- package/lib/animation/utils.js.map +1 -1
- package/lib/animation/waveIn.js +2 -13
- package/lib/animation/waveIn.js.map +1 -1
- package/lib/component/title.js +2 -1
- package/lib/component/title.js.map +1 -1
- package/lib/exports.js +0 -2
- package/lib/exports.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/interaction/brushAxisHighlight.js +3 -3
- package/lib/interaction/brushAxisHighlight.js.map +1 -1
- package/lib/interaction/brushHighlight.js +4 -5
- package/lib/interaction/brushHighlight.js.map +1 -1
- package/lib/interaction/elementPointMove.d.ts +9 -0
- package/lib/interaction/elementPointMove.js +510 -0
- package/lib/interaction/elementPointMove.js.map +1 -0
- package/lib/interaction/event.js +4 -11
- package/lib/interaction/event.js.map +1 -1
- package/lib/interaction/index.d.ts +1 -0
- package/lib/interaction/index.js +3 -1
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/tooltip.js +14 -4
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/interaction/treemapDrillDown.js +2 -5
- package/lib/interaction/treemapDrillDown.js.map +1 -1
- package/lib/interaction/utils.d.ts +8 -2
- package/lib/interaction/utils.js +56 -8
- package/lib/interaction/utils.js.map +1 -1
- package/lib/lib/core.d.ts +2 -1
- package/lib/lib/core.js +1 -0
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/std.d.ts +1 -0
- package/lib/mark/chord.js +0 -1
- package/lib/mark/chord.js.map +1 -1
- package/lib/mark/point.js +2 -0
- package/lib/mark/point.js.map +1 -1
- package/lib/mark/sankey.js +1 -1
- package/lib/mark/sankey.js.map +1 -1
- package/lib/runtime/plot.js +4 -7
- package/lib/runtime/plot.js.map +1 -1
- package/lib/shape/connector/connector.js +1 -1
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/gauge/round.js +1 -1
- package/lib/shape/gauge/round.js.map +1 -1
- package/lib/shape/image/image.js +1 -1
- package/lib/shape/index.d.ts +2 -0
- package/lib/shape/index.js +6 -2
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/interval/color.js +1 -1
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/interval/funnel.js +1 -1
- package/lib/shape/interval/funnel.js.map +1 -1
- package/lib/shape/label/position/default.js +9 -9
- package/lib/shape/label/position/default.js.map +1 -1
- package/lib/shape/lineXY/line.js +1 -1
- package/lib/shape/lineXY/line.js.map +1 -1
- package/lib/shape/liquid/liquid.js +4 -4
- package/lib/shape/liquid/liquid.js.map +1 -1
- package/lib/shape/liquid/wave.js +2 -2
- package/lib/shape/liquid/wave.js.map +1 -1
- package/lib/shape/point/circle.d.ts +16 -0
- package/lib/shape/point/circle.js +61 -0
- package/lib/shape/point/circle.js.map +1 -0
- package/lib/shape/point/color.d.ts +2 -0
- package/lib/shape/point/color.js +3 -1
- package/lib/shape/point/color.js.map +1 -1
- package/lib/shape/point/hollowCircle.d.ts +6 -0
- package/lib/shape/point/hollowCircle.js +13 -0
- package/lib/shape/point/hollowCircle.js.map +1 -0
- package/lib/shape/text/advance.js +2 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/text/badge.js +2 -3
- package/lib/shape/text/badge.js.map +1 -1
- package/lib/theme/create.d.ts +4 -2
- package/lib/theme/create.js +4 -2
- package/lib/theme/create.js.map +1 -1
- package/lib/utils/helper.js +1 -8
- package/lib/utils/helper.js.map +1 -1
- package/lib/utils/marker.d.ts +1 -1
- package/lib/utils/marker.js +2 -2
- package/lib/utils/marker.js.map +1 -1
- package/package.json +12 -13
- package/src/animation/growInX.ts +9 -2
- package/src/animation/growInY.ts +9 -2
- package/src/animation/morphing.ts +36 -24
- package/src/animation/scaleInY.ts +2 -5
- package/src/animation/utils.ts +34 -4
- package/src/animation/waveIn.ts +3 -20
- package/src/component/title.ts +4 -0
- package/src/exports.ts +0 -4
- package/src/interaction/brushAxisHighlight.ts +5 -4
- package/src/interaction/brushHighlight.ts +8 -5
- package/src/interaction/elementPointMove.ts +659 -0
- package/src/interaction/event.ts +1 -7
- package/src/interaction/index.ts +1 -0
- package/src/interaction/tooltip.ts +15 -4
- package/src/interaction/treemapDrillDown.ts +1 -5
- package/src/interaction/utils.ts +71 -7
- package/src/lib/core.ts +2 -0
- package/src/mark/chord.ts +0 -1
- package/src/mark/point.ts +4 -0
- package/src/mark/sankey.ts +1 -1
- package/src/runtime/plot.ts +12 -7
- package/src/shape/connector/connector.ts +1 -1
- package/src/shape/gauge/round.ts +1 -1
- package/src/shape/image/image.ts +1 -1
- package/src/shape/index.ts +2 -0
- package/src/shape/interval/color.ts +1 -1
- package/src/shape/interval/funnel.ts +1 -1
- package/src/shape/label/position/default.ts +9 -9
- package/src/shape/lineXY/line.ts +1 -2
- package/src/shape/liquid/liquid.ts +4 -4
- package/src/shape/liquid/wave.ts +2 -2
- package/src/shape/point/circle.ts +57 -0
- package/src/shape/point/color.ts +2 -1
- package/src/shape/point/hollowCircle.ts +16 -0
- package/src/shape/text/advance.ts +3 -1
- package/src/shape/text/badge.ts +2 -3
- package/src/theme/create.ts +4 -2
- package/src/utils/helper.ts +1 -7
- package/src/utils/marker.ts +2 -11
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
createDatumof,
|
|
18
18
|
selectElementByData,
|
|
19
19
|
bboxOf,
|
|
20
|
+
maybeRoot,
|
|
20
21
|
} from './utils';
|
|
21
22
|
import { dataOf } from './event';
|
|
22
23
|
|
|
@@ -381,7 +382,7 @@ function updateMarker(root, { data, style, theme }) {
|
|
|
381
382
|
fill,
|
|
382
383
|
r: 4,
|
|
383
384
|
stroke: '#fff',
|
|
384
|
-
|
|
385
|
+
lineWidth: 2,
|
|
385
386
|
...style,
|
|
386
387
|
},
|
|
387
388
|
});
|
|
@@ -422,6 +423,13 @@ function hasSeries(markState): boolean {
|
|
|
422
423
|
);
|
|
423
424
|
}
|
|
424
425
|
|
|
426
|
+
function findElement(node: DisplayObject) {
|
|
427
|
+
return maybeRoot(node, (node) => {
|
|
428
|
+
if (!node.classList) return false;
|
|
429
|
+
return node.classList.includes('element');
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
425
433
|
/**
|
|
426
434
|
* Show tooltip for series item.
|
|
427
435
|
*/
|
|
@@ -798,18 +806,21 @@ export function tooltip(
|
|
|
798
806
|
}: Record<string, any>,
|
|
799
807
|
) {
|
|
800
808
|
const elements = elementsof(root);
|
|
801
|
-
const elementSet = new Set(elements);
|
|
802
809
|
const keyGroup = group(elements, groupKey);
|
|
803
810
|
|
|
804
811
|
const pointermove = throttle(
|
|
805
812
|
(event) => {
|
|
806
|
-
const { target
|
|
807
|
-
|
|
813
|
+
const { target } = event;
|
|
814
|
+
const element = findElement(target);
|
|
815
|
+
if (!element) {
|
|
808
816
|
hideTooltip({ root, single, emitter, event });
|
|
809
817
|
return;
|
|
810
818
|
}
|
|
811
819
|
const k = groupKey(element);
|
|
812
820
|
const group = keyGroup.get(k);
|
|
821
|
+
if (!group) {
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
813
824
|
const data =
|
|
814
825
|
group.length === 1 && !shared
|
|
815
826
|
? singleItem(group[0])
|
|
@@ -7,11 +7,7 @@ import { PLOT_CLASS_NAME } from '../runtime';
|
|
|
7
7
|
import { select } from '../utils/selection';
|
|
8
8
|
import { treeDataTransform } from '../utils/treeDataTransform';
|
|
9
9
|
import { legendClearSetState } from './legendFilter';
|
|
10
|
-
|
|
11
|
-
// Get element.
|
|
12
|
-
const getElements = (plot) => {
|
|
13
|
-
return plot.querySelectorAll('.element');
|
|
14
|
-
};
|
|
10
|
+
import { getElements } from './utils';
|
|
15
11
|
|
|
16
12
|
function selectPlotArea(root: DisplayObject): DisplayObject {
|
|
17
13
|
return select(root).select(`.${PLOT_CLASS_NAME}`).node();
|
package/src/interaction/utils.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { DisplayObject, Path } from '@antv/g';
|
|
1
|
+
import { DisplayObject, Path, AABB } from '@antv/g';
|
|
2
2
|
import { path as d3Path } from 'd3-path';
|
|
3
3
|
import { sort } from 'd3-array';
|
|
4
4
|
import { Vector2 } from '@antv/coord';
|
|
5
|
+
import { filter } from '@antv/util';
|
|
6
|
+
import type { PathArray } from '@antv/util';
|
|
5
7
|
import { G2Element, select } from '../utils/selection';
|
|
6
8
|
import { mapObject } from '../utils/array';
|
|
7
9
|
import {
|
|
@@ -42,10 +44,15 @@ export function selectPlotArea(root: DisplayObject): DisplayObject {
|
|
|
42
44
|
return select(root).select(`.${PLOT_CLASS_NAME}`).node();
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
export function bboxOf(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
export function bboxOf(element: DisplayObject) {
|
|
48
|
+
// The geometry bounds of a group is empty, so return the render bounds.
|
|
49
|
+
if (element.tagName === 'g') return element.getRenderBounds();
|
|
50
|
+
|
|
51
|
+
// Compute the geometry bounds related to the parent.
|
|
52
|
+
const bounds = element.getGeometryBounds();
|
|
53
|
+
const aabb = new AABB();
|
|
54
|
+
aabb.setFromTransformedAABB(bounds, element.getWorldTransform());
|
|
55
|
+
return aabb;
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
export function mousePosition(target, event) {
|
|
@@ -419,7 +426,7 @@ export function renderBackground({
|
|
|
419
426
|
fillOpacity = 0.3,
|
|
420
427
|
zIndex = -2,
|
|
421
428
|
padding = 0.001,
|
|
422
|
-
|
|
429
|
+
lineWidth = 0,
|
|
423
430
|
...style
|
|
424
431
|
} = mapObject(rest, (d) => valueof(d, element));
|
|
425
432
|
const finalStyle = {
|
|
@@ -428,7 +435,7 @@ export function renderBackground({
|
|
|
428
435
|
fillOpacity,
|
|
429
436
|
zIndex,
|
|
430
437
|
padding,
|
|
431
|
-
|
|
438
|
+
lineWidth,
|
|
432
439
|
};
|
|
433
440
|
const shapeOf = isOrdinalShape() ? bandShapeOf : cloneShapeOf;
|
|
434
441
|
const shape = shapeOf(element, finalStyle);
|
|
@@ -468,3 +475,60 @@ export function selectElementByData(elements, data, datum) {
|
|
|
468
475
|
Object.entries(data).every(([key, value]) => datum(d)[key] === value),
|
|
469
476
|
);
|
|
470
477
|
}
|
|
478
|
+
|
|
479
|
+
export function getPointsR(point: number[], nextPoint: number[]) {
|
|
480
|
+
return Math.sqrt(
|
|
481
|
+
Math.pow(point[0] - nextPoint[0], 2) + Math.pow(point[1] - nextPoint[1], 2),
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Points create path.
|
|
486
|
+
export function getPointsPath(points: number[][], isClose = false) {
|
|
487
|
+
const path = filter(points, (d) => !!d).map((d, i) => {
|
|
488
|
+
return [i === 0 ? 'M' : 'L', ...d];
|
|
489
|
+
}) as PathArray;
|
|
490
|
+
|
|
491
|
+
if (isClose) {
|
|
492
|
+
path.push(['Z']);
|
|
493
|
+
}
|
|
494
|
+
return path;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Get element.
|
|
498
|
+
export function getElements(plot) {
|
|
499
|
+
return plot.querySelectorAll('.element');
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Get Theta coordinate round path.
|
|
503
|
+
export function getThetaPath(
|
|
504
|
+
center: number[],
|
|
505
|
+
points: number[][],
|
|
506
|
+
isBig = 0,
|
|
507
|
+
): PathArray {
|
|
508
|
+
const path = [['M', ...points[1]]];
|
|
509
|
+
const innerRadius = getPointsR(center, points[1]);
|
|
510
|
+
const outerRadius = getPointsR(center, points[0]);
|
|
511
|
+
|
|
512
|
+
if (innerRadius === 0) {
|
|
513
|
+
path.push(
|
|
514
|
+
['L', ...points[3]],
|
|
515
|
+
['A', outerRadius, outerRadius, 0, isBig, 1, ...points[0]],
|
|
516
|
+
['Z'],
|
|
517
|
+
);
|
|
518
|
+
} else {
|
|
519
|
+
path.push(
|
|
520
|
+
['A', innerRadius, innerRadius, 0, isBig, 0, ...points[2]],
|
|
521
|
+
['L', ...points[3]],
|
|
522
|
+
['A', outerRadius, outerRadius, 0, isBig, 1, ...points[0]],
|
|
523
|
+
['Z'],
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
return path as PathArray;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export function maybeRoot(node, rootOf) {
|
|
530
|
+
if (rootOf(node)) return node;
|
|
531
|
+
let root = node.parent;
|
|
532
|
+
while (root && !rootOf(root)) root = root.parent;
|
|
533
|
+
return root;
|
|
534
|
+
}
|
package/src/lib/core.ts
CHANGED
|
@@ -101,6 +101,7 @@ import {
|
|
|
101
101
|
Poptip,
|
|
102
102
|
ScrollbarFilter,
|
|
103
103
|
TreemapDrillDown,
|
|
104
|
+
ElementPointMove,
|
|
104
105
|
} from '../interaction';
|
|
105
106
|
import {
|
|
106
107
|
SpaceLayer,
|
|
@@ -301,6 +302,7 @@ export function corelib() {
|
|
|
301
302
|
'interaction.scrollbarFilter': ScrollbarFilter,
|
|
302
303
|
'interaction.poptip': Poptip,
|
|
303
304
|
'interaction.treemapDrillDown': TreemapDrillDown,
|
|
305
|
+
'interaction.elementPointMove': ElementPointMove,
|
|
304
306
|
'composition.spaceLayer': SpaceLayer,
|
|
305
307
|
'composition.spaceFlex': SpaceFlex,
|
|
306
308
|
'composition.facetRect': FacetRect,
|
package/src/mark/chord.ts
CHANGED
package/src/mark/point.ts
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
PointShape,
|
|
21
21
|
PointTick,
|
|
22
22
|
PointTriangle,
|
|
23
|
+
PointCircle,
|
|
24
|
+
PointHollowCircle,
|
|
23
25
|
} from '../shape';
|
|
24
26
|
import { MaybeZeroX, MaybeZeroY, MaybeSize } from '../transform';
|
|
25
27
|
import {
|
|
@@ -38,6 +40,7 @@ const shape = {
|
|
|
38
40
|
hollowTriangleDown: PointHollowTriangleDown,
|
|
39
41
|
hollowTriangle: PointHollowTriangle,
|
|
40
42
|
hollowBowtie: PointHollowBowtie,
|
|
43
|
+
hollowCircle: PointHollowCircle,
|
|
41
44
|
point: PointShape,
|
|
42
45
|
plus: PointPlus,
|
|
43
46
|
diamond: PointDiamond,
|
|
@@ -50,6 +53,7 @@ const shape = {
|
|
|
50
53
|
line: PointLine,
|
|
51
54
|
tick: PointTick,
|
|
52
55
|
triangleDown: PointTriangleDown,
|
|
56
|
+
circle: PointCircle,
|
|
53
57
|
};
|
|
54
58
|
|
|
55
59
|
export type PointOptions = Omit<PointMark, 'type'>;
|
package/src/mark/sankey.ts
CHANGED
package/src/runtime/plot.ts
CHANGED
|
@@ -1694,8 +1694,13 @@ async function applyTransform<T extends G2ViewTree>(
|
|
|
1694
1694
|
|
|
1695
1695
|
function updateBBox(selection: Selection) {
|
|
1696
1696
|
selection
|
|
1697
|
-
.style(
|
|
1698
|
-
|
|
1697
|
+
.style(
|
|
1698
|
+
'transform',
|
|
1699
|
+
(d) =>
|
|
1700
|
+
`translate(${d.paddingLeft + d.marginLeft}, ${
|
|
1701
|
+
d.paddingTop + d.marginTop
|
|
1702
|
+
})`,
|
|
1703
|
+
)
|
|
1699
1704
|
.style('width', (d) => d.innerWidth)
|
|
1700
1705
|
.style('height', (d) => d.innerHeight);
|
|
1701
1706
|
}
|
|
@@ -1703,7 +1708,7 @@ function updateBBox(selection: Selection) {
|
|
|
1703
1708
|
function animateBBox(selection: Selection, extent: [number, number]) {
|
|
1704
1709
|
const [delay, duration] = extent;
|
|
1705
1710
|
selection.transition(function (data, i, element) {
|
|
1706
|
-
const {
|
|
1711
|
+
const { transform, width, height } = element.style;
|
|
1707
1712
|
const {
|
|
1708
1713
|
paddingLeft,
|
|
1709
1714
|
paddingTop,
|
|
@@ -1714,14 +1719,14 @@ function animateBBox(selection: Selection, extent: [number, number]) {
|
|
|
1714
1719
|
} = data;
|
|
1715
1720
|
const keyframes = [
|
|
1716
1721
|
{
|
|
1717
|
-
|
|
1718
|
-
y,
|
|
1722
|
+
transform,
|
|
1719
1723
|
width,
|
|
1720
1724
|
height,
|
|
1721
1725
|
},
|
|
1722
1726
|
{
|
|
1723
|
-
|
|
1724
|
-
|
|
1727
|
+
transform: `translate(${paddingLeft + marginLeft}, ${
|
|
1728
|
+
paddingTop + marginTop
|
|
1729
|
+
})`,
|
|
1725
1730
|
width: innerWidth,
|
|
1726
1731
|
height: innerHeight,
|
|
1727
1732
|
},
|
|
@@ -89,7 +89,7 @@ export const Connector: SC<ConnectorOptions> = (options, context) => {
|
|
|
89
89
|
|
|
90
90
|
return select(new Path())
|
|
91
91
|
.call(applyStyle, rest)
|
|
92
|
-
.style('
|
|
92
|
+
.style('d', inferConnectorPath(P))
|
|
93
93
|
.style('stroke', color || defaultColor)
|
|
94
94
|
.style('transform', transform)
|
|
95
95
|
.style(
|
package/src/shape/gauge/round.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const Round: SC<RoundOptions> = (options, context) => {
|
|
|
36
36
|
*/
|
|
37
37
|
const roundPath = document.createElement('path', {
|
|
38
38
|
style: {
|
|
39
|
-
|
|
39
|
+
d: [
|
|
40
40
|
['M', ...points[0]],
|
|
41
41
|
['A', minR, minR, 0, 1, 0, ...points[1]],
|
|
42
42
|
['A', maxR + minR * 2, maxR + minR * 2, 0, 0, 0, ...points[2]],
|
package/src/shape/image/image.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const Image: SC<ImageOptions> = (options, context) => {
|
|
|
25
25
|
.call(applyStyle, rest)
|
|
26
26
|
.style('x', x)
|
|
27
27
|
.style('y', y)
|
|
28
|
-
.style('
|
|
28
|
+
.style('src', src)
|
|
29
29
|
.style('stroke', color)
|
|
30
30
|
.style('transform', transform)
|
|
31
31
|
.call(applyStyle, options)
|
package/src/shape/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { HollowPoint as PointHollow } from './point/hollow';
|
|
|
17
17
|
export { HollowSquare as PointHollowSquare } from './point/hollowSquare';
|
|
18
18
|
export { HollowTriangle as PointHollowTriangle } from './point/hollowTriangle';
|
|
19
19
|
export { HollowTriangleDown as PointHollowTriangleDown } from './point/hollowTriangleDown';
|
|
20
|
+
export { HollowCircle as PointHollowCircle } from './point/hollowCircle';
|
|
20
21
|
export { Bowtie as PointBowtie } from './point/bowtie';
|
|
21
22
|
export { Cross as PointCross } from './point/cross';
|
|
22
23
|
export { Diamond as PointDiamond } from './point/diamond';
|
|
@@ -29,6 +30,7 @@ export { Square as PointSquare } from './point/square';
|
|
|
29
30
|
export { Tick as PointTick } from './point/tick';
|
|
30
31
|
export { Triangle as PointTriangle } from './point/triangle';
|
|
31
32
|
export { TriangleDown as PointTriangleDown } from './point/triangleDown';
|
|
33
|
+
export { Circle as PointCircle } from './point/circle';
|
|
32
34
|
export { Vector as VectorShape } from './vector/vector';
|
|
33
35
|
export { Text as TextShape } from './text/text';
|
|
34
36
|
export { Badge as TextBadge } from './text/badge';
|
|
@@ -101,7 +101,7 @@ export function rect(
|
|
|
101
101
|
.padAngle((inset * Math.PI) / 180);
|
|
102
102
|
|
|
103
103
|
return select(document.createElement('path', {}))
|
|
104
|
-
.style('
|
|
104
|
+
.style('d', path(arcObject))
|
|
105
105
|
.style('transform', `translate(${center[0]}, ${center[1]})`)
|
|
106
106
|
.style('radius', radius)
|
|
107
107
|
.style('inset', inset)
|
|
@@ -51,7 +51,7 @@ export const Funnel: SC<FunnelOptions> = (options, context) => {
|
|
|
51
51
|
const b = line().curve(curveLinearClosed)([p0, p1, p2, p3]);
|
|
52
52
|
return select(document.createElement('path', {}))
|
|
53
53
|
.call(applyStyle, rest)
|
|
54
|
-
.style('
|
|
54
|
+
.style('d', b)
|
|
55
55
|
.style('fill', color)
|
|
56
56
|
.style('fillOpacity', opacity)
|
|
57
57
|
.call(applyStyle, style)
|
|
@@ -42,27 +42,27 @@ export function inferNonCircularStyle(
|
|
|
42
42
|
};
|
|
43
43
|
// 4 direction.
|
|
44
44
|
if (position === 'left')
|
|
45
|
-
return xy({ x: 0, y: h / 2,
|
|
45
|
+
return xy({ x: 0, y: h / 2, textAlign: 'start', textBaseline: 'middle' });
|
|
46
46
|
if (position === 'right')
|
|
47
|
-
return xy({ x: w, y: h / 2,
|
|
47
|
+
return xy({ x: w, y: h / 2, textAlign: 'end', textBaseline: 'middle' });
|
|
48
48
|
if (position === 'top')
|
|
49
|
-
return xy({ x: w / 2, y: 0,
|
|
49
|
+
return xy({ x: w / 2, y: 0, textAlign: 'center', textBaseline: 'top' });
|
|
50
50
|
if (position === 'bottom')
|
|
51
|
-
return xy({ x: w / 2, y: h,
|
|
51
|
+
return xy({ x: w / 2, y: h, textAlign: 'center', textBaseline: 'bottom' });
|
|
52
52
|
// 4 corner position.
|
|
53
53
|
if (position === 'top-left')
|
|
54
|
-
return xy({ x: 0, y: 0,
|
|
54
|
+
return xy({ x: 0, y: 0, textAlign: 'start', textBaseline: 'top' });
|
|
55
55
|
if (position === 'top-right')
|
|
56
|
-
return xy({ x: w, y: 0,
|
|
56
|
+
return xy({ x: w, y: 0, textAlign: 'end', textBaseline: 'top' });
|
|
57
57
|
if (position === 'bottom-left')
|
|
58
|
-
return xy({ x: 0, y: h,
|
|
58
|
+
return xy({ x: 0, y: h, textAlign: 'start', textBaseline: 'bottom' });
|
|
59
59
|
if (position === 'bottom-right')
|
|
60
|
-
return xy({ x: w, y: h,
|
|
60
|
+
return xy({ x: w, y: h, textAlign: 'end', textBaseline: 'bottom' });
|
|
61
61
|
// default return 'inside'
|
|
62
62
|
return xy({
|
|
63
63
|
x: w / 2,
|
|
64
64
|
y: h / 2,
|
|
65
|
-
|
|
65
|
+
textAlign: 'center',
|
|
66
66
|
textBaseline: 'middle',
|
|
67
67
|
});
|
|
68
68
|
}
|
package/src/shape/lineXY/line.ts
CHANGED
|
@@ -38,8 +38,7 @@ function getArrowMarker(
|
|
|
38
38
|
) {
|
|
39
39
|
const arrowMarker = document.createElement('path', {
|
|
40
40
|
style: {
|
|
41
|
-
|
|
42
|
-
anchor: '0.5 0.5',
|
|
41
|
+
d: `M ${arrowSize},${arrowSize} L -${arrowSize},0 L ${arrowSize},-${arrowSize} L 0,0 Z`,
|
|
43
42
|
transformOrigin: 'center',
|
|
44
43
|
...arrowStyle,
|
|
45
44
|
},
|
|
@@ -46,7 +46,7 @@ export const Liquid: SC<LiquidOptions> = (options, context) => {
|
|
|
46
46
|
if (Object.keys(backgroundStyle).length) {
|
|
47
47
|
const backgroundShape = document.createElement('path', {
|
|
48
48
|
style: {
|
|
49
|
-
|
|
49
|
+
d: shapePath,
|
|
50
50
|
fill: '#fff',
|
|
51
51
|
...backgroundStyle,
|
|
52
52
|
},
|
|
@@ -60,7 +60,7 @@ export const Liquid: SC<LiquidOptions> = (options, context) => {
|
|
|
60
60
|
// 3. Clip create.
|
|
61
61
|
const clipShape = document.createElement('path', {
|
|
62
62
|
style: {
|
|
63
|
-
|
|
63
|
+
d: shapePath,
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -86,7 +86,7 @@ export const Liquid: SC<LiquidOptions> = (options, context) => {
|
|
|
86
86
|
// 5. Draw distance.
|
|
87
87
|
const distanceShape = document.createElement('path', {
|
|
88
88
|
style: {
|
|
89
|
-
|
|
89
|
+
d: shapePath,
|
|
90
90
|
fill: 'transparent',
|
|
91
91
|
lineWidth: border + 2 * distance,
|
|
92
92
|
stroke: '#fff',
|
|
@@ -96,7 +96,7 @@ export const Liquid: SC<LiquidOptions> = (options, context) => {
|
|
|
96
96
|
// 6. Draw border.
|
|
97
97
|
const borderShape = document.createElement('path', {
|
|
98
98
|
style: {
|
|
99
|
-
|
|
99
|
+
d: shapePath,
|
|
100
100
|
stroke: color,
|
|
101
101
|
strokeOpacity: fillOpacity,
|
|
102
102
|
lineWidth: border,
|
package/src/shape/liquid/wave.ts
CHANGED
|
@@ -214,7 +214,7 @@ export function addWave(
|
|
|
214
214
|
// Create wave path.
|
|
215
215
|
const wave = document.createElement('path', {
|
|
216
216
|
style: {
|
|
217
|
-
path,
|
|
217
|
+
d: path,
|
|
218
218
|
fill,
|
|
219
219
|
opacity: lerp(0.2, 0.9, factor) * Number(opacity || fillOpacity),
|
|
220
220
|
},
|
|
@@ -230,7 +230,7 @@ export function addWave(
|
|
|
230
230
|
transform: 'translate(0, 0)',
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
|
-
transform: `translate(${waveLength * 2}
|
|
233
|
+
transform: `translate(${waveLength * 2}, 0)`,
|
|
234
234
|
},
|
|
235
235
|
];
|
|
236
236
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ShapeComponent as SC } from '../../runtime';
|
|
2
|
+
import { select } from '../../utils/selection';
|
|
3
|
+
import { applyStyle, getOrigin, toOpacityKey } from '../utils';
|
|
4
|
+
import { getRadius } from './color';
|
|
5
|
+
|
|
6
|
+
export type PointOptions = Record<string, any>;
|
|
7
|
+
|
|
8
|
+
type ColorOptions = {
|
|
9
|
+
colorAttribute: 'fill' | 'stroke';
|
|
10
|
+
mode?: 'fixed' | 'auto' | 'normal';
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Render point in different coordinate.
|
|
16
|
+
*/
|
|
17
|
+
export const BaseCircle: SC<ColorOptions> = (options, context) => {
|
|
18
|
+
// Render border only when colorAttribute is stroke.
|
|
19
|
+
const { colorAttribute, mode = 'auto', ...style } = options;
|
|
20
|
+
|
|
21
|
+
const { coordinate, document } = context;
|
|
22
|
+
return (points, value, defaults) => {
|
|
23
|
+
const { lineWidth, color: defaultColor } = defaults;
|
|
24
|
+
const finalLineWidth = style.stroke ? lineWidth || 1 : lineWidth;
|
|
25
|
+
const { color = defaultColor, transform, opacity } = value;
|
|
26
|
+
const [cx, cy] = getOrigin(points);
|
|
27
|
+
const r = getRadius(mode, points, value, coordinate);
|
|
28
|
+
const finalRadius = r || style.r || defaults.r;
|
|
29
|
+
return select(document.createElement('circle', {}))
|
|
30
|
+
.call(applyStyle, defaults)
|
|
31
|
+
.style('fill', 'transparent')
|
|
32
|
+
.style('cx', cx)
|
|
33
|
+
.style('cy', cy)
|
|
34
|
+
.style('r', finalRadius)
|
|
35
|
+
.style('lineWidth', finalLineWidth)
|
|
36
|
+
.style('transform', transform)
|
|
37
|
+
.style('transformOrigin', `${cx} ${cy}`)
|
|
38
|
+
.style('stroke', color)
|
|
39
|
+
.style(toOpacityKey(options), opacity)
|
|
40
|
+
.style(colorAttribute, color)
|
|
41
|
+
.call(applyStyle, style)
|
|
42
|
+
.node();
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* ●
|
|
48
|
+
*/
|
|
49
|
+
export const Circle: SC<PointOptions> = (options, context) => {
|
|
50
|
+
return BaseCircle({ colorAttribute: 'fill', ...options }, context);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Circle.props = {
|
|
54
|
+
defaultMarker: 'circle',
|
|
55
|
+
defaultEnterAnimation: 'fadeIn',
|
|
56
|
+
defaultExitAnimation: 'fadeOut',
|
|
57
|
+
};
|
package/src/shape/point/color.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type ColorOptions = {
|
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
function getRadius(
|
|
15
|
+
export function getRadius(
|
|
16
16
|
mode: ColorOptions['mode'],
|
|
17
17
|
points: Vector2[],
|
|
18
18
|
value: Record<string, any>,
|
|
@@ -51,6 +51,7 @@ export const Color: SC<ColorOptions> = (options, context) => {
|
|
|
51
51
|
.style('d', path(cx, cy, finalRadius))
|
|
52
52
|
.style('lineWidth', finalLineWidth)
|
|
53
53
|
.style('transform', transform)
|
|
54
|
+
.style('transformOrigin', `${cx - finalRadius} ${cy - finalRadius}`)
|
|
54
55
|
.style('stroke', color)
|
|
55
56
|
.style(toOpacityKey(options), opacity)
|
|
56
57
|
.style(colorAttribute, color)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ShapeComponent as SC } from '../../runtime';
|
|
2
|
+
import { BaseCircle, Circle } from './circle';
|
|
3
|
+
|
|
4
|
+
export type HollowCircleOptions = Record<string, any>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ○
|
|
8
|
+
*/
|
|
9
|
+
export const HollowCircle: SC<HollowCircleOptions> = (options, context) => {
|
|
10
|
+
return BaseCircle({ colorAttribute: 'stroke', ...options }, context);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
HollowCircle.props = {
|
|
14
|
+
defaultMarker: 'hollowPoint',
|
|
15
|
+
...Circle.props,
|
|
16
|
+
};
|
|
@@ -151,6 +151,8 @@ export const Advance = createElement((g) => {
|
|
|
151
151
|
...rest
|
|
152
152
|
} = g.attributes as TextShapeStyleProps;
|
|
153
153
|
|
|
154
|
+
g.style.transform = `translate(${x}, ${y})`;
|
|
155
|
+
|
|
154
156
|
// Position is invalid, do not render the UI,
|
|
155
157
|
// or clear previous elements.
|
|
156
158
|
if ([x, y, x0, y0].some((v) => !isNumber(v))) {
|
|
@@ -220,7 +222,7 @@ export const Advance = createElement((g) => {
|
|
|
220
222
|
select(g)
|
|
221
223
|
.maybeAppend('connector', 'path')
|
|
222
224
|
.style('zIndex', 0)
|
|
223
|
-
.style('
|
|
225
|
+
.style('d', connectorPath)
|
|
224
226
|
.style('markerStart', markerStart)
|
|
225
227
|
.style('markerEnd', markerEnd)
|
|
226
228
|
.call(applyStyle, connector ? connectorStyle : {});
|
package/src/shape/text/badge.ts
CHANGED
|
@@ -35,7 +35,7 @@ function inferTextPosition(shape: DisplayObject) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const BadgeShape = createElement((g) => {
|
|
38
|
-
const { class: className, x: x0, y: y0, ...rest } = g.attributes;
|
|
38
|
+
const { class: className, x: x0, y: y0, transform, ...rest } = g.attributes;
|
|
39
39
|
|
|
40
40
|
const markerStyle = subObject(rest, 'marker');
|
|
41
41
|
const { size = 24 } = markerStyle;
|
|
@@ -69,8 +69,7 @@ export const Badge: SC<BadgeOptions> = (options, context) => {
|
|
|
69
69
|
const [[x0, y0]] = points;
|
|
70
70
|
return select(new BadgeShape())
|
|
71
71
|
.call(applyStyle, rest)
|
|
72
|
-
.style('
|
|
73
|
-
.style('y', y0)
|
|
72
|
+
.style('transform', `translate(${x0},${y0})`)
|
|
74
73
|
.call(applyStyle, textStyle)
|
|
75
74
|
.call(applyStyle, style)
|
|
76
75
|
.node();
|
package/src/theme/create.ts
CHANGED
|
@@ -139,7 +139,7 @@ export function create({
|
|
|
139
139
|
text: {
|
|
140
140
|
fill: '#1D2129',
|
|
141
141
|
fontSize: 12,
|
|
142
|
-
|
|
142
|
+
lineWidth: 0,
|
|
143
143
|
connectorStroke: colorStroke,
|
|
144
144
|
connectorStrokeOpacity: 0.45,
|
|
145
145
|
connectorLineWidth: 1,
|
|
@@ -154,7 +154,7 @@ export function create({
|
|
|
154
154
|
badge: {
|
|
155
155
|
fill: '#1D2129',
|
|
156
156
|
fillOpacity: 0.65,
|
|
157
|
-
|
|
157
|
+
lineWidth: 0,
|
|
158
158
|
fontSize: 10,
|
|
159
159
|
textAlign: 'center',
|
|
160
160
|
textBaseline: 'middle',
|
|
@@ -249,6 +249,7 @@ export function create({
|
|
|
249
249
|
titleSpacing: 12,
|
|
250
250
|
labelSpacing: 4,
|
|
251
251
|
titleTextBaseline: 'bottom',
|
|
252
|
+
titleTransform: 'translate(0, 8)',
|
|
252
253
|
},
|
|
253
254
|
axisLeft: {
|
|
254
255
|
gridDirection: 'positive',
|
|
@@ -259,6 +260,7 @@ export function create({
|
|
|
259
260
|
titleSpacing: 12,
|
|
260
261
|
titleTextBaseline: 'middle',
|
|
261
262
|
titleDirection: 'vertical',
|
|
263
|
+
titleTransform: 'rotate(-90) translate(0, -8)',
|
|
262
264
|
titleTransformOrigin: 'center',
|
|
263
265
|
},
|
|
264
266
|
axisRight: {
|
package/src/utils/helper.ts
CHANGED
|
@@ -46,13 +46,7 @@ export function copyAttributes(target: DisplayObject, source: DisplayObject) {
|
|
|
46
46
|
const exclude = new Set(['id', 'className']);
|
|
47
47
|
for (const [key, value] of Object.entries(attributes)) {
|
|
48
48
|
if (!exclude.has(key)) {
|
|
49
|
-
|
|
50
|
-
if (key === 'transform') {
|
|
51
|
-
target.attr(key, '');
|
|
52
|
-
target.attr(key, value);
|
|
53
|
-
} else {
|
|
54
|
-
target.attr(key, value);
|
|
55
|
-
}
|
|
49
|
+
target.attr(key, value);
|
|
56
50
|
}
|
|
57
51
|
}
|
|
58
52
|
}
|
package/src/utils/marker.ts
CHANGED
|
@@ -255,23 +255,14 @@ export const Symbols = new Map<string, SymbolFactor>([
|
|
|
255
255
|
|
|
256
256
|
export function useMarker(
|
|
257
257
|
type: string,
|
|
258
|
-
{
|
|
259
|
-
d,
|
|
260
|
-
fill,
|
|
261
|
-
strokeWidth,
|
|
262
|
-
path,
|
|
263
|
-
stroke,
|
|
264
|
-
lineWidth,
|
|
265
|
-
color,
|
|
266
|
-
...style
|
|
267
|
-
}: Record<string, any>,
|
|
258
|
+
{ d, fill, lineWidth, path, stroke, color, ...style }: Record<string, any>,
|
|
268
259
|
) {
|
|
269
260
|
const symbol = Symbols.get(type) || Symbols.get('point');
|
|
270
261
|
return (...args: Parameters<SymbolFactor>) => {
|
|
271
262
|
const path = new Path({
|
|
272
263
|
style: {
|
|
273
264
|
...style,
|
|
274
|
-
|
|
265
|
+
d: symbol(...args),
|
|
275
266
|
stroke: symbol.style.includes('stroke') ? color || stroke : '',
|
|
276
267
|
fill: symbol.style.includes('fill') ? color || fill : '',
|
|
277
268
|
lineWidth: symbol.style.includes('lineWidth')
|