@antv/gpt-vis 1.0.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +113 -36
  2. package/README.zh-CN.md +113 -36
  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/resolve.d.ts +7 -0
  11. package/dist/cjs/theme/resolve.js +58 -0
  12. package/dist/cjs/theme/shared.d.ts +7 -0
  13. package/dist/cjs/theme/shared.js +61 -0
  14. package/dist/cjs/theme/summary.d.ts +11 -0
  15. package/dist/cjs/theme/summary.js +61 -0
  16. package/dist/cjs/theme/table.d.ts +13 -0
  17. package/dist/cjs/theme/table.js +121 -0
  18. package/dist/cjs/types/index.d.ts +8 -5
  19. package/dist/cjs/types/theme.d.ts +107 -0
  20. package/dist/cjs/types/theme.js +17 -0
  21. package/dist/cjs/util/animation.js +6 -1
  22. package/dist/cjs/util/components.d.ts +20 -0
  23. package/dist/cjs/util/components.js +40 -0
  24. package/dist/cjs/util/crosshair-axis-labels.d.ts +7 -2
  25. package/dist/cjs/util/crosshair-axis-labels.js +144 -30
  26. package/dist/cjs/util/html.d.ts +1 -0
  27. package/dist/cjs/util/html.js +29 -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 +13 -10
  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 +87 -51
  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 -6
  49. package/dist/cjs/vis/funnel/index.js +77 -58
  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 +56 -8
  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/resolve.d.ts +7 -0
  93. package/dist/esm/theme/resolve.js +27 -0
  94. package/dist/esm/theme/shared.d.ts +7 -0
  95. package/dist/esm/theme/shared.js +21 -0
  96. package/dist/esm/theme/summary.d.ts +11 -0
  97. package/dist/esm/theme/summary.js +45 -0
  98. package/dist/esm/theme/table.d.ts +13 -0
  99. package/dist/esm/theme/table.js +112 -0
  100. package/dist/esm/types/index.d.ts +8 -5
  101. package/dist/esm/types/theme.d.ts +107 -0
  102. package/dist/esm/types/theme.js +1 -0
  103. package/dist/esm/util/animation.js +12 -2
  104. package/dist/esm/util/components.d.ts +20 -0
  105. package/dist/esm/util/components.js +57 -1
  106. package/dist/esm/util/crosshair-axis-labels.d.ts +7 -2
  107. package/dist/esm/util/crosshair-axis-labels.js +156 -35
  108. package/dist/esm/util/html.d.ts +1 -0
  109. package/dist/esm/util/html.js +3 -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 +13 -10
  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 +97 -57
  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 -6
  131. package/dist/esm/vis/funnel/index.js +78 -68
  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 +48 -11
  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,7 +23,10 @@ __export(line_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(line_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 Line = (options) => {
28
31
  const { container, width, height, theme: chartTheme = "default" } = options;
29
32
  let chart = null;
@@ -31,16 +34,44 @@ var Line = (options) => {
31
34
  let cleanupCrosshairAxisLabels = null;
32
35
  const render = (config) => {
33
36
  var _a;
34
- const { data = [], theme = chartTheme, title, axisXTitle, axisYTitle, style = {} } = config;
37
+ const {
38
+ data = [],
39
+ theme = chartTheme,
40
+ title,
41
+ subtitle,
42
+ axisXTitle,
43
+ axisYTitle,
44
+ style: localStyle = {}
45
+ } = config;
35
46
  if (chart) {
36
47
  cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
37
48
  cleanupCrosshairAxisLabels = null;
38
49
  chart.destroy();
39
50
  }
40
- const { lineWidth = import_util.CHART_STYLE_DEFAULTS.lineWidth } = style;
41
51
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
42
- const colors = (0, import_util.normalizePalette)(style.palette, theme);
43
- const backgroundColor = style.backgroundColor || (0, import_util.getBackgroundColor)(theme);
52
+ const cartesianAxisOptions = {
53
+ axisXTitle,
54
+ axisYTitle,
55
+ xLabels: data.map(({ time }) => time),
56
+ chartWidth: width
57
+ };
58
+ const appearance = (0, import_g22.getThemeObject)("line", theme, localStyle);
59
+ const { theme: rendererTheme } = appearance;
60
+ const lineMark = {
61
+ lineWidth: import_tokens.CHART_STYLE_DEFAULTS.lineWidth,
62
+ lineCap: "round",
63
+ lineJoin: "round",
64
+ ...appearance.mark.line
65
+ };
66
+ const pointStyle = {
67
+ shape: "point",
68
+ size: import_tokens.CHART_STYLE_DEFAULTS.pointSize,
69
+ lineWidth: import_tokens.CHART_STYLE_DEFAULTS.pointLineWidth,
70
+ stroke: rendererTheme.view.viewFill,
71
+ ...appearance.mark.point
72
+ };
73
+ const baseTheme = rendererTheme.type;
74
+ const colors = rendererTheme.category10;
44
75
  const tooltip = {
45
76
  items: [
46
77
  (d) => ({
@@ -51,12 +82,6 @@ var Line = (options) => {
51
82
  };
52
83
  const lineAnimation = (0, import_util.getChartAnimation)(hasRendered, "pathIn");
53
84
  const pointAnimation = (0, import_util.getChartAnimation)(hasRendered, "fadeIn");
54
- const cartesianAxisOptions = {
55
- axisXTitle,
56
- axisYTitle,
57
- xLabels: data.map(({ time }) => time),
58
- chartWidth: width
59
- };
60
85
  chart = new import_g2.Chart({
61
86
  container,
62
87
  width,
@@ -76,9 +101,7 @@ var Line = (options) => {
76
101
  type: "line",
77
102
  tooltip,
78
103
  style: {
79
- lineWidth,
80
- lineCap: "round",
81
- lineJoin: "round",
104
+ ...lineMark,
82
105
  ...!hasGroupField ? { stroke: colors[0] } : {}
83
106
  },
84
107
  animate: lineAnimation
@@ -86,20 +109,19 @@ var Line = (options) => {
86
109
  ];
87
110
  const showPoints = data.length <= (hasGroupField ? 36 : 24);
88
111
  if (showPoints) {
112
+ const { size: pointSize, ...pointMark } = pointStyle;
89
113
  children.push({
90
114
  type: "point",
91
115
  encode: {
92
116
  x: "time",
93
117
  y: "value",
94
- shape: "point",
95
- size: import_util.CHART_STYLE_DEFAULTS.pointSize,
118
+ size: pointSize,
96
119
  ...hasGroupField ? { color: "group" } : {}
97
120
  },
98
121
  animate: pointAnimation,
99
122
  tooltip: false,
100
123
  style: {
101
- lineWidth: import_util.CHART_STYLE_DEFAULTS.pointLineWidth,
102
- stroke: backgroundColor,
124
+ ...pointMark,
103
125
  ...!hasGroupField ? { fill: colors[0] } : {}
104
126
  }
105
127
  });
@@ -107,21 +129,20 @@ var Line = (options) => {
107
129
  const chartOptions = {
108
130
  type: "view",
109
131
  data,
110
- title: title || "",
132
+ title: title ? { title, subtitle } : "",
111
133
  encode,
112
134
  children,
113
135
  scale: scaleConfig,
114
136
  ...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
115
137
  axis: (0, import_util.getCartesianAxis)(cartesianAxisOptions),
116
- legend: (0, import_util.getColorLegend)(hasGroupField),
138
+ legend: (0, import_components.getColorLegend)(hasGroupField),
117
139
  interaction: {
118
140
  tooltip: (0, import_util.getSharedTooltipInteraction)({ crosshairs: true })
119
141
  },
120
- viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
121
- theme: (0, import_util.getThemeObject)(theme)
142
+ theme: rendererTheme
122
143
  };
123
144
  chart.options(chartOptions);
124
- cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart, theme);
145
+ cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart, baseTheme);
125
146
  chart.render();
126
147
  hasRendered = true;
127
148
  };
@@ -1,17 +1,15 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * LiquidConfig defines the configuration for rendering the liquid chart.
4
4
  */
5
5
  export interface LiquidConfig {
6
6
  type?: 'liquid';
7
7
  percent: number;
8
- shape?: 'rect' | 'circle' | 'pin' | 'triangle';
8
+ shape?: 'circle' | 'rect' | 'pin' | 'triangle';
9
9
  theme?: VisualizationTheme;
10
10
  title?: string;
11
- style?: {
12
- backgroundColor?: string;
13
- palette?: string[];
14
- };
11
+ subtitle?: string;
12
+ style?: ThemeStyle;
15
13
  }
16
14
  /**
17
15
  * LiquidInstance represents a liquid chart instance with render and destroy methods.
@@ -23,20 +23,25 @@ __export(liquid_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(liquid_exports);
25
25
  var import_g2 = require("@antv/g2");
26
- var import_util = require("../../util");
26
+ var import_g22 = require("../../theme/g2");
27
+ var import_tokens = require("../../util/tokens");
27
28
  var DEFAULT_WIDTH = 640;
28
29
  var DEFAULT_HEIGHT = 480;
29
30
  var Liquid = (options) => {
30
31
  const { container, width, height, theme: chartTheme = "default" } = options;
31
32
  let chart = null;
32
33
  const render = (config) => {
33
- const { percent, shape = "circle", theme = chartTheme, title, style = {} } = config;
34
+ const { percent, shape, theme = chartTheme, title, subtitle, style: localStyle = {} } = config;
34
35
  if (chart) {
35
36
  chart.destroy();
36
37
  }
37
- const colors = (0, import_util.normalizePalette)(style.palette, theme);
38
- const backgroundColor = style.backgroundColor || (0, import_util.getBackgroundColor)(theme);
39
- const tokens = (0, import_util.getChartVisualTokens)(theme);
38
+ const appearance = (0, import_g22.getThemeObject)("liquid", theme, localStyle);
39
+ const { theme: rendererTheme } = appearance;
40
+ const baseTheme = rendererTheme.type;
41
+ const liquidStyle = appearance.mark.liquid;
42
+ const resolvedShape = shape ?? liquidStyle.shape ?? "circle";
43
+ const colors = rendererTheme.category10;
44
+ const backgroundColor = rendererTheme.view.viewFill;
40
45
  const normalizedPercent = Number.isFinite(percent) ? Math.max(0, Math.min(1, percent)) : 0;
41
46
  const inferFontSize = Math.min(width ?? DEFAULT_WIDTH, height ?? DEFAULT_HEIGHT) / 10;
42
47
  const fontSize = Math.min(Math.max(inferFontSize, 24), 64);
@@ -44,8 +49,8 @@ var Liquid = (options) => {
44
49
  const waveLength = Math.min(Math.max(chartSize * 0.4, 96), 192);
45
50
  const formattedPercent = `${Number((normalizedPercent * 100).toFixed(1))}%`;
46
51
  const liquidColor = colors[0];
47
- const isAcademy = theme === "academy";
48
- const outlineShadowColor = theme === "dark" ? "rgba(0, 0, 0, 0.32)" : "rgba(15, 23, 42, 0.10)";
52
+ const isAcademy = baseTheme === "academy";
53
+ const outlineShadowColor = baseTheme === "dark" ? "rgba(0, 0, 0, 0.32)" : "rgba(15, 23, 42, 0.10)";
49
54
  chart = new import_g2.Chart({
50
55
  container,
51
56
  width,
@@ -56,25 +61,24 @@ var Liquid = (options) => {
56
61
  animate: false,
57
62
  type: "liquid",
58
63
  data: normalizedPercent,
59
- title: title || "",
64
+ title: title ? { title, subtitle } : "",
60
65
  inset: 20,
61
66
  style: {
62
- shape,
63
67
  contentText: formattedPercent,
64
68
  contentFontSize: fontSize,
65
- contentFill: tokens.textPrimary,
69
+ contentFill: rendererTheme.label.fill,
66
70
  contentStroke: backgroundColor,
67
71
  contentStrokeOpacity: 0.92,
68
- contentLineWidth: theme === "dark" ? 3 : 2.5,
69
- contentFontFamily: import_util.CHART_FONT_FAMILY,
72
+ contentLineWidth: baseTheme === "dark" ? 3 : 2.5,
73
+ contentFontFamily: import_tokens.CHART_FONT_FAMILY,
70
74
  contentFontWeight: 600,
71
75
  contentLetterSpacing: -0.8,
72
76
  contentFontVariantNumeric: "tabular-nums",
73
77
  contentPaintOrder: "stroke",
74
78
  backgroundFill: liquidColor,
75
- backgroundFillOpacity: theme === "dark" ? 0.14 : isAcademy ? 0.06 : 0.08,
79
+ backgroundFillOpacity: baseTheme === "dark" ? 0.14 : isAcademy ? 0.06 : 0.08,
76
80
  backgroundStroke: liquidColor,
77
- backgroundStrokeOpacity: theme === "dark" ? 0.3 : 0.22,
81
+ backgroundStrokeOpacity: baseTheme === "dark" ? 0.3 : 0.22,
78
82
  backgroundLineWidth: 1,
79
83
  outlineBorder: isAcademy ? 1.5 : 2,
80
84
  outlineDistance: 0,
@@ -87,10 +91,11 @@ var Liquid = (options) => {
87
91
  fillOpacity: isAcademy ? 0.9 : 0.88,
88
92
  contentPointerEvents: "none",
89
93
  // Use palette color if provided
90
- ...liquidColor ? { fill: liquidColor, outlineStroke: liquidColor } : {}
94
+ ...liquidColor ? { fill: liquidColor, outlineStroke: liquidColor } : {},
95
+ ...liquidStyle,
96
+ shape: resolvedShape
91
97
  },
92
- viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
93
- theme: (0, import_util.getThemeObject)(theme),
98
+ theme: rendererTheme,
94
99
  tooltip: false
95
100
  };
96
101
  chart.options(chartOptions);
@@ -1,4 +1,4 @@
1
- import type { TreeGraphData, VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, TreeGraphData, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  export type MindmapData = TreeGraphData;
3
3
  /**
4
4
  * MindmapConfig defines the configuration for rendering the mindmap.
@@ -7,12 +7,10 @@ export interface MindmapConfig {
7
7
  type?: 'mindmap';
8
8
  data: MindmapData;
9
9
  direction?: 'H' | 'LR' | 'RL';
10
- theme?: 'default' | 'academy' | 'dark';
10
+ theme?: VisualizationTheme;
11
11
  title?: string;
12
- style?: {
13
- backgroundColor?: string;
14
- palette?: string[];
15
- };
12
+ subtitle?: string;
13
+ style?: ThemeStyle;
16
14
  }
17
15
  /**
18
16
  * MindmapInstance represents a mindmap instance with render and destroy methods.
@@ -23,7 +23,8 @@ __export(mindmap_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(mindmap_exports);
25
25
  var import_g6 = require("@antv/g6");
26
- var import_theme = require("../../util/theme");
26
+ var import_g62 = require("../../theme/g6");
27
+ var import_components = require("../../util/components");
27
28
  function toG6TreeData(node) {
28
29
  return {
29
30
  id: node.name,
@@ -78,7 +79,14 @@ var Mindmap = (options) => {
78
79
  const { container, width, height, theme: chartTheme = "default" } = options;
79
80
  let graph = null;
80
81
  const render = (config) => {
81
- const { data, direction = "H", theme = chartTheme, title, style = {} } = config;
82
+ const {
83
+ data,
84
+ direction = "H",
85
+ theme = chartTheme,
86
+ title,
87
+ subtitle,
88
+ style: localStyle = {}
89
+ } = config;
82
90
  if (!data || !data.name) {
83
91
  throw new Error("Mindmap: data with a name field is required");
84
92
  }
@@ -91,18 +99,27 @@ var Mindmap = (options) => {
91
99
  throw new Error("Mindmap: container element not found");
92
100
  }
93
101
  containerEl.innerHTML = "";
94
- const colors = (0, import_theme.normalizePalette)(style.palette, theme);
95
- const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
96
- const isDark = theme === "dark";
102
+ const appearance = (0, import_g62.getThemeObject)("mindmap", theme, localStyle);
103
+ const graphTitle = (0, import_components.getGraphTitle)(title, subtitle, appearance.titleStyle);
104
+ const { theme: rendererTheme } = appearance;
105
+ const baseTheme = appearance.baseTheme;
106
+ const colors = appearance.colors;
107
+ const backgroundColor = appearance.backgroundColor;
108
+ const isDark = baseTheme === "dark";
109
+ const nodeTheme = appearance.node.style;
110
+ const edgeTheme = appearance.edge.style;
97
111
  containerEl.style.background = backgroundColor;
98
112
  const graphData = convertTreeData(data);
99
113
  assignBranchColors(graphData, colors);
100
114
  for (const node of graphData.nodes || []) {
101
115
  const label = String(node.id);
102
116
  const depth = node.depth ?? 0;
103
- const fontSize = depth === 0 ? 24 : 16;
117
+ const fontSize = nodeTheme.labelFontSize ?? (depth === 0 ? 24 : 16);
104
118
  const pad = depth === 0 ? 64 : 36;
105
- node.layoutSize = [estimateNodeWidth(label, fontSize, pad), depth === 0 ? 60 : 48];
119
+ node.layoutSize = [
120
+ estimateNodeWidth(label, fontSize, pad),
121
+ Math.max(depth === 0 ? 60 : 48, Math.ceil(fontSize * 1.2) + 16)
122
+ ];
106
123
  }
107
124
  graph = new import_g6.Graph({
108
125
  animation: false,
@@ -111,20 +128,12 @@ var Mindmap = (options) => {
111
128
  height,
112
129
  autoFit: "view",
113
130
  autoResize: true,
114
- padding: title ? [46, 20, 20, 20] : 20,
131
+ padding: graphTitle.padding,
115
132
  zoomRange: [0.1, 5],
116
133
  zoom: 1,
117
- theme: (0, import_theme.getTheme)(theme),
134
+ theme: rendererTheme,
118
135
  data: graphData,
119
- plugins: title ? [
120
- {
121
- key: "title",
122
- type: "title",
123
- title,
124
- titleFill: isDark ? "#e0e6ed" : "#000",
125
- titleFontFamily: "sans-serif"
126
- }
127
- ] : [],
136
+ plugins: graphTitle.plugins,
128
137
  node: {
129
138
  type: "rect",
130
139
  animation: { translate: false, update: false },
@@ -140,27 +149,33 @@ var Mindmap = (options) => {
140
149
  const fontWeight = depth <= 1 ? 600 : 400;
141
150
  const dx = side === "left" ? -nodeWidth : side === "center" ? -nodeWidth / 2 : 0;
142
151
  const base = {
152
+ radius: baseTheme === "academy" ? 0 : 8,
153
+ labelFontSize: fontSize,
154
+ labelFontWeight: fontWeight
155
+ };
156
+ const structuralStyle = {
143
157
  size: [nodeWidth, nodeHeight],
144
158
  dx,
145
- radius: theme === "academy" ? 0 : 8,
146
159
  labelText: label,
147
160
  labelPlacement: "center",
148
- labelFontSize: fontSize,
149
- labelFontWeight: fontWeight,
150
161
  ports: [{ placement: "left" }, { placement: "right" }]
151
162
  };
152
163
  if (depth === 0) {
153
164
  return {
154
165
  ...base,
155
166
  fill: isDark ? "#333" : "#f1f4f5",
156
- labelFill: isDark ? "#e0e0e0" : "#252525"
167
+ labelFill: isDark ? "#e0e0e0" : "#252525",
168
+ ...nodeTheme,
169
+ ...structuralStyle
157
170
  };
158
171
  }
159
172
  if (depth === 1) {
160
173
  return {
161
174
  ...base,
162
175
  fill: color || "#99ADD1",
163
- labelFill: "#fff"
176
+ labelFill: "#fff",
177
+ ...nodeTheme,
178
+ ...structuralStyle
164
179
  };
165
180
  }
166
181
  return {
@@ -168,7 +183,9 @@ var Mindmap = (options) => {
168
183
  fill: backgroundColor,
169
184
  stroke: color || (isDark ? "#555" : "#99ADD1"),
170
185
  lineWidth: 3,
171
- labelFill: isDark ? color || "#ccc" : color || "#333"
186
+ labelFill: isDark ? color || "#ccc" : color || "#333",
187
+ ...nodeTheme,
188
+ ...structuralStyle
172
189
  };
173
190
  }
174
191
  },
@@ -181,7 +198,8 @@ var Mindmap = (options) => {
181
198
  var _a;
182
199
  const sourceNode = this.getNodeData(edgeData.source);
183
200
  return ((_a = sourceNode == null ? void 0 : sourceNode.style) == null ? void 0 : _a.color) || (isDark ? "#555" : "#99ADD1");
184
- }
201
+ },
202
+ ...edgeTheme
185
203
  }
186
204
  },
187
205
  layout: {
@@ -1,4 +1,4 @@
1
- import type { GraphData, VisualizationOptions } from '../../types';
1
+ import type { GraphData, ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  export type NetworkGraphNode = GraphData['nodes'][number];
3
3
  export type NetworkGraphEdge = GraphData['edges'][number];
4
4
  export type NetworkGraphData = GraphData;
@@ -9,12 +9,10 @@ export interface NetworkGraphConfig {
9
9
  type?: 'network-graph';
10
10
  data: NetworkGraphData;
11
11
  layout?: 'force' | 'circular' | 'grid' | 'radial' | 'concentric' | 'dagre';
12
- theme?: 'default' | 'academy' | 'dark';
12
+ theme?: VisualizationTheme;
13
13
  title?: string;
14
- style?: {
15
- backgroundColor?: string;
16
- palette?: string[];
17
- };
14
+ subtitle?: string;
15
+ style?: ThemeStyle;
18
16
  }
19
17
  /**
20
18
  * NetworkGraphInstance represents a network graph instance with render and destroy methods.
@@ -23,7 +23,8 @@ __export(network_graph_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(network_graph_exports);
25
25
  var import_g6 = require("@antv/g6");
26
- var import_theme = require("../../util/theme");
26
+ var import_g62 = require("../../theme/g6");
27
+ var import_components = require("../../util/components");
27
28
  var NetworkGraph = (options) => {
28
29
  const { container, width, height, theme: chartTheme = "default" } = options;
29
30
  let graph = null;
@@ -33,16 +34,23 @@ var NetworkGraph = (options) => {
33
34
  layout = "force",
34
35
  theme = chartTheme,
35
36
  title,
36
- style = {}
37
+ subtitle,
38
+ style: localStyle = {}
37
39
  } = config;
38
40
  const { nodes = [], edges = [] } = data;
39
41
  if (graph) {
40
42
  graph.destroy();
41
43
  graph = null;
42
44
  }
43
- const colors = (0, import_theme.normalizePalette)(style.palette, theme);
44
- const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
45
- const isDark = theme === "dark";
45
+ const appearance = (0, import_g62.getThemeObject)("network-graph", theme, localStyle);
46
+ const graphTitle = (0, import_components.getGraphTitle)(title, subtitle, appearance.titleStyle);
47
+ const { theme: rendererTheme } = appearance;
48
+ const baseTheme = appearance.baseTheme;
49
+ const colors = appearance.colors;
50
+ const backgroundColor = appearance.backgroundColor;
51
+ const isDark = baseTheme === "dark";
52
+ const nodeTheme = appearance.node;
53
+ const edgeTheme = appearance.edge;
46
54
  const containerEl = typeof container === "string" ? document.querySelector(container) : container;
47
55
  if (!containerEl) {
48
56
  throw new Error("NetworkGraph: container element not found");
@@ -58,10 +66,11 @@ var NetworkGraph = (options) => {
58
66
  fill: colors[index % colors.length],
59
67
  stroke: isDark ? "#444" : "#fff",
60
68
  lineWidth: 2,
61
- labelText: node.name,
62
69
  labelFill: isDark ? "#e0e0e0" : "#333",
63
70
  labelFontSize: 12,
64
- size: 28
71
+ ...nodeTheme.style,
72
+ size: 28,
73
+ labelText: node.name
65
74
  }
66
75
  }));
67
76
  const edgeData = edges.map((edge) => ({
@@ -72,12 +81,13 @@ var NetworkGraph = (options) => {
72
81
  stroke: isDark ? "#555" : "#ccc",
73
82
  lineWidth: 1.5,
74
83
  endArrow: true,
75
- labelText: edge.name ?? "",
76
84
  labelFill: isDark ? "#aaa" : "#666",
77
85
  labelFontSize: 11,
78
86
  labelBackground: !!edge.name,
79
87
  labelBackgroundFill: backgroundColor,
80
- labelBackgroundOpacity: 0.8
88
+ labelBackgroundOpacity: 0.8,
89
+ ...edgeTheme.style,
90
+ labelText: edge.name ?? ""
81
91
  }
82
92
  }));
83
93
  const layoutConfig = {
@@ -119,29 +129,25 @@ var NetworkGraph = (options) => {
119
129
  height,
120
130
  autoFit: "view",
121
131
  autoResize: true,
122
- theme: (0, import_theme.getTheme)(theme),
123
- padding: title ? [46, 20, 20, 20] : 20,
132
+ theme: rendererTheme,
133
+ padding: graphTitle.padding,
124
134
  data: {
125
135
  nodes: nodeData,
126
136
  edges: edgeData
127
137
  },
128
138
  layout: layoutConfig[layout] || layoutConfig.force,
129
139
  node: {
140
+ type: nodeTheme.type ?? "circle",
130
141
  style: {
131
142
  labelPlacement: "bottom",
132
143
  labelMaxWidth: 100
133
144
  }
134
145
  },
146
+ edge: {
147
+ type: edgeTheme.type ?? "line"
148
+ },
135
149
  behaviors: ["drag-canvas", "drag-element", "click-select"],
136
- plugins: title ? [
137
- {
138
- key: "title",
139
- type: "title",
140
- title,
141
- titleFill: isDark ? "#e0e6ed" : "#000",
142
- titleFontFamily: "sans-serif"
143
- }
144
- ] : []
150
+ plugins: graphTitle.plugins
145
151
  });
146
152
  graph.render();
147
153
  };
@@ -1,4 +1,4 @@
1
- import type { TreeGraphData, VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, TreeGraphData, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  export type OrganizationChartData = TreeGraphData;
3
3
  /**
4
4
  * OrganizationChartConfig defines the configuration for rendering the organization chart.
@@ -6,12 +6,10 @@ export type OrganizationChartData = TreeGraphData;
6
6
  export interface OrganizationChartConfig {
7
7
  type?: 'organization-chart';
8
8
  data: OrganizationChartData;
9
- theme?: 'default' | 'academy' | 'dark';
9
+ theme?: VisualizationTheme;
10
10
  title?: string;
11
- style?: {
12
- backgroundColor?: string;
13
- palette?: string[];
14
- };
11
+ subtitle?: string;
12
+ style?: ThemeStyle;
15
13
  }
16
14
  /**
17
15
  * OrganizationChartInstance represents a chart instance with render and destroy methods.