@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,34 @@
|
|
|
1
|
+
export { bottomN } from './bottom-n';
|
|
2
|
+
export { centroid } from './centroid';
|
|
3
|
+
export { connector } from './connector';
|
|
4
|
+
export { contribution } from './contribution';
|
|
5
|
+
export { crossing } from './crossing';
|
|
6
|
+
export { event } from './event';
|
|
7
|
+
export { first } from './first';
|
|
8
|
+
export { group } from './group';
|
|
9
|
+
export { highlight } from './highlight';
|
|
10
|
+
export { last } from './last';
|
|
11
|
+
export { maxX } from './max-x';
|
|
12
|
+
export { maxY } from './max-y';
|
|
13
|
+
export { mean } from './mean';
|
|
14
|
+
export { median } from './median';
|
|
15
|
+
export { minX } from './min-x';
|
|
16
|
+
export { minY } from './min-y';
|
|
17
|
+
export { outlier } from './outlier';
|
|
18
|
+
export { path } from './path';
|
|
19
|
+
export { peak } from './peak';
|
|
20
|
+
export { point } from './point';
|
|
21
|
+
export { quadrant } from './quadrant';
|
|
22
|
+
export { quantile } from './quantile';
|
|
23
|
+
export { range } from './range';
|
|
24
|
+
export { rangeInside } from './range-inside';
|
|
25
|
+
export { rangeOutside } from './range-outside';
|
|
26
|
+
export { rangeX } from './range-x';
|
|
27
|
+
export { rangeY } from './range-y';
|
|
28
|
+
export { target } from './target';
|
|
29
|
+
export { text } from './text';
|
|
30
|
+
export { thresholdHighlight } from './threshold-highlight';
|
|
31
|
+
export { thresholdX } from './threshold-x';
|
|
32
|
+
export { thresholdY } from './threshold-y';
|
|
33
|
+
export { topN } from './top-n';
|
|
34
|
+
export { valley } from './valley';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { bottomN } from "./bottom-n";
|
|
2
|
+
export { centroid } from "./centroid";
|
|
3
|
+
export { connector } from "./connector";
|
|
4
|
+
export { contribution } from "./contribution";
|
|
5
|
+
export { crossing } from "./crossing";
|
|
6
|
+
export { event } from "./event";
|
|
7
|
+
export { first } from "./first";
|
|
8
|
+
export { group } from "./group";
|
|
9
|
+
export { highlight } from "./highlight";
|
|
10
|
+
export { last } from "./last";
|
|
11
|
+
export { maxX } from "./max-x";
|
|
12
|
+
export { maxY } from "./max-y";
|
|
13
|
+
export { mean } from "./mean";
|
|
14
|
+
export { median } from "./median";
|
|
15
|
+
export { minX } from "./min-x";
|
|
16
|
+
export { minY } from "./min-y";
|
|
17
|
+
export { outlier } from "./outlier";
|
|
18
|
+
export { path } from "./path";
|
|
19
|
+
export { peak } from "./peak";
|
|
20
|
+
export { point } from "./point";
|
|
21
|
+
export { quadrant } from "./quadrant";
|
|
22
|
+
export { quantile } from "./quantile";
|
|
23
|
+
export { range } from "./range";
|
|
24
|
+
export { rangeInside } from "./range-inside";
|
|
25
|
+
export { rangeOutside } from "./range-outside";
|
|
26
|
+
export { rangeX } from "./range-x";
|
|
27
|
+
export { rangeY } from "./range-y";
|
|
28
|
+
export { target } from "./target";
|
|
29
|
+
export { text } from "./text";
|
|
30
|
+
export { thresholdHighlight } from "./threshold-highlight";
|
|
31
|
+
export { thresholdX } from "./threshold-x";
|
|
32
|
+
export { thresholdY } from "./threshold-y";
|
|
33
|
+
export { topN } from "./top-n";
|
|
34
|
+
export { valley } from "./valley";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { selectRows } from "../utils";
|
|
2
|
+
import { highlight } from "./highlight";
|
|
3
|
+
export var last = {
|
|
4
|
+
g2: function g2(annotations, _ref) {
|
|
5
|
+
var mapping = _ref.mapping;
|
|
6
|
+
return annotations.flatMap(function (annotation) {
|
|
7
|
+
var rows = selectRows(mapping.data, annotation.data);
|
|
8
|
+
return rows.slice(-1).flatMap(function (row) {
|
|
9
|
+
var _annotation$label;
|
|
10
|
+
return highlight.create({
|
|
11
|
+
data: [row],
|
|
12
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Last: ".concat(row[mapping.y]),
|
|
13
|
+
style: annotation.style
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { selectExtreme, selectRows } from "../utils";
|
|
2
|
+
import { highlight } from "./highlight";
|
|
3
|
+
export var maxX = {
|
|
4
|
+
g2: function g2(annotations, _ref) {
|
|
5
|
+
var mapping = _ref.mapping;
|
|
6
|
+
return annotations.flatMap(function (annotation) {
|
|
7
|
+
return selectExtreme(selectRows(mapping.data, annotation.data), mapping.x, true, true).flatMap(function (row) {
|
|
8
|
+
var _annotation$label;
|
|
9
|
+
return highlight.create({
|
|
10
|
+
data: [row],
|
|
11
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Max X: ".concat(row[mapping.x]),
|
|
12
|
+
style: annotation.style
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { selectExtreme, selectRows } from "../utils";
|
|
2
|
+
import { highlight } from "./highlight";
|
|
3
|
+
export var maxY = {
|
|
4
|
+
g2: function g2(annotations, _ref) {
|
|
5
|
+
var mapping = _ref.mapping;
|
|
6
|
+
return annotations.flatMap(function (annotation) {
|
|
7
|
+
return selectExtreme(selectRows(mapping.data, annotation.data), mapping.y, true, false).flatMap(function (row) {
|
|
8
|
+
var _annotation$label;
|
|
9
|
+
return highlight.create({
|
|
10
|
+
data: [row],
|
|
11
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Max Y: ".concat(row[mapping.y]),
|
|
12
|
+
style: annotation.style
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { annotationField, axisPosition, formatNumber, numericRows, selectRows } from "../utils";
|
|
8
|
+
import { path } from "./path";
|
|
9
|
+
export var mean = {
|
|
10
|
+
g2: function g2(annotations, _ref) {
|
|
11
|
+
var mapping = _ref.mapping;
|
|
12
|
+
return annotations.flatMap(function (annotation) {
|
|
13
|
+
var _annotation$label;
|
|
14
|
+
var field = annotationField(mapping, annotation.axis);
|
|
15
|
+
var values = numericRows(selectRows(mapping.data, annotation.data), field).map(function (_ref2) {
|
|
16
|
+
var value = _ref2.value;
|
|
17
|
+
return value;
|
|
18
|
+
});
|
|
19
|
+
if (!values.length) return [];
|
|
20
|
+
var value = meanValue(values);
|
|
21
|
+
return path.create({
|
|
22
|
+
data: axisPosition(field, value),
|
|
23
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Mean: ".concat(formatNumber(value)),
|
|
24
|
+
style: _objectSpread({
|
|
25
|
+
lineDash: [4, 4]
|
|
26
|
+
}, annotation.style)
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Scale before summation to avoid overflowing finite means. */
|
|
33
|
+
function meanValue(values) {
|
|
34
|
+
var scale = values.reduce(function (max, value) {
|
|
35
|
+
return Math.max(max, Math.abs(value));
|
|
36
|
+
}, 0);
|
|
37
|
+
return scale === 0 ? 0 : values.reduce(function (sum, value) {
|
|
38
|
+
return sum + value / scale / values.length;
|
|
39
|
+
}, 0) * scale;
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { annotationField, axisPosition, formatNumber, numericRows, quantileValue, selectRows } from "../utils";
|
|
8
|
+
import { path } from "./path";
|
|
9
|
+
export var median = {
|
|
10
|
+
g2: function g2(annotations, _ref) {
|
|
11
|
+
var mapping = _ref.mapping;
|
|
12
|
+
return annotations.flatMap(function (annotation) {
|
|
13
|
+
var _annotation$label;
|
|
14
|
+
var field = annotationField(mapping, annotation.axis);
|
|
15
|
+
var values = numericRows(selectRows(mapping.data, annotation.data), field).map(function (_ref2) {
|
|
16
|
+
var value = _ref2.value;
|
|
17
|
+
return value;
|
|
18
|
+
});
|
|
19
|
+
if (!values.length) return [];
|
|
20
|
+
var value = quantileValue(values.sort(function (a, b) {
|
|
21
|
+
return a - b;
|
|
22
|
+
}), 0.5);
|
|
23
|
+
return path.create({
|
|
24
|
+
data: axisPosition(field, value),
|
|
25
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Median: ".concat(formatNumber(value)),
|
|
26
|
+
style: _objectSpread({
|
|
27
|
+
lineDash: [4, 4]
|
|
28
|
+
}, annotation.style)
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { selectExtreme, selectRows } from "../utils";
|
|
2
|
+
import { highlight } from "./highlight";
|
|
3
|
+
export var minX = {
|
|
4
|
+
g2: function g2(annotations, _ref) {
|
|
5
|
+
var mapping = _ref.mapping;
|
|
6
|
+
return annotations.flatMap(function (annotation) {
|
|
7
|
+
return selectExtreme(selectRows(mapping.data, annotation.data), mapping.x, false, true).flatMap(function (row) {
|
|
8
|
+
var _annotation$label;
|
|
9
|
+
return highlight.create({
|
|
10
|
+
data: [row],
|
|
11
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Min X: ".concat(row[mapping.x]),
|
|
12
|
+
style: annotation.style
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { selectExtreme, selectRows } from "../utils";
|
|
2
|
+
import { highlight } from "./highlight";
|
|
3
|
+
export var minY = {
|
|
4
|
+
g2: function g2(annotations, _ref) {
|
|
5
|
+
var mapping = _ref.mapping;
|
|
6
|
+
return annotations.flatMap(function (annotation) {
|
|
7
|
+
return selectExtreme(selectRows(mapping.data, annotation.data), mapping.y, false, false).flatMap(function (row) {
|
|
8
|
+
var _annotation$label;
|
|
9
|
+
return highlight.create({
|
|
10
|
+
data: [row],
|
|
11
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Min Y: ".concat(row[mapping.y]),
|
|
12
|
+
style: annotation.style
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
+
import { numericRows, quantileValue, selectRows } from "../utils";
|
|
5
|
+
import { highlight } from "./highlight";
|
|
6
|
+
|
|
7
|
+
/** Tukey's IQR fences, matching G2 boxplots; each series is analyzed independently. */
|
|
8
|
+
export var outlier = {
|
|
9
|
+
g2: function g2(annotations, _ref) {
|
|
10
|
+
var mapping = _ref.mapping;
|
|
11
|
+
return annotations.flatMap(function (annotation) {
|
|
12
|
+
return selectOutliers(selectRows(mapping.data, annotation.data), mapping.y, annotation.factor, mapping.series).flatMap(function (row) {
|
|
13
|
+
var _annotation$label;
|
|
14
|
+
return highlight.create({
|
|
15
|
+
data: [row],
|
|
16
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Outlier: ".concat(row[mapping.y]),
|
|
17
|
+
style: annotation.style
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
table: function table(annotations, _ref2) {
|
|
23
|
+
var data = _ref2.data;
|
|
24
|
+
return annotations.flatMap(function (annotation) {
|
|
25
|
+
return selectOutliers(selectRows(data, annotation.data.row), annotation.data.field, annotation.factor).flatMap(function (row) {
|
|
26
|
+
var _annotation$label2;
|
|
27
|
+
return highlight.create({
|
|
28
|
+
data: [{
|
|
29
|
+
row: row,
|
|
30
|
+
column: annotation.data.column
|
|
31
|
+
}],
|
|
32
|
+
label: (_annotation$label2 = annotation.label) !== null && _annotation$label2 !== void 0 ? _annotation$label2 : "Outlier: ".concat(row[annotation.data.field]),
|
|
33
|
+
style: annotation.style
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
function selectOutliers(data, field) {
|
|
40
|
+
var factor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.5;
|
|
41
|
+
var series = arguments.length > 3 ? arguments[3] : undefined;
|
|
42
|
+
if (!Number.isFinite(factor) || factor <= 0) throw new Error('Invalid annotation: outlier factor must be positive and finite.');
|
|
43
|
+
var groups = new Map();
|
|
44
|
+
var _iterator = _createForOfIteratorHelper(numericRows(data, field)),
|
|
45
|
+
_step;
|
|
46
|
+
try {
|
|
47
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
48
|
+
var item = _step.value;
|
|
49
|
+
var key = series ? item.row[series] : undefined;
|
|
50
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
51
|
+
groups.get(key).push(item);
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_iterator.e(err);
|
|
55
|
+
} finally {
|
|
56
|
+
_iterator.f();
|
|
57
|
+
}
|
|
58
|
+
var selected = new Set();
|
|
59
|
+
var _iterator2 = _createForOfIteratorHelper(groups.values()),
|
|
60
|
+
_step2;
|
|
61
|
+
try {
|
|
62
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
63
|
+
var items = _step2.value;
|
|
64
|
+
// Quartile-based detection is uninformative for fewer than four finite observations.
|
|
65
|
+
if (items.length < 4) continue;
|
|
66
|
+
var values = items.map(function (_ref3) {
|
|
67
|
+
var value = _ref3.value;
|
|
68
|
+
return value;
|
|
69
|
+
}).sort(function (a, b) {
|
|
70
|
+
return a - b;
|
|
71
|
+
});
|
|
72
|
+
var q1 = quantileValue(values, 0.25);
|
|
73
|
+
var q3 = quantileValue(values, 0.75);
|
|
74
|
+
var spread = factor * (q3 - q1);
|
|
75
|
+
var _iterator3 = _createForOfIteratorHelper(items),
|
|
76
|
+
_step3;
|
|
77
|
+
try {
|
|
78
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
79
|
+
var _step3$value = _step3.value,
|
|
80
|
+
row = _step3$value.row,
|
|
81
|
+
value = _step3$value.value;
|
|
82
|
+
if (value < q1 - spread || value > q3 + spread) selected.add(row);
|
|
83
|
+
}
|
|
84
|
+
} catch (err) {
|
|
85
|
+
_iterator3.e(err);
|
|
86
|
+
} finally {
|
|
87
|
+
_iterator3.f();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
_iterator2.e(err);
|
|
92
|
+
} finally {
|
|
93
|
+
_iterator2.f();
|
|
94
|
+
}
|
|
95
|
+
return data.filter(function (row) {
|
|
96
|
+
return selected.has(row);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/** One axis value spans a chart; multiple anchors form an ordered path. */
|
|
6
|
+
export declare const path: AnnotationComponent<'path', 'g2' | 'g6'> & {
|
|
7
|
+
create: typeof createPath;
|
|
8
|
+
};
|
|
9
|
+
type Region = {
|
|
10
|
+
fill: string;
|
|
11
|
+
fillOpacity: number;
|
|
12
|
+
visible?: () => boolean;
|
|
13
|
+
positions?: (context: Pick<G2AnnotationContext<object>, 'library' | 'axisValue' | 'getScene'>, coordinate: Parameters<G2AnnotationContext<object>['position']>[1]) => Point[][];
|
|
14
|
+
};
|
|
15
|
+
declare function createPath<T extends object>(options: Omit<Extract<Annotation<T>, {
|
|
16
|
+
type: 'path';
|
|
17
|
+
}>, 'type'>, region?: Region): Extract<Annotation<T>, {
|
|
18
|
+
type: 'path';
|
|
19
|
+
}>[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
/** One axis value spans a chart; multiple anchors form an ordered path. */
|
|
15
|
+
export var path = {
|
|
16
|
+
create: createPath,
|
|
17
|
+
g2: function g2() {
|
|
18
|
+
return drawG2;
|
|
19
|
+
},
|
|
20
|
+
g6: function g6() {
|
|
21
|
+
return drawG6;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var regions = new WeakMap();
|
|
25
|
+
function createPath(options, region) {
|
|
26
|
+
var annotation = _objectSpread(_objectSpread({}, options), {}, {
|
|
27
|
+
type: 'path'
|
|
28
|
+
});
|
|
29
|
+
if (region) regions.set(annotation, region);
|
|
30
|
+
return [annotation];
|
|
31
|
+
}
|
|
32
|
+
var drawG2 = function drawG2(annotations, context) {
|
|
33
|
+
var defaults = context.defaults,
|
|
34
|
+
mapping = context.mapping;
|
|
35
|
+
return {
|
|
36
|
+
marks: annotations.map(function (annotation) {
|
|
37
|
+
var region = regions.get(annotation);
|
|
38
|
+
var connected = Array.isArray(annotation.data);
|
|
39
|
+
var axis = !Array.isArray(annotation.data) && annotation.data[mapping.x] !== undefined;
|
|
40
|
+
var style = getStyle(annotation.style, defaults, connected ? defaults.stroke : defaults.labels.path.fill);
|
|
41
|
+
var labelPoints = [];
|
|
42
|
+
var resolved = [];
|
|
43
|
+
return context.createMark(annotation, {
|
|
44
|
+
nativeType: connected ? 'line' : axis ? 'lineX' : 'lineY',
|
|
45
|
+
style: _objectSpread(_objectSpread({}, style), region ? {
|
|
46
|
+
fill: region.fill,
|
|
47
|
+
fillOpacity: region.fillOpacity,
|
|
48
|
+
lineWidth: 0
|
|
49
|
+
} : {}),
|
|
50
|
+
data: region !== null && region !== void 0 && region.positions ? function (coordinate) {
|
|
51
|
+
var _region$visible;
|
|
52
|
+
resolved = ((_region$visible = region.visible) === null || _region$visible === void 0 ? void 0 : _region$visible.call(region)) === false ? [] : region.positions(context, coordinate);
|
|
53
|
+
return resolved.map(function (positions) {
|
|
54
|
+
return {
|
|
55
|
+
positions: positions
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
} : undefined,
|
|
59
|
+
zIndex: region ? -1 : 1,
|
|
60
|
+
clip: !!region,
|
|
61
|
+
label: _objectSpread(_objectSpread({}, connected ? {
|
|
62
|
+
selector: 'last'
|
|
63
|
+
} : {}), {}, {
|
|
64
|
+
annotationPath: function annotationPath() {
|
|
65
|
+
return connected ? labelPoints.slice(-1) : labelPoints;
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
decorate: function decorate(element, points) {
|
|
69
|
+
labelPoints = points;
|
|
70
|
+
if (region) element.setAttribute('annotationIgnoreObstacle', true);
|
|
71
|
+
element.setAttribute('annotationSegments', points.slice(1).map(function (point, i) {
|
|
72
|
+
return [points[i], point];
|
|
73
|
+
}));
|
|
74
|
+
},
|
|
75
|
+
geometry: function geometry(native) {
|
|
76
|
+
return function (_index, scale, value, coordinate) {
|
|
77
|
+
var _region$visible2;
|
|
78
|
+
if ((region === null || region === void 0 || (_region$visible2 = region.visible) === null || _region$visible2 === void 0 ? void 0 : _region$visible2.call(region)) === false) return [[], []];
|
|
79
|
+
if (region !== null && region !== void 0 && region.positions) return [resolved.map(function (_, i) {
|
|
80
|
+
return i;
|
|
81
|
+
}), resolved.map(function (points) {
|
|
82
|
+
return points.map(function (position) {
|
|
83
|
+
return coordinate.map(position);
|
|
84
|
+
});
|
|
85
|
+
})];
|
|
86
|
+
if (!Array.isArray(annotation.data)) {
|
|
87
|
+
var x = annotation.data[mapping.x];
|
|
88
|
+
var y = annotation.data[mapping.y];
|
|
89
|
+
return native([0], scale, _objectSpread(_objectSpread({}, value), {}, {
|
|
90
|
+
x: [x === undefined ? 0 : context.axisValue('x', x)],
|
|
91
|
+
y: [y === undefined ? 0 : context.axisValue('y', y)]
|
|
92
|
+
}), coordinate);
|
|
93
|
+
}
|
|
94
|
+
var positions = annotation.data.map(function (datum) {
|
|
95
|
+
return context.position(datum, coordinate);
|
|
96
|
+
});
|
|
97
|
+
if (positions.some(function (point) {
|
|
98
|
+
return !point;
|
|
99
|
+
})) return [[], []];
|
|
100
|
+
var points = positions;
|
|
101
|
+
return native(points.map(function (_, i) {
|
|
102
|
+
return i;
|
|
103
|
+
}), scale, _objectSpread(_objectSpread({}, value), {}, {
|
|
104
|
+
x: points.map(function (p) {
|
|
105
|
+
return p[0];
|
|
106
|
+
}),
|
|
107
|
+
y: points.map(function (p) {
|
|
108
|
+
return p[1];
|
|
109
|
+
})
|
|
110
|
+
}), coordinate);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
})
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
var drawG6 = function drawG6(annotations, context) {
|
|
118
|
+
var _iterator = _createForOfIteratorHelper(annotations),
|
|
119
|
+
_step;
|
|
120
|
+
try {
|
|
121
|
+
var _loop = function _loop() {
|
|
122
|
+
var annotation = _step.value;
|
|
123
|
+
if (!Array.isArray(annotation.data)) throw new Error('Invalid annotation: graph path needs an array of anchors.');
|
|
124
|
+
var positions = annotation.data.map(function (datum) {
|
|
125
|
+
return context.position(datum);
|
|
126
|
+
});
|
|
127
|
+
if (positions.some(function (point) {
|
|
128
|
+
return !point;
|
|
129
|
+
})) return 1; // continue
|
|
130
|
+
var points = positions;
|
|
131
|
+
points.slice(1).forEach(function (point, index) {
|
|
132
|
+
return context.segments.push([points[index], point]);
|
|
133
|
+
});
|
|
134
|
+
context.add('path', _objectSpread(_objectSpread({}, getStyle(annotation.style, context.defaults)), {}, {
|
|
135
|
+
d: points.map(function (_ref, i) {
|
|
136
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
137
|
+
x = _ref2[0],
|
|
138
|
+
y = _ref2[1];
|
|
139
|
+
return [i ? 'L' : 'M', x, y];
|
|
140
|
+
})
|
|
141
|
+
}));
|
|
142
|
+
context.label(_objectSpread(_objectSpread({}, annotation), {}, {
|
|
143
|
+
data: annotation.data
|
|
144
|
+
}), points[points.length - 1]);
|
|
145
|
+
};
|
|
146
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
147
|
+
if (_loop()) continue;
|
|
148
|
+
}
|
|
149
|
+
} catch (err) {
|
|
150
|
+
_iterator.e(err);
|
|
151
|
+
} finally {
|
|
152
|
+
_iterator.f();
|
|
153
|
+
}
|
|
154
|
+
return {};
|
|
155
|
+
};
|
|
156
|
+
function getStyle(style, defaults) {
|
|
157
|
+
var _style$stroke, _style$lineWidth;
|
|
158
|
+
var stroke = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaults.stroke;
|
|
159
|
+
return {
|
|
160
|
+
stroke: (_style$stroke = style === null || style === void 0 ? void 0 : style.stroke) !== null && _style$stroke !== void 0 ? _style$stroke : stroke,
|
|
161
|
+
lineWidth: (_style$lineWidth = style === null || style === void 0 ? void 0 : style.lineWidth) !== null && _style$lineWidth !== void 0 ? _style$lineWidth : defaults.lineWidth.path,
|
|
162
|
+
lineDash: style === null || style === void 0 ? void 0 : style.lineDash,
|
|
163
|
+
fill: 'none'
|
|
164
|
+
};
|
|
165
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { selectLocalExtrema, selectRows } from "../utils";
|
|
2
|
+
import { highlight } from "./highlight";
|
|
3
|
+
export var peak = {
|
|
4
|
+
g2: function g2(annotations, _ref) {
|
|
5
|
+
var mapping = _ref.mapping;
|
|
6
|
+
return annotations.flatMap(function (annotation) {
|
|
7
|
+
var selected = new Set(selectRows(mapping.data, annotation.data));
|
|
8
|
+
return selectLocalExtrema(mapping.data, mapping.y, true, mapping.series, annotation).filter(function (row) {
|
|
9
|
+
return selected.has(row);
|
|
10
|
+
}).flatMap(function (row) {
|
|
11
|
+
var _annotation$label;
|
|
12
|
+
return highlight.create({
|
|
13
|
+
data: [row],
|
|
14
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Peak: ".concat(row[mapping.y]),
|
|
15
|
+
style: annotation.style
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -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 {};
|