@antv/gpt-vis 1.0.0-beta.1 → 1.0.0-beta.2

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 (157) hide show
  1. package/README.md +6 -4
  2. package/README.zh-CN.md +6 -4
  3. package/dist/cjs/gpt-vis/index.d.ts +8 -1
  4. package/dist/cjs/gpt-vis/index.js +43 -20
  5. package/dist/cjs/index.d.ts +15 -2
  6. package/dist/cjs/index.js +22 -2
  7. package/dist/cjs/syntax/parser.d.ts +17 -2
  8. package/dist/cjs/syntax/parser.js +151 -38
  9. package/dist/cjs/util/container.d.ts +5 -0
  10. package/dist/cjs/util/container.js +43 -0
  11. package/dist/cjs/util/theme.d.ts +5 -0
  12. package/dist/cjs/util/theme.js +9 -2
  13. package/dist/cjs/vis/area/index.js +2 -1
  14. package/dist/cjs/vis/bar/index.js +5 -4
  15. package/dist/cjs/vis/boxplot/index.js +7 -2
  16. package/dist/cjs/vis/column/index.js +5 -4
  17. package/dist/cjs/vis/dual-axes/index.js +2 -1
  18. package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
  19. package/dist/cjs/vis/fishbone-diagram/index.js +183 -0
  20. package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
  21. package/dist/cjs/vis/flow-diagram/index.js +271 -0
  22. package/dist/cjs/vis/funnel/index.js +2 -1
  23. package/dist/cjs/vis/histogram/index.js +3 -7
  24. package/dist/cjs/vis/indented-tree/index.d.ts +40 -0
  25. package/dist/cjs/vis/indented-tree/index.js +375 -0
  26. package/dist/cjs/vis/line/index.js +2 -1
  27. package/dist/cjs/vis/liquid/index.js +2 -1
  28. package/dist/cjs/vis/mindmap/index.d.ts +32 -0
  29. package/dist/cjs/vis/mindmap/index.js +214 -0
  30. package/dist/cjs/vis/network-graph/index.d.ts +59 -0
  31. package/dist/cjs/vis/network-graph/index.js +166 -0
  32. package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
  33. package/dist/cjs/vis/organization-chart/index.js +191 -0
  34. package/dist/cjs/vis/pie/index.js +3 -3
  35. package/dist/cjs/vis/radar/index.d.ts +1 -0
  36. package/dist/cjs/vis/radar/index.js +10 -9
  37. package/dist/cjs/vis/sankey/index.js +2 -1
  38. package/dist/cjs/vis/scatter/index.js +2 -1
  39. package/dist/cjs/vis/summary/index.js +17 -3
  40. package/dist/cjs/vis/table/index.d.ts +1 -0
  41. package/dist/cjs/vis/table/index.js +37 -1
  42. package/dist/cjs/vis/treemap/index.js +2 -1
  43. package/dist/cjs/vis/venn/index.d.ts +2 -1
  44. package/dist/cjs/vis/venn/index.js +18 -3
  45. package/dist/cjs/vis/violin/index.js +2 -1
  46. package/dist/cjs/vis/waterfall/index.d.ts +6 -9
  47. package/dist/cjs/vis/waterfall/index.js +28 -5
  48. package/dist/cjs/vis/word-cloud/index.js +2 -1
  49. package/dist/cjs/vis-wrapper/icons.js +2 -2
  50. package/dist/cjs/vis-wrapper/index.d.ts +1 -0
  51. package/dist/cjs/vis-wrapper/index.js +27 -16
  52. package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
  53. package/dist/cjs/vis-wrapper/styles.js +8 -1
  54. package/dist/esm/gpt-vis/index.d.ts +8 -1
  55. package/dist/esm/gpt-vis/index.js +47 -26
  56. package/dist/esm/index.d.ts +15 -2
  57. package/dist/esm/index.js +7 -1
  58. package/dist/esm/syntax/parser.d.ts +17 -2
  59. package/dist/esm/syntax/parser.js +248 -90
  60. package/dist/esm/util/container.d.ts +5 -0
  61. package/dist/esm/util/container.js +20 -0
  62. package/dist/esm/util/theme.d.ts +5 -0
  63. package/dist/esm/util/theme.js +9 -0
  64. package/dist/esm/vis/area/index.js +3 -2
  65. package/dist/esm/vis/bar/index.js +7 -6
  66. package/dist/esm/vis/boxplot/index.js +17 -4
  67. package/dist/esm/vis/column/index.js +7 -6
  68. package/dist/esm/vis/dual-axes/index.js +3 -2
  69. package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
  70. package/dist/esm/vis/fishbone-diagram/index.js +218 -0
  71. package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
  72. package/dist/esm/vis/flow-diagram/index.js +342 -0
  73. package/dist/esm/vis/funnel/index.js +3 -2
  74. package/dist/esm/vis/histogram/index.js +6 -7
  75. package/dist/esm/vis/indented-tree/index.d.ts +40 -0
  76. package/dist/esm/vis/indented-tree/index.js +564 -0
  77. package/dist/esm/vis/line/index.js +3 -2
  78. package/dist/esm/vis/liquid/index.js +3 -2
  79. package/dist/esm/vis/mindmap/index.d.ts +32 -0
  80. package/dist/esm/vis/mindmap/index.js +315 -0
  81. package/dist/esm/vis/network-graph/index.d.ts +59 -0
  82. package/dist/esm/vis/network-graph/index.js +240 -0
  83. package/dist/esm/vis/organization-chart/index.d.ts +64 -0
  84. package/dist/esm/vis/organization-chart/index.js +269 -0
  85. package/dist/esm/vis/pie/index.js +4 -8
  86. package/dist/esm/vis/radar/index.d.ts +1 -0
  87. package/dist/esm/vis/radar/index.js +20 -4
  88. package/dist/esm/vis/sankey/index.js +3 -2
  89. package/dist/esm/vis/scatter/index.js +3 -2
  90. package/dist/esm/vis/summary/index.js +25 -4
  91. package/dist/esm/vis/table/index.d.ts +1 -0
  92. package/dist/esm/vis/table/index.js +9 -2
  93. package/dist/esm/vis/treemap/index.js +3 -2
  94. package/dist/esm/vis/venn/index.d.ts +2 -1
  95. package/dist/esm/vis/venn/index.js +29 -4
  96. package/dist/esm/vis/violin/index.js +3 -2
  97. package/dist/esm/vis/waterfall/index.d.ts +6 -9
  98. package/dist/esm/vis/waterfall/index.js +27 -9
  99. package/dist/esm/vis/word-cloud/index.js +3 -2
  100. package/dist/esm/vis-wrapper/icons.js +2 -2
  101. package/dist/esm/vis-wrapper/index.d.ts +1 -0
  102. package/dist/esm/vis-wrapper/index.js +15 -10
  103. package/dist/esm/vis-wrapper/styles.d.ts +1 -1
  104. package/dist/esm/vis-wrapper/styles.js +1 -1
  105. package/dist/umd/index.min.js +1 -1
  106. package/package.json +19 -19
  107. package/src/gpt-vis/index.ts +0 -283
  108. package/src/index.ts +0 -44
  109. package/src/readme.md +0 -37
  110. package/src/syntax/index.ts +0 -2
  111. package/src/syntax/parser.ts +0 -411
  112. package/src/types/index.ts +0 -29
  113. package/src/util/theme.ts +0 -167
  114. package/src/vis/area/README.md +0 -143
  115. package/src/vis/area/index.ts +0 -212
  116. package/src/vis/bar/README.md +0 -158
  117. package/src/vis/bar/index.ts +0 -186
  118. package/src/vis/boxplot/README.md +0 -168
  119. package/src/vis/boxplot/index.ts +0 -162
  120. package/src/vis/column/README.md +0 -158
  121. package/src/vis/column/index.ts +0 -185
  122. package/src/vis/dual-axes/README.md +0 -191
  123. package/src/vis/dual-axes/index.ts +0 -218
  124. package/src/vis/funnel/README.md +0 -143
  125. package/src/vis/funnel/index.ts +0 -238
  126. package/src/vis/histogram/README.md +0 -130
  127. package/src/vis/histogram/index.ts +0 -153
  128. package/src/vis/line/README.md +0 -138
  129. package/src/vis/line/index.ts +0 -159
  130. package/src/vis/liquid/README.md +0 -150
  131. package/src/vis/liquid/index.ts +0 -130
  132. package/src/vis/pie/README.md +0 -127
  133. package/src/vis/pie/index.ts +0 -163
  134. package/src/vis/radar/README.md +0 -184
  135. package/src/vis/radar/index.ts +0 -214
  136. package/src/vis/sankey/README.md +0 -144
  137. package/src/vis/sankey/index.ts +0 -144
  138. package/src/vis/scatter/README.md +0 -145
  139. package/src/vis/scatter/index.ts +0 -147
  140. package/src/vis/summary/README.md +0 -272
  141. package/src/vis/summary/index.ts +0 -91
  142. package/src/vis/table/README.md +0 -174
  143. package/src/vis/table/index.ts +0 -241
  144. package/src/vis/treemap/README.md +0 -199
  145. package/src/vis/treemap/index.ts +0 -167
  146. package/src/vis/venn/README.md +0 -153
  147. package/src/vis/venn/index.ts +0 -149
  148. package/src/vis/violin/README.md +0 -168
  149. package/src/vis/violin/index.ts +0 -216
  150. package/src/vis/waterfall/README.md +0 -178
  151. package/src/vis/waterfall/index.ts +0 -258
  152. package/src/vis/word-cloud/README.md +0 -137
  153. package/src/vis/word-cloud/index.ts +0 -137
  154. package/src/vis-wrapper/README.md +0 -159
  155. package/src/vis-wrapper/icons.ts +0 -35
  156. package/src/vis-wrapper/index.ts +0 -276
  157. package/src/vis-wrapper/styles.ts +0 -195
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
8
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
9
9
 
10
10
  /**
11
11
  * BarDataItem is the type for each data item in the bar chart.
@@ -57,7 +57,7 @@ export var Bar = function Bar(options) {
57
57
  * Render the bar chart with the given configuration.
58
58
  */
59
59
  var render = function render(config) {
60
- var _data$, _style$palette;
60
+ var _data$;
61
61
  var _config$data = config.data,
62
62
  data = _config$data === void 0 ? [] : _config$data,
63
63
  _config$theme = config.theme,
@@ -77,7 +77,7 @@ export var Bar = function Bar(options) {
77
77
  chart.destroy();
78
78
  }
79
79
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
80
- var colors = style.palette || getThemeColors(theme);
80
+ var colors = normalizePalette(style.palette, theme);
81
81
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
82
82
 
83
83
  // Create chart
@@ -93,8 +93,8 @@ export var Bar = function Bar(options) {
93
93
  var transform = [];
94
94
  var radiusStyle = {};
95
95
 
96
- // Set radius style for default theme
97
- if (theme === 'default') {
96
+ // academy theme uses no rounded corners; other themes use rounded top corners
97
+ if (theme !== 'academy') {
98
98
  radiusStyle = {
99
99
  radiusTopLeft: 4,
100
100
  radiusTopRight: 4
@@ -133,7 +133,7 @@ export var Bar = function Bar(options) {
133
133
  y: {
134
134
  nice: true
135
135
  }
136
- }, (_style$palette = style.palette) !== null && _style$palette !== void 0 && _style$palette.length ? {
136
+ }, style.palette ? {
137
137
  color: {
138
138
  range: colors
139
139
  }
@@ -143,6 +143,7 @@ export var Bar = function Bar(options) {
143
143
  // Note: Using 'any' type due to G2's complex type system with transformations
144
144
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
145
145
  var chartOptions = {
146
+ animate: false,
146
147
  type: 'interval',
147
148
  data: data,
148
149
  title: title !== null && title !== void 0 ? title : '',
@@ -1,5 +1,11 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
7
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
8
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
3
9
 
4
10
  /**
5
11
  * BoxplotDataItem is the type for each data item in the boxplot chart.
@@ -68,7 +74,7 @@ export var Boxplot = function Boxplot(options) {
68
74
  }
69
75
 
70
76
  // Get colors from style.palette or theme defaults
71
- var colors = style.palette || getThemeColors(theme);
77
+ var colors = normalizePalette(style.palette, theme);
72
78
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
73
79
  var startAtZero = style.startAtZero || false;
74
80
 
@@ -102,6 +108,7 @@ export var Boxplot = function Boxplot(options) {
102
108
  // Note: Using 'any' type due to G2's complex type system with transformations
103
109
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
104
110
  var chartOptions = {
111
+ animate: false,
105
112
  type: 'boxplot',
106
113
  data: data,
107
114
  title: title !== null && title !== void 0 ? title : '',
@@ -131,9 +138,15 @@ export var Boxplot = function Boxplot(options) {
131
138
  range: colors
132
139
  }
133
140
  },
134
- style: {
141
+ // When hasGroupField is true, set point to false to prevent G2's Boxplot composite mark
142
+ // from splitting into box + point child marks. The point child mark does not inherit
143
+ // the `scale` config, causing legendFilter interaction to throw
144
+ // "Cannot read properties of undefined (reading 'color')" when clicking legend items.
145
+ style: _objectSpread({
135
146
  stroke: 'black'
136
- },
147
+ }, hasGroupField ? {
148
+ point: false
149
+ } : {}),
137
150
  legend: {
138
151
  color: hasGroupField ? {
139
152
  position: 'top'
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
8
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
9
9
 
10
10
  /**
11
11
  * ColumnDataItem is the type for each data item in the column chart.
@@ -57,7 +57,7 @@ export var Column = function Column(options) {
57
57
  * Render the column chart with the given configuration.
58
58
  */
59
59
  var render = function render(config) {
60
- var _data$, _style$palette;
60
+ var _data$;
61
61
  var _config$data = config.data,
62
62
  data = _config$data === void 0 ? [] : _config$data,
63
63
  _config$theme = config.theme,
@@ -77,7 +77,7 @@ export var Column = function Column(options) {
77
77
  chart.destroy();
78
78
  }
79
79
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
80
- var colors = style.palette || getThemeColors(theme);
80
+ var colors = normalizePalette(style.palette, theme);
81
81
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
82
82
 
83
83
  // Create chart
@@ -93,8 +93,8 @@ export var Column = function Column(options) {
93
93
  var transform = [];
94
94
  var radiusStyle = {};
95
95
 
96
- // Set radius style for default theme
97
- if (theme === 'default') {
96
+ // academy theme uses no rounded corners; other themes use rounded top corners
97
+ if (theme !== 'academy') {
98
98
  radiusStyle = {
99
99
  radiusTopLeft: 4,
100
100
  radiusTopRight: 4
@@ -133,7 +133,7 @@ export var Column = function Column(options) {
133
133
  y: {
134
134
  nice: true
135
135
  }
136
- }, (_style$palette = style.palette) !== null && _style$palette !== void 0 && _style$palette.length ? {
136
+ }, style.palette ? {
137
137
  color: {
138
138
  range: colors
139
139
  }
@@ -143,6 +143,7 @@ export var Column = function Column(options) {
143
143
  // Note: Using 'any' type due to G2's complex type system with transformations
144
144
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
145
145
  var chartOptions = {
146
+ animate: false,
146
147
  type: 'interval',
147
148
  data: data,
148
149
  title: title !== null && title !== void 0 ? title : '',
@@ -5,7 +5,7 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
5
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
6
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
8
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
9
9
 
10
10
  /**
11
11
  * DualAxesSeriesItem defines a single series in the dual-axes chart.
@@ -94,7 +94,7 @@ export var DualAxes = function DualAxes(options) {
94
94
  }
95
95
  var _style$startAtZero = style.startAtZero,
96
96
  startAtZero = _style$startAtZero === void 0 ? false : _style$startAtZero;
97
- var colors = style.palette || getThemeColors(theme);
97
+ var colors = normalizePalette(style.palette, theme);
98
98
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
99
99
 
100
100
  // Transform data
@@ -186,6 +186,7 @@ export var DualAxes = function DualAxes(options) {
186
186
  // Note: Using 'any' type due to G2's complex type system with transformations
187
187
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
188
188
  var chartOptions = {
189
+ animate: false,
189
190
  type: 'view',
190
191
  data: data,
191
192
  title: title !== null && title !== void 0 ? title : '',
@@ -0,0 +1,35 @@
1
+ import type { VisualizationOptions } from '../../types';
2
+ export interface FishboneNode {
3
+ name: string;
4
+ children?: FishboneNode[];
5
+ }
6
+ /**
7
+ * FishboneDiagramConfig defines the configuration for rendering the fishbone diagram.
8
+ */
9
+ export interface FishboneDiagramConfig {
10
+ type?: 'fishbone-diagram';
11
+ data: FishboneNode;
12
+ theme?: 'default' | 'academy' | 'dark';
13
+ title?: string;
14
+ style?: {
15
+ /** Custom color palette for branch nodes, overrides theme default */
16
+ palette?: string[];
17
+ /** Canvas background color, overrides theme default */
18
+ backgroundColor?: string;
19
+ /** Node rendering style: 'rough' for hand-drawn look, 'default' for smooth */
20
+ texture?: 'rough' | 'default';
21
+ };
22
+ }
23
+ /**
24
+ * FishboneDiagramInstance represents a fishbone diagram instance.
25
+ */
26
+ export interface FishboneDiagramInstance {
27
+ render: (config: FishboneDiagramConfig) => void;
28
+ destroy: () => void;
29
+ zoomTo: (zoom: number) => void;
30
+ getZoom: () => number | undefined;
31
+ }
32
+ /**
33
+ * FishboneDiagram chart component using G6 with fishbone layout.
34
+ */
35
+ export declare const FishboneDiagram: (options: VisualizationOptions) => FishboneDiagramInstance;
@@ -0,0 +1,218 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["children"];
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+ import { Graph, treeToGraphData } from '@antv/g6';
11
+ import { getBackgroundColor, normalizePalette } from "../../util/theme";
12
+
13
+ /**
14
+ * FishboneDiagramConfig defines the configuration for rendering the fishbone diagram.
15
+ */
16
+
17
+ /**
18
+ * FishboneDiagramInstance represents a fishbone diagram instance.
19
+ */
20
+
21
+ var FONT_FAMILY = 'system-ui, sans-serif';
22
+ function getNodeSize(id, depth) {
23
+ return depth === 0 ? [measureText(id, 24, 'bold') + 80, 70] : depth === 1 ? [measureText(id, 18) + 50, 42] : [2, 30];
24
+ }
25
+ var measureText = function () {
26
+ var canvas = null;
27
+ return function (text) {
28
+ var fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
29
+ var fontWeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'normal';
30
+ if (typeof document === 'undefined') return text.length * fontSize * 0.6;
31
+ if (!canvas) canvas = document.createElement('canvas');
32
+ var ctx = canvas.getContext('2d');
33
+ if (!ctx) return 0;
34
+ ctx.font = "".concat(fontWeight, " ").concat(fontSize, "px ").concat(FONT_FAMILY);
35
+ return ctx.measureText(text).width;
36
+ };
37
+ }();
38
+
39
+ /**
40
+ * Convert name-based tree to G6 tree format (name → id).
41
+ */
42
+ function toG6TreeData(node) {
43
+ return {
44
+ id: node.name,
45
+ children: (node.children || []).map(toG6TreeData)
46
+ };
47
+ }
48
+
49
+ /**
50
+ * Convert GPT-Vis tree data to flat G6 graph data, attaching depth to each node.
51
+ */
52
+ function convertData(data) {
53
+ return treeToGraphData(toG6TreeData(data), {
54
+ getNodeData: function getNodeData(datum, depth) {
55
+ datum.depth = depth;
56
+ if (!datum.children) return datum;
57
+ var children = datum.children,
58
+ rest = _objectWithoutProperties(datum, _excluded);
59
+ return _objectSpread(_objectSpread({}, rest), {}, {
60
+ children: children.map(function (c) {
61
+ return c.id;
62
+ })
63
+ });
64
+ }
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Assign a unique palette color to each depth-1 branch node so that each
70
+ * branch is visually distinct, matching the v0.6.1 multi-color style.
71
+ */
72
+ function assignBranchColors(graphData, palette) {
73
+ var nodes = graphData.nodes || [];
74
+ var colorIndex = 0;
75
+ nodes.filter(function (n) {
76
+ return n.depth === 1;
77
+ }).forEach(function (n) {
78
+ n.style = n.style || {};
79
+ n.style.branchColor = palette[colorIndex++ % palette.length];
80
+ });
81
+ }
82
+
83
+ /**
84
+ * FishboneDiagram chart component using G6 with fishbone layout.
85
+ */
86
+ export var FishboneDiagram = function FishboneDiagram(options) {
87
+ var container = options.container,
88
+ width = options.width,
89
+ height = options.height,
90
+ _options$theme = options.theme,
91
+ chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
92
+ var graph = null;
93
+ var render = function render(config) {
94
+ var data = config.data,
95
+ _config$theme = config.theme,
96
+ theme = _config$theme === void 0 ? chartTheme : _config$theme,
97
+ title = config.title,
98
+ _config$style = config.style,
99
+ _style = _config$style === void 0 ? {} : _config$style;
100
+ if (!(data !== null && data !== void 0 && data.name)) {
101
+ throw new Error('FishboneDiagram: data with a name field is required');
102
+ }
103
+ if (graph) {
104
+ graph.destroy();
105
+ graph = null;
106
+ }
107
+ var containerEl = typeof container === 'string' ? document.querySelector(container) : container;
108
+ if (!containerEl) throw new Error('FishboneDiagram: container element not found');
109
+ containerEl.innerHTML = '';
110
+
111
+ // Theme-derived colors, allowing style.palette to override the theme default
112
+ var isDark = theme === 'dark';
113
+ var backgroundColor = _style.backgroundColor || getBackgroundColor(theme);
114
+ var palette = normalizePalette(_style.palette, theme);
115
+ var rootFill = isDark ? '#2a2a2a' : '#EFF0F0';
116
+ var rootLabelFill = isDark ? '#e0e0e0' : '#262626';
117
+ var leafLabelFill = isDark ? '#c0c0c0' : '#262626';
118
+ var edgeStroke = isDark ? '#555' : '#99ADD1';
119
+ containerEl.style.backgroundColor = backgroundColor;
120
+ var graphData = convertData(data);
121
+ assignBranchColors(graphData, palette);
122
+ graph = new Graph({
123
+ animation: false,
124
+ container: containerEl,
125
+ width: width,
126
+ height: height,
127
+ autoFit: 'view',
128
+ autoResize: true,
129
+ padding: 20,
130
+ theme: chartTheme,
131
+ plugins: title ? [{
132
+ key: 'title',
133
+ type: 'title',
134
+ title: title,
135
+ titleFill: isDark ? '#e0e6ed' : '#1a1a2e'
136
+ }] : [],
137
+ data: graphData,
138
+ node: {
139
+ type: 'rect',
140
+ style: function style(d) {
141
+ var _d$depth;
142
+ var depth = (_d$depth = d.depth) !== null && _d$depth !== void 0 ? _d$depth : 0;
143
+ var nodeStyle = {
144
+ radius: 8,
145
+ size: getNodeSize(String(d.id), depth),
146
+ labelText: String(d.id),
147
+ labelPlacement: 'left',
148
+ labelFontFamily: FONT_FAMILY
149
+ };
150
+ if (depth === 0) {
151
+ Object.assign(nodeStyle, {
152
+ fill: rootFill,
153
+ labelFill: rootLabelFill,
154
+ labelFontWeight: 'bold',
155
+ labelFontSize: 24,
156
+ labelOffsetY: 4,
157
+ labelPlacement: 'center'
158
+ });
159
+ } else if (depth === 1) {
160
+ var _d$style;
161
+ var color = ((_d$style = d.style) === null || _d$style === void 0 ? void 0 : _d$style.branchColor) || palette[0];
162
+ Object.assign(nodeStyle, {
163
+ fill: color,
164
+ labelFill: '#fff',
165
+ labelFontSize: 18,
166
+ labelPlacement: 'center'
167
+ });
168
+ } else {
169
+ Object.assign(nodeStyle, {
170
+ fill: 'transparent',
171
+ labelFill: leafLabelFill,
172
+ labelFontSize: 16
173
+ });
174
+ }
175
+ if (_style.texture === 'rough') {
176
+ nodeStyle.lineWidth = 0.5;
177
+ }
178
+ return nodeStyle;
179
+ }
180
+ },
181
+ edge: {
182
+ type: 'polyline',
183
+ style: _objectSpread({
184
+ lineWidth: 3,
185
+ stroke: edgeStroke
186
+ }, _style.texture === 'rough' ? {
187
+ labelFontFamily: 'Comic Sans MS'
188
+ } : {})
189
+ },
190
+ layout: {
191
+ type: 'fishbone',
192
+ direction: 'RL',
193
+ hGap: 40,
194
+ vGap: 60
195
+ },
196
+ behaviors: ['drag-canvas']
197
+ });
198
+ graph.render();
199
+ };
200
+ var destroy = function destroy() {
201
+ if (graph) {
202
+ graph.destroy();
203
+ graph = null;
204
+ }
205
+ };
206
+ return {
207
+ render: render,
208
+ destroy: destroy,
209
+ zoomTo: function zoomTo(zoom) {
210
+ var _graph;
211
+ return (_graph = graph) === null || _graph === void 0 ? void 0 : _graph.zoomTo(zoom);
212
+ },
213
+ getZoom: function getZoom() {
214
+ var _graph$getZoom, _graph2;
215
+ return (_graph$getZoom = (_graph2 = graph) === null || _graph2 === void 0 ? void 0 : _graph2.getZoom()) !== null && _graph$getZoom !== void 0 ? _graph$getZoom : 1;
216
+ }
217
+ };
218
+ };
@@ -0,0 +1,27 @@
1
+ import type { GraphData, VisualizationOptions } from '../../types';
2
+ /**
3
+ * FlowDiagramConfig defines the configuration for rendering the flow diagram.
4
+ */
5
+ export interface FlowDiagramConfig {
6
+ type?: 'flow-diagram';
7
+ data: GraphData;
8
+ title?: string;
9
+ theme?: 'default' | 'academy' | 'dark';
10
+ style?: {
11
+ backgroundColor?: string;
12
+ palette?: string[];
13
+ };
14
+ }
15
+ /**
16
+ * FlowDiagramInstance represents a flow diagram instance with render and destroy methods.
17
+ */
18
+ export interface FlowDiagramInstance {
19
+ render: (config: FlowDiagramConfig) => void;
20
+ destroy: () => void;
21
+ zoomTo: (zoom: number) => void;
22
+ getZoom: () => number | undefined;
23
+ }
24
+ /**
25
+ * FlowDiagram chart component using G6 5.0 with dagre layout.
26
+ */
27
+ export declare const FlowDiagram: (options: VisualizationOptions) => FlowDiagramInstance;