@antv/gpt-vis 1.3.2 → 1.4.1
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/README.md +261 -137
- package/README.zh-CN.md +263 -116
- package/dist/cjs/annotation/components/bottom-n.d.ts +2 -0
- package/dist/cjs/annotation/components/bottom-n.js +57 -0
- package/dist/cjs/annotation/components/centroid.d.ts +2 -0
- package/dist/cjs/annotation/components/centroid.js +75 -0
- package/dist/cjs/annotation/components/connector.d.ts +25 -0
- package/dist/cjs/annotation/components/connector.js +298 -0
- package/dist/cjs/annotation/components/contribution.d.ts +3 -0
- package/dist/cjs/annotation/components/contribution.js +136 -0
- package/dist/cjs/annotation/components/crossing.d.ts +3 -0
- package/dist/cjs/annotation/components/crossing.js +504 -0
- package/dist/cjs/annotation/components/event.d.ts +2 -0
- package/dist/cjs/annotation/components/event.js +62 -0
- package/dist/cjs/annotation/components/first.d.ts +2 -0
- package/dist/cjs/annotation/components/first.js +42 -0
- package/dist/cjs/annotation/components/group.d.ts +3 -0
- package/dist/cjs/annotation/components/group.js +73 -0
- package/dist/cjs/annotation/components/highlight.d.ts +14 -0
- package/dist/cjs/annotation/components/highlight.js +552 -0
- package/dist/cjs/annotation/components/index.d.ts +34 -0
- package/dist/cjs/annotation/components/index.js +128 -0
- package/dist/cjs/annotation/components/last.d.ts +2 -0
- package/dist/cjs/annotation/components/last.js +42 -0
- package/dist/cjs/annotation/components/max-x.d.ts +2 -0
- package/dist/cjs/annotation/components/max-x.js +41 -0
- package/dist/cjs/annotation/components/max-y.d.ts +2 -0
- package/dist/cjs/annotation/components/max-y.js +41 -0
- package/dist/cjs/annotation/components/mean.d.ts +2 -0
- package/dist/cjs/annotation/components/mean.js +50 -0
- package/dist/cjs/annotation/components/median.d.ts +2 -0
- package/dist/cjs/annotation/components/median.js +49 -0
- package/dist/cjs/annotation/components/min-x.d.ts +2 -0
- package/dist/cjs/annotation/components/min-x.js +41 -0
- package/dist/cjs/annotation/components/min-y.d.ts +2 -0
- package/dist/cjs/annotation/components/min-y.js +41 -0
- package/dist/cjs/annotation/components/outlier.d.ts +3 -0
- package/dist/cjs/annotation/components/outlier.js +83 -0
- package/dist/cjs/annotation/components/path.d.ts +20 -0
- package/dist/cjs/annotation/components/path.js +147 -0
- package/dist/cjs/annotation/components/peak.d.ts +2 -0
- package/dist/cjs/annotation/components/peak.js +42 -0
- package/dist/cjs/annotation/components/point.d.ts +26 -0
- package/dist/cjs/annotation/components/point.js +241 -0
- package/dist/cjs/annotation/components/quadrant.d.ts +3 -0
- package/dist/cjs/annotation/components/quadrant.js +97 -0
- package/dist/cjs/annotation/components/quantile.d.ts +2 -0
- package/dist/cjs/annotation/components/quantile.js +49 -0
- package/dist/cjs/annotation/components/range-inside.d.ts +2 -0
- package/dist/cjs/annotation/components/range-inside.js +65 -0
- package/dist/cjs/annotation/components/range-outside.d.ts +2 -0
- package/dist/cjs/annotation/components/range-outside.js +65 -0
- package/dist/cjs/annotation/components/range-x.d.ts +2 -0
- package/dist/cjs/annotation/components/range-x.js +39 -0
- package/dist/cjs/annotation/components/range-y.d.ts +2 -0
- package/dist/cjs/annotation/components/range-y.js +39 -0
- package/dist/cjs/annotation/components/range.d.ts +15 -0
- package/dist/cjs/annotation/components/range.js +87 -0
- package/dist/cjs/annotation/components/target.d.ts +2 -0
- package/dist/cjs/annotation/components/target.js +51 -0
- package/dist/cjs/annotation/components/text.d.ts +15 -0
- package/dist/cjs/annotation/components/text.js +74 -0
- package/dist/cjs/annotation/components/threshold-highlight.d.ts +3 -0
- package/dist/cjs/annotation/components/threshold-highlight.js +223 -0
- package/dist/cjs/annotation/components/threshold-x.d.ts +2 -0
- package/dist/cjs/annotation/components/threshold-x.js +39 -0
- package/dist/cjs/annotation/components/threshold-y.d.ts +2 -0
- package/dist/cjs/annotation/components/threshold-y.js +40 -0
- package/dist/cjs/annotation/components/top-n.d.ts +2 -0
- package/dist/cjs/annotation/components/top-n.js +57 -0
- package/dist/cjs/annotation/components/valley.d.ts +2 -0
- package/dist/cjs/annotation/components/valley.js +42 -0
- package/dist/cjs/annotation/index.d.ts +1 -0
- package/dist/cjs/annotation/index.js +29 -0
- package/dist/cjs/annotation/label.d.ts +38 -0
- package/dist/cjs/annotation/label.js +347 -0
- package/dist/cjs/annotation/layout.d.ts +12 -0
- package/dist/cjs/annotation/layout.js +142 -0
- package/dist/cjs/annotation/merge.d.ts +19 -0
- package/dist/cjs/annotation/merge.js +60 -0
- package/dist/cjs/annotation/registry.d.ts +190 -0
- package/dist/cjs/annotation/registry.js +134 -0
- package/dist/cjs/annotation/runtime/g2.d.ts +90 -0
- package/dist/cjs/annotation/runtime/g2.js +521 -0
- package/dist/cjs/annotation/runtime/g6.d.ts +40 -0
- package/dist/cjs/annotation/runtime/g6.js +310 -0
- package/dist/cjs/annotation/runtime/index.d.ts +11 -0
- package/dist/cjs/annotation/runtime/index.js +41 -0
- package/dist/cjs/annotation/runtime/summary.d.ts +17 -0
- package/dist/cjs/annotation/runtime/summary.js +39 -0
- package/dist/cjs/annotation/runtime/table.d.ts +16 -0
- package/dist/cjs/annotation/runtime/table.js +39 -0
- package/dist/cjs/annotation/utils.d.ts +40 -0
- package/dist/cjs/annotation/utils.js +275 -0
- package/dist/cjs/theme/annotation.d.ts +236 -0
- package/dist/cjs/theme/annotation.js +167 -0
- package/dist/cjs/theme/g2.js +13 -15
- package/dist/cjs/theme/g6.js +2 -2
- package/dist/cjs/theme/summary.js +2 -2
- package/dist/cjs/types/annotation.d.ts +310 -0
- package/dist/cjs/types/annotation.js +17 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/util/axis.d.ts +28 -0
- package/dist/cjs/util/axis.js +184 -0
- package/dist/cjs/util/components.d.ts +0 -10
- package/dist/cjs/util/components.js +9 -64
- package/dist/cjs/util/index.d.ts +7 -4
- package/dist/cjs/util/index.js +53 -9
- package/dist/cjs/vis/area/index.d.ts +2 -0
- package/dist/cjs/vis/area/index.js +30 -13
- package/dist/cjs/vis/bar/index.d.ts +2 -0
- package/dist/cjs/vis/bar/index.js +37 -7
- package/dist/cjs/vis/boxplot/index.js +14 -3
- package/dist/cjs/vis/column/index.d.ts +2 -0
- package/dist/cjs/vis/column/index.js +28 -9
- package/dist/cjs/vis/dual-axes/index.js +9 -9
- package/dist/cjs/vis/fishbone-diagram/index.js +2 -2
- package/dist/cjs/vis/flow-diagram/index.js +2 -2
- package/dist/cjs/vis/funnel/index.js +10 -13
- package/dist/cjs/vis/histogram/index.js +2 -2
- package/dist/cjs/vis/indented-tree/index.js +2 -2
- package/dist/cjs/vis/line/index.d.ts +2 -0
- package/dist/cjs/vis/line/index.js +26 -10
- package/dist/cjs/vis/liquid/index.js +2 -2
- package/dist/cjs/vis/mindmap/index.js +2 -2
- package/dist/cjs/vis/network-graph/index.d.ts +2 -0
- package/dist/cjs/vis/network-graph/index.js +24 -3
- package/dist/cjs/vis/organization-chart/index.js +2 -2
- package/dist/cjs/vis/pie/index.d.ts +2 -0
- package/dist/cjs/vis/pie/index.js +21 -10
- package/dist/cjs/vis/radar/index.js +4 -6
- package/dist/cjs/vis/sankey/index.js +14 -1
- package/dist/cjs/vis/scatter/index.d.ts +10 -3
- package/dist/cjs/vis/scatter/index.js +18 -7
- package/dist/cjs/vis/summary/index.d.ts +12 -3
- package/dist/cjs/vis/summary/index.js +29 -11
- package/dist/cjs/vis/table/index.d.ts +2 -0
- package/dist/cjs/vis/table/index.js +48 -30
- package/dist/cjs/vis/venn/index.js +2 -2
- package/dist/cjs/vis/violin/index.js +14 -3
- package/dist/cjs/vis/waterfall/index.js +17 -9
- package/dist/cjs/vis/word-cloud/index.js +4 -6
- package/dist/esm/annotation/components/bottom-n.d.ts +2 -0
- package/dist/esm/annotation/components/bottom-n.js +42 -0
- package/dist/esm/annotation/components/centroid.d.ts +2 -0
- package/dist/esm/annotation/components/centroid.js +73 -0
- package/dist/esm/annotation/components/connector.d.ts +25 -0
- package/dist/esm/annotation/components/connector.js +332 -0
- package/dist/esm/annotation/components/contribution.d.ts +3 -0
- package/dist/esm/annotation/components/contribution.js +174 -0
- package/dist/esm/annotation/components/crossing.d.ts +3 -0
- package/dist/esm/annotation/components/crossing.js +665 -0
- package/dist/esm/annotation/components/event.d.ts +2 -0
- package/dist/esm/annotation/components/event.js +46 -0
- package/dist/esm/annotation/components/first.d.ts +2 -0
- package/dist/esm/annotation/components/first.js +18 -0
- package/dist/esm/annotation/components/group.d.ts +3 -0
- package/dist/esm/annotation/components/group.js +64 -0
- package/dist/esm/annotation/components/highlight.d.ts +14 -0
- package/dist/esm/annotation/components/highlight.js +838 -0
- package/dist/esm/annotation/components/index.d.ts +34 -0
- package/dist/esm/annotation/components/index.js +34 -0
- package/dist/esm/annotation/components/last.d.ts +2 -0
- package/dist/esm/annotation/components/last.js +18 -0
- package/dist/esm/annotation/components/max-x.d.ts +2 -0
- package/dist/esm/annotation/components/max-x.js +17 -0
- package/dist/esm/annotation/components/max-y.d.ts +2 -0
- package/dist/esm/annotation/components/max-y.js +17 -0
- package/dist/esm/annotation/components/mean.d.ts +2 -0
- package/dist/esm/annotation/components/mean.js +40 -0
- package/dist/esm/annotation/components/median.d.ts +2 -0
- package/dist/esm/annotation/components/median.js +32 -0
- package/dist/esm/annotation/components/min-x.d.ts +2 -0
- package/dist/esm/annotation/components/min-x.js +17 -0
- package/dist/esm/annotation/components/min-y.d.ts +2 -0
- package/dist/esm/annotation/components/min-y.js +17 -0
- package/dist/esm/annotation/components/outlier.d.ts +3 -0
- package/dist/esm/annotation/components/outlier.js +98 -0
- package/dist/esm/annotation/components/path.d.ts +20 -0
- package/dist/esm/annotation/components/path.js +165 -0
- package/dist/esm/annotation/components/peak.d.ts +2 -0
- package/dist/esm/annotation/components/peak.js +20 -0
- package/dist/esm/annotation/components/point.d.ts +26 -0
- package/dist/esm/annotation/components/point.js +277 -0
- package/dist/esm/annotation/components/quadrant.d.ts +3 -0
- package/dist/esm/annotation/components/quadrant.js +83 -0
- package/dist/esm/annotation/components/quantile.d.ts +2 -0
- package/dist/esm/annotation/components/quantile.js +32 -0
- package/dist/esm/annotation/components/range-inside.d.ts +2 -0
- package/dist/esm/annotation/components/range-inside.js +55 -0
- package/dist/esm/annotation/components/range-outside.d.ts +2 -0
- package/dist/esm/annotation/components/range-outside.js +55 -0
- package/dist/esm/annotation/components/range-x.d.ts +2 -0
- package/dist/esm/annotation/components/range-x.js +15 -0
- package/dist/esm/annotation/components/range-y.d.ts +2 -0
- package/dist/esm/annotation/components/range-y.js +15 -0
- package/dist/esm/annotation/components/range.d.ts +15 -0
- package/dist/esm/annotation/components/range.js +92 -0
- package/dist/esm/annotation/components/target.d.ts +2 -0
- package/dist/esm/annotation/components/target.js +44 -0
- package/dist/esm/annotation/components/text.d.ts +15 -0
- package/dist/esm/annotation/components/text.js +78 -0
- package/dist/esm/annotation/components/threshold-highlight.d.ts +3 -0
- package/dist/esm/annotation/components/threshold-highlight.js +297 -0
- package/dist/esm/annotation/components/threshold-x.d.ts +2 -0
- package/dist/esm/annotation/components/threshold-x.js +23 -0
- package/dist/esm/annotation/components/threshold-y.d.ts +2 -0
- package/dist/esm/annotation/components/threshold-y.js +24 -0
- package/dist/esm/annotation/components/top-n.d.ts +2 -0
- package/dist/esm/annotation/components/top-n.js +42 -0
- package/dist/esm/annotation/components/valley.d.ts +2 -0
- package/dist/esm/annotation/components/valley.js +20 -0
- package/dist/esm/annotation/index.d.ts +1 -0
- package/dist/esm/annotation/index.js +1 -0
- package/dist/esm/annotation/label.d.ts +38 -0
- package/dist/esm/annotation/label.js +449 -0
- package/dist/esm/annotation/layout.d.ts +12 -0
- package/dist/esm/annotation/layout.js +182 -0
- package/dist/esm/annotation/merge.d.ts +19 -0
- package/dist/esm/annotation/merge.js +67 -0
- package/dist/esm/annotation/registry.d.ts +190 -0
- package/dist/esm/annotation/registry.js +220 -0
- package/dist/esm/annotation/runtime/g2.d.ts +90 -0
- package/dist/esm/annotation/runtime/g2.js +754 -0
- package/dist/esm/annotation/runtime/g6.d.ts +40 -0
- package/dist/esm/annotation/runtime/g6.js +447 -0
- package/dist/esm/annotation/runtime/index.d.ts +11 -0
- package/dist/esm/annotation/runtime/index.js +26 -0
- package/dist/esm/annotation/runtime/summary.d.ts +17 -0
- package/dist/esm/annotation/runtime/summary.js +21 -0
- package/dist/esm/annotation/runtime/table.d.ts +16 -0
- package/dist/esm/annotation/runtime/table.js +21 -0
- package/dist/esm/annotation/utils.d.ts +40 -0
- package/dist/esm/annotation/utils.js +370 -0
- package/dist/esm/theme/annotation.d.ts +236 -0
- package/dist/esm/theme/annotation.js +186 -0
- package/dist/esm/theme/g2.js +2 -10
- package/dist/esm/theme/g6.js +1 -1
- package/dist/esm/theme/summary.js +1 -1
- package/dist/esm/types/annotation.d.ts +310 -0
- package/dist/esm/types/annotation.js +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/util/axis.d.ts +28 -0
- package/dist/esm/util/axis.js +222 -0
- package/dist/esm/util/components.d.ts +0 -10
- package/dist/esm/util/components.js +24 -69
- package/dist/esm/util/index.d.ts +7 -4
- package/dist/esm/util/index.js +7 -4
- package/dist/esm/vis/area/index.d.ts +2 -0
- package/dist/esm/vis/area/index.js +32 -9
- package/dist/esm/vis/bar/index.d.ts +2 -0
- package/dist/esm/vis/bar/index.js +37 -6
- package/dist/esm/vis/boxplot/index.js +10 -2
- package/dist/esm/vis/column/index.d.ts +2 -0
- package/dist/esm/vis/column/index.js +33 -12
- package/dist/esm/vis/dual-axes/index.js +10 -10
- package/dist/esm/vis/fishbone-diagram/index.js +1 -1
- package/dist/esm/vis/flow-diagram/index.js +1 -1
- package/dist/esm/vis/funnel/index.js +2 -7
- package/dist/esm/vis/histogram/index.js +4 -3
- package/dist/esm/vis/indented-tree/index.js +1 -1
- package/dist/esm/vis/line/index.d.ts +2 -0
- package/dist/esm/vis/line/index.js +31 -9
- package/dist/esm/vis/liquid/index.js +1 -1
- package/dist/esm/vis/mindmap/index.js +1 -1
- package/dist/esm/vis/network-graph/index.d.ts +2 -0
- package/dist/esm/vis/network-graph/index.js +29 -2
- package/dist/esm/vis/organization-chart/index.js +1 -1
- package/dist/esm/vis/pie/index.d.ts +2 -0
- package/dist/esm/vis/pie/index.js +25 -8
- package/dist/esm/vis/radar/index.js +1 -3
- package/dist/esm/vis/sankey/index.js +15 -1
- package/dist/esm/vis/scatter/index.d.ts +10 -3
- package/dist/esm/vis/scatter/index.js +28 -5
- package/dist/esm/vis/summary/index.d.ts +12 -3
- package/dist/esm/vis/summary/index.js +35 -16
- package/dist/esm/vis/table/index.d.ts +2 -0
- package/dist/esm/vis/table/index.js +50 -33
- package/dist/esm/vis/venn/index.js +1 -1
- package/dist/esm/vis/violin/index.js +10 -2
- package/dist/esm/vis/waterfall/index.js +16 -13
- package/dist/esm/vis/word-cloud/index.js +1 -3
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/annotation/components/path.ts
|
|
20
|
+
var path_exports = {};
|
|
21
|
+
__export(path_exports, {
|
|
22
|
+
path: () => path
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(path_exports);
|
|
25
|
+
var path = {
|
|
26
|
+
create: createPath,
|
|
27
|
+
g2: () => drawG2,
|
|
28
|
+
g6: () => drawG6
|
|
29
|
+
};
|
|
30
|
+
var regions = /* @__PURE__ */ new WeakMap();
|
|
31
|
+
function createPath(options, region) {
|
|
32
|
+
const annotation = { ...options, type: "path" };
|
|
33
|
+
if (region)
|
|
34
|
+
regions.set(annotation, region);
|
|
35
|
+
return [annotation];
|
|
36
|
+
}
|
|
37
|
+
var drawG2 = (annotations, context) => {
|
|
38
|
+
const { defaults, mapping } = context;
|
|
39
|
+
return {
|
|
40
|
+
marks: annotations.map((annotation) => {
|
|
41
|
+
const region = regions.get(annotation);
|
|
42
|
+
const connected = Array.isArray(annotation.data);
|
|
43
|
+
const axis = !Array.isArray(annotation.data) && annotation.data[mapping.x] !== void 0;
|
|
44
|
+
const style = getStyle(
|
|
45
|
+
annotation.style,
|
|
46
|
+
defaults,
|
|
47
|
+
connected ? defaults.stroke : defaults.labels.path.fill
|
|
48
|
+
);
|
|
49
|
+
let labelPoints = [];
|
|
50
|
+
let resolved = [];
|
|
51
|
+
return context.createMark(annotation, {
|
|
52
|
+
nativeType: connected ? "line" : axis ? "lineX" : "lineY",
|
|
53
|
+
style: {
|
|
54
|
+
...style,
|
|
55
|
+
...region ? { fill: region.fill, fillOpacity: region.fillOpacity, lineWidth: 0 } : {}
|
|
56
|
+
},
|
|
57
|
+
data: (region == null ? void 0 : region.positions) ? (coordinate) => {
|
|
58
|
+
var _a;
|
|
59
|
+
resolved = ((_a = region.visible) == null ? void 0 : _a.call(region)) === false ? [] : region.positions(context, coordinate);
|
|
60
|
+
return resolved.map((positions) => ({ positions }));
|
|
61
|
+
} : void 0,
|
|
62
|
+
zIndex: region ? -1 : 1,
|
|
63
|
+
clip: !!region,
|
|
64
|
+
label: {
|
|
65
|
+
...connected ? { selector: "last" } : {},
|
|
66
|
+
annotationPath: () => connected ? labelPoints.slice(-1) : labelPoints
|
|
67
|
+
},
|
|
68
|
+
decorate: (element, points) => {
|
|
69
|
+
labelPoints = points;
|
|
70
|
+
if (region)
|
|
71
|
+
element.setAttribute("annotationIgnoreObstacle", true);
|
|
72
|
+
element.setAttribute(
|
|
73
|
+
"annotationSegments",
|
|
74
|
+
points.slice(1).map((point, i) => [points[i], point])
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
geometry: (native) => (_index, scale, value, coordinate) => {
|
|
78
|
+
var _a;
|
|
79
|
+
if (((_a = region == null ? void 0 : region.visible) == null ? void 0 : _a.call(region)) === false)
|
|
80
|
+
return [[], []];
|
|
81
|
+
if (region == null ? void 0 : region.positions)
|
|
82
|
+
return [
|
|
83
|
+
resolved.map((_, i) => i),
|
|
84
|
+
resolved.map((points2) => points2.map((position) => coordinate.map(position)))
|
|
85
|
+
];
|
|
86
|
+
if (!Array.isArray(annotation.data)) {
|
|
87
|
+
const x = annotation.data[mapping.x];
|
|
88
|
+
const y = annotation.data[mapping.y];
|
|
89
|
+
return native(
|
|
90
|
+
[0],
|
|
91
|
+
scale,
|
|
92
|
+
{
|
|
93
|
+
...value,
|
|
94
|
+
x: [x === void 0 ? 0 : context.axisValue("x", x)],
|
|
95
|
+
y: [y === void 0 ? 0 : context.axisValue("y", y)]
|
|
96
|
+
},
|
|
97
|
+
coordinate
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const positions = annotation.data.map((datum) => context.position(datum, coordinate));
|
|
101
|
+
if (positions.some((point) => !point))
|
|
102
|
+
return [[], []];
|
|
103
|
+
const points = positions;
|
|
104
|
+
return native(
|
|
105
|
+
points.map((_, i) => i),
|
|
106
|
+
scale,
|
|
107
|
+
{
|
|
108
|
+
...value,
|
|
109
|
+
x: points.map((p) => p[0]),
|
|
110
|
+
y: points.map((p) => p[1])
|
|
111
|
+
},
|
|
112
|
+
coordinate
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
})
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
var drawG6 = (annotations, context) => {
|
|
120
|
+
for (const annotation of annotations) {
|
|
121
|
+
if (!Array.isArray(annotation.data))
|
|
122
|
+
throw new Error("Invalid annotation: graph path needs an array of anchors.");
|
|
123
|
+
const positions = annotation.data.map((datum) => context.position(datum));
|
|
124
|
+
if (positions.some((point) => !point))
|
|
125
|
+
continue;
|
|
126
|
+
const points = positions;
|
|
127
|
+
points.slice(1).forEach((point, index) => context.segments.push([points[index], point]));
|
|
128
|
+
context.add("path", {
|
|
129
|
+
...getStyle(annotation.style, context.defaults),
|
|
130
|
+
d: points.map(([x, y], i) => [i ? "L" : "M", x, y])
|
|
131
|
+
});
|
|
132
|
+
context.label({ ...annotation, data: annotation.data }, points[points.length - 1]);
|
|
133
|
+
}
|
|
134
|
+
return {};
|
|
135
|
+
};
|
|
136
|
+
function getStyle(style, defaults, stroke = defaults.stroke) {
|
|
137
|
+
return {
|
|
138
|
+
stroke: (style == null ? void 0 : style.stroke) ?? stroke,
|
|
139
|
+
lineWidth: (style == null ? void 0 : style.lineWidth) ?? defaults.lineWidth.path,
|
|
140
|
+
lineDash: style == null ? void 0 : style.lineDash,
|
|
141
|
+
fill: "none"
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
145
|
+
0 && (module.exports = {
|
|
146
|
+
path
|
|
147
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/annotation/components/peak.ts
|
|
20
|
+
var peak_exports = {};
|
|
21
|
+
__export(peak_exports, {
|
|
22
|
+
peak: () => peak
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(peak_exports);
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var import_highlight = require("./highlight");
|
|
27
|
+
var peak = {
|
|
28
|
+
g2: (annotations, { mapping }) => annotations.flatMap((annotation) => {
|
|
29
|
+
const selected = new Set((0, import_utils.selectRows)(mapping.data, annotation.data));
|
|
30
|
+
return (0, import_utils.selectLocalExtrema)(mapping.data, mapping.y, true, mapping.series, annotation).filter((row) => selected.has(row)).flatMap(
|
|
31
|
+
(row) => import_highlight.highlight.create({
|
|
32
|
+
data: [row],
|
|
33
|
+
label: annotation.label ?? `Peak: ${row[mapping.y]}`,
|
|
34
|
+
style: annotation.style
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
peak
|
|
42
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Annotation } from '../../types/annotation';
|
|
2
|
+
import type { Point } from '../layout';
|
|
3
|
+
import type { AnnotationComponent } from '../registry';
|
|
4
|
+
import type { G2AnnotationContext } from '../runtime';
|
|
5
|
+
/** Mark geometry and point halos belong to the same capability on both rendering stacks. */
|
|
6
|
+
export declare const point: AnnotationComponent<'point', 'g2' | 'g6'> & {
|
|
7
|
+
create: typeof createPoint;
|
|
8
|
+
};
|
|
9
|
+
type PointPreset = {
|
|
10
|
+
/** Follow the source mark's position and series color. */
|
|
11
|
+
useSourceGeometry?: boolean;
|
|
12
|
+
fillOpacity?: number;
|
|
13
|
+
shape?: string;
|
|
14
|
+
outline?: string;
|
|
15
|
+
zIndex?: number;
|
|
16
|
+
halo?: boolean;
|
|
17
|
+
visible?: () => boolean;
|
|
18
|
+
positions?: (context: Pick<G2AnnotationContext<object>, 'library' | 'axisValue' | 'getScene'>, coordinate: Parameters<G2AnnotationContext<object>['position']>[1]) => Point[];
|
|
19
|
+
};
|
|
20
|
+
/** Internal presets preserve native observations or specialize semantic markers without public options. */
|
|
21
|
+
declare function createPoint<T extends object>(options: Omit<Extract<Annotation<T>, {
|
|
22
|
+
type: 'point';
|
|
23
|
+
}>, 'type'>, preset?: PointPreset): Extract<Annotation<T>, {
|
|
24
|
+
type: 'point';
|
|
25
|
+
}>[];
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/annotation/components/point.ts
|
|
20
|
+
var point_exports = {};
|
|
21
|
+
__export(point_exports, {
|
|
22
|
+
point: () => point
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(point_exports);
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var point = {
|
|
27
|
+
create: createPoint,
|
|
28
|
+
g2: () => drawG2,
|
|
29
|
+
g6: () => drawG6
|
|
30
|
+
};
|
|
31
|
+
var presets = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
function createPoint(options, preset) {
|
|
33
|
+
if (Array.isArray(options.data) && !options.data.length)
|
|
34
|
+
return [];
|
|
35
|
+
const annotation = { ...options, type: "point" };
|
|
36
|
+
if (preset)
|
|
37
|
+
presets.set(annotation, preset);
|
|
38
|
+
return [annotation];
|
|
39
|
+
}
|
|
40
|
+
var drawG2 = (annotations, context) => {
|
|
41
|
+
const { defaults } = context;
|
|
42
|
+
const owner = Symbol("point");
|
|
43
|
+
let disposed = false;
|
|
44
|
+
let pulse;
|
|
45
|
+
const update = () => {
|
|
46
|
+
if (disposed)
|
|
47
|
+
return;
|
|
48
|
+
const scene = context.getScene();
|
|
49
|
+
const elements = scene.querySelectorAll(".element").filter(
|
|
50
|
+
(element) => !element.__removed__
|
|
51
|
+
);
|
|
52
|
+
const points = elements.filter(
|
|
53
|
+
(element) => {
|
|
54
|
+
var _a;
|
|
55
|
+
return ((_a = element.getAttribute("annotationPoint")) == null ? void 0 : _a.owner) === owner;
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
pulse == null ? void 0 : pulse.clear();
|
|
59
|
+
if (!points.length)
|
|
60
|
+
return;
|
|
61
|
+
const centers = elements.flatMap((element) => {
|
|
62
|
+
if (element.markType !== "point" || !element.isVisible())
|
|
63
|
+
return [];
|
|
64
|
+
const { halfExtents } = element.getLocalBounds();
|
|
65
|
+
if (!halfExtents[0] && !halfExtents[1])
|
|
66
|
+
return [];
|
|
67
|
+
const { points: points2 } = element.__data__;
|
|
68
|
+
const a = points2[0], b = points2[points2.length - 1];
|
|
69
|
+
return [[(a[0] + b[0]) / 2, (a[1] + b[1]) / 2]];
|
|
70
|
+
});
|
|
71
|
+
for (const element of points) {
|
|
72
|
+
const {
|
|
73
|
+
anchor,
|
|
74
|
+
size,
|
|
75
|
+
color,
|
|
76
|
+
fill,
|
|
77
|
+
stroke,
|
|
78
|
+
pulse: animated,
|
|
79
|
+
halo
|
|
80
|
+
} = element.getAttribute("annotationPoint");
|
|
81
|
+
const covered = fill === void 0 && hasPointAt(centers, anchor);
|
|
82
|
+
element.setAttribute("fill", fill ?? (covered ? "transparent" : color));
|
|
83
|
+
element.setAttribute("stroke", covered ? "transparent" : stroke);
|
|
84
|
+
if (halo) {
|
|
85
|
+
pulse ?? (pulse = (0, import_utils.createPointPulse)(scene, defaults.pulse, update));
|
|
86
|
+
pulse.add(element.parentNode, anchor, size, color, animated);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
update,
|
|
92
|
+
cleanup() {
|
|
93
|
+
disposed = true;
|
|
94
|
+
pulse == null ? void 0 : pulse.destroy();
|
|
95
|
+
},
|
|
96
|
+
marks: annotations.map((annotation) => {
|
|
97
|
+
var _a, _b, _c, _d, _e;
|
|
98
|
+
const preset = presets.get(annotation);
|
|
99
|
+
const useSourceGeometry = preset == null ? void 0 : preset.useSourceGeometry;
|
|
100
|
+
const size = ((_a = annotation.style) == null ? void 0 : _a.size) ?? defaults.size;
|
|
101
|
+
const stroke = ((_b = annotation.style) == null ? void 0 : _b.stroke) ?? defaults.stroke;
|
|
102
|
+
const outline = (preset == null ? void 0 : preset.outline) ?? ((_c = annotation.style) == null ? void 0 : _c.stroke) ?? defaults.pointStroke;
|
|
103
|
+
const shape = (preset == null ? void 0 : preset.shape) ?? defaults.shape;
|
|
104
|
+
const radius = size * ((preset == null ? void 0 : preset.halo) === false ? 1 : defaults.pulse.endScale);
|
|
105
|
+
let resolved = [];
|
|
106
|
+
return context.createMark(annotation, {
|
|
107
|
+
nativeType: "point",
|
|
108
|
+
shape,
|
|
109
|
+
zIndex: preset == null ? void 0 : preset.zIndex,
|
|
110
|
+
encode: { size },
|
|
111
|
+
data: (preset == null ? void 0 : preset.positions) ? (coordinate) => {
|
|
112
|
+
var _a2;
|
|
113
|
+
resolved = ((_a2 = preset.visible) == null ? void 0 : _a2.call(preset)) === false ? [] : preset.positions(context, coordinate);
|
|
114
|
+
return resolved.map((position) => ({ position }));
|
|
115
|
+
} : void 0,
|
|
116
|
+
labelGap: radius,
|
|
117
|
+
label: {
|
|
118
|
+
annotationPreferSide: true,
|
|
119
|
+
connectorStroke: stroke
|
|
120
|
+
},
|
|
121
|
+
style: {
|
|
122
|
+
shape,
|
|
123
|
+
stroke: outline,
|
|
124
|
+
lineWidth: ((_d = annotation.style) == null ? void 0 : _d.lineWidth) ?? defaults.lineWidth.point,
|
|
125
|
+
fill: ((_e = annotation.style) == null ? void 0 : _e.fill) ?? "transparent",
|
|
126
|
+
fillOpacity: preset == null ? void 0 : preset.fillOpacity
|
|
127
|
+
},
|
|
128
|
+
decorate: (element, points) => {
|
|
129
|
+
var _a2;
|
|
130
|
+
const [a, b = a] = points;
|
|
131
|
+
const fill = (_a2 = annotation.style) == null ? void 0 : _a2.fill;
|
|
132
|
+
const anchor = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
|
|
133
|
+
element.setAttribute("annotationBounds", {
|
|
134
|
+
x: anchor[0] - radius,
|
|
135
|
+
y: anchor[1] - radius,
|
|
136
|
+
width: radius * 2,
|
|
137
|
+
height: radius * 2
|
|
138
|
+
});
|
|
139
|
+
element.setAttribute("annotationPoint", {
|
|
140
|
+
owner,
|
|
141
|
+
anchor,
|
|
142
|
+
size,
|
|
143
|
+
color: useSourceGeometry ? fill ?? context.color(
|
|
144
|
+
Array.isArray(annotation.data) ? annotation.data[0] : annotation.data
|
|
145
|
+
) : fill && fill !== "none" && fill !== "transparent" ? fill : stroke,
|
|
146
|
+
fill,
|
|
147
|
+
stroke: outline,
|
|
148
|
+
pulse: annotation.pulse,
|
|
149
|
+
halo: (preset == null ? void 0 : preset.halo) !== false
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
geometry: (native) => (_index, scale, value, coordinate) => {
|
|
153
|
+
var _a2;
|
|
154
|
+
if (((_a2 = preset == null ? void 0 : preset.visible) == null ? void 0 : _a2.call(preset)) === false)
|
|
155
|
+
return [[], []];
|
|
156
|
+
const data = Array.isArray(annotation.data) ? annotation.data : [annotation.data];
|
|
157
|
+
const positions = (preset == null ? void 0 : preset.positions) ? resolved : data.map((datum) => context.position(datum, coordinate, !!useSourceGeometry));
|
|
158
|
+
const channels = { ...value };
|
|
159
|
+
for (const key of ["x1", "y1", "dx", "dy"])
|
|
160
|
+
delete channels[key];
|
|
161
|
+
return native(
|
|
162
|
+
positions.flatMap((p, i) => p ? [i] : []),
|
|
163
|
+
scale,
|
|
164
|
+
{
|
|
165
|
+
...channels,
|
|
166
|
+
x: positions.map((p) => (p == null ? void 0 : p[0]) ?? 0),
|
|
167
|
+
y: positions.map((p) => (p == null ? void 0 : p[1]) ?? 0)
|
|
168
|
+
},
|
|
169
|
+
coordinate
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
})
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
var drawG6 = (annotations, context) => {
|
|
177
|
+
var _a, _b, _c, _d, _e, _f;
|
|
178
|
+
const { defaults } = context;
|
|
179
|
+
for (const annotation of annotations) {
|
|
180
|
+
for (const data of Array.isArray(annotation.data) ? annotation.data : [annotation.data]) {
|
|
181
|
+
const anchor = context.position(data);
|
|
182
|
+
if (!anchor)
|
|
183
|
+
continue;
|
|
184
|
+
const [x, y] = anchor;
|
|
185
|
+
const r = ((_a = annotation.style) == null ? void 0 : _a.size) ?? defaults.size;
|
|
186
|
+
const halo = r * defaults.pulse.endScale;
|
|
187
|
+
context.boxes.push({ x: x - halo, y: y - halo, width: halo * 2, height: halo * 2 });
|
|
188
|
+
const stroke = ((_b = annotation.style) == null ? void 0 : _b.stroke) ?? defaults.stroke;
|
|
189
|
+
const covered = ((_c = annotation.style) == null ? void 0 : _c.fill) === void 0 && hasPointAt(context.centers, anchor);
|
|
190
|
+
const paint = {
|
|
191
|
+
lineWidth: ((_d = annotation.style) == null ? void 0 : _d.lineWidth) ?? defaults.lineWidth.point,
|
|
192
|
+
stroke: covered ? "transparent" : ((_e = annotation.style) == null ? void 0 : _e.stroke) ?? defaults.pointStroke,
|
|
193
|
+
fill: ((_f = annotation.style) == null ? void 0 : _f.fill) ?? (covered ? "transparent" : stroke)
|
|
194
|
+
};
|
|
195
|
+
context.pulse().add(
|
|
196
|
+
context.root,
|
|
197
|
+
anchor,
|
|
198
|
+
r,
|
|
199
|
+
paint.fill !== "none" && paint.fill !== "transparent" ? paint.fill : stroke,
|
|
200
|
+
annotation.pulse
|
|
201
|
+
);
|
|
202
|
+
const shape = defaults.shape;
|
|
203
|
+
if (shape === "square" || shape === "hollowSquare")
|
|
204
|
+
context.add("rect", { ...paint, x: x - r, y: y - r, width: 2 * r, height: 2 * r });
|
|
205
|
+
else if (shape === "diamond" || shape === "hollowDiamond")
|
|
206
|
+
context.add("path", {
|
|
207
|
+
...paint,
|
|
208
|
+
d: [
|
|
209
|
+
["M", x, y - r * 1.5],
|
|
210
|
+
["L", x + r, y],
|
|
211
|
+
["L", x, y + r * 1.5],
|
|
212
|
+
["L", x - r, y],
|
|
213
|
+
["Z"]
|
|
214
|
+
]
|
|
215
|
+
});
|
|
216
|
+
else if (shape === "triangle" || shape === "hollowTriangle")
|
|
217
|
+
context.add("path", {
|
|
218
|
+
...paint,
|
|
219
|
+
d: [["M", x, y - r], ["L", x + r, y + r], ["L", x - r, y + r], ["Z"]]
|
|
220
|
+
});
|
|
221
|
+
else if (shape === "triangleDown")
|
|
222
|
+
context.add("path", {
|
|
223
|
+
...paint,
|
|
224
|
+
d: [["M", x, y + r], ["L", x + r, y - r], ["L", x - r, y - r], ["Z"]]
|
|
225
|
+
});
|
|
226
|
+
else if (["point", "circle", "hollow", "hollowCircle"].includes(shape))
|
|
227
|
+
context.add("circle", { ...paint, cx: x, cy: y, r });
|
|
228
|
+
else
|
|
229
|
+
throw new Error(`Unsupported annotation point shape: ${shape}.`);
|
|
230
|
+
context.label(annotation, anchor, { gap: halo });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return {};
|
|
234
|
+
};
|
|
235
|
+
function hasPointAt(points, [x, y]) {
|
|
236
|
+
return points.some(([px, py]) => Math.hypot(px - x, py - y) < 1e-6);
|
|
237
|
+
}
|
|
238
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
239
|
+
0 && (module.exports = {
|
|
240
|
+
point
|
|
241
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/annotation/components/quadrant.ts
|
|
20
|
+
var quadrant_exports = {};
|
|
21
|
+
__export(quadrant_exports, {
|
|
22
|
+
quadrant: () => quadrant
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(quadrant_exports);
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var import_path = require("./path");
|
|
27
|
+
var import_range = require("./range");
|
|
28
|
+
var import_text = require("./text");
|
|
29
|
+
var quadrant = {
|
|
30
|
+
g2: (annotations, { mapping, defaults }) => annotations.flatMap((annotation) => {
|
|
31
|
+
if (!annotation.data || Object.keys(annotation.data).some((key) => key !== mapping.x && key !== mapping.y))
|
|
32
|
+
throw new Error("Invalid annotation: quadrant needs both axis coordinates.");
|
|
33
|
+
const x = (0, import_utils.finiteValue)(annotation.data[mapping.x], mapping.x);
|
|
34
|
+
const y = (0, import_utils.finiteValue)(annotation.data[mapping.y], mapping.y);
|
|
35
|
+
const hidden = annotation.label === "";
|
|
36
|
+
const regions = ["topRight", "topLeft", "bottomLeft", "bottomRight"].flatMap(
|
|
37
|
+
(name, i) => {
|
|
38
|
+
var _a, _b, _c, _d, _e;
|
|
39
|
+
const right = name.endsWith("Right");
|
|
40
|
+
const top = name.startsWith("top");
|
|
41
|
+
const bounds = (context) => {
|
|
42
|
+
const splitX = Math.max(0, Math.min(1, context.axisValue("x", x)));
|
|
43
|
+
const splitY = Math.max(0, Math.min(1, context.axisValue("y", y)));
|
|
44
|
+
return [
|
|
45
|
+
[right ? splitX : 0, top ? 0 : splitY],
|
|
46
|
+
[right ? 1 : splitX, top ? splitY : 1]
|
|
47
|
+
];
|
|
48
|
+
};
|
|
49
|
+
const label = hidden ? "" : ((_a = annotation.labels) == null ? void 0 : _a[name]) ?? `${right ? "High" : "Low"} ${mapping.x} · ${top ? "High" : "Low"} ${mapping.y}`;
|
|
50
|
+
return [
|
|
51
|
+
...import_range.range.create(
|
|
52
|
+
{
|
|
53
|
+
data: { [mapping.x]: [x, x], [mapping.y]: [y, y] },
|
|
54
|
+
label: "",
|
|
55
|
+
style: {
|
|
56
|
+
fill: ((_b = annotation.style) == null ? void 0 : _b.fill) ?? defaults.palette[i % defaults.palette.length],
|
|
57
|
+
fillOpacity: ((_c = annotation.style) == null ? void 0 : _c.fillOpacity) ?? 0.06
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
bounds
|
|
61
|
+
),
|
|
62
|
+
...label ? import_text.text.create(
|
|
63
|
+
{
|
|
64
|
+
data: annotation.data,
|
|
65
|
+
label,
|
|
66
|
+
style: {
|
|
67
|
+
labelFill: (_d = annotation.style) == null ? void 0 : _d.labelFill,
|
|
68
|
+
labelFontSize: (_e = annotation.style) == null ? void 0 : _e.labelFontSize
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
(context, coordinate) => {
|
|
72
|
+
const [from, to] = bounds(context);
|
|
73
|
+
if (to[0] <= from[0] || to[1] <= from[1])
|
|
74
|
+
return void 0;
|
|
75
|
+
const inset = Math.min((to[1] - from[1]) / 2, 18 / coordinate.getSize()[1]);
|
|
76
|
+
return [(from[0] + to[0]) / 2, from[1] + inset];
|
|
77
|
+
}
|
|
78
|
+
) : []
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
const dividers = ["x", "y"].flatMap((axis) => {
|
|
83
|
+
const field = mapping[axis];
|
|
84
|
+
const value = axis === "x" ? x : y;
|
|
85
|
+
return import_path.path.create({
|
|
86
|
+
data: (0, import_utils.axisPosition)(field, value),
|
|
87
|
+
label: annotation.label ?? `${axis.toUpperCase()}: ${value}`,
|
|
88
|
+
style: { lineDash: [4, 4], ...annotation.style }
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
return [...regions, ...dividers];
|
|
92
|
+
})
|
|
93
|
+
};
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
quadrant
|
|
97
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/annotation/components/quantile.ts
|
|
20
|
+
var quantile_exports = {};
|
|
21
|
+
__export(quantile_exports, {
|
|
22
|
+
quantile: () => quantile
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(quantile_exports);
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var import_path = require("./path");
|
|
27
|
+
var quantile = {
|
|
28
|
+
g2: (annotations, { mapping }) => annotations.flatMap((annotation) => {
|
|
29
|
+
const field = (0, import_utils.annotationField)(mapping, annotation.axis);
|
|
30
|
+
const values = (0, import_utils.numericRows)((0, import_utils.selectRows)(mapping.data, annotation.data), field).map(
|
|
31
|
+
({ value: value2 }) => value2
|
|
32
|
+
);
|
|
33
|
+
const value = (0, import_utils.quantileValue)(
|
|
34
|
+
values.sort((a, b) => a - b),
|
|
35
|
+
annotation.p
|
|
36
|
+
);
|
|
37
|
+
if (!values.length)
|
|
38
|
+
return [];
|
|
39
|
+
return import_path.path.create({
|
|
40
|
+
data: (0, import_utils.axisPosition)(field, value),
|
|
41
|
+
label: annotation.label ?? `P${(0, import_utils.formatNumber)(annotation.p * 100)}: ${(0, import_utils.formatNumber)(value)}`,
|
|
42
|
+
style: { lineDash: [4, 4], ...annotation.style }
|
|
43
|
+
});
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
quantile
|
|
49
|
+
});
|