@antv/gpt-vis 1.3.1 → 1.4.0
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 +9 -2
- package/dist/cjs/vis/summary/index.js +25 -8
- 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/cjs/vis-wrapper/index.js +2 -1
- 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 +9 -2
- package/dist/esm/vis/summary/index.js +31 -13
- 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/esm/vis-wrapper/index.js +2 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,223 @@
|
|
|
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/threshold-highlight.ts
|
|
20
|
+
var threshold_highlight_exports = {};
|
|
21
|
+
__export(threshold_highlight_exports, {
|
|
22
|
+
thresholdHighlight: () => thresholdHighlight
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(threshold_highlight_exports);
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var import_highlight = require("./highlight");
|
|
27
|
+
var import_path = require("./path");
|
|
28
|
+
var thresholdHighlight = {
|
|
29
|
+
g2: (annotations, context) => {
|
|
30
|
+
const { mapping, chartType } = context;
|
|
31
|
+
const selections = annotations.map((annotation) => ({
|
|
32
|
+
annotation,
|
|
33
|
+
rows: selectThreshold((0, import_utils.selectRows)(mapping.data, annotation.data), mapping.y, annotation),
|
|
34
|
+
color: getColor(annotation, context)
|
|
35
|
+
}));
|
|
36
|
+
const references = selections.flatMap(
|
|
37
|
+
({ annotation }) => {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
return import_path.path.create({
|
|
40
|
+
data: { [mapping.y]: annotation.threshold },
|
|
41
|
+
label: annotation.label ?? `${annotation.direction === "below" ? "Below" : "Above"} threshold: ${annotation.threshold}`,
|
|
42
|
+
style: {
|
|
43
|
+
stroke: (_a = annotation.style) == null ? void 0 : _a.stroke,
|
|
44
|
+
lineDash: [4, 4],
|
|
45
|
+
lineWidth: (_b = annotation.style) == null ? void 0 : _b.lineWidth,
|
|
46
|
+
labelFill: (_c = annotation.style) == null ? void 0 : _c.labelFill,
|
|
47
|
+
labelFontSize: (_d = annotation.style) == null ? void 0 : _d.labelFontSize
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
switch (chartType) {
|
|
53
|
+
case "scatter":
|
|
54
|
+
return [
|
|
55
|
+
...references,
|
|
56
|
+
...selections.flatMap(
|
|
57
|
+
({ annotation, rows, color }) => import_highlight.highlight.create({
|
|
58
|
+
data: rows,
|
|
59
|
+
style: { ...annotation.style, fill: color, stroke: color }
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
];
|
|
63
|
+
default:
|
|
64
|
+
return [drawG2, ...references];
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
table: (annotations, { data, defaults }) => annotations.flatMap((annotation) => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
const rows = selectThreshold(
|
|
70
|
+
(0, import_utils.selectRows)(data, annotation.data.row),
|
|
71
|
+
annotation.data.field,
|
|
72
|
+
annotation
|
|
73
|
+
);
|
|
74
|
+
const color = ((_a = annotation.style) == null ? void 0 : _a.fill) ?? ((_b = annotation.style) == null ? void 0 : _b.stroke) ?? defaults.highlight.color;
|
|
75
|
+
return import_highlight.highlight.create({
|
|
76
|
+
data: rows.map((row) => ({ row, column: annotation.data.column })),
|
|
77
|
+
label: annotation.label ?? `${annotation.direction === "below" ? "Below" : "Above"} threshold: ${annotation.threshold}`,
|
|
78
|
+
style: { fill: color, stroke: color, ...annotation.style }
|
|
79
|
+
});
|
|
80
|
+
})
|
|
81
|
+
};
|
|
82
|
+
var drawG2 = (annotations, context) => {
|
|
83
|
+
const selections = annotations.map((annotation) => ({
|
|
84
|
+
annotation,
|
|
85
|
+
rows: (0, import_utils.selectRows)(context.mapping.data, annotation.data),
|
|
86
|
+
color: getColor(annotation, context)
|
|
87
|
+
}));
|
|
88
|
+
if (!annotations.length)
|
|
89
|
+
return {};
|
|
90
|
+
if (context.chartType === "line" || context.chartType === "area") {
|
|
91
|
+
for (const { rows } of selections) {
|
|
92
|
+
const selected = new Set(rows);
|
|
93
|
+
const groups = new Set(
|
|
94
|
+
[...selected].map(
|
|
95
|
+
(row) => context.mapping.series ? row[context.mapping.series] : void 0
|
|
96
|
+
)
|
|
97
|
+
);
|
|
98
|
+
if (context.mapping.data.some(
|
|
99
|
+
(row) => groups.has(context.mapping.series ? row[context.mapping.series] : void 0) && !selected.has(row)
|
|
100
|
+
))
|
|
101
|
+
throw new Error("Invalid annotation: line thresholds must select complete series.");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const original = /* @__PURE__ */ new Map();
|
|
105
|
+
const reset = () => {
|
|
106
|
+
for (const [element, { key, paint }] of original)
|
|
107
|
+
element.setAttribute(key, paint);
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
update: () => {
|
|
111
|
+
const elements = context.getScene().querySelectorAll(".element").filter(
|
|
112
|
+
(element) => !element.__removed__ && !element.getAttribute("annotationKind")
|
|
113
|
+
);
|
|
114
|
+
const live = new Set(elements);
|
|
115
|
+
for (const element of original.keys())
|
|
116
|
+
if (!live.has(element))
|
|
117
|
+
original.delete(element);
|
|
118
|
+
reset();
|
|
119
|
+
const coordinate = context.getCoordinate();
|
|
120
|
+
const pointAt = (value) => coordinate.map([0.5, context.axisValue("y", value)]);
|
|
121
|
+
for (const element of elements) {
|
|
122
|
+
if (element.markType !== "area" && element.markType !== "line" && element.markType !== "interval" && element.markType !== "point")
|
|
123
|
+
continue;
|
|
124
|
+
const rows = context.getSourceData(element);
|
|
125
|
+
const active = selections.filter(
|
|
126
|
+
(selection) => rows.every((row) => selection.rows.includes(row))
|
|
127
|
+
);
|
|
128
|
+
if (!active.length)
|
|
129
|
+
continue;
|
|
130
|
+
const first = active[0].annotation;
|
|
131
|
+
const a = pointAt(first.threshold);
|
|
132
|
+
const b = pointAt(first.threshold + Math.max(1, Math.abs(first.threshold)) * 1e-6);
|
|
133
|
+
const horizontal = Math.abs(b[0] - a[0]) > Math.abs(b[1] - a[1]);
|
|
134
|
+
const dimension = horizontal ? 0 : 1;
|
|
135
|
+
const increasing = b[dimension] > a[dimension];
|
|
136
|
+
const regions = active.map(({ annotation, color }) => ({
|
|
137
|
+
position: pointAt(annotation.threshold)[dimension],
|
|
138
|
+
inclusive: annotation.inclusive,
|
|
139
|
+
greater: (annotation.direction ?? "above") === "above" ? increasing : !increasing,
|
|
140
|
+
color
|
|
141
|
+
}));
|
|
142
|
+
const key = element.markType === "line" ? "stroke" : "fill";
|
|
143
|
+
if (!original.has(element))
|
|
144
|
+
original.set(element, { key, paint: element.getAttribute(key) });
|
|
145
|
+
const base = original.get(element).paint;
|
|
146
|
+
const { min, max } = element.getLocalBounds();
|
|
147
|
+
const center = (min[dimension] + max[dimension]) / 2;
|
|
148
|
+
let paint = thresholdPaint(
|
|
149
|
+
element.markType === "area" ? "transparent" : base,
|
|
150
|
+
element.markType === "point" ? center : min[dimension],
|
|
151
|
+
element.markType === "point" ? center : max[dimension],
|
|
152
|
+
regions,
|
|
153
|
+
horizontal
|
|
154
|
+
);
|
|
155
|
+
if (element.markType === "area") {
|
|
156
|
+
if (paint === "transparent")
|
|
157
|
+
continue;
|
|
158
|
+
const background = base.includes("gradient(") ? base : `linear-gradient(0deg, ${base} 0%, ${base} 100%)`;
|
|
159
|
+
const region = paint.includes("gradient(") ? paint : `linear-gradient(0deg, ${paint} 0%, ${paint} 100%)`;
|
|
160
|
+
paint = `${background}, ${region}`;
|
|
161
|
+
}
|
|
162
|
+
element.setAttribute(key, paint);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
cleanup: () => {
|
|
166
|
+
reset();
|
|
167
|
+
original.clear();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
function getColor(annotation, { mapping, defaults }) {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
const seriesCount = mapping.series ? new Set(mapping.data.map((row) => row[mapping.series])).size : 1;
|
|
174
|
+
const used = new Set(defaults.palette.slice(0, seriesCount));
|
|
175
|
+
const accent = defaults.palette.find((color) => !used.has(color)) ?? defaults.labels.highlight.fill;
|
|
176
|
+
return ((_a = annotation.style) == null ? void 0 : _a.fill) ?? ((_b = annotation.style) == null ? void 0 : _b.stroke) ?? accent;
|
|
177
|
+
}
|
|
178
|
+
function thresholdPaint(base, min, max, regions, horizontal) {
|
|
179
|
+
const colorAt = (position) => {
|
|
180
|
+
var _a;
|
|
181
|
+
return ((_a = regions.findLast((region) => {
|
|
182
|
+
const delta = position - region.position;
|
|
183
|
+
if (Math.abs(delta) < 1e-7)
|
|
184
|
+
return region.inclusive;
|
|
185
|
+
return region.greater ? delta > 0 : delta < 0;
|
|
186
|
+
})) == null ? void 0 : _a.color) ?? base;
|
|
187
|
+
};
|
|
188
|
+
if (max <= min)
|
|
189
|
+
return colorAt(min);
|
|
190
|
+
const stops = [
|
|
191
|
+
.../* @__PURE__ */ new Set([
|
|
192
|
+
min,
|
|
193
|
+
...regions.map(({ position }) => position).filter((p) => p > min + 1e-7 && p < max - 1e-7),
|
|
194
|
+
max
|
|
195
|
+
])
|
|
196
|
+
].sort((a, b) => a - b);
|
|
197
|
+
const colors = stops.slice(1).map((end, i) => colorAt((stops[i] + end) / 2));
|
|
198
|
+
if (colors.every((color) => color === colors[0]))
|
|
199
|
+
return colors[0];
|
|
200
|
+
const percent = (position) => ((position - min) / (max - min) * 100).toFixed(6);
|
|
201
|
+
const gradient = colors.flatMap((color, i) => [
|
|
202
|
+
`${color} ${percent(stops[i])}%`,
|
|
203
|
+
`${color} ${percent(stops[i + 1])}%`
|
|
204
|
+
]);
|
|
205
|
+
return `linear-gradient(${horizontal ? 0 : 90}deg, ${gradient.join(", ")})`;
|
|
206
|
+
}
|
|
207
|
+
function selectThreshold(data, field, {
|
|
208
|
+
threshold,
|
|
209
|
+
direction = "above",
|
|
210
|
+
inclusive = false
|
|
211
|
+
}) {
|
|
212
|
+
if (!Number.isFinite(threshold))
|
|
213
|
+
throw new Error("Invalid annotation: threshold must be finite.");
|
|
214
|
+
if (direction !== "above" && direction !== "below")
|
|
215
|
+
throw new Error("Invalid annotation: threshold direction must be above or below.");
|
|
216
|
+
return (0, import_utils.numericRows)(data, field).filter(
|
|
217
|
+
({ value }) => inclusive && value === threshold || (direction === "above" ? value > threshold : value < threshold)
|
|
218
|
+
).map(({ row }) => row);
|
|
219
|
+
}
|
|
220
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
0 && (module.exports = {
|
|
222
|
+
thresholdHighlight
|
|
223
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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/threshold-x.ts
|
|
20
|
+
var threshold_x_exports = {};
|
|
21
|
+
__export(threshold_x_exports, {
|
|
22
|
+
thresholdX: () => thresholdX
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(threshold_x_exports);
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var import_path = require("./path");
|
|
27
|
+
var thresholdX = {
|
|
28
|
+
g2: (annotations, { mapping }) => annotations.flatMap((annotation) => {
|
|
29
|
+
return import_path.path.create({
|
|
30
|
+
data: (0, import_utils.axisPosition)(mapping.x, annotation.threshold),
|
|
31
|
+
label: annotation.label ?? `Threshold: ${annotation.threshold}`,
|
|
32
|
+
style: { lineDash: [4, 4], ...annotation.style }
|
|
33
|
+
});
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
thresholdX
|
|
39
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
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/threshold-y.ts
|
|
20
|
+
var threshold_y_exports = {};
|
|
21
|
+
__export(threshold_y_exports, {
|
|
22
|
+
thresholdY: () => thresholdY
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(threshold_y_exports);
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var import_path = require("./path");
|
|
27
|
+
var thresholdY = {
|
|
28
|
+
g2: (annotations, { mapping }) => annotations.flatMap((annotation) => {
|
|
29
|
+
(0, import_utils.finiteValue)(annotation.threshold, "threshold");
|
|
30
|
+
return import_path.path.create({
|
|
31
|
+
data: (0, import_utils.axisPosition)(mapping.y, annotation.threshold),
|
|
32
|
+
label: annotation.label ?? `Threshold: ${annotation.threshold}`,
|
|
33
|
+
style: { lineDash: [4, 4], ...annotation.style }
|
|
34
|
+
});
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
thresholdY
|
|
40
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
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/top-n.ts
|
|
20
|
+
var top_n_exports = {};
|
|
21
|
+
__export(top_n_exports, {
|
|
22
|
+
topN: () => topN
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(top_n_exports);
|
|
25
|
+
var import_label = require("../label");
|
|
26
|
+
var import_utils = require("../utils");
|
|
27
|
+
var import_highlight = require("./highlight");
|
|
28
|
+
var topN = {
|
|
29
|
+
g2: (annotations, { mapping }) => annotations.flatMap((annotation) => {
|
|
30
|
+
const rows = (0, import_utils.selectRows)(mapping.data, annotation.data);
|
|
31
|
+
const field = mapping.y;
|
|
32
|
+
return (0, import_utils.selectRank)(rows, field, annotation.n, true).flatMap((row, index) => {
|
|
33
|
+
const highlights = import_highlight.highlight.create({
|
|
34
|
+
data: [row],
|
|
35
|
+
label: annotation.label ?? `Top ${index + 1}`,
|
|
36
|
+
style: annotation.style
|
|
37
|
+
});
|
|
38
|
+
highlights.forEach((highlight2) => import_label.rankedLabels.set(highlight2, annotation));
|
|
39
|
+
return highlights;
|
|
40
|
+
});
|
|
41
|
+
}),
|
|
42
|
+
table: (annotations, { data }) => annotations.flatMap((annotation) => {
|
|
43
|
+
const rows = (0, import_utils.selectRows)(data, annotation.data.row);
|
|
44
|
+
const field = annotation.data.field;
|
|
45
|
+
return (0, import_utils.selectRank)(rows, field, annotation.n, true).flatMap(
|
|
46
|
+
(row, index) => import_highlight.highlight.create({
|
|
47
|
+
data: [{ row, column: annotation.data.column }],
|
|
48
|
+
label: annotation.label ?? `Top ${index + 1}`,
|
|
49
|
+
style: annotation.style
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
topN
|
|
57
|
+
});
|
|
@@ -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/valley.ts
|
|
20
|
+
var valley_exports = {};
|
|
21
|
+
__export(valley_exports, {
|
|
22
|
+
valley: () => valley
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(valley_exports);
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var import_highlight = require("./highlight");
|
|
27
|
+
var valley = {
|
|
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, false, mapping.series, annotation).filter((row) => selected.has(row)).flatMap(
|
|
31
|
+
(row) => import_highlight.highlight.create({
|
|
32
|
+
data: [row],
|
|
33
|
+
label: annotation.label ?? `Valley: ${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
|
+
valley
|
|
42
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { bindAnnotations } from './runtime';
|
|
@@ -0,0 +1,29 @@
|
|
|
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/index.ts
|
|
20
|
+
var annotation_exports = {};
|
|
21
|
+
__export(annotation_exports, {
|
|
22
|
+
bindAnnotations: () => import_runtime.bindAnnotations
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(annotation_exports);
|
|
25
|
+
var import_runtime = require("./runtime");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
bindAnnotations
|
|
29
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { getAnnotationDefaults } from '../theme/annotation';
|
|
2
|
+
import type { ConnectorShape } from './components/connector';
|
|
3
|
+
import type { Box, Point } from './layout';
|
|
4
|
+
import type { AnnotationResult, RendererAnnotation } from './registry';
|
|
5
|
+
import type { G2AnnotationContext, LabelElement, Scene } from './runtime/g2';
|
|
6
|
+
/** Only automatically computed pie percentages may reuse a native percentage label. */
|
|
7
|
+
export declare const nativePercentageLabels: WeakSet<object>;
|
|
8
|
+
/** Composing annotations supply connector geometry after their targets are measured. */
|
|
9
|
+
export type LabelConnector = (anchors: Point[], geometry: {
|
|
10
|
+
points: Point[];
|
|
11
|
+
y?: number;
|
|
12
|
+
y1?: number;
|
|
13
|
+
}[], coordinate: ReturnType<G2AnnotationContext<object>['getCoordinate']> | undefined, index: number, count: number) => ConnectorShape | undefined;
|
|
14
|
+
export declare const labelConnectors: WeakMap<object, LabelConnector>;
|
|
15
|
+
/** Ranks from one analysis annotation share a native label configuration. */
|
|
16
|
+
export declare const rankedLabels: WeakMap<object, object>;
|
|
17
|
+
/** Group explanations identify their selected native colors without adding public options. */
|
|
18
|
+
export declare const groupLabels: WeakSet<object>;
|
|
19
|
+
type Defaults = ReturnType<typeof getAnnotationDefaults>;
|
|
20
|
+
/** Shared DOM labels; renderers provide the current geometry of their own targets. */
|
|
21
|
+
export declare function bindLabels(container: HTMLElement, content: HTMLElement, items: {
|
|
22
|
+
annotation: Pick<Extract<RendererAnnotation<Record<string, unknown>, 'g2'>, {
|
|
23
|
+
type: 'highlight';
|
|
24
|
+
}>, 'label' | 'style'>;
|
|
25
|
+
bounds: () => DOMRect | DOMRect[] | undefined;
|
|
26
|
+
}[], defaults: Defaults): () => void;
|
|
27
|
+
/** Reserve space inside the measured card, so color keys participate in label avoidance. */
|
|
28
|
+
export declare function getLabelColorWidth(colors: string[]): number;
|
|
29
|
+
/** Native canvas color keys stay inside their label and share its movement and cleanup. */
|
|
30
|
+
export declare function drawLabelColors(label: Pick<LabelElement, 'appendChild'>, scene: Scene, colors: string[], box: Box, padding: number): void;
|
|
31
|
+
/** Decide after native overlap hiding, so a hidden percentage never suppresses the fallback. */
|
|
32
|
+
export declare function bindPieLabels<T extends object>(selections: {
|
|
33
|
+
annotation: Extract<RendererAnnotation<T, 'g2'>, {
|
|
34
|
+
type: 'highlight';
|
|
35
|
+
}>;
|
|
36
|
+
rows: T[];
|
|
37
|
+
}[], context: G2AnnotationContext<T>): AnnotationResult;
|
|
38
|
+
export {};
|