@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.
Files changed (172) hide show
  1. package/README.md +53 -7
  2. package/README.zh-CN.md +32 -9
  3. package/dist/cjs/index.d.ts +1 -1
  4. package/dist/cjs/theme/g2.d.ts +9 -0
  5. package/dist/cjs/theme/g2.js +605 -0
  6. package/dist/cjs/theme/g6.d.ts +28 -0
  7. package/dist/cjs/theme/g6.js +124 -0
  8. package/dist/cjs/theme/merge.d.ts +2 -0
  9. package/dist/cjs/theme/merge.js +49 -0
  10. package/dist/cjs/theme/presets.d.ts +5 -0
  11. package/dist/cjs/theme/presets.js +663 -0
  12. package/dist/cjs/theme/resolve.d.ts +7 -0
  13. package/dist/cjs/theme/resolve.js +59 -0
  14. package/dist/cjs/theme/shared.d.ts +7 -0
  15. package/dist/cjs/theme/shared.js +61 -0
  16. package/dist/cjs/theme/summary.d.ts +11 -0
  17. package/dist/cjs/theme/summary.js +61 -0
  18. package/dist/cjs/theme/table.d.ts +13 -0
  19. package/dist/cjs/theme/table.js +121 -0
  20. package/dist/cjs/types/index.d.ts +8 -5
  21. package/dist/cjs/types/theme.d.ts +109 -0
  22. package/dist/cjs/types/theme.js +17 -0
  23. package/dist/cjs/util/animation.js +6 -1
  24. package/dist/cjs/util/components.d.ts +20 -0
  25. package/dist/cjs/util/components.js +40 -0
  26. package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
  27. package/dist/cjs/util/crosshair-axis-labels.js +17 -0
  28. package/dist/cjs/util/index.d.ts +0 -2
  29. package/dist/cjs/util/index.js +1 -5
  30. package/dist/cjs/util/interaction.d.ts +4 -3
  31. package/dist/cjs/util/interaction.js +14 -1
  32. package/dist/cjs/util/tokens.d.ts +4 -3
  33. package/dist/cjs/util/tokens.js +9 -6
  34. package/dist/cjs/vis/area/index.d.ts +3 -6
  35. package/dist/cjs/vis/area/index.js +43 -30
  36. package/dist/cjs/vis/bar/index.d.ts +5 -5
  37. package/dist/cjs/vis/bar/index.js +34 -20
  38. package/dist/cjs/vis/boxplot/index.d.ts +4 -5
  39. package/dist/cjs/vis/boxplot/index.js +36 -23
  40. package/dist/cjs/vis/column/index.d.ts +5 -5
  41. package/dist/cjs/vis/column/index.js +38 -26
  42. package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
  43. package/dist/cjs/vis/dual-axes/index.js +70 -52
  44. package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
  45. package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
  46. package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
  47. package/dist/cjs/vis/flow-diagram/index.js +21 -22
  48. package/dist/cjs/vis/funnel/index.d.ts +3 -5
  49. package/dist/cjs/vis/funnel/index.js +63 -42
  50. package/dist/cjs/vis/histogram/index.d.ts +4 -6
  51. package/dist/cjs/vis/histogram/index.js +17 -19
  52. package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
  53. package/dist/cjs/vis/indented-tree/index.js +58 -34
  54. package/dist/cjs/vis/line/index.d.ts +3 -6
  55. package/dist/cjs/vis/line/index.js +43 -22
  56. package/dist/cjs/vis/liquid/index.d.ts +4 -6
  57. package/dist/cjs/vis/liquid/index.js +22 -17
  58. package/dist/cjs/vis/mindmap/index.d.ts +4 -6
  59. package/dist/cjs/vis/mindmap/index.js +43 -25
  60. package/dist/cjs/vis/network-graph/index.d.ts +4 -6
  61. package/dist/cjs/vis/network-graph/index.js +26 -20
  62. package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
  63. package/dist/cjs/vis/organization-chart/index.js +39 -33
  64. package/dist/cjs/vis/pie/index.d.ts +3 -5
  65. package/dist/cjs/vis/pie/index.js +45 -26
  66. package/dist/cjs/vis/radar/index.d.ts +3 -6
  67. package/dist/cjs/vis/radar/index.js +32 -24
  68. package/dist/cjs/vis/sankey/index.d.ts +4 -6
  69. package/dist/cjs/vis/sankey/index.js +17 -7
  70. package/dist/cjs/vis/scatter/index.d.ts +3 -5
  71. package/dist/cjs/vis/scatter/index.js +32 -19
  72. package/dist/cjs/vis/summary/index.js +5 -6
  73. package/dist/cjs/vis/table/index.d.ts +4 -2
  74. package/dist/cjs/vis/table/index.js +46 -4
  75. package/dist/cjs/vis/treemap/index.d.ts +4 -6
  76. package/dist/cjs/vis/treemap/index.js +11 -7
  77. package/dist/cjs/vis/venn/index.d.ts +4 -6
  78. package/dist/cjs/vis/venn/index.js +18 -16
  79. package/dist/cjs/vis/violin/index.d.ts +4 -5
  80. package/dist/cjs/vis/violin/index.js +35 -27
  81. package/dist/cjs/vis/waterfall/index.d.ts +4 -4
  82. package/dist/cjs/vis/waterfall/index.js +48 -39
  83. package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
  84. package/dist/cjs/vis/word-cloud/index.js +18 -12
  85. package/dist/esm/index.d.ts +1 -1
  86. package/dist/esm/theme/g2.d.ts +9 -0
  87. package/dist/esm/theme/g2.js +504 -0
  88. package/dist/esm/theme/g6.d.ts +28 -0
  89. package/dist/esm/theme/g6.js +84 -0
  90. package/dist/esm/theme/merge.d.ts +2 -0
  91. package/dist/esm/theme/merge.js +36 -0
  92. package/dist/esm/theme/presets.d.ts +5 -0
  93. package/dist/esm/theme/presets.js +1070 -0
  94. package/dist/esm/theme/resolve.d.ts +7 -0
  95. package/dist/esm/theme/resolve.js +31 -0
  96. package/dist/esm/theme/shared.d.ts +7 -0
  97. package/dist/esm/theme/shared.js +21 -0
  98. package/dist/esm/theme/summary.d.ts +11 -0
  99. package/dist/esm/theme/summary.js +45 -0
  100. package/dist/esm/theme/table.d.ts +13 -0
  101. package/dist/esm/theme/table.js +112 -0
  102. package/dist/esm/types/index.d.ts +8 -5
  103. package/dist/esm/types/theme.d.ts +109 -0
  104. package/dist/esm/types/theme.js +1 -0
  105. package/dist/esm/util/animation.js +12 -2
  106. package/dist/esm/util/components.d.ts +20 -0
  107. package/dist/esm/util/components.js +57 -1
  108. package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
  109. package/dist/esm/util/crosshair-axis-labels.js +18 -0
  110. package/dist/esm/util/index.d.ts +0 -2
  111. package/dist/esm/util/index.js +1 -3
  112. package/dist/esm/util/interaction.d.ts +4 -3
  113. package/dist/esm/util/interaction.js +18 -1
  114. package/dist/esm/util/tokens.d.ts +4 -3
  115. package/dist/esm/util/tokens.js +9 -6
  116. package/dist/esm/vis/area/index.d.ts +3 -6
  117. package/dist/esm/vis/area/index.js +53 -45
  118. package/dist/esm/vis/bar/index.d.ts +5 -5
  119. package/dist/esm/vis/bar/index.js +38 -27
  120. package/dist/esm/vis/boxplot/index.d.ts +4 -5
  121. package/dist/esm/vis/boxplot/index.js +47 -29
  122. package/dist/esm/vis/column/index.d.ts +5 -5
  123. package/dist/esm/vis/column/index.js +46 -36
  124. package/dist/esm/vis/dual-axes/index.d.ts +3 -4
  125. package/dist/esm/vis/dual-axes/index.js +68 -58
  126. package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
  127. package/dist/esm/vis/fishbone-diagram/index.js +52 -27
  128. package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
  129. package/dist/esm/vis/flow-diagram/index.js +28 -23
  130. package/dist/esm/vis/funnel/index.d.ts +3 -5
  131. package/dist/esm/vis/funnel/index.js +63 -54
  132. package/dist/esm/vis/histogram/index.d.ts +4 -6
  133. package/dist/esm/vis/histogram/index.js +28 -21
  134. package/dist/esm/vis/indented-tree/index.d.ts +4 -6
  135. package/dist/esm/vis/indented-tree/index.js +59 -52
  136. package/dist/esm/vis/line/index.d.ts +3 -6
  137. package/dist/esm/vis/line/index.js +44 -32
  138. package/dist/esm/vis/liquid/index.d.ts +4 -6
  139. package/dist/esm/vis/liquid/index.js +28 -21
  140. package/dist/esm/vis/mindmap/index.d.ts +4 -6
  141. package/dist/esm/vis/mindmap/index.js +32 -28
  142. package/dist/esm/vis/network-graph/index.d.ts +4 -6
  143. package/dist/esm/vis/network-graph/index.js +37 -22
  144. package/dist/esm/vis/organization-chart/index.d.ts +4 -6
  145. package/dist/esm/vis/organization-chart/index.js +47 -36
  146. package/dist/esm/vis/pie/index.d.ts +3 -5
  147. package/dist/esm/vis/pie/index.js +42 -26
  148. package/dist/esm/vis/radar/index.d.ts +3 -6
  149. package/dist/esm/vis/radar/index.js +28 -20
  150. package/dist/esm/vis/sankey/index.d.ts +4 -6
  151. package/dist/esm/vis/sankey/index.js +20 -10
  152. package/dist/esm/vis/scatter/index.d.ts +3 -5
  153. package/dist/esm/vis/scatter/index.js +32 -21
  154. package/dist/esm/vis/summary/index.js +5 -7
  155. package/dist/esm/vis/table/index.d.ts +4 -2
  156. package/dist/esm/vis/table/index.js +41 -4
  157. package/dist/esm/vis/treemap/index.d.ts +4 -6
  158. package/dist/esm/vis/treemap/index.js +16 -11
  159. package/dist/esm/vis/venn/index.d.ts +4 -6
  160. package/dist/esm/vis/venn/index.js +24 -16
  161. package/dist/esm/vis/violin/index.d.ts +4 -5
  162. package/dist/esm/vis/violin/index.js +45 -37
  163. package/dist/esm/vis/waterfall/index.d.ts +4 -4
  164. package/dist/esm/vis/waterfall/index.js +46 -36
  165. package/dist/esm/vis/word-cloud/index.d.ts +3 -5
  166. package/dist/esm/vis/word-cloud/index.js +24 -17
  167. package/dist/umd/index.min.js +1 -1
  168. package/package.json +1 -1
  169. package/dist/cjs/util/theme.d.ts +0 -20
  170. package/dist/cjs/util/theme.js +0 -372
  171. package/dist/esm/util/theme.d.ts +0 -20
  172. package/dist/esm/util/theme.js +0 -326
@@ -23,20 +23,38 @@ __export(pie_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(pie_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_interaction = require("../../util/interaction");
30
+ var import_tokens = require("../../util/tokens");
27
31
  var Pie = (options) => {
28
32
  const { container, width, height, theme: chartTheme = "default" } = options;
29
33
  let chart = null;
30
34
  let hasRendered = false;
31
35
  const PERCENTAGE_PRECISION_MULTIPLIER = 1e4;
32
36
  const render = (config) => {
33
- const { data = [], innerRadius = 0, theme = chartTheme, title, style = {} } = config;
37
+ const {
38
+ data = [],
39
+ innerRadius,
40
+ theme = chartTheme,
41
+ title,
42
+ subtitle,
43
+ style: localStyle = {}
44
+ } = config;
34
45
  if (chart) {
35
46
  chart.destroy();
36
47
  }
37
- const colors = (0, import_util.normalizePalette)(style.palette, theme);
38
- const tokens = (0, import_util.getChartVisualTokens)(theme);
39
48
  const sumValue = data.reduce((sum, item) => sum + item.value, 0);
49
+ const appearance = (0, import_g22.getThemeObject)("pie", theme, localStyle);
50
+ const { theme: rendererTheme } = appearance;
51
+ const intervalMark = {
52
+ fillOpacity: 1,
53
+ stroke: (0, import_tokens.getChartVisualTokens)(rendererTheme.type).separator,
54
+ lineWidth: 2,
55
+ ...appearance.mark.interval
56
+ };
57
+ const colors = rendererTheme.category10;
40
58
  chart = new import_g2.Chart({
41
59
  container,
42
60
  width,
@@ -47,28 +65,31 @@ var Pie = (options) => {
47
65
  animate: (0, import_util.getChartAnimation)(hasRendered, "waveIn"),
48
66
  type: "interval",
49
67
  data,
50
- title: title || "",
68
+ title: title ? { title, subtitle } : "",
51
69
  encode: {
52
70
  y: "value",
53
71
  color: "category"
54
72
  },
55
73
  transform: [{ type: "stackY" }],
56
- coordinate: { type: "theta", innerRadius: Math.max(0, Math.min(1, innerRadius)) },
74
+ coordinate: {
75
+ type: "theta",
76
+ innerRadius: Math.max(0, Math.min(1, innerRadius ?? 0))
77
+ },
57
78
  scale: {
58
79
  color: { range: colors }
59
80
  },
60
- legend: (0, import_util.getColorLegend)(true),
61
- labels: data.length > 8 ? [] : [
62
- {
63
- text: (d) => {
64
- const percentage = sumValue ? Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER : 0;
65
- const formattedPercentage = Number(percentage.toFixed(1)).toString();
66
- return `${d.category}: ${formattedPercentage}%`;
67
- },
68
- position: "outside",
69
- transform: [{ type: "overlapHide" }]
70
- }
71
- ],
81
+ legend: (0, import_components.getColorLegend)(true),
82
+ labels: (0, import_components.getDataLabels)(rendererTheme, {
83
+ defaultVisible: data.length <= 8,
84
+ text: (d) => {
85
+ const percentage = sumValue ? Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER : 0;
86
+ const formattedPercentage = Number(percentage.toFixed(1)).toString();
87
+ return `${d.category}: ${formattedPercentage}%`;
88
+ },
89
+ position: "outside",
90
+ contrast: "outside",
91
+ transform: [{ type: "exceedAdjust", offsetX: 4, offsetY: 4 }, { type: "overlapHide" }]
92
+ }),
72
93
  tooltip: {
73
94
  items: [
74
95
  (d) => ({
@@ -79,8 +100,11 @@ var Pie = (options) => {
79
100
  },
80
101
  interaction: {
81
102
  tooltip: true,
82
- elementHighlight: true,
83
- elementHoverScale: { shadow: false },
103
+ elementHighlight: { delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay },
104
+ elementHoverScale: {
105
+ ...(0, import_interaction.getElementHoverScaleInteraction)(rendererTheme.type),
106
+ shadow: false
107
+ },
84
108
  elementSelect: { single: true }
85
109
  },
86
110
  state: {
@@ -88,13 +112,8 @@ var Pie = (options) => {
88
112
  inactive: { fillOpacity: 0.3 },
89
113
  selected: { fillOpacity: 1, lineWidth: 3 }
90
114
  },
91
- style: {
92
- fillOpacity: 1,
93
- stroke: tokens.separator,
94
- lineWidth: 2
95
- },
96
- viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
97
- theme: (0, import_util.getThemeObject)(theme)
115
+ style: intervalMark,
116
+ theme: rendererTheme
98
117
  };
99
118
  chart.options(chartOptions);
100
119
  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
  * RadarDataItem is the type for each data item in the radar chart.
4
4
  */
@@ -14,13 +14,10 @@ export interface RadarConfig {
14
14
  type?: 'radar';
15
15
  data: RadarDataItem[];
16
16
  title?: string;
17
+ subtitle?: string;
17
18
  align?: boolean;
18
19
  theme?: VisualizationTheme;
19
- style?: {
20
- backgroundColor?: string;
21
- palette?: string[];
22
- lineWidth?: number;
23
- };
20
+ style?: ThemeStyle;
24
21
  }
25
22
  /**
26
23
  * RadarInstance represents a radar chart instance with render and destroy methods.
@@ -23,7 +23,10 @@ __export(radar_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(radar_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
  function transformRadarToParallel(data) {
28
31
  if (!data || data.length === 0) {
29
32
  return [];
@@ -51,16 +54,32 @@ var Radar = (options) => {
51
54
  const { container, width, height, theme: chartTheme = "default" } = options;
52
55
  let chart = null;
53
56
  const render = (config) => {
54
- const { data = [], theme = chartTheme, title, align = false, style = {} } = config;
57
+ const {
58
+ data = [],
59
+ theme = chartTheme,
60
+ title,
61
+ subtitle,
62
+ align = false,
63
+ style: localStyle = {}
64
+ } = config;
55
65
  if (chart) {
56
66
  chart.destroy();
57
67
  }
58
- const { lineWidth = import_util.CHART_STYLE_DEFAULTS.lineWidth } = style;
59
- const colors = (0, import_util.normalizePalette)(style.palette, theme);
60
68
  const parallelData = transformRadarToParallel(data);
69
+ const appearance = (0, import_g22.getThemeObject)("radar", theme, localStyle);
70
+ const { theme: rendererTheme } = appearance;
71
+ const lineMark = {
72
+ lineWidth: import_tokens.CHART_STYLE_DEFAULTS.lineWidth,
73
+ lineCap: "round",
74
+ lineJoin: "round",
75
+ strokeOpacity: import_tokens.CHART_STYLE_DEFAULTS.lineOpacity,
76
+ ...appearance.mark.line
77
+ };
78
+ const lineWidth = lineMark.lineWidth ?? import_tokens.CHART_STYLE_DEFAULTS.lineWidth;
79
+ const colors = rendererTheme.category10;
61
80
  const position = Object.keys(parallelData[0] || {}).filter((key) => key !== "group");
62
81
  const hasMultipleSeries = parallelData.length > 1;
63
- const legend = (0, import_util.getColorLegend)(hasMultipleSeries);
82
+ const legend = (0, import_components.getColorLegend)(parallelData.length > 1);
64
83
  chart = new import_g2.Chart({
65
84
  container,
66
85
  width,
@@ -71,7 +90,7 @@ var Radar = (options) => {
71
90
  animate: false,
72
91
  type: "line",
73
92
  data: parallelData,
74
- title: title || "",
93
+ title: title ? { title, subtitle } : "",
75
94
  coordinate: { type: "radar" },
76
95
  inset: 24,
77
96
  encode: {
@@ -94,36 +113,25 @@ var Radar = (options) => {
94
113
  }
95
114
  },
96
115
  axis: Object.fromEntries(
97
- Array.from({ length: position.length }, (_, i) => [
98
- `position${i === 0 ? "" : i}`,
99
- {
116
+ Array.from({ length: position.length }, (_, i) => {
117
+ const defaults = {
100
118
  label: align ? i === 0 : true,
101
119
  tickFilter: (_2, idx) => {
102
120
  return !(i !== 0 && idx === 0);
103
121
  },
104
122
  grid: i === 0
105
- }
106
- ])
123
+ };
124
+ return [`position${i === 0 ? "" : i}`, { ...defaults, ...rendererTheme.axis }];
125
+ })
107
126
  ),
108
- style: {
109
- lineWidth,
110
- lineCap: "round",
111
- lineJoin: "round",
112
- strokeOpacity: import_util.CHART_STYLE_DEFAULTS.lineOpacity
113
- },
127
+ style: lineMark,
114
128
  state: hasMultipleSeries ? (0, import_util.getLineHighlightState)(lineWidth) : void 0,
115
- legend: legend === false ? false : {
116
- color: {
117
- ...legend.color,
118
- itemMarker: "smooth"
119
- }
120
- },
129
+ legend: legend === false ? false : { color: { ...legend.color, itemMarker: "smooth" } },
121
130
  interaction: {
122
131
  tooltip: true,
123
132
  ...hasMultipleSeries ? (0, import_util.getSeriesHighlightByColorInteraction)() : {}
124
133
  },
125
- viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
126
- theme: (0, import_util.getThemeObject)(theme)
134
+ theme: rendererTheme
127
135
  };
128
136
  chart.options(chartOptions);
129
137
  chart.render();
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * SankeyDataItem is the type for each data item in the sankey chart.
4
4
  */
@@ -14,12 +14,10 @@ export interface SankeyConfig {
14
14
  type?: 'sankey';
15
15
  data: SankeyDataItem[];
16
16
  nodeAlign?: 'left' | 'center' | 'right' | 'justify';
17
- theme?: 'default' | 'academy' | 'dark';
17
+ theme?: VisualizationTheme;
18
18
  title?: string;
19
- style?: {
20
- backgroundColor?: string;
21
- palette?: string[];
22
- };
19
+ subtitle?: string;
20
+ style?: ThemeStyle;
23
21
  }
24
22
  /**
25
23
  * SankeyInstance represents a sankey chart instance with render and destroy methods.
@@ -23,16 +23,26 @@ __export(sankey_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(sankey_exports);
25
25
  var import_g2 = require("@antv/g2");
26
- var import_theme = require("../../util/theme");
26
+ var import_g22 = require("../../theme/g2");
27
27
  var Sankey = (options) => {
28
28
  const { container, width, height, theme: chartTheme = "default" } = options;
29
29
  let chart = null;
30
30
  const render = (config) => {
31
- const { data = [], nodeAlign = "center", theme = chartTheme, title, style = {} } = config;
31
+ const {
32
+ data = [],
33
+ nodeAlign = "center",
34
+ theme = chartTheme,
35
+ title,
36
+ subtitle,
37
+ style: localStyle = {}
38
+ } = config;
32
39
  if (chart) {
33
40
  chart.destroy();
34
41
  }
35
- const colors = (0, import_theme.normalizePalette)(style.palette, theme);
42
+ const appearance = (0, import_g22.getThemeObject)("sankey", theme, localStyle);
43
+ const { theme: rendererTheme } = appearance;
44
+ const colors = rendererTheme.category10;
45
+ const sankeyStyle = appearance.mark.sankey;
36
46
  chart = new import_g2.Chart({
37
47
  container,
38
48
  width,
@@ -57,17 +67,17 @@ var Sankey = (options) => {
57
67
  nodeAlign,
58
68
  nodePadding: 0.01
59
69
  },
60
- title: title ?? "",
70
+ title: title ? { title, subtitle } : "",
61
71
  scale: {
62
72
  color: { range: colors }
63
73
  },
64
74
  style: {
65
75
  labelSpacing: 2,
66
76
  nodeLineWidth: 1,
67
- linkFillOpacity: 0.3
77
+ linkFillOpacity: 0.3,
78
+ ...sankeyStyle
68
79
  },
69
- viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
70
- theme: (0, import_theme.getThemeObject)(theme),
80
+ theme: rendererTheme,
71
81
  legend: false,
72
82
  tooltip: false
73
83
  };
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * ScatterDataItem is the type for each data item in the scatter chart.
4
4
  */
@@ -14,13 +14,11 @@ export interface ScatterConfig {
14
14
  type?: 'scatter';
15
15
  data: ScatterDataItem[];
16
16
  title?: string;
17
+ subtitle?: string;
17
18
  axisXTitle?: string;
18
19
  axisYTitle?: string;
19
20
  theme?: VisualizationTheme;
20
- style?: {
21
- backgroundColor?: string;
22
- palette?: string[];
23
- };
21
+ style?: ThemeStyle;
24
22
  }
25
23
  /**
26
24
  * ScatterInstance represents a scatter chart instance with render and destroy methods.
@@ -23,20 +23,41 @@ __export(scatter_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(scatter_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 Scatter = (options) => {
28
31
  const { container, width, height, theme: chartTheme = "default" } = options;
29
32
  let chart = null;
30
33
  let hasRendered = false;
31
34
  const render = (config) => {
32
35
  var _a;
33
- const { data = [], theme = chartTheme, title, axisXTitle, axisYTitle, style = {} } = config;
36
+ const {
37
+ data = [],
38
+ theme = chartTheme,
39
+ title,
40
+ subtitle,
41
+ axisXTitle,
42
+ axisYTitle,
43
+ style: localStyle = {}
44
+ } = config;
34
45
  if (chart) {
35
46
  chart.destroy();
36
47
  }
37
- const colors = (0, import_util.normalizePalette)(style.palette, theme);
38
- const backgroundColor = style.backgroundColor || (0, import_util.getBackgroundColor)(theme);
39
48
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
49
+ const appearance = (0, import_g22.getThemeObject)("scatter", theme, localStyle);
50
+ const { theme: rendererTheme } = appearance;
51
+ const pointStyle = {
52
+ shape: "point",
53
+ size: import_tokens.CHART_STYLE_DEFAULTS.scatterPointSize,
54
+ lineWidth: import_tokens.CHART_STYLE_DEFAULTS.pointLineWidth,
55
+ fillOpacity: 0.88,
56
+ stroke: rendererTheme.view.viewFill,
57
+ ...appearance.mark.point
58
+ };
59
+ const colors = rendererTheme.category10;
60
+ const { size: pointSize, ...pointMark } = pointStyle;
40
61
  chart = new import_g2.Chart({
41
62
  container,
42
63
  width,
@@ -53,34 +74,27 @@ var Scatter = (options) => {
53
74
  x: "x",
54
75
  y: "y",
55
76
  color: "group",
56
- shape: "point",
57
- size: import_util.CHART_STYLE_DEFAULTS.scatterPointSize
77
+ size: pointSize
58
78
  };
59
79
  scaleConfig.color = { range: colors };
60
80
  } else {
61
81
  encode = {
62
82
  x: "x",
63
83
  y: "y",
64
- shape: "point",
65
- size: import_util.CHART_STYLE_DEFAULTS.scatterPointSize
84
+ size: pointSize
66
85
  };
67
86
  }
68
87
  const chartOptions = {
69
88
  animate: (0, import_util.getChartAnimation)(hasRendered, "fadeIn"),
70
89
  type: "point",
71
90
  data,
72
- title: title || "",
91
+ title: title ? { title, subtitle } : "",
73
92
  encode,
74
- legend: (0, import_util.getColorLegend)(hasGroupField),
93
+ legend: (0, import_components.getColorLegend)(hasGroupField),
75
94
  scale: scaleConfig,
76
- axis: (0, import_util.getCartesianAxis)({
77
- axisXTitle,
78
- axisYTitle
79
- }),
95
+ axis: (0, import_util.getCartesianAxis)({ axisXTitle, axisYTitle }),
80
96
  style: {
81
- lineWidth: import_util.CHART_STYLE_DEFAULTS.pointLineWidth,
82
- fillOpacity: 0.88,
83
- stroke: backgroundColor,
97
+ ...pointMark,
84
98
  ...!hasGroupField ? { fill: colors[0] } : {}
85
99
  },
86
100
  // A same-color stroke enlarges the rendered path without changing its transform or
@@ -95,10 +109,9 @@ var Scatter = (options) => {
95
109
  },
96
110
  interaction: {
97
111
  tooltip: true,
98
- elementHighlight: true
112
+ elementHighlight: { delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay }
99
113
  },
100
- viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
101
- theme: (0, import_util.getThemeObject)(theme)
114
+ theme: rendererTheme
102
115
  };
103
116
  chart.options(chartOptions);
104
117
  chart.render();
@@ -23,11 +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_theme = require("../../util/theme");
26
+ var import_summary = require("../../theme/summary");
27
27
  var Summary = (options) => {
28
- let { theme = "light" } = options;
29
- if (theme === "academy" || theme === "default")
30
- theme = "light";
28
+ const appearance = (0, import_summary.getThemeObject)("summary", options.theme);
29
+ const { theme } = appearance;
31
30
  const container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
32
31
  if (!container) {
33
32
  throw new Error("Container not found");
@@ -46,9 +45,9 @@ var Summary = (options) => {
46
45
  return "";
47
46
  });
48
47
  text = new import_t8.Text(wrapper);
49
- wrapper.style.backgroundColor = activeTheme === "dark" ? (0, import_theme.getBackgroundColor)("dark") : "";
48
+ wrapper.style.backgroundColor = appearance.backgrounds[activeTheme];
50
49
  wrapper.style.padding = "16px";
51
- text.theme(activeTheme);
50
+ text.theme(activeTheme, appearance.summary);
52
51
  text.render(cleanedSyntax.trim());
53
52
  };
54
53
  const destroy = () => {
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * TableConfig defines the configuration for rendering the table.
4
4
  */
@@ -6,7 +6,9 @@ export interface TableConfig {
6
6
  type?: 'table';
7
7
  data: Record<string, any>[];
8
8
  title?: string;
9
- theme?: 'default' | 'dark';
9
+ subtitle?: string;
10
+ theme?: VisualizationTheme;
11
+ style?: ThemeStyle;
10
12
  }
11
13
  /**
12
14
  * TableInstance represents a table instance with render and destroy methods.
@@ -24,6 +24,7 @@ __export(table_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(table_exports);
26
26
  var import_measury = require("measury");
27
+ var import_table = require("../../theme/table");
27
28
  var import_html = require("../../util/html");
28
29
  var SCOPE_ID = "__gpt-vis-table__";
29
30
  var FONT_FAMILY = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
@@ -32,18 +33,29 @@ var MIN_WIDTH_MULTIPLIER = 1.1;
32
33
  var TABLE_STYLES = `
33
34
  .${SCOPE_ID} {
34
35
  font-family: ${FONT_FAMILY};
36
+ line-height: normal;
37
+ overflow-wrap: normal;
35
38
  overflow: auto;
36
39
  height: 100%;
37
40
  padding: 16px;
38
41
  }
39
42
 
43
+ .${SCOPE_ID} .table-heading {
44
+ margin-bottom: 12px;
45
+ }
46
+
40
47
  .${SCOPE_ID} .table-title {
41
48
  font-size: 16px;
42
49
  font-weight: 500;
43
- margin-bottom: 12px;
44
50
  color: #1d2129;
45
51
  }
46
52
 
53
+ .${SCOPE_ID} .table-subtitle {
54
+ margin-top: 4px;
55
+ font-size: 12px;
56
+ color: #667085;
57
+ }
58
+
47
59
  .${SCOPE_ID} .table-empty {
48
60
  padding: 20px;
49
61
  text-align: center;
@@ -102,6 +114,10 @@ var TABLE_STYLES = `
102
114
  color: #ffffffd9;
103
115
  }
104
116
 
117
+ .${SCOPE_ID}[data-theme="dark"] .table-subtitle {
118
+ color: #ffffffa6;
119
+ }
120
+
105
121
  .${SCOPE_ID}[data-theme="dark"] table {
106
122
  background: #141414;
107
123
  }
@@ -156,6 +172,23 @@ var injectStyles = () => {
156
172
  styleElement.textContent = TABLE_STYLES;
157
173
  document.head.appendChild(styleElement);
158
174
  };
175
+ var applyDomStyle = (elements, style) => {
176
+ if (!elements)
177
+ return;
178
+ const targets = elements instanceof Element ? [elements] : elements;
179
+ for (const target of targets) {
180
+ Object.assign(target.style, style);
181
+ }
182
+ };
183
+ var applyResolvedTableStyle = (wrapper, style) => {
184
+ applyDomStyle(wrapper.querySelector(".table-title"), style.title);
185
+ applyDomStyle(wrapper.querySelector(".table-subtitle"), style.subtitle);
186
+ applyDomStyle(wrapper.querySelectorAll("th"), style.header);
187
+ applyDomStyle(wrapper.querySelectorAll("td"), style.cell);
188
+ const borderStyle = style.border;
189
+ applyDomStyle(wrapper.querySelector("table"), borderStyle.table);
190
+ applyDomStyle(wrapper.querySelectorAll("th, td"), borderStyle.cell);
191
+ };
159
192
  var Table = (options) => {
160
193
  const { theme: chartTheme = "default" } = options;
161
194
  const container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
@@ -164,22 +197,30 @@ var Table = (options) => {
164
197
  }
165
198
  let tableWrapper = null;
166
199
  const render = (config) => {
167
- const { data = [], title, theme = chartTheme } = config;
200
+ const { data = [], title, subtitle, theme = chartTheme, style: localStyle = {} } = config;
201
+ const style = (0, import_table.getThemeObject)("table", theme, localStyle);
202
+ const { theme: rendererTheme } = style;
168
203
  injectStyles();
169
204
  if (tableWrapper) {
170
205
  tableWrapper.remove();
171
206
  }
172
207
  tableWrapper = document.createElement("div");
173
208
  tableWrapper.className = SCOPE_ID;
174
- if (theme === "dark") {
209
+ if (rendererTheme === "dark") {
175
210
  tableWrapper.setAttribute("data-theme", "dark");
176
211
  }
177
- const titleHTML = title ? `<div class="table-title">${(0, import_html.escapeHtml)(title)}</div>` : "";
212
+ if (style.backgroundColor)
213
+ tableWrapper.style.backgroundColor = style.backgroundColor;
214
+ const titleHTML = title || subtitle ? `<div class="table-heading">
215
+ ${title ? `<div class="table-title">${(0, import_html.escapeHtml)(title)}</div>` : ""}
216
+ ${subtitle ? `<div class="table-subtitle">${(0, import_html.escapeHtml)(subtitle)}</div>` : ""}
217
+ </div>` : "";
178
218
  if (data.length === 0) {
179
219
  tableWrapper.innerHTML = `
180
220
  ${titleHTML}
181
221
  <div class="table-empty">No data available</div>
182
222
  `;
223
+ applyResolvedTableStyle(tableWrapper, style);
183
224
  container.appendChild(tableWrapper);
184
225
  return;
185
226
  }
@@ -197,6 +238,7 @@ var Table = (options) => {
197
238
  <tbody>${bodyHTML}</tbody>
198
239
  </table>
199
240
  `;
241
+ applyResolvedTableStyle(tableWrapper, style);
200
242
  container.appendChild(tableWrapper);
201
243
  };
202
244
  const destroy = () => {
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * TreemapDataItem is the type for each data item in the treemap chart.
4
4
  */
@@ -13,12 +13,10 @@ export type TreemapDataItem = {
13
13
  export interface TreemapConfig {
14
14
  type?: 'treemap';
15
15
  data: TreemapDataItem[];
16
- theme?: 'default' | 'academy' | 'dark';
16
+ theme?: VisualizationTheme;
17
17
  title?: string;
18
- style?: {
19
- backgroundColor?: string;
20
- palette?: string[];
21
- };
18
+ subtitle?: string;
19
+ style?: ThemeStyle;
22
20
  }
23
21
  /**
24
22
  * TreemapInstance represents a treemap chart instance with render and destroy methods.
@@ -23,16 +23,19 @@ __export(treemap_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(treemap_exports);
25
25
  var import_g2 = require("@antv/g2");
26
- var import_theme = require("../../util/theme");
26
+ var import_g22 = require("../../theme/g2");
27
27
  var Treemap = (options) => {
28
28
  const { container, width, height, theme: chartTheme = "default" } = options;
29
29
  let chart = null;
30
30
  const render = (config) => {
31
- const { data = [], theme = chartTheme, title, style = {} } = config;
31
+ const { data = [], theme = chartTheme, title, subtitle, style: localStyle = {} } = config;
32
32
  if (chart) {
33
33
  chart.destroy();
34
34
  }
35
- const colors = (0, import_theme.normalizePalette)(style.palette, theme);
35
+ const appearance = (0, import_g22.getThemeObject)("treemap", theme, localStyle);
36
+ const { theme: rendererTheme } = appearance;
37
+ const colors = rendererTheme.category10;
38
+ const treemapStyle = appearance.mark.treemap;
36
39
  chart = new import_g2.Chart({
37
40
  container,
38
41
  width,
@@ -49,7 +52,7 @@ var Treemap = (options) => {
49
52
  children: data
50
53
  }
51
54
  },
52
- title: title ?? "",
55
+ title: title ? { title, subtitle } : "",
53
56
  layout: {
54
57
  tile: "treemapBinary",
55
58
  paddingInner: 2
@@ -59,7 +62,9 @@ var Treemap = (options) => {
59
62
  },
60
63
  style: {
61
64
  fillOpacity: 0.8,
62
- labelFontSize: 10
65
+ labelFontSize: 10,
66
+ labelFill: rendererTheme.label.fill,
67
+ ...treemapStyle
63
68
  },
64
69
  legend: false,
65
70
  tooltip: {
@@ -73,8 +78,7 @@ var Treemap = (options) => {
73
78
  }
74
79
  ]
75
80
  },
76
- viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
77
- theme: (0, import_theme.getThemeObject)(theme),
81
+ theme: rendererTheme,
78
82
  scale: {
79
83
  ...colors.length > 0 ? {
80
84
  color: {