@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
|
@@ -25,8 +25,6 @@ module.exports = __toCommonJS(radar_exports);
|
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
27
|
var import_util = require("../../util");
|
|
28
|
-
var import_components = require("../../util/components");
|
|
29
|
-
var import_tokens = require("../../util/tokens");
|
|
30
28
|
function transformRadarToParallel(data) {
|
|
31
29
|
if (!data || data.length === 0) {
|
|
32
30
|
return [];
|
|
@@ -69,17 +67,17 @@ var Radar = (options) => {
|
|
|
69
67
|
const appearance = (0, import_g22.getThemeObject)("radar", theme, localStyle);
|
|
70
68
|
const { theme: rendererTheme } = appearance;
|
|
71
69
|
const lineMark = {
|
|
72
|
-
lineWidth:
|
|
70
|
+
lineWidth: import_util.CHART_STYLE_DEFAULTS.lineWidth,
|
|
73
71
|
lineCap: "round",
|
|
74
72
|
lineJoin: "round",
|
|
75
|
-
strokeOpacity:
|
|
73
|
+
strokeOpacity: import_util.CHART_STYLE_DEFAULTS.lineOpacity,
|
|
76
74
|
...appearance.mark.line
|
|
77
75
|
};
|
|
78
|
-
const lineWidth = lineMark.lineWidth ??
|
|
76
|
+
const lineWidth = lineMark.lineWidth ?? import_util.CHART_STYLE_DEFAULTS.lineWidth;
|
|
79
77
|
const colors = rendererTheme.category10;
|
|
80
78
|
const position = Object.keys(parallelData[0] || {}).filter((key) => key !== "group");
|
|
81
79
|
const hasMultipleSeries = parallelData.length > 1;
|
|
82
|
-
const legend = (0,
|
|
80
|
+
const legend = (0, import_util.getColorLegend)(parallelData.length > 1);
|
|
83
81
|
chart = new import_g2.Chart({
|
|
84
82
|
container,
|
|
85
83
|
width,
|
|
@@ -74,9 +74,22 @@ var Sankey = (options) => {
|
|
|
74
74
|
style: {
|
|
75
75
|
labelSpacing: 2,
|
|
76
76
|
nodeLineWidth: 1,
|
|
77
|
-
|
|
77
|
+
nodeFillOpacity: 0.5,
|
|
78
|
+
linkFillOpacity: 0.5,
|
|
78
79
|
...sankeyStyle
|
|
79
80
|
},
|
|
81
|
+
state: {
|
|
82
|
+
active: {
|
|
83
|
+
fillOpacity: 1
|
|
84
|
+
},
|
|
85
|
+
inactive: {
|
|
86
|
+
nodeFillOpacity: sankeyStyle.nodeFillOpacity ?? 0.5,
|
|
87
|
+
linkFillOpacity: sankeyStyle.linkFillOpacity ?? 0.5
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
interaction: {
|
|
91
|
+
elementHighlight: true
|
|
92
|
+
},
|
|
80
93
|
theme: rendererTheme,
|
|
81
94
|
legend: false,
|
|
82
95
|
tooltip: false
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RendererAnnotation } from '../../annotation/registry';
|
|
1
2
|
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
3
|
/**
|
|
3
4
|
* ScatterDataItem is the type for each data item in the scatter chart.
|
|
@@ -7,24 +8,29 @@ export type ScatterDataItem = {
|
|
|
7
8
|
y: number;
|
|
8
9
|
group?: string;
|
|
9
10
|
};
|
|
11
|
+
/** Accept business fields without requiring caller interfaces to have an index signature. */
|
|
12
|
+
type ScatterRow = ScatterDataItem | (ScatterDataItem & Record<string, unknown>);
|
|
13
|
+
/** Distribute row alternatives so custom selector and weight fields remain available. */
|
|
14
|
+
type ScatterAnnotation<T extends ScatterDataItem> = T extends ScatterDataItem ? RendererAnnotation<T, 'g2', 'scatter'> : never;
|
|
10
15
|
/**
|
|
11
16
|
* ScatterConfig defines the configuration for rendering the scatter chart.
|
|
12
17
|
*/
|
|
13
|
-
export interface ScatterConfig {
|
|
18
|
+
export interface ScatterConfig<T extends ScatterDataItem = ScatterRow> {
|
|
14
19
|
type?: 'scatter';
|
|
15
|
-
data:
|
|
20
|
+
data: T[];
|
|
16
21
|
title?: string;
|
|
17
22
|
subtitle?: string;
|
|
18
23
|
axisXTitle?: string;
|
|
19
24
|
axisYTitle?: string;
|
|
20
25
|
theme?: VisualizationTheme;
|
|
21
26
|
style?: ThemeStyle;
|
|
27
|
+
annotations?: ScatterAnnotation<T>[];
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* ScatterInstance represents a scatter chart instance with render and destroy methods.
|
|
25
31
|
*/
|
|
26
32
|
export interface ScatterInstance {
|
|
27
|
-
render: (config: ScatterConfig) => void;
|
|
33
|
+
render: <T extends ScatterDataItem>(config: ScatterConfig<T>) => void;
|
|
28
34
|
destroy: () => void;
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
@@ -52,3 +58,4 @@ export interface ScatterInstance {
|
|
|
52
58
|
* ```
|
|
53
59
|
*/
|
|
54
60
|
export declare const Scatter: (options: VisualizationOptions) => ScatterInstance;
|
|
61
|
+
export {};
|
|
@@ -23,14 +23,14 @@ __export(scatter_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(scatter_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_annotation = require("../../annotation");
|
|
26
27
|
var import_g22 = require("../../theme/g2");
|
|
27
28
|
var import_util = require("../../util");
|
|
28
|
-
var import_components = require("../../util/components");
|
|
29
|
-
var import_tokens = require("../../util/tokens");
|
|
30
29
|
var Scatter = (options) => {
|
|
31
30
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
32
31
|
let chart = null;
|
|
33
32
|
let hasRendered = false;
|
|
33
|
+
let cleanupAnnotations;
|
|
34
34
|
const render = (config) => {
|
|
35
35
|
var _a;
|
|
36
36
|
const {
|
|
@@ -43,6 +43,7 @@ var Scatter = (options) => {
|
|
|
43
43
|
style: localStyle = {}
|
|
44
44
|
} = config;
|
|
45
45
|
if (chart) {
|
|
46
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
46
47
|
chart.destroy();
|
|
47
48
|
}
|
|
48
49
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
@@ -50,8 +51,8 @@ var Scatter = (options) => {
|
|
|
50
51
|
const { theme: rendererTheme } = appearance;
|
|
51
52
|
const pointStyle = {
|
|
52
53
|
shape: "point",
|
|
53
|
-
size:
|
|
54
|
-
lineWidth:
|
|
54
|
+
size: import_util.CHART_STYLE_DEFAULTS.scatterPointSize,
|
|
55
|
+
lineWidth: import_util.CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
55
56
|
fillOpacity: 0.88,
|
|
56
57
|
stroke: rendererTheme.view.viewFill,
|
|
57
58
|
...appearance.mark.point
|
|
@@ -90,9 +91,9 @@ var Scatter = (options) => {
|
|
|
90
91
|
data,
|
|
91
92
|
title: title ? { title, subtitle } : "",
|
|
92
93
|
encode,
|
|
93
|
-
legend: (0,
|
|
94
|
+
legend: (0, import_util.getColorLegend)(hasGroupField),
|
|
94
95
|
scale: scaleConfig,
|
|
95
|
-
axis: (0, import_util.getCartesianAxis)({ axisXTitle, axisYTitle }),
|
|
96
|
+
axis: (0, import_util.getCartesianAxis)({ axisXTitle, axisYTitle, xType: "number" }, rendererTheme),
|
|
96
97
|
style: {
|
|
97
98
|
...pointMark,
|
|
98
99
|
...!hasGroupField ? { fill: colors[0] } : {}
|
|
@@ -109,15 +110,25 @@ var Scatter = (options) => {
|
|
|
109
110
|
},
|
|
110
111
|
interaction: {
|
|
111
112
|
tooltip: true,
|
|
112
|
-
elementHighlight: { delay:
|
|
113
|
+
elementHighlight: { delay: import_util.CHART_STYLE_DEFAULTS.interactionDelay }
|
|
113
114
|
},
|
|
114
115
|
theme: rendererTheme
|
|
115
116
|
};
|
|
116
117
|
chart.options(chartOptions);
|
|
118
|
+
cleanupAnnotations = (0, import_annotation.bindAnnotations)({
|
|
119
|
+
renderer: "g2",
|
|
120
|
+
chartType: "scatter",
|
|
121
|
+
chart,
|
|
122
|
+
annotations: config.annotations,
|
|
123
|
+
mapping: { x: "x", y: "y", series: hasGroupField ? "group" : void 0, data },
|
|
124
|
+
themeObject: appearance
|
|
125
|
+
});
|
|
117
126
|
chart.render();
|
|
118
127
|
hasRendered = true;
|
|
119
128
|
};
|
|
120
129
|
const destroy = () => {
|
|
130
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
131
|
+
cleanupAnnotations = void 0;
|
|
121
132
|
if (chart) {
|
|
122
133
|
chart.destroy();
|
|
123
134
|
chart = null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RendererAnnotation } from '../../annotation/registry';
|
|
2
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* T8 syntax, or an object pairing syntax with text highlight annotations.
|
|
4
5
|
* Supports markdown-like syntax with special annotations for metrics.
|
|
5
6
|
* @example
|
|
6
7
|
* ```
|
|
@@ -8,7 +9,15 @@ import type { VisualizationOptions } from '../../types';
|
|
|
8
9
|
* Total sales reached [¥1,234,567](metric_value, origin=1234567).
|
|
9
10
|
* ```
|
|
10
11
|
*/
|
|
11
|
-
export type SummaryConfig = string
|
|
12
|
+
export type SummaryConfig = string | {
|
|
13
|
+
type?: 'summary';
|
|
14
|
+
text: string;
|
|
15
|
+
theme?: VisualizationTheme;
|
|
16
|
+
style?: ThemeStyle;
|
|
17
|
+
annotations?: RendererAnnotation<{
|
|
18
|
+
text: string;
|
|
19
|
+
}, 'summary', 'summary'>[];
|
|
20
|
+
};
|
|
12
21
|
/**
|
|
13
22
|
* SummaryInstance represents a summary instance with render and destroy methods.
|
|
14
23
|
*/
|
|
@@ -23,10 +23,10 @@ __export(summary_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(summary_exports);
|
|
25
25
|
var import_t8 = require("@antv/t8");
|
|
26
|
+
var import_annotation = require("../../annotation");
|
|
27
|
+
var import_annotation2 = require("../../theme/annotation");
|
|
26
28
|
var import_summary = require("../../theme/summary");
|
|
27
29
|
var Summary = (options) => {
|
|
28
|
-
const appearance = (0, import_summary.getThemeObject)("summary", options.theme);
|
|
29
|
-
const { theme } = appearance;
|
|
30
30
|
const container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
|
|
31
31
|
if (!container) {
|
|
32
32
|
throw new Error("Container not found");
|
|
@@ -35,29 +35,47 @@ var Summary = (options) => {
|
|
|
35
35
|
wrapper.className = "gpt-vis-summary";
|
|
36
36
|
container.appendChild(wrapper);
|
|
37
37
|
let text = null;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
38
|
+
let cleanupAnnotations;
|
|
39
|
+
const render = (config) => {
|
|
40
|
+
const input = typeof config === "string" ? { text: config } : config;
|
|
41
|
+
const { text: syntax, annotations, theme = options.theme, style: localStyle } = input;
|
|
42
|
+
const appearance = (0, import_summary.getThemeObject)("summary", theme, localStyle);
|
|
43
|
+
let activeTheme = appearance.theme;
|
|
43
44
|
const cleanedSyntax = syntax.replace(/^theme\s+(light|dark)\s*$/im, (_, t) => {
|
|
44
45
|
activeTheme = t;
|
|
45
46
|
return "";
|
|
46
47
|
});
|
|
47
|
-
|
|
48
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
49
|
+
cleanupAnnotations = void 0;
|
|
50
|
+
text == null ? void 0 : text.unmount();
|
|
51
|
+
const content = document.createElement("div");
|
|
52
|
+
wrapper.textContent = "";
|
|
53
|
+
wrapper.appendChild(content);
|
|
54
|
+
text = new import_t8.Text(content);
|
|
48
55
|
wrapper.style.backgroundColor = appearance.backgrounds[activeTheme];
|
|
49
56
|
wrapper.style.padding = "16px";
|
|
50
57
|
text.theme(activeTheme, appearance.summary);
|
|
51
58
|
text.render(cleanedSyntax.trim());
|
|
59
|
+
cleanupAnnotations = (0, import_annotation.bindAnnotations)({
|
|
60
|
+
renderer: "summary",
|
|
61
|
+
container: wrapper,
|
|
62
|
+
content,
|
|
63
|
+
annotations,
|
|
64
|
+
defaults: (0, import_annotation2.getAnnotationDefaults)(
|
|
65
|
+
"summary",
|
|
66
|
+
activeTheme === appearance.theme ? theme : activeTheme,
|
|
67
|
+
localStyle
|
|
68
|
+
)
|
|
69
|
+
});
|
|
52
70
|
};
|
|
53
71
|
const destroy = () => {
|
|
72
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
73
|
+
cleanupAnnotations = void 0;
|
|
54
74
|
if (text) {
|
|
55
75
|
text.unmount();
|
|
56
76
|
text = null;
|
|
57
77
|
}
|
|
58
|
-
|
|
59
|
-
wrapper.parentNode.removeChild(wrapper);
|
|
60
|
-
}
|
|
78
|
+
wrapper.remove();
|
|
61
79
|
};
|
|
62
80
|
return {
|
|
63
81
|
render,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RendererAnnotation } from '../../annotation/registry';
|
|
1
2
|
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
3
|
/**
|
|
3
4
|
* TableConfig defines the configuration for rendering the table.
|
|
@@ -9,6 +10,7 @@ export interface TableConfig {
|
|
|
9
10
|
subtitle?: string;
|
|
10
11
|
theme?: VisualizationTheme;
|
|
11
12
|
style?: ThemeStyle;
|
|
13
|
+
annotations?: RendererAnnotation<Record<string, unknown>, 'table', 'table'>[];
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* TableInstance represents a table instance with render and destroy methods.
|
|
@@ -24,8 +24,10 @@ __export(table_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(table_exports);
|
|
26
26
|
var import_measury = require("measury");
|
|
27
|
+
var import_annotation = require("../../annotation");
|
|
28
|
+
var import_annotation2 = require("../../theme/annotation");
|
|
27
29
|
var import_table = require("../../theme/table");
|
|
28
|
-
var
|
|
30
|
+
var import_util = require("../../util");
|
|
29
31
|
var SCOPE_ID = "__gpt-vis-table__";
|
|
30
32
|
var FONT_FAMILY = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
|
|
31
33
|
var CELL_PADDING = 16;
|
|
@@ -196,52 +198,68 @@ var Table = (options) => {
|
|
|
196
198
|
throw new Error("Container not found");
|
|
197
199
|
}
|
|
198
200
|
let tableWrapper = null;
|
|
201
|
+
let cleanupAnnotations;
|
|
199
202
|
const render = (config) => {
|
|
203
|
+
var _a;
|
|
200
204
|
const { data = [], title, subtitle, theme = chartTheme, style: localStyle = {} } = config;
|
|
201
205
|
const style = (0, import_table.getThemeObject)("table", theme, localStyle);
|
|
202
206
|
const { theme: rendererTheme } = style;
|
|
203
207
|
injectStyles();
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
tableWrapper
|
|
208
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
209
|
+
cleanupAnnotations = void 0;
|
|
210
|
+
tableWrapper == null ? void 0 : tableWrapper.remove();
|
|
211
|
+
const wrapper = document.createElement("div");
|
|
212
|
+
tableWrapper = wrapper;
|
|
213
|
+
container.appendChild(wrapper);
|
|
214
|
+
wrapper.className = SCOPE_ID;
|
|
209
215
|
if (rendererTheme === "dark") {
|
|
210
|
-
|
|
216
|
+
wrapper.setAttribute("data-theme", "dark");
|
|
211
217
|
}
|
|
212
218
|
if (style.backgroundColor)
|
|
213
|
-
|
|
219
|
+
wrapper.style.backgroundColor = style.backgroundColor;
|
|
214
220
|
const titleHTML = title || subtitle ? `<div class="table-heading">
|
|
215
|
-
${title ? `<div class="table-title">${(0,
|
|
216
|
-
${subtitle ? `<div class="table-subtitle">${(0,
|
|
221
|
+
${title ? `<div class="table-title">${(0, import_util.escapeHtml)(title)}</div>` : ""}
|
|
222
|
+
${subtitle ? `<div class="table-subtitle">${(0, import_util.escapeHtml)(subtitle)}</div>` : ""}
|
|
217
223
|
</div>` : "";
|
|
218
224
|
if (data.length === 0) {
|
|
219
|
-
|
|
225
|
+
wrapper.innerHTML = `
|
|
220
226
|
${titleHTML}
|
|
221
227
|
<div class="table-empty">No data available</div>
|
|
222
228
|
`;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
229
|
+
} else {
|
|
230
|
+
const columns = Object.keys(data[0]);
|
|
231
|
+
const minWidth = Math.max(calculateTableMinWidth(data, columns), columns.length * 100);
|
|
232
|
+
const headerHTML = columns.map((column) => `<th>${(0, import_util.escapeHtml)(column)}</th>`).join("");
|
|
233
|
+
const bodyHTML = data.map(
|
|
234
|
+
(row) => `<tr>${columns.map((column) => `<td>${(0, import_util.escapeHtml)(row[column])}</td>`).join("")}</tr>`
|
|
235
|
+
).join("");
|
|
236
|
+
wrapper.innerHTML = `
|
|
237
|
+
${titleHTML}
|
|
238
|
+
<table style="min-width: ${minWidth}px;">
|
|
239
|
+
<thead><tr>${headerHTML}</tr></thead>
|
|
240
|
+
<tbody>${bodyHTML}</tbody>
|
|
241
|
+
</table>
|
|
242
|
+
`;
|
|
243
|
+
}
|
|
244
|
+
applyResolvedTableStyle(wrapper, style);
|
|
245
|
+
if ((_a = config.annotations) == null ? void 0 : _a.length) {
|
|
246
|
+
const content = document.createElement("div");
|
|
247
|
+
content.style.overflow = "auto";
|
|
248
|
+
content.append(...wrapper.childNodes);
|
|
249
|
+
wrapper.appendChild(content);
|
|
250
|
+
cleanupAnnotations = (0, import_annotation.bindAnnotations)({
|
|
251
|
+
renderer: "table",
|
|
252
|
+
container: wrapper,
|
|
253
|
+
content,
|
|
254
|
+
data,
|
|
255
|
+
annotations: config.annotations,
|
|
256
|
+
defaults: (0, import_annotation2.getAnnotationDefaults)("table", theme, localStyle)
|
|
257
|
+
});
|
|
226
258
|
}
|
|
227
|
-
const columns = Object.keys(data[0]);
|
|
228
|
-
let minWidth = calculateTableMinWidth(data, columns);
|
|
229
|
-
minWidth = Math.max(minWidth, columns.length * 100);
|
|
230
|
-
const headerHTML = columns.map((column) => `<th>${(0, import_html.escapeHtml)(column)}</th>`).join("");
|
|
231
|
-
const bodyHTML = data.map(
|
|
232
|
-
(row) => `<tr>${columns.map((column) => `<td>${(0, import_html.escapeHtml)(row[column])}</td>`).join("")}</tr>`
|
|
233
|
-
).join("");
|
|
234
|
-
tableWrapper.innerHTML = `
|
|
235
|
-
${titleHTML}
|
|
236
|
-
<table style="min-width: ${minWidth}px;">
|
|
237
|
-
<thead><tr>${headerHTML}</tr></thead>
|
|
238
|
-
<tbody>${bodyHTML}</tbody>
|
|
239
|
-
</table>
|
|
240
|
-
`;
|
|
241
|
-
applyResolvedTableStyle(tableWrapper, style);
|
|
242
|
-
container.appendChild(tableWrapper);
|
|
243
259
|
};
|
|
244
260
|
const destroy = () => {
|
|
261
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
262
|
+
cleanupAnnotations = void 0;
|
|
245
263
|
if (tableWrapper) {
|
|
246
264
|
tableWrapper.remove();
|
|
247
265
|
tableWrapper = null;
|
|
@@ -24,7 +24,7 @@ __export(venn_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(venn_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
function normalizeVennSets(sets) {
|
|
29
29
|
if (Array.isArray(sets))
|
|
30
30
|
return sets.map((s) => String(s));
|
|
@@ -82,7 +82,7 @@ var Venn = (options) => {
|
|
|
82
82
|
opacity: (d) => normalizeVennSets(d.sets).length > 1 ? 1e-3 : 0.65,
|
|
83
83
|
...pathMark
|
|
84
84
|
},
|
|
85
|
-
labels: (0,
|
|
85
|
+
labels: (0, import_util.getDataLabels)(rendererTheme, {
|
|
86
86
|
style: { fillOpacity: 0.85, fontSize: 10 },
|
|
87
87
|
defaultVisible: true,
|
|
88
88
|
position: "inside",
|
|
@@ -24,7 +24,7 @@ __export(violin_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(violin_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
var Violin = (options) => {
|
|
29
29
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
30
30
|
let chart = null;
|
|
@@ -54,7 +54,7 @@ var Violin = (options) => {
|
|
|
54
54
|
const colors = rendererTheme.category10;
|
|
55
55
|
const startAtZero = localStyle.startAtZero || false;
|
|
56
56
|
const densityStyle = appearance.mark.density;
|
|
57
|
-
const legend = (0,
|
|
57
|
+
const legend = (0, import_util.getColorLegend)(hasGroupField);
|
|
58
58
|
chart = new import_g2.Chart({
|
|
59
59
|
container,
|
|
60
60
|
width,
|
|
@@ -136,7 +136,18 @@ var Violin = (options) => {
|
|
|
136
136
|
type: "view",
|
|
137
137
|
data,
|
|
138
138
|
title: title ? { title, subtitle } : "",
|
|
139
|
-
axis: (0,
|
|
139
|
+
axis: (0, import_util.getCartesianAxis)(
|
|
140
|
+
{
|
|
141
|
+
xType: "category",
|
|
142
|
+
xValues: data.map(({ category }) => category),
|
|
143
|
+
container,
|
|
144
|
+
chartWidth: width,
|
|
145
|
+
chartHeight: height,
|
|
146
|
+
axisXTitle,
|
|
147
|
+
axisYTitle
|
|
148
|
+
},
|
|
149
|
+
rendererTheme
|
|
150
|
+
),
|
|
140
151
|
scale: {
|
|
141
152
|
y: { nice: true, zero: startAtZero }
|
|
142
153
|
},
|
|
@@ -24,7 +24,7 @@ __export(waterfall_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(waterfall_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
function transformWaterfallData(data) {
|
|
29
29
|
let cumulative = 0;
|
|
30
30
|
let lastIntermediateTotalEnd = 0;
|
|
@@ -99,6 +99,19 @@ var Waterfall = (options) => {
|
|
|
99
99
|
const [positiveColor, negativeColor, totalColor] = rendererTheme.category10;
|
|
100
100
|
const transformedData = transformWaterfallData(data);
|
|
101
101
|
const linkData = generateLinkData(transformedData);
|
|
102
|
+
const cartesianAxis = (0, import_util.getCartesianAxis)(
|
|
103
|
+
{
|
|
104
|
+
xType: "category",
|
|
105
|
+
xValues: data.map(({ category }) => category),
|
|
106
|
+
container,
|
|
107
|
+
chartWidth: width,
|
|
108
|
+
chartHeight: height,
|
|
109
|
+
axisXTitle,
|
|
110
|
+
axisYTitle
|
|
111
|
+
},
|
|
112
|
+
rendererTheme
|
|
113
|
+
);
|
|
114
|
+
cartesianAxis.y.labelFormatter = "~s";
|
|
102
115
|
chart = new import_g2.Chart({
|
|
103
116
|
container,
|
|
104
117
|
width,
|
|
@@ -110,11 +123,7 @@ var Waterfall = (options) => {
|
|
|
110
123
|
type: "view",
|
|
111
124
|
data: transformedData,
|
|
112
125
|
title: title ? { title, subtitle } : "",
|
|
113
|
-
|
|
114
|
-
axis: {
|
|
115
|
-
x: { title: axisXTitle || false },
|
|
116
|
-
y: { title: axisYTitle || false, labelFormatter: "~s" }
|
|
117
|
-
},
|
|
126
|
+
axis: cartesianAxis,
|
|
118
127
|
scale: {
|
|
119
128
|
y: { nice: true }
|
|
120
129
|
},
|
|
@@ -134,11 +143,10 @@ var Waterfall = (options) => {
|
|
|
134
143
|
},
|
|
135
144
|
...intervalMark
|
|
136
145
|
},
|
|
137
|
-
labels: (0,
|
|
146
|
+
labels: (0, import_util.getDataLabels)(rendererTheme, {
|
|
138
147
|
style: {
|
|
139
148
|
fontSize: 10,
|
|
140
|
-
fontWeight: 600
|
|
141
|
-
stroke: "#fff"
|
|
149
|
+
fontWeight: 600
|
|
142
150
|
},
|
|
143
151
|
defaultVisible: true,
|
|
144
152
|
text: "__value__",
|
|
@@ -24,9 +24,7 @@ __export(word_cloud_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(word_cloud_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
|
-
var
|
|
28
|
-
var import_interaction = require("../../util/interaction");
|
|
29
|
-
var import_tokens = require("../../util/tokens");
|
|
27
|
+
var import_util = require("../../util");
|
|
30
28
|
var WORD_CLOUD_MAX_WORDS = 50;
|
|
31
29
|
var WORD_CLOUD_FONT_FAMILY = "Impact";
|
|
32
30
|
var WORD_CLOUD_ROTATIONS = [-90, -60, -30, 0, 30, 60];
|
|
@@ -102,7 +100,7 @@ var WordCloud = (options) => {
|
|
|
102
100
|
locale: renderLocale = locale,
|
|
103
101
|
style: localStyle = {}
|
|
104
102
|
} = config;
|
|
105
|
-
const chartLocale = (0,
|
|
103
|
+
const chartLocale = (0, import_util.resolveChartLocale)(renderLocale);
|
|
106
104
|
const labels = WORD_CLOUD_LABELS[chartLocale];
|
|
107
105
|
const valueFormatter = new Intl.NumberFormat(chartLocale, {
|
|
108
106
|
maximumFractionDigits: 2
|
|
@@ -186,8 +184,8 @@ var WordCloud = (options) => {
|
|
|
186
184
|
},
|
|
187
185
|
interaction: {
|
|
188
186
|
tooltip: true,
|
|
189
|
-
elementHighlight: { delay:
|
|
190
|
-
elementHoverScale: (0,
|
|
187
|
+
elementHighlight: { delay: import_util.CHART_STYLE_DEFAULTS.interactionDelay },
|
|
188
|
+
elementHoverScale: (0, import_util.getElementHoverScaleInteraction)(rendererTheme.type)
|
|
191
189
|
},
|
|
192
190
|
theme: rendererTheme
|
|
193
191
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { rankedLabels } from "../label";
|
|
2
|
+
import { selectRank, selectRows } from "../utils";
|
|
3
|
+
import { highlight } from "./highlight";
|
|
4
|
+
export var bottomN = {
|
|
5
|
+
g2: function g2(annotations, _ref) {
|
|
6
|
+
var mapping = _ref.mapping;
|
|
7
|
+
return annotations.flatMap(function (annotation) {
|
|
8
|
+
var rows = selectRows(mapping.data, annotation.data);
|
|
9
|
+
var field = mapping.y;
|
|
10
|
+
return selectRank(rows, field, annotation.n, false).flatMap(function (row, index) {
|
|
11
|
+
var _annotation$label;
|
|
12
|
+
var highlights = highlight.create({
|
|
13
|
+
data: [row],
|
|
14
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Bottom ".concat(index + 1),
|
|
15
|
+
style: annotation.style
|
|
16
|
+
});
|
|
17
|
+
highlights.forEach(function (highlight) {
|
|
18
|
+
return rankedLabels.set(highlight, annotation);
|
|
19
|
+
});
|
|
20
|
+
return highlights;
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
table: function table(annotations, _ref2) {
|
|
25
|
+
var data = _ref2.data;
|
|
26
|
+
return annotations.flatMap(function (annotation) {
|
|
27
|
+
var rows = selectRows(data, annotation.data.row);
|
|
28
|
+
var field = annotation.data.field;
|
|
29
|
+
return selectRank(rows, field, annotation.n, false).flatMap(function (row, index) {
|
|
30
|
+
var _annotation$label2;
|
|
31
|
+
return highlight.create({
|
|
32
|
+
data: [{
|
|
33
|
+
row: row,
|
|
34
|
+
column: annotation.data.column
|
|
35
|
+
}],
|
|
36
|
+
label: (_annotation$label2 = annotation.label) !== null && _annotation$label2 !== void 0 ? _annotation$label2 : "Bottom ".concat(index + 1),
|
|
37
|
+
style: annotation.style
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
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 { finiteValue, numericRows, selectRows } from "../utils";
|
|
8
|
+
import { point } from "./point";
|
|
9
|
+
export var centroid = {
|
|
10
|
+
g2: function g2(annotations, _ref) {
|
|
11
|
+
var mapping = _ref.mapping,
|
|
12
|
+
defaults = _ref.defaults;
|
|
13
|
+
return annotations.flatMap(function (annotation) {
|
|
14
|
+
var _annotation$label, _annotation$pulse, _annotation$style$siz, _annotation$style, _annotation$style$lin, _annotation$style2, _annotation$style$fil, _annotation$style3, _annotation$style$str, _annotation$style4;
|
|
15
|
+
var rows = selectRows(mapping.data, annotation.data);
|
|
16
|
+
var xs = numericRows(rows, mapping.x);
|
|
17
|
+
var ys = new Set(numericRows(rows, mapping.y).map(function (_ref2) {
|
|
18
|
+
var row = _ref2.row;
|
|
19
|
+
return row;
|
|
20
|
+
}));
|
|
21
|
+
var selected = xs.filter(function (_ref3) {
|
|
22
|
+
var row = _ref3.row;
|
|
23
|
+
return ys.has(row);
|
|
24
|
+
}).map(function (_ref4) {
|
|
25
|
+
var row = _ref4.row;
|
|
26
|
+
return row;
|
|
27
|
+
});
|
|
28
|
+
if (!selected.length) return [];
|
|
29
|
+
var weights = selected.map(function (row) {
|
|
30
|
+
return annotation.weight === undefined ? 1 : finiteValue(row[annotation.weight], 'weight');
|
|
31
|
+
});
|
|
32
|
+
if (weights.some(function (weight) {
|
|
33
|
+
return weight < 0;
|
|
34
|
+
})) throw new Error('Invalid annotation: centroid weights must be nonnegative.');
|
|
35
|
+
var max = weights.reduce(function (a, b) {
|
|
36
|
+
return Math.max(a, b);
|
|
37
|
+
}, 0);
|
|
38
|
+
if (max === 0) throw new Error('Invalid annotation: centroid needs positive total weight.');
|
|
39
|
+
var normalized = weights.map(function (weight) {
|
|
40
|
+
return weight / max;
|
|
41
|
+
});
|
|
42
|
+
var total = normalized.reduce(function (a, b) {
|
|
43
|
+
return a + b;
|
|
44
|
+
}, 0);
|
|
45
|
+
var center = function center(field) {
|
|
46
|
+
var values = selected.map(function (row) {
|
|
47
|
+
return finiteValue(row[field], field);
|
|
48
|
+
});
|
|
49
|
+
var scale = values.reduce(function (a, b) {
|
|
50
|
+
return Math.max(a, Math.abs(b));
|
|
51
|
+
}, 0);
|
|
52
|
+
return scale === 0 ? 0 : values.reduce(function (sum, value, i) {
|
|
53
|
+
return sum + value / scale * (normalized[i] / total);
|
|
54
|
+
}, 0) * scale;
|
|
55
|
+
};
|
|
56
|
+
return point.create({
|
|
57
|
+
data: _defineProperty(_defineProperty({}, mapping.x, center(mapping.x)), mapping.y, center(mapping.y)),
|
|
58
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : annotation.weight === undefined ? 'Center' : 'Weighted center',
|
|
59
|
+
pulse: (_annotation$pulse = annotation.pulse) !== null && _annotation$pulse !== void 0 ? _annotation$pulse : false,
|
|
60
|
+
style: _objectSpread(_objectSpread({}, annotation.style), {}, {
|
|
61
|
+
size: (_annotation$style$siz = (_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style.size) !== null && _annotation$style$siz !== void 0 ? _annotation$style$siz : Math.max(defaults.size, 7),
|
|
62
|
+
lineWidth: (_annotation$style$lin = (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2.lineWidth) !== null && _annotation$style$lin !== void 0 ? _annotation$style$lin : 2,
|
|
63
|
+
fill: (_annotation$style$fil = (_annotation$style3 = annotation.style) === null || _annotation$style3 === void 0 ? void 0 : _annotation$style3.fill) !== null && _annotation$style$fil !== void 0 ? _annotation$style$fil : 'none'
|
|
64
|
+
})
|
|
65
|
+
}, {
|
|
66
|
+
shape: 'plus',
|
|
67
|
+
outline: (_annotation$style$str = (_annotation$style4 = annotation.style) === null || _annotation$style4 === void 0 ? void 0 : _annotation$style4.stroke) !== null && _annotation$style$str !== void 0 ? _annotation$style$str : defaults.stroke,
|
|
68
|
+
halo: annotation.pulse === true,
|
|
69
|
+
zIndex: 2
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|