@antv/gpt-vis 1.0.2 → 1.3.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 +53 -7
- package/README.zh-CN.md +32 -9
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/theme/g2.d.ts +9 -0
- package/dist/cjs/theme/g2.js +605 -0
- package/dist/cjs/theme/g6.d.ts +28 -0
- package/dist/cjs/theme/g6.js +124 -0
- package/dist/cjs/theme/merge.d.ts +2 -0
- package/dist/cjs/theme/merge.js +49 -0
- package/dist/cjs/theme/presets.d.ts +5 -0
- package/dist/cjs/theme/presets.js +663 -0
- package/dist/cjs/theme/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +59 -0
- package/dist/cjs/theme/shared.d.ts +7 -0
- package/dist/cjs/theme/shared.js +61 -0
- package/dist/cjs/theme/summary.d.ts +11 -0
- package/dist/cjs/theme/summary.js +61 -0
- package/dist/cjs/theme/table.d.ts +13 -0
- package/dist/cjs/theme/table.js +121 -0
- package/dist/cjs/types/index.d.ts +8 -5
- package/dist/cjs/types/theme.d.ts +109 -0
- package/dist/cjs/types/theme.js +17 -0
- package/dist/cjs/util/animation.js +6 -1
- package/dist/cjs/util/components.d.ts +20 -0
- package/dist/cjs/util/components.js +40 -0
- package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/cjs/util/crosshair-axis-labels.js +17 -0
- package/dist/cjs/util/index.d.ts +0 -2
- package/dist/cjs/util/index.js +1 -5
- package/dist/cjs/util/interaction.d.ts +4 -3
- package/dist/cjs/util/interaction.js +14 -1
- package/dist/cjs/util/tokens.d.ts +4 -3
- package/dist/cjs/util/tokens.js +9 -6
- package/dist/cjs/vis/area/index.d.ts +3 -6
- package/dist/cjs/vis/area/index.js +43 -30
- package/dist/cjs/vis/bar/index.d.ts +5 -5
- package/dist/cjs/vis/bar/index.js +34 -20
- package/dist/cjs/vis/boxplot/index.d.ts +4 -5
- package/dist/cjs/vis/boxplot/index.js +36 -23
- package/dist/cjs/vis/column/index.d.ts +5 -5
- package/dist/cjs/vis/column/index.js +38 -26
- package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
- package/dist/cjs/vis/dual-axes/index.js +70 -52
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
- package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
- package/dist/cjs/vis/flow-diagram/index.js +21 -22
- package/dist/cjs/vis/funnel/index.d.ts +3 -5
- package/dist/cjs/vis/funnel/index.js +63 -42
- package/dist/cjs/vis/histogram/index.d.ts +4 -6
- package/dist/cjs/vis/histogram/index.js +17 -19
- package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
- package/dist/cjs/vis/indented-tree/index.js +58 -34
- package/dist/cjs/vis/line/index.d.ts +3 -6
- package/dist/cjs/vis/line/index.js +43 -22
- package/dist/cjs/vis/liquid/index.d.ts +4 -6
- package/dist/cjs/vis/liquid/index.js +22 -17
- package/dist/cjs/vis/mindmap/index.d.ts +4 -6
- package/dist/cjs/vis/mindmap/index.js +43 -25
- package/dist/cjs/vis/network-graph/index.d.ts +4 -6
- package/dist/cjs/vis/network-graph/index.js +26 -20
- package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
- package/dist/cjs/vis/organization-chart/index.js +39 -33
- package/dist/cjs/vis/pie/index.d.ts +3 -5
- package/dist/cjs/vis/pie/index.js +45 -26
- package/dist/cjs/vis/radar/index.d.ts +3 -6
- package/dist/cjs/vis/radar/index.js +32 -24
- package/dist/cjs/vis/sankey/index.d.ts +4 -6
- package/dist/cjs/vis/sankey/index.js +17 -7
- package/dist/cjs/vis/scatter/index.d.ts +3 -5
- package/dist/cjs/vis/scatter/index.js +32 -19
- package/dist/cjs/vis/summary/index.js +5 -6
- package/dist/cjs/vis/table/index.d.ts +4 -2
- package/dist/cjs/vis/table/index.js +46 -4
- package/dist/cjs/vis/treemap/index.d.ts +4 -6
- package/dist/cjs/vis/treemap/index.js +11 -7
- package/dist/cjs/vis/venn/index.d.ts +4 -6
- package/dist/cjs/vis/venn/index.js +18 -16
- package/dist/cjs/vis/violin/index.d.ts +4 -5
- package/dist/cjs/vis/violin/index.js +35 -27
- package/dist/cjs/vis/waterfall/index.d.ts +4 -4
- package/dist/cjs/vis/waterfall/index.js +48 -39
- package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
- package/dist/cjs/vis/word-cloud/index.js +18 -12
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/theme/g2.d.ts +9 -0
- package/dist/esm/theme/g2.js +504 -0
- package/dist/esm/theme/g6.d.ts +28 -0
- package/dist/esm/theme/g6.js +84 -0
- package/dist/esm/theme/merge.d.ts +2 -0
- package/dist/esm/theme/merge.js +36 -0
- package/dist/esm/theme/presets.d.ts +5 -0
- package/dist/esm/theme/presets.js +1070 -0
- package/dist/esm/theme/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +31 -0
- package/dist/esm/theme/shared.d.ts +7 -0
- package/dist/esm/theme/shared.js +21 -0
- package/dist/esm/theme/summary.d.ts +11 -0
- package/dist/esm/theme/summary.js +45 -0
- package/dist/esm/theme/table.d.ts +13 -0
- package/dist/esm/theme/table.js +112 -0
- package/dist/esm/types/index.d.ts +8 -5
- package/dist/esm/types/theme.d.ts +109 -0
- package/dist/esm/types/theme.js +1 -0
- package/dist/esm/util/animation.js +12 -2
- package/dist/esm/util/components.d.ts +20 -0
- package/dist/esm/util/components.js +57 -1
- package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/esm/util/crosshair-axis-labels.js +18 -0
- package/dist/esm/util/index.d.ts +0 -2
- package/dist/esm/util/index.js +1 -3
- package/dist/esm/util/interaction.d.ts +4 -3
- package/dist/esm/util/interaction.js +18 -1
- package/dist/esm/util/tokens.d.ts +4 -3
- package/dist/esm/util/tokens.js +9 -6
- package/dist/esm/vis/area/index.d.ts +3 -6
- package/dist/esm/vis/area/index.js +53 -45
- package/dist/esm/vis/bar/index.d.ts +5 -5
- package/dist/esm/vis/bar/index.js +38 -27
- package/dist/esm/vis/boxplot/index.d.ts +4 -5
- package/dist/esm/vis/boxplot/index.js +47 -29
- package/dist/esm/vis/column/index.d.ts +5 -5
- package/dist/esm/vis/column/index.js +46 -36
- package/dist/esm/vis/dual-axes/index.d.ts +3 -4
- package/dist/esm/vis/dual-axes/index.js +68 -58
- package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/esm/vis/fishbone-diagram/index.js +52 -27
- package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
- package/dist/esm/vis/flow-diagram/index.js +28 -23
- package/dist/esm/vis/funnel/index.d.ts +3 -5
- package/dist/esm/vis/funnel/index.js +63 -54
- package/dist/esm/vis/histogram/index.d.ts +4 -6
- package/dist/esm/vis/histogram/index.js +28 -21
- package/dist/esm/vis/indented-tree/index.d.ts +4 -6
- package/dist/esm/vis/indented-tree/index.js +59 -52
- package/dist/esm/vis/line/index.d.ts +3 -6
- package/dist/esm/vis/line/index.js +44 -32
- package/dist/esm/vis/liquid/index.d.ts +4 -6
- package/dist/esm/vis/liquid/index.js +28 -21
- package/dist/esm/vis/mindmap/index.d.ts +4 -6
- package/dist/esm/vis/mindmap/index.js +32 -28
- package/dist/esm/vis/network-graph/index.d.ts +4 -6
- package/dist/esm/vis/network-graph/index.js +37 -22
- package/dist/esm/vis/organization-chart/index.d.ts +4 -6
- package/dist/esm/vis/organization-chart/index.js +47 -36
- package/dist/esm/vis/pie/index.d.ts +3 -5
- package/dist/esm/vis/pie/index.js +42 -26
- package/dist/esm/vis/radar/index.d.ts +3 -6
- package/dist/esm/vis/radar/index.js +28 -20
- package/dist/esm/vis/sankey/index.d.ts +4 -6
- package/dist/esm/vis/sankey/index.js +20 -10
- package/dist/esm/vis/scatter/index.d.ts +3 -5
- package/dist/esm/vis/scatter/index.js +32 -21
- package/dist/esm/vis/summary/index.js +5 -7
- package/dist/esm/vis/table/index.d.ts +4 -2
- package/dist/esm/vis/table/index.js +41 -4
- package/dist/esm/vis/treemap/index.d.ts +4 -6
- package/dist/esm/vis/treemap/index.js +16 -11
- package/dist/esm/vis/venn/index.d.ts +4 -6
- package/dist/esm/vis/venn/index.js +24 -16
- package/dist/esm/vis/violin/index.d.ts +4 -5
- package/dist/esm/vis/violin/index.js +45 -37
- package/dist/esm/vis/waterfall/index.d.ts +4 -4
- package/dist/esm/vis/waterfall/index.js +46 -36
- package/dist/esm/vis/word-cloud/index.d.ts +3 -5
- package/dist/esm/vis/word-cloud/index.js +24 -17
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/util/theme.d.ts +0 -20
- package/dist/cjs/util/theme.js +0 -372
- package/dist/esm/util/theme.d.ts +0 -20
- package/dist/esm/util/theme.js +0 -326
package/dist/cjs/util/index.js
CHANGED
|
@@ -20,14 +20,10 @@ __reExport(util_exports, require("./animation"), module.exports);
|
|
|
20
20
|
__reExport(util_exports, require("./components"), module.exports);
|
|
21
21
|
__reExport(util_exports, require("./crosshair-axis-labels"), module.exports);
|
|
22
22
|
__reExport(util_exports, require("./interaction"), module.exports);
|
|
23
|
-
__reExport(util_exports, require("./theme"), module.exports);
|
|
24
|
-
__reExport(util_exports, require("./tokens"), module.exports);
|
|
25
23
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
24
|
0 && (module.exports = {
|
|
27
25
|
...require("./animation"),
|
|
28
26
|
...require("./components"),
|
|
29
27
|
...require("./crosshair-axis-labels"),
|
|
30
|
-
...require("./interaction")
|
|
31
|
-
...require("./theme"),
|
|
32
|
-
...require("./tokens")
|
|
28
|
+
...require("./interaction")
|
|
33
29
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { VisualizationTheme } from '../types';
|
|
2
1
|
export type SharedTooltipInteractionOptions = {
|
|
3
2
|
crosshairs?: boolean;
|
|
4
3
|
};
|
|
@@ -7,8 +6,10 @@ export type PointHighlightStateOptions = {
|
|
|
7
6
|
inactiveOpacity?: number;
|
|
8
7
|
};
|
|
9
8
|
export declare const getSharedTooltipInteraction: ({ crosshairs, }?: SharedTooltipInteractionOptions) => Record<string, boolean>;
|
|
10
|
-
export declare const getCategoryBackgroundHighlightState: (theme:
|
|
9
|
+
export declare const getCategoryBackgroundHighlightState: (theme: string) => Record<string, any>;
|
|
11
10
|
export declare const getCategoryHighlightInteraction: () => Record<string, any>;
|
|
12
11
|
export declare const getPointHighlightState: ({ activeLineWidth, inactiveOpacity, }?: PointHighlightStateOptions) => Record<string, any>;
|
|
13
|
-
export declare const getSeriesHighlightByColorInteraction: () => Record<string,
|
|
12
|
+
export declare const getSeriesHighlightByColorInteraction: () => Record<string, any>;
|
|
14
13
|
export declare const getLineHighlightState: (lineWidth: number) => Record<string, any>;
|
|
14
|
+
/** Preserve GPT-Vis hover feedback independently of the visual theme. */
|
|
15
|
+
export declare const getElementHoverScaleInteraction: (theme: string) => Record<string, unknown>;
|
|
@@ -21,6 +21,7 @@ var interaction_exports = {};
|
|
|
21
21
|
__export(interaction_exports, {
|
|
22
22
|
getCategoryBackgroundHighlightState: () => getCategoryBackgroundHighlightState,
|
|
23
23
|
getCategoryHighlightInteraction: () => getCategoryHighlightInteraction,
|
|
24
|
+
getElementHoverScaleInteraction: () => getElementHoverScaleInteraction,
|
|
24
25
|
getLineHighlightState: () => getLineHighlightState,
|
|
25
26
|
getPointHighlightState: () => getPointHighlightState,
|
|
26
27
|
getSeriesHighlightByColorInteraction: () => getSeriesHighlightByColorInteraction,
|
|
@@ -48,6 +49,7 @@ var getCategoryBackgroundHighlightState = (theme) => {
|
|
|
48
49
|
};
|
|
49
50
|
};
|
|
50
51
|
var getCategoryHighlightInteraction = () => ({
|
|
52
|
+
delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay,
|
|
51
53
|
background: true,
|
|
52
54
|
region: true
|
|
53
55
|
});
|
|
@@ -72,16 +74,27 @@ var getPointHighlightState = ({
|
|
|
72
74
|
}
|
|
73
75
|
});
|
|
74
76
|
var getSeriesHighlightByColorInteraction = () => ({
|
|
75
|
-
elementHighlightByColor:
|
|
77
|
+
elementHighlightByColor: { delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay }
|
|
76
78
|
});
|
|
77
79
|
var getLineHighlightState = (lineWidth) => ({
|
|
78
80
|
active: { lineWidth: lineWidth + 1, strokeOpacity: 1 },
|
|
79
81
|
inactive: { strokeOpacity: import_tokens.CHART_STYLE_DEFAULTS.inactiveOpacity }
|
|
80
82
|
});
|
|
83
|
+
var getElementHoverScaleInteraction = (theme) => ({
|
|
84
|
+
delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay,
|
|
85
|
+
scale: 1.04,
|
|
86
|
+
shadow: true,
|
|
87
|
+
shadowBlur: theme === "dark" ? 7 : theme === "academy" ? 5 : 6,
|
|
88
|
+
shadowColor: theme === "dark" ? "rgba(226, 232, 240, 0.38)" : theme === "academy" ? "rgba(63, 49, 38, 0.44)" : "rgba(15, 23, 42, 0.46)",
|
|
89
|
+
shadowOffsetX: 0,
|
|
90
|
+
shadowOffsetY: theme === "dark" ? 0 : 3,
|
|
91
|
+
zIndex: 10
|
|
92
|
+
});
|
|
81
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
94
|
0 && (module.exports = {
|
|
83
95
|
getCategoryBackgroundHighlightState,
|
|
84
96
|
getCategoryHighlightInteraction,
|
|
97
|
+
getElementHoverScaleInteraction,
|
|
85
98
|
getLineHighlightState,
|
|
86
99
|
getPointHighlightState,
|
|
87
100
|
getSeriesHighlightByColorInteraction,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { VisualizationTheme } from '../types';
|
|
2
1
|
export declare const CHART_FONT_FAMILY = "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif";
|
|
3
2
|
export declare const CHART_STYLE_DEFAULTS: {
|
|
4
3
|
readonly animationDuration: 260;
|
|
@@ -13,9 +12,10 @@ export declare const CHART_STYLE_DEFAULTS: {
|
|
|
13
12
|
readonly pointActiveLineWidth: 5;
|
|
14
13
|
readonly intervalWidthRatio: 0.64;
|
|
15
14
|
};
|
|
16
|
-
|
|
15
|
+
type BuiltInThemeValues = {
|
|
17
16
|
background: string;
|
|
18
17
|
textPrimary: string;
|
|
18
|
+
textInverse: string;
|
|
19
19
|
textSecondary: string;
|
|
20
20
|
grid: string;
|
|
21
21
|
axisGrid: string;
|
|
@@ -28,4 +28,5 @@ export type ChartVisualTokens = {
|
|
|
28
28
|
tooltipMarkerShadow: string;
|
|
29
29
|
tooltipShadow: string;
|
|
30
30
|
};
|
|
31
|
-
export declare const getChartVisualTokens: (theme:
|
|
31
|
+
export declare const getChartVisualTokens: (theme: string) => BuiltInThemeValues;
|
|
32
|
+
export {};
|
package/dist/cjs/util/tokens.js
CHANGED
|
@@ -38,9 +38,10 @@ var CHART_STYLE_DEFAULTS = {
|
|
|
38
38
|
pointActiveLineWidth: 5,
|
|
39
39
|
intervalWidthRatio: 0.64
|
|
40
40
|
};
|
|
41
|
-
var
|
|
41
|
+
var LIGHT_THEME_VALUES = {
|
|
42
42
|
background: "#FFFFFF",
|
|
43
43
|
textPrimary: "#1F2937",
|
|
44
|
+
textInverse: "#FFFFFF",
|
|
44
45
|
textSecondary: "#667085",
|
|
45
46
|
grid: "#E7EAF0",
|
|
46
47
|
axisGrid: "#D0D5DD",
|
|
@@ -53,9 +54,10 @@ var LIGHT_TOKENS = {
|
|
|
53
54
|
tooltipMarkerShadow: "0 0 0 2px #FFFFFF, 0 1px 3px rgba(15, 23, 42, 0.20)",
|
|
54
55
|
tooltipShadow: "0 12px 32px rgba(15, 23, 42, 0.12), 0 3px 8px rgba(15, 23, 42, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.82)"
|
|
55
56
|
};
|
|
56
|
-
var
|
|
57
|
+
var DARK_THEME_VALUES = {
|
|
57
58
|
background: "#141414",
|
|
58
59
|
textPrimary: "#F3F4F6",
|
|
60
|
+
textInverse: "#111827",
|
|
59
61
|
textSecondary: "#A7AFBE",
|
|
60
62
|
grid: "#343841",
|
|
61
63
|
axisGrid: "#475467",
|
|
@@ -68,9 +70,10 @@ var DARK_TOKENS = {
|
|
|
68
70
|
tooltipMarkerShadow: "0 0 0 2px #1A1B1F, 0 1px 3px rgba(0, 0, 0, 0.42)",
|
|
69
71
|
tooltipShadow: "0 14px 36px rgba(0, 0, 0, 0.34), 0 3px 10px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08)"
|
|
70
72
|
};
|
|
71
|
-
var
|
|
73
|
+
var ACADEMY_THEME_VALUES = {
|
|
72
74
|
background: "#FFFFFF",
|
|
73
75
|
textPrimary: "#23262D",
|
|
76
|
+
textInverse: "#FFFFFF",
|
|
74
77
|
textSecondary: "#626975",
|
|
75
78
|
grid: "#DDDDDD",
|
|
76
79
|
axisGrid: "#DDDDDD",
|
|
@@ -85,10 +88,10 @@ var ACADEMY_TOKENS = {
|
|
|
85
88
|
};
|
|
86
89
|
var getChartVisualTokens = (theme) => {
|
|
87
90
|
if (theme === "dark")
|
|
88
|
-
return
|
|
91
|
+
return DARK_THEME_VALUES;
|
|
89
92
|
if (theme === "academy")
|
|
90
|
-
return
|
|
91
|
-
return
|
|
93
|
+
return ACADEMY_THEME_VALUES;
|
|
94
|
+
return LIGHT_THEME_VALUES;
|
|
92
95
|
};
|
|
93
96
|
// Annotate the CommonJS export names for ESM import in node:
|
|
94
97
|
0 && (module.exports = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* AreaDataItem is the type for each data item in the area chart.
|
|
4
4
|
*/
|
|
@@ -15,14 +15,11 @@ export interface AreaConfig {
|
|
|
15
15
|
data: AreaDataItem[];
|
|
16
16
|
stack?: boolean;
|
|
17
17
|
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
18
19
|
axisXTitle?: string;
|
|
19
20
|
axisYTitle?: string;
|
|
20
21
|
theme?: VisualizationTheme;
|
|
21
|
-
style?:
|
|
22
|
-
backgroundColor?: string;
|
|
23
|
-
palette?: string[];
|
|
24
|
-
lineWidth?: number;
|
|
25
|
-
};
|
|
22
|
+
style?: ThemeStyle;
|
|
26
23
|
}
|
|
27
24
|
/**
|
|
28
25
|
* AreaInstance represents an area chart instance with render and destroy methods.
|
|
@@ -23,7 +23,10 @@ __export(area_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(area_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
26
27
|
var import_util = require("../../util");
|
|
28
|
+
var import_components = require("../../util/components");
|
|
29
|
+
var import_tokens = require("../../util/tokens");
|
|
27
30
|
var getLinearGradientColor = (color, backgroundColor = "white") => `linear-gradient(-90deg, ${backgroundColor} 0%, ${color} 100%)`;
|
|
28
31
|
var DEFAULT_COLOR = "#3A95FF";
|
|
29
32
|
var Area = (options) => {
|
|
@@ -37,29 +40,48 @@ var Area = (options) => {
|
|
|
37
40
|
data = [],
|
|
38
41
|
theme = chartTheme,
|
|
39
42
|
title,
|
|
43
|
+
subtitle,
|
|
40
44
|
axisXTitle,
|
|
41
45
|
axisYTitle,
|
|
42
46
|
stack = false,
|
|
43
|
-
style = {}
|
|
47
|
+
style: localStyle = {}
|
|
44
48
|
} = config;
|
|
45
49
|
if (chart) {
|
|
46
50
|
cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
|
|
47
51
|
cleanupCrosshairAxisLabels = null;
|
|
48
52
|
chart.destroy();
|
|
49
53
|
}
|
|
50
|
-
const { lineWidth = import_util.CHART_STYLE_DEFAULTS.lineWidth } = style;
|
|
51
54
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
52
|
-
const colors = (0, import_util.normalizePalette)(style.palette, theme);
|
|
53
|
-
const backgroundColor = style.backgroundColor || (0, import_util.getBackgroundColor)(theme);
|
|
54
|
-
const fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
|
|
55
|
-
const areaOpacity = import_util.CHART_STYLE_DEFAULTS.areaOpacity;
|
|
56
|
-
const lineOpacity = import_util.CHART_STYLE_DEFAULTS.lineOpacity;
|
|
57
55
|
const cartesianAxisOptions = {
|
|
58
56
|
axisXTitle,
|
|
59
57
|
axisYTitle,
|
|
60
58
|
xLabels: data.map(({ time }) => time),
|
|
61
59
|
chartWidth: width
|
|
62
60
|
};
|
|
61
|
+
const appearance = (0, import_g22.getThemeObject)("area", theme, localStyle);
|
|
62
|
+
const { theme: rendererTheme } = appearance;
|
|
63
|
+
const areaMark = {
|
|
64
|
+
fillOpacity: import_tokens.CHART_STYLE_DEFAULTS.areaOpacity,
|
|
65
|
+
...appearance.mark.area
|
|
66
|
+
};
|
|
67
|
+
const lineMark = {
|
|
68
|
+
lineWidth: import_tokens.CHART_STYLE_DEFAULTS.lineWidth,
|
|
69
|
+
strokeOpacity: import_tokens.CHART_STYLE_DEFAULTS.lineOpacity,
|
|
70
|
+
...appearance.mark.line
|
|
71
|
+
};
|
|
72
|
+
const pointStyle = {
|
|
73
|
+
shape: "point",
|
|
74
|
+
size: import_tokens.CHART_STYLE_DEFAULTS.pointSize,
|
|
75
|
+
lineWidth: import_tokens.CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
76
|
+
stroke: rendererTheme.view.viewFill,
|
|
77
|
+
...appearance.mark.point
|
|
78
|
+
};
|
|
79
|
+
const baseTheme = rendererTheme.type;
|
|
80
|
+
const lineWidth = lineMark.lineWidth;
|
|
81
|
+
const colors = rendererTheme.category10;
|
|
82
|
+
const backgroundColor = rendererTheme.view.viewFill;
|
|
83
|
+
const fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
|
|
84
|
+
const areaOpacity = areaMark.fillOpacity ?? import_tokens.CHART_STYLE_DEFAULTS.areaOpacity;
|
|
63
85
|
const tooltip = {
|
|
64
86
|
items: [
|
|
65
87
|
(d) => ({
|
|
@@ -85,12 +107,9 @@ var Area = (options) => {
|
|
|
85
107
|
children = [
|
|
86
108
|
{
|
|
87
109
|
type: "area",
|
|
88
|
-
style:
|
|
110
|
+
style: areaMark
|
|
89
111
|
},
|
|
90
|
-
{
|
|
91
|
-
type: "line",
|
|
92
|
-
style: { lineWidth, strokeOpacity: lineOpacity }
|
|
93
|
-
}
|
|
112
|
+
{ type: "line", style: lineMark }
|
|
94
113
|
];
|
|
95
114
|
} else if (hasGroupField) {
|
|
96
115
|
encode = { x: "time", y: "value", color: "group" };
|
|
@@ -98,12 +117,9 @@ var Area = (options) => {
|
|
|
98
117
|
children = [
|
|
99
118
|
{
|
|
100
119
|
type: "area",
|
|
101
|
-
style:
|
|
120
|
+
style: areaMark
|
|
102
121
|
},
|
|
103
|
-
{
|
|
104
|
-
type: "line",
|
|
105
|
-
style: { lineWidth, strokeOpacity: lineOpacity }
|
|
106
|
-
}
|
|
122
|
+
{ type: "line", style: lineMark }
|
|
107
123
|
];
|
|
108
124
|
} else {
|
|
109
125
|
encode = { x: "time", y: "value" };
|
|
@@ -111,17 +127,16 @@ var Area = (options) => {
|
|
|
111
127
|
{
|
|
112
128
|
type: "area",
|
|
113
129
|
style: {
|
|
114
|
-
|
|
130
|
+
...areaMark,
|
|
115
131
|
fill: fillColor
|
|
116
132
|
}
|
|
117
133
|
},
|
|
118
134
|
{
|
|
119
135
|
type: "line",
|
|
120
136
|
style: {
|
|
121
|
-
lineWidth,
|
|
122
|
-
strokeOpacity: lineOpacity,
|
|
123
137
|
lineCap: "round",
|
|
124
138
|
lineJoin: "round",
|
|
139
|
+
...lineMark,
|
|
125
140
|
stroke: colors[0]
|
|
126
141
|
}
|
|
127
142
|
}
|
|
@@ -137,43 +152,41 @@ var Area = (options) => {
|
|
|
137
152
|
} : (0, import_util.getLineHighlightState)(lineWidth) : void 0
|
|
138
153
|
}));
|
|
139
154
|
if (!hasGroupField && data.length <= 24) {
|
|
155
|
+
const { size: pointSize, ...pointMark } = pointStyle;
|
|
140
156
|
children.push({
|
|
141
157
|
type: "point",
|
|
142
158
|
encode: {
|
|
143
159
|
x: "time",
|
|
144
160
|
y: "value",
|
|
145
|
-
|
|
146
|
-
size: import_util.CHART_STYLE_DEFAULTS.pointSize
|
|
161
|
+
size: pointSize
|
|
147
162
|
},
|
|
148
163
|
animate: (0, import_util.getChartAnimation)(hasRendered, "fadeIn"),
|
|
149
164
|
tooltip: false,
|
|
150
165
|
style: {
|
|
151
|
-
|
|
152
|
-
fill: colors[0]
|
|
153
|
-
stroke: backgroundColor
|
|
166
|
+
...pointMark,
|
|
167
|
+
fill: colors[0]
|
|
154
168
|
}
|
|
155
169
|
});
|
|
156
170
|
}
|
|
157
171
|
const chartOptions = {
|
|
158
172
|
type: "view",
|
|
159
173
|
data,
|
|
160
|
-
title: title
|
|
174
|
+
title: title ? { title, subtitle } : "",
|
|
161
175
|
encode,
|
|
162
176
|
transform,
|
|
163
177
|
children,
|
|
164
178
|
scale: scaleConfig,
|
|
165
179
|
...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
|
|
166
180
|
axis: (0, import_util.getCartesianAxis)(cartesianAxisOptions),
|
|
167
|
-
legend: (0,
|
|
181
|
+
legend: (0, import_components.getColorLegend)(hasGroupField),
|
|
168
182
|
interaction: {
|
|
169
183
|
tooltip: (0, import_util.getSharedTooltipInteraction)({ crosshairs: true }),
|
|
170
184
|
...hasGroupField ? (0, import_util.getSeriesHighlightByColorInteraction)() : {}
|
|
171
185
|
},
|
|
172
|
-
|
|
173
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
186
|
+
theme: rendererTheme
|
|
174
187
|
};
|
|
175
188
|
chart.options(chartOptions);
|
|
176
|
-
cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart,
|
|
189
|
+
cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart, baseTheme);
|
|
177
190
|
chart.render();
|
|
178
191
|
hasRendered = true;
|
|
179
192
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* BarDataItem is the type for each data item in the bar chart.
|
|
4
4
|
*/
|
|
@@ -16,13 +16,13 @@ export interface BarConfig {
|
|
|
16
16
|
group?: boolean;
|
|
17
17
|
stack?: boolean;
|
|
18
18
|
title?: string;
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
/** Show value labels. Defaults to `true`. */
|
|
21
|
+
label?: boolean;
|
|
19
22
|
axisXTitle?: string;
|
|
20
23
|
axisYTitle?: string;
|
|
21
24
|
theme?: VisualizationTheme;
|
|
22
|
-
style?:
|
|
23
|
-
backgroundColor?: string;
|
|
24
|
-
palette?: string[];
|
|
25
|
-
};
|
|
25
|
+
style?: ThemeStyle;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* BarInstance represents a bar chart instance with render and destroy methods.
|
|
@@ -23,28 +23,41 @@ __export(bar_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(bar_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
26
27
|
var import_util = require("../../util");
|
|
28
|
+
var import_components = require("../../util/components");
|
|
29
|
+
var import_tokens = require("../../util/tokens");
|
|
27
30
|
var Bar = (options) => {
|
|
28
31
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
32
|
let chart = null;
|
|
30
|
-
let hasRendered = false;
|
|
31
33
|
const render = (config) => {
|
|
32
34
|
var _a;
|
|
33
35
|
const {
|
|
34
36
|
data = [],
|
|
35
37
|
theme = chartTheme,
|
|
36
38
|
title,
|
|
39
|
+
subtitle,
|
|
40
|
+
label,
|
|
37
41
|
axisXTitle,
|
|
38
42
|
axisYTitle,
|
|
39
43
|
group = false,
|
|
40
44
|
stack = false,
|
|
41
|
-
style = {}
|
|
45
|
+
style: localStyle = {}
|
|
42
46
|
} = config;
|
|
43
47
|
if (chart) {
|
|
44
48
|
chart.destroy();
|
|
45
49
|
}
|
|
46
50
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
47
|
-
const
|
|
51
|
+
const appearance = (0, import_g22.getThemeObject)("bar", theme, localStyle);
|
|
52
|
+
const { theme: rendererTheme } = appearance;
|
|
53
|
+
const intervalMark = {
|
|
54
|
+
...rendererTheme.type !== "academy" ? { radius: 4 } : {},
|
|
55
|
+
columnWidthRatio: import_tokens.CHART_STYLE_DEFAULTS.intervalWidthRatio,
|
|
56
|
+
...!hasGroupField ? { fill: rendererTheme.category10[0] } : {},
|
|
57
|
+
...appearance.mark.interval
|
|
58
|
+
};
|
|
59
|
+
const baseTheme = rendererTheme.type;
|
|
60
|
+
const colors = rendererTheme.category10;
|
|
48
61
|
chart = new import_g2.Chart({
|
|
49
62
|
container,
|
|
50
63
|
width,
|
|
@@ -53,10 +66,6 @@ var Bar = (options) => {
|
|
|
53
66
|
});
|
|
54
67
|
let encode = {};
|
|
55
68
|
let transform = [];
|
|
56
|
-
let radiusStyle = {};
|
|
57
|
-
if (theme !== "academy") {
|
|
58
|
-
radiusStyle = { radius: 4 };
|
|
59
|
-
}
|
|
60
69
|
if (hasGroupField && group) {
|
|
61
70
|
transform = [{ type: "dodgeX" }];
|
|
62
71
|
}
|
|
@@ -73,16 +82,28 @@ var Bar = (options) => {
|
|
|
73
82
|
...hasGroupField ? { color: { range: colors } } : {}
|
|
74
83
|
};
|
|
75
84
|
const chartOptions = {
|
|
76
|
-
|
|
85
|
+
// G2 growInX currently computes interval label bounds from the animated
|
|
86
|
+
// clip path, which leaves inside labels at the axis baseline. Keep the
|
|
87
|
+
// interval and its labels in sync until the upstream runtime is fixed.
|
|
88
|
+
animate: false,
|
|
77
89
|
type: "interval",
|
|
78
90
|
data,
|
|
79
|
-
title: title
|
|
91
|
+
title: title ? { title, subtitle } : "",
|
|
80
92
|
encode,
|
|
81
93
|
transform,
|
|
82
94
|
coordinate: { transform: [{ type: "transpose" }] },
|
|
83
95
|
scale: scaleConfig,
|
|
84
96
|
axis: (0, import_util.getCartesianAxis)({ axisXTitle, axisYTitle }),
|
|
85
|
-
legend: (0,
|
|
97
|
+
legend: (0, import_components.getColorLegend)(hasGroupField),
|
|
98
|
+
labels: (0, import_components.getDataLabels)(rendererTheme, {
|
|
99
|
+
visible: label,
|
|
100
|
+
defaultVisible: true,
|
|
101
|
+
text: "value",
|
|
102
|
+
position: "right",
|
|
103
|
+
contrast: "inside",
|
|
104
|
+
dx: -4,
|
|
105
|
+
dy: 0
|
|
106
|
+
}),
|
|
86
107
|
tooltip: {
|
|
87
108
|
items: [
|
|
88
109
|
(d) => ({
|
|
@@ -91,29 +112,22 @@ var Bar = (options) => {
|
|
|
91
112
|
})
|
|
92
113
|
]
|
|
93
114
|
},
|
|
94
|
-
state: (0, import_util.getCategoryBackgroundHighlightState)(
|
|
115
|
+
state: (0, import_util.getCategoryBackgroundHighlightState)(baseTheme),
|
|
95
116
|
interaction: {
|
|
96
117
|
tooltip: true,
|
|
97
118
|
elementHighlight: (0, import_util.getCategoryHighlightInteraction)()
|
|
98
119
|
},
|
|
99
|
-
style:
|
|
100
|
-
|
|
101
|
-
columnWidthRatio: import_util.CHART_STYLE_DEFAULTS.intervalWidthRatio,
|
|
102
|
-
...!hasGroupField ? { fill: colors[0] } : {}
|
|
103
|
-
},
|
|
104
|
-
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
105
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
120
|
+
style: intervalMark,
|
|
121
|
+
theme: rendererTheme
|
|
106
122
|
};
|
|
107
123
|
chart.options(chartOptions);
|
|
108
124
|
chart.render();
|
|
109
|
-
hasRendered = true;
|
|
110
125
|
};
|
|
111
126
|
const destroy = () => {
|
|
112
127
|
if (chart) {
|
|
113
128
|
chart.destroy();
|
|
114
129
|
chart = null;
|
|
115
130
|
}
|
|
116
|
-
hasRendered = false;
|
|
117
131
|
};
|
|
118
132
|
return {
|
|
119
133
|
render,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* BoxplotDataItem is the type for each data item in the boxplot chart.
|
|
4
4
|
*/
|
|
@@ -13,13 +13,12 @@ export type BoxplotDataItem = {
|
|
|
13
13
|
export interface BoxplotConfig {
|
|
14
14
|
type?: 'boxplot';
|
|
15
15
|
data: BoxplotDataItem[];
|
|
16
|
-
theme?:
|
|
16
|
+
theme?: VisualizationTheme;
|
|
17
17
|
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
18
19
|
axisXTitle?: string;
|
|
19
20
|
axisYTitle?: string;
|
|
20
|
-
style?: {
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
21
|
+
style?: ThemeStyle & {
|
|
23
22
|
startAtZero?: boolean;
|
|
24
23
|
};
|
|
25
24
|
}
|
|
@@ -23,19 +23,36 @@ __export(boxplot_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(boxplot_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
-
var
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
27
|
+
var import_components = require("../../util/components");
|
|
28
|
+
var prefixMarkStyle = (prefix, style) => Object.fromEntries(
|
|
29
|
+
Object.entries(style ?? {}).map(([key, value]) => [
|
|
30
|
+
`${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`,
|
|
31
|
+
value
|
|
32
|
+
])
|
|
33
|
+
);
|
|
27
34
|
var Boxplot = (options) => {
|
|
28
35
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
36
|
let chart = null;
|
|
30
37
|
const render = (config) => {
|
|
31
38
|
var _a;
|
|
32
|
-
const {
|
|
39
|
+
const {
|
|
40
|
+
data = [],
|
|
41
|
+
theme = chartTheme,
|
|
42
|
+
title,
|
|
43
|
+
subtitle,
|
|
44
|
+
axisXTitle,
|
|
45
|
+
axisYTitle,
|
|
46
|
+
style: localStyle = {}
|
|
47
|
+
} = config;
|
|
33
48
|
if (chart) {
|
|
34
49
|
chart.destroy();
|
|
35
50
|
}
|
|
36
|
-
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
37
|
-
const startAtZero = style.startAtZero || false;
|
|
38
51
|
const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
|
|
52
|
+
const appearance = (0, import_g22.getThemeObject)("boxplot", theme, localStyle);
|
|
53
|
+
const { theme: rendererTheme } = appearance;
|
|
54
|
+
const colors = rendererTheme.category10;
|
|
55
|
+
const startAtZero = localStyle.startAtZero || false;
|
|
39
56
|
let encode = {};
|
|
40
57
|
if (hasGroupField) {
|
|
41
58
|
encode = {
|
|
@@ -51,6 +68,14 @@ var Boxplot = (options) => {
|
|
|
51
68
|
color: "category"
|
|
52
69
|
};
|
|
53
70
|
}
|
|
71
|
+
const showPoints = !hasGroupField;
|
|
72
|
+
const boxStyle = appearance.mark.box;
|
|
73
|
+
const resolvedPointStyle = appearance.mark.point;
|
|
74
|
+
const markStyle = showPoints ? {
|
|
75
|
+
...prefixMarkStyle("box", boxStyle),
|
|
76
|
+
...prefixMarkStyle("point", resolvedPointStyle)
|
|
77
|
+
} : { ...boxStyle, point: false };
|
|
78
|
+
const legend = (0, import_components.getColorLegend)(hasGroupField);
|
|
54
79
|
chart = new import_g2.Chart({
|
|
55
80
|
container,
|
|
56
81
|
width,
|
|
@@ -61,32 +86,20 @@ var Boxplot = (options) => {
|
|
|
61
86
|
animate: false,
|
|
62
87
|
type: "boxplot",
|
|
63
88
|
data,
|
|
64
|
-
title: title
|
|
89
|
+
title: title ? { title, subtitle } : "",
|
|
65
90
|
encode,
|
|
66
|
-
axis: {
|
|
67
|
-
x: {
|
|
68
|
-
title: axisXTitle || false
|
|
69
|
-
},
|
|
70
|
-
y: {
|
|
71
|
-
title: axisYTitle || false
|
|
72
|
-
}
|
|
73
|
-
},
|
|
91
|
+
axis: (0, import_components.getCartesianAxis)({ axisXTitle, axisYTitle }),
|
|
74
92
|
scale: {
|
|
75
93
|
x: { paddingInner: 0.6, paddingOuter: 0.3 },
|
|
76
94
|
series: { paddingInner: 0.3, paddingOuter: 0.1 },
|
|
77
95
|
y: { nice: true, zero: startAtZero },
|
|
78
96
|
color: { range: colors }
|
|
79
97
|
},
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
legend: {
|
|
86
|
-
color: hasGroupField ? { position: "top" } : false
|
|
87
|
-
},
|
|
88
|
-
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
89
|
-
theme: (0, import_theme.getThemeObject)(theme)
|
|
98
|
+
// Grouped boxplots keep outliers disabled because G2's point child does
|
|
99
|
+
// not inherit the composite color scale used by legend filtering.
|
|
100
|
+
style: { stroke: "black", ...markStyle },
|
|
101
|
+
legend: legend === false ? { color: false } : { color: { position: "top", ...legend.color } },
|
|
102
|
+
theme: rendererTheme
|
|
90
103
|
};
|
|
91
104
|
chart.options(chartOptions);
|
|
92
105
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* ColumnDataItem is the type for each data item in the column chart.
|
|
4
4
|
*/
|
|
@@ -16,13 +16,13 @@ export interface ColumnConfig {
|
|
|
16
16
|
group?: boolean;
|
|
17
17
|
stack?: boolean;
|
|
18
18
|
title?: string;
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
/** Show value labels. Defaults to `true`. */
|
|
21
|
+
label?: boolean;
|
|
19
22
|
axisXTitle?: string;
|
|
20
23
|
axisYTitle?: string;
|
|
21
24
|
theme?: VisualizationTheme;
|
|
22
|
-
style?:
|
|
23
|
-
backgroundColor?: string;
|
|
24
|
-
palette?: string[];
|
|
25
|
-
};
|
|
25
|
+
style?: ThemeStyle;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* ColumnInstance represents a column chart instance with render and destroy methods.
|