@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
package/README.md CHANGED
@@ -52,7 +52,7 @@ npm install @antv/gpt-vis
52
52
  import { GPTVis } from '@antv/gpt-vis';
53
53
 
54
54
  const gptVis = new GPTVis({
55
- container: '#container',
55
+ container: 'container',
56
56
  width: 600,
57
57
  height: 400,
58
58
  });
@@ -77,7 +77,7 @@ gptVis.render(visSyntax);
77
77
  ```javascript
78
78
  import { GPTVis, isVisSyntax } from '@antv/gpt-vis';
79
79
 
80
- const gptVis = new GPTVis({ container: '#container', width: 600, height: 400 });
80
+ const gptVis = new GPTVis({ container: 'container', width: 600, height: 400 });
81
81
  let buffer = '';
82
82
 
83
83
  function onToken(token) {
@@ -124,7 +124,9 @@ data
124
124
  value 120
125
125
  style
126
126
  lineWidth 3
127
- palette #5B8FF9 #5AD8A6
127
+ palette
128
+ - #5B8FF9
129
+ - #5AD8A6
128
130
  ```
129
131
 
130
132
  **Hierarchical data:**
@@ -146,7 +148,7 @@ data
146
148
  ```javascript
147
149
  import { GPTVis } from '@antv/gpt-vis';
148
150
 
149
- const gptVis = new GPTVis({ container: '#chart', width: 600, height: 400 });
151
+ const gptVis = new GPTVis({ container: 'chart', width: 600, height: 400 });
150
152
  gptVis.render(visSyntaxString);
151
153
  ```
152
154
 
package/README.zh-CN.md CHANGED
@@ -52,7 +52,7 @@ npm install @antv/gpt-vis
52
52
  import { GPTVis } from '@antv/gpt-vis';
53
53
 
54
54
  const gptVis = new GPTVis({
55
- container: '#container',
55
+ container: 'container',
56
56
  width: 600,
57
57
  height: 400,
58
58
  });
@@ -77,7 +77,7 @@ gptVis.render(visSyntax);
77
77
  ```javascript
78
78
  import { GPTVis, isVisSyntax } from '@antv/gpt-vis';
79
79
 
80
- const gptVis = new GPTVis({ container: '#container', width: 600, height: 400 });
80
+ const gptVis = new GPTVis({ container: 'container', width: 600, height: 400 });
81
81
  let buffer = '';
82
82
 
83
83
  function onToken(token) {
@@ -124,7 +124,9 @@ data
124
124
  value 120
125
125
  style
126
126
  lineWidth 3
127
- palette #5B8FF9 #5AD8A6
127
+ palette
128
+ - #5B8FF9
129
+ - #5AD8A6
128
130
  ```
129
131
 
130
132
  **层次数据:**
@@ -146,7 +148,7 @@ data
146
148
  ```javascript
147
149
  import { GPTVis } from '@antv/gpt-vis';
148
150
 
149
- const gptVis = new GPTVis({ container: '#chart', width: 600, height: 400 });
151
+ const gptVis = new GPTVis({ container: 'chart', width: 600, height: 400 });
150
152
  gptVis.render(visSyntaxString);
151
153
  ```
152
154
 
@@ -4,10 +4,16 @@ import type { BarConfig } from '../vis/bar';
4
4
  import type { BoxplotConfig } from '../vis/boxplot';
5
5
  import type { ColumnConfig } from '../vis/column';
6
6
  import type { DualAxesConfig } from '../vis/dual-axes';
7
+ import type { FishboneDiagramConfig } from '../vis/fishbone-diagram';
8
+ import type { FlowDiagramConfig } from '../vis/flow-diagram';
7
9
  import type { FunnelConfig } from '../vis/funnel';
8
10
  import type { HistogramConfig } from '../vis/histogram';
11
+ import type { IndentedTreeConfig } from '../vis/indented-tree';
9
12
  import type { LineConfig } from '../vis/line';
10
13
  import type { LiquidConfig } from '../vis/liquid';
14
+ import type { MindmapConfig } from '../vis/mindmap';
15
+ import type { NetworkGraphConfig } from '../vis/network-graph';
16
+ import type { OrganizationChartConfig } from '../vis/organization-chart';
11
17
  import type { PieConfig } from '../vis/pie';
12
18
  import type { RadarConfig } from '../vis/radar';
13
19
  import type { SankeyConfig } from '../vis/sankey';
@@ -22,7 +28,7 @@ import type { WordCloudConfig } from '../vis/word-cloud';
22
28
  /**
23
29
  * Union type for all supported chart configurations
24
30
  */
25
- export type GPTVisConfig = AreaConfig | BarConfig | BoxplotConfig | ColumnConfig | DualAxesConfig | FunnelConfig | HistogramConfig | LineConfig | LiquidConfig | PieConfig | RadarConfig | SankeyConfig | ScatterConfig | SummaryConfig | TableConfig | TreemapConfig | VennConfig | ViolinConfig | WaterfallConfig | WordCloudConfig;
31
+ export type GPTVisConfig = AreaConfig | BarConfig | BoxplotConfig | ColumnConfig | DualAxesConfig | FlowDiagramConfig | FunnelConfig | HistogramConfig | IndentedTreeConfig | LineConfig | LiquidConfig | MindmapConfig | NetworkGraphConfig | OrganizationChartConfig | PieConfig | RadarConfig | SankeyConfig | ScatterConfig | SummaryConfig | TableConfig | TreemapConfig | VennConfig | ViolinConfig | WaterfallConfig | WordCloudConfig | FishboneDiagramConfig;
26
32
  /**
27
33
  * GPTVis is the unified API for all chart types.
28
34
  * It provides a simple interface to render different types of visualizations.
@@ -66,6 +72,7 @@ export type GPTVisConfig = AreaConfig | BarConfig | BoxplotConfig | ColumnConfig
66
72
  export declare class GPTVis {
67
73
  private options;
68
74
  private currentChart;
75
+ private currentChartType;
69
76
  private wrapperInstance;
70
77
  /**
71
78
  * Chart type registry mapping type strings to factory functions
@@ -23,16 +23,23 @@ __export(gpt_vis_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(gpt_vis_exports);
25
25
  var import_parser = require("../syntax/parser");
26
+ var import_container = require("../util/container");
26
27
  var import_vis_wrapper = require("../vis-wrapper");
27
28
  var import_area = require("../vis/area");
28
29
  var import_bar = require("../vis/bar");
29
30
  var import_boxplot = require("../vis/boxplot");
30
31
  var import_column = require("../vis/column");
31
32
  var import_dual_axes = require("../vis/dual-axes");
33
+ var import_fishbone_diagram = require("../vis/fishbone-diagram");
34
+ var import_flow_diagram = require("../vis/flow-diagram");
32
35
  var import_funnel = require("../vis/funnel");
33
36
  var import_histogram = require("../vis/histogram");
37
+ var import_indented_tree = require("../vis/indented-tree");
34
38
  var import_line = require("../vis/line");
35
39
  var import_liquid = require("../vis/liquid");
40
+ var import_mindmap = require("../vis/mindmap");
41
+ var import_network_graph = require("../vis/network-graph");
42
+ var import_organization_chart = require("../vis/organization-chart");
36
43
  var import_pie = require("../vis/pie");
37
44
  var import_radar = require("../vis/radar");
38
45
  var import_sankey = require("../vis/sankey");
@@ -51,8 +58,12 @@ var _GPTVis = class {
51
58
  */
52
59
  constructor(options) {
53
60
  this.currentChart = null;
61
+ this.currentChartType = "";
54
62
  this.wrapperInstance = null;
55
- this.options = options;
63
+ this.options = {
64
+ ...options,
65
+ container: (0, import_container.resolveContainer)(options.container)
66
+ };
56
67
  }
57
68
  /**
58
69
  * Render a chart based on the provided configuration or syntax string.
@@ -101,28 +112,33 @@ var _GPTVis = class {
101
112
  const availableTypes = Object.keys(_GPTVis.chartRegistry).join(", ");
102
113
  throw new Error(`Unsupported chart type: "${type}". Available types: ${availableTypes}`);
103
114
  }
104
- if (this.currentChart) {
105
- this.currentChart.destroy();
106
- }
107
- if (this.wrapperInstance) {
108
- this.wrapperInstance.destroy();
109
- this.wrapperInstance = null;
110
- }
111
115
  let chartContainer = this.options.container;
112
116
  if (this.options.wrapper) {
113
- this.wrapperInstance = (0, import_vis_wrapper.createVisWrapper)(this.options.container, {
114
- chartType: type,
115
- syntax: config,
116
- locale: this.options.locale || "zh-CN"
117
- });
117
+ if (!this.wrapperInstance) {
118
+ this.wrapperInstance = (0, import_vis_wrapper.createVisWrapper)(this.options.container, {
119
+ chartType: type,
120
+ syntax: config,
121
+ locale: this.options.locale || "zh-CN"
122
+ });
123
+ } else {
124
+ this.wrapperInstance.update(config);
125
+ }
118
126
  chartContainer = this.wrapperInstance.chartContainer;
119
127
  }
120
- const chartOptions = {
121
- ...this.options,
122
- container: chartContainer
123
- };
124
- this.currentChart = chartFactory(chartOptions);
125
- this.currentChart.render(chartConfig);
128
+ if (this.currentChart && this.currentChartType === type) {
129
+ this.currentChart.render(chartConfig);
130
+ } else {
131
+ if (this.currentChart) {
132
+ this.currentChart.destroy();
133
+ }
134
+ const chartOptions = {
135
+ ...this.options,
136
+ container: chartContainer
137
+ };
138
+ this.currentChart = chartFactory(chartOptions);
139
+ this.currentChartType = type;
140
+ this.currentChart.render(chartConfig);
141
+ }
126
142
  if (this.wrapperInstance) {
127
143
  this.wrapperInstance.setChartRef(this.currentChart);
128
144
  }
@@ -134,6 +150,7 @@ var _GPTVis = class {
134
150
  if (this.currentChart) {
135
151
  this.currentChart.destroy();
136
152
  this.currentChart = null;
153
+ this.currentChartType = "";
137
154
  }
138
155
  if (this.wrapperInstance) {
139
156
  this.wrapperInstance.destroy();
@@ -151,10 +168,15 @@ GPTVis.chartRegistry = {
151
168
  boxplot: import_boxplot.Boxplot,
152
169
  column: import_column.Column,
153
170
  "dual-axes": import_dual_axes.DualAxes,
171
+ "flow-diagram": import_flow_diagram.FlowDiagram,
154
172
  funnel: import_funnel.Funnel,
155
173
  histogram: import_histogram.Histogram,
174
+ "indented-tree": import_indented_tree.IndentedTree,
156
175
  line: import_line.Line,
157
176
  liquid: import_liquid.Liquid,
177
+ mindmap: import_mindmap.Mindmap,
178
+ "network-graph": import_network_graph.NetworkGraph,
179
+ "organization-chart": import_organization_chart.OrganizationChart,
158
180
  pie: import_pie.Pie,
159
181
  radar: import_radar.Radar,
160
182
  sankey: import_sankey.Sankey,
@@ -165,7 +187,8 @@ GPTVis.chartRegistry = {
165
187
  venn: import_venn.Venn,
166
188
  violin: import_violin.Violin,
167
189
  waterfall: import_waterfall.Waterfall,
168
- "word-cloud": import_word_cloud.WordCloud
190
+ "word-cloud": import_word_cloud.WordCloud,
191
+ "fishbone-diagram": import_fishbone_diagram.FishboneDiagram
169
192
  };
170
193
  // Annotate the CommonJS export names for ESM import in node:
171
194
  0 && (module.exports = {
@@ -1,6 +1,7 @@
1
1
  export { GPTVis } from './gpt-vis';
2
2
  export type { GPTVisConfig } from './gpt-vis';
3
- export { isVisSyntax } from './syntax';
3
+ export { isVisSyntax, parse } from './syntax';
4
+ export type { ParsedConfig } from './syntax';
4
5
  export type { VisualizationOptions } from './types';
5
6
  export { Area } from './vis/area';
6
7
  export type { AreaConfig, AreaDataItem } from './vis/area';
@@ -12,14 +13,26 @@ export { Column } from './vis/column';
12
13
  export type { ColumnConfig, ColumnDataItem } from './vis/column';
13
14
  export { DualAxes } from './vis/dual-axes';
14
15
  export type { DualAxesConfig, DualAxesSeriesItem } from './vis/dual-axes';
16
+ export { FishboneDiagram } from './vis/fishbone-diagram';
17
+ export type { FishboneDiagramConfig, FishboneDiagramInstance, FishboneNode, } from './vis/fishbone-diagram';
18
+ export { FlowDiagram } from './vis/flow-diagram';
19
+ export type { FlowDiagramConfig } from './vis/flow-diagram';
15
20
  export { Funnel } from './vis/funnel';
16
21
  export type { FunnelConfig, FunnelDataItem } from './vis/funnel';
17
22
  export { Histogram } from './vis/histogram';
18
23
  export type { HistogramConfig } from './vis/histogram';
24
+ export { IndentedTree } from './vis/indented-tree';
25
+ export type { IndentedTreeConfig, IndentedTreeData, IndentedTreeInstance, } from './vis/indented-tree';
19
26
  export { Line } from './vis/line';
20
27
  export type { LineConfig, LineDataItem } from './vis/line';
21
28
  export { Liquid } from './vis/liquid';
22
29
  export type { LiquidConfig } from './vis/liquid';
30
+ export { Mindmap } from './vis/mindmap';
31
+ export type { MindMapProps, MindmapConfig, MindmapData } from './vis/mindmap';
32
+ export { NetworkGraph } from './vis/network-graph';
33
+ export type { NetworkGraphConfig, NetworkGraphData, NetworkGraphEdge, NetworkGraphNode, } from './vis/network-graph';
34
+ export { OrganizationChart } from './vis/organization-chart';
35
+ export type { OrganizationChartConfig, OrganizationChartData } from './vis/organization-chart';
23
36
  export { Pie } from './vis/pie';
24
37
  export type { PieConfig } from './vis/pie';
25
38
  export { Radar } from './vis/radar';
@@ -39,6 +52,6 @@ export type { VennConfig, VennDataItem } from './vis/venn';
39
52
  export { Violin } from './vis/violin';
40
53
  export type { ViolinConfig, ViolinDataItem } from './vis/violin';
41
54
  export { Waterfall } from './vis/waterfall';
42
- export type { WaterfallConfig, WaterfallDataItem, WaterfallPalette } from './vis/waterfall';
55
+ export type { WaterfallConfig, WaterfallDataItem } from './vis/waterfall';
43
56
  export { WordCloud } from './vis/word-cloud';
44
57
  export type { WordCloudConfig, WordCloudDataItem } from './vis/word-cloud';
package/dist/cjs/index.js CHANGED
@@ -24,11 +24,17 @@ __export(src_exports, {
24
24
  Boxplot: () => import_boxplot.Boxplot,
25
25
  Column: () => import_column.Column,
26
26
  DualAxes: () => import_dual_axes.DualAxes,
27
+ FishboneDiagram: () => import_fishbone_diagram.FishboneDiagram,
28
+ FlowDiagram: () => import_flow_diagram.FlowDiagram,
27
29
  Funnel: () => import_funnel.Funnel,
28
30
  GPTVis: () => import_gpt_vis.GPTVis,
29
31
  Histogram: () => import_histogram.Histogram,
32
+ IndentedTree: () => import_indented_tree.IndentedTree,
30
33
  Line: () => import_line.Line,
31
34
  Liquid: () => import_liquid.Liquid,
35
+ Mindmap: () => import_mindmap.Mindmap,
36
+ NetworkGraph: () => import_network_graph.NetworkGraph,
37
+ OrganizationChart: () => import_organization_chart.OrganizationChart,
32
38
  Pie: () => import_pie.Pie,
33
39
  Radar: () => import_radar.Radar,
34
40
  Sankey: () => import_sankey.Sankey,
@@ -40,7 +46,8 @@ __export(src_exports, {
40
46
  Violin: () => import_violin.Violin,
41
47
  Waterfall: () => import_waterfall.Waterfall,
42
48
  WordCloud: () => import_word_cloud.WordCloud,
43
- isVisSyntax: () => import_syntax.isVisSyntax
49
+ isVisSyntax: () => import_syntax.isVisSyntax,
50
+ parse: () => import_syntax.parse
44
51
  });
45
52
  module.exports = __toCommonJS(src_exports);
46
53
  var import_gpt_vis = require("./gpt-vis");
@@ -50,10 +57,16 @@ var import_bar = require("./vis/bar");
50
57
  var import_boxplot = require("./vis/boxplot");
51
58
  var import_column = require("./vis/column");
52
59
  var import_dual_axes = require("./vis/dual-axes");
60
+ var import_fishbone_diagram = require("./vis/fishbone-diagram");
61
+ var import_flow_diagram = require("./vis/flow-diagram");
53
62
  var import_funnel = require("./vis/funnel");
54
63
  var import_histogram = require("./vis/histogram");
64
+ var import_indented_tree = require("./vis/indented-tree");
55
65
  var import_line = require("./vis/line");
56
66
  var import_liquid = require("./vis/liquid");
67
+ var import_mindmap = require("./vis/mindmap");
68
+ var import_network_graph = require("./vis/network-graph");
69
+ var import_organization_chart = require("./vis/organization-chart");
57
70
  var import_pie = require("./vis/pie");
58
71
  var import_radar = require("./vis/radar");
59
72
  var import_sankey = require("./vis/sankey");
@@ -72,11 +85,17 @@ var import_word_cloud = require("./vis/word-cloud");
72
85
  Boxplot,
73
86
  Column,
74
87
  DualAxes,
88
+ FishboneDiagram,
89
+ FlowDiagram,
75
90
  Funnel,
76
91
  GPTVis,
77
92
  Histogram,
93
+ IndentedTree,
78
94
  Line,
79
95
  Liquid,
96
+ Mindmap,
97
+ NetworkGraph,
98
+ OrganizationChart,
80
99
  Pie,
81
100
  Radar,
82
101
  Sankey,
@@ -88,5 +107,6 @@ var import_word_cloud = require("./vis/word-cloud");
88
107
  Violin,
89
108
  Waterfall,
90
109
  WordCloud,
91
- isVisSyntax
110
+ isVisSyntax,
111
+ parse
92
112
  });
@@ -8,9 +8,12 @@
8
8
  * - `data` - Starts a data array section
9
9
  * - ` - key value` - Array item with key-value pairs
10
10
  * - ` - value` - Simple array item (for flat arrays like histogram data)
11
+ * - ` - "value with spaces"` - Quoted string item; single or double quotes both supported.
12
+ * Quotes are required when the value contains spaces; optional otherwise.
13
+ * Quoted values are never coerced to numbers or booleans.
11
14
  * - `key: value` or `key value` - Top-level key-value pair
12
15
  * - `style` - Starts a style object section
13
- * - Multiple values separated by spaces become arrays (e.g., `palette #ff5a5f #1fb6ff`)
16
+ * - `palette` inside `style` uses array syntax with dash-prefixed items
14
17
  * - `children` - Nested array for hierarchical data (mind-map, treemap, etc.)
15
18
  *
16
19
  * @example
@@ -24,7 +27,10 @@
24
27
  * innerRadius: 0.6
25
28
  * style
26
29
  * backgroundColor #333
27
- * palette #ff5a5f #1fb6ff #13ce66
30
+ * palette
31
+ * - #ff5a5f
32
+ * - #1fb6ff
33
+ * - #13ce66
28
34
  * ```
29
35
  *
30
36
  * @example Simple array (histogram)
@@ -37,6 +43,15 @@
37
43
  * binNumber 5
38
44
  * ```
39
45
  *
46
+ * @example Quoted string values (values containing spaces)
47
+ * ```
48
+ * vis dual-axes
49
+ * categories
50
+ * - "North America"
51
+ * - '东南 亚'
52
+ * - 欧洲
53
+ * ```
54
+ *
40
55
  * @example Hierarchical data (mind-map)
41
56
  * ```
42
57
  * vis mind-map
@@ -23,13 +23,24 @@ __export(parser_exports, {
23
23
  parse: () => parse
24
24
  });
25
25
  module.exports = __toCommonJS(parser_exports);
26
- var ARRAY_SECTIONS = /* @__PURE__ */ new Set(["data", "categories", "series", "children"]);
26
+ var ARRAY_SECTIONS = /* @__PURE__ */ new Set(["data", "categories", "series", "children", "nodes", "edges"]);
27
27
  var OBJECT_SECTIONS = /* @__PURE__ */ new Set(["style"]);
28
+ function isQuotedString(s) {
29
+ if (s.length < 2)
30
+ return false;
31
+ const quote = s[0];
32
+ if (quote !== '"' && quote !== "'")
33
+ return false;
34
+ return s.endsWith(quote) && s.indexOf(quote, 1) === s.length - 1;
35
+ }
28
36
  function parseValue(value) {
29
37
  const trimmed = value.trim();
30
38
  if (trimmed === "") {
31
39
  return "";
32
40
  }
41
+ if (isQuotedString(trimmed)) {
42
+ return trimmed.slice(1, -1);
43
+ }
33
44
  if (trimmed === "true")
34
45
  return true;
35
46
  if (trimmed === "false")
@@ -40,44 +51,41 @@ function parseValue(value) {
40
51
  }
41
52
  return trimmed;
42
53
  }
43
- function parseMultipleValues(values) {
44
- const trimmed = values.trim();
45
- const parts = trimmed.split(/\s+/).filter((p) => p.length > 0);
46
- if (parts.length === 0) {
47
- return "";
54
+ function parseKeyValue(raw) {
55
+ const text = raw.trim();
56
+ if (!text)
57
+ return null;
58
+ const match = text.match(/^([^:\s=]+)\s*[:=]\s*(.*)$/);
59
+ if (match) {
60
+ return { key: match[1], value: match[2] };
48
61
  }
49
- if (parts.length === 1) {
50
- return parseValue(parts[0]);
62
+ const matchSpace = text.match(/^([^\s]+)\s+(.*)$/);
63
+ if (matchSpace) {
64
+ return { key: matchSpace[1], value: matchSpace[2] };
51
65
  }
52
- return parts.map(parseValue);
53
- }
54
- function parseKeyValue(line) {
55
- const trimmed = line.trim();
56
- const colonMatch = trimmed.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\s*:\s*(.*)$/);
57
- if (colonMatch) {
58
- return { key: colonMatch[1], value: colonMatch[2] };
59
- }
60
- const spaceMatch = trimmed.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\s+(.+)$/);
61
- if (spaceMatch) {
62
- return { key: spaceMatch[1], value: spaceMatch[2] };
63
- }
64
- const singleKey = trimmed.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)$/);
65
- if (singleKey) {
66
- return { key: singleKey[1], value: "" };
67
- }
68
- return null;
66
+ return { key: text, value: "" };
69
67
  }
70
68
  function isSimpleValue(line) {
71
69
  const trimmed = line.trim();
70
+ if (isQuotedString(trimmed)) {
71
+ return true;
72
+ }
72
73
  const hasKeyValue = parseKeyValue(trimmed);
73
74
  if (hasKeyValue && hasKeyValue.value !== "") {
74
75
  return false;
75
76
  }
76
77
  return true;
77
78
  }
79
+ var TAB_INDENT_WIDTH = 2;
78
80
  function getIndentLevel(line) {
79
- const match = line.match(/^(\s*)/);
80
- return match ? match[1].length : 0;
81
+ const match = line.match(/^([\t ]*)/);
82
+ if (!match)
83
+ return 0;
84
+ let w = 0;
85
+ for (const ch of match[1]) {
86
+ w += ch === " " ? TAB_INDENT_WIDTH : 1;
87
+ }
88
+ return w;
81
89
  }
82
90
  function isArrayItemLine(line) {
83
91
  return line.trim().startsWith("-");
@@ -106,6 +114,28 @@ function parseLines(syntax) {
106
114
  }
107
115
  return result;
108
116
  }
117
+ function parseTreeNode(lines, startIndex, baseIndent) {
118
+ const node = {};
119
+ let i = startIndex;
120
+ while (i < lines.length) {
121
+ const { trimmed, indent } = lines[i];
122
+ if (indent <= baseIndent)
123
+ break;
124
+ const kv = parseKeyValue(trimmed);
125
+ if (kv) {
126
+ if (kv.key === "children" && kv.value === "") {
127
+ const { items: childItems, nextIndex } = parseArraySection(lines, i + 1, indent);
128
+ node.children = childItems;
129
+ i = nextIndex;
130
+ continue;
131
+ } else {
132
+ node[kv.key] = parseValue(kv.value);
133
+ }
134
+ }
135
+ i++;
136
+ }
137
+ return { node, nextIndex: i };
138
+ }
109
139
  function parseArraySection(lines, startIndex, baseIndent) {
110
140
  const items = [];
111
141
  let currentItem = null;
@@ -117,7 +147,7 @@ function parseArraySection(lines, startIndex, baseIndent) {
117
147
  if (indent <= baseIndent && !isArrayItemLine(trimmed)) {
118
148
  break;
119
149
  }
120
- if (isArrayItemLine(trimmed) && indent <= baseIndent) {
150
+ if (isArrayItemLine(trimmed) && indent < baseIndent) {
121
151
  break;
122
152
  }
123
153
  const isThisLevelItem = isArrayItemLine(trimmed) && (firstItemIndent === -1 || indent === firstItemIndent);
@@ -148,6 +178,30 @@ function parseArraySection(lines, startIndex, baseIndent) {
148
178
  continue;
149
179
  }
150
180
  if (isArrayItemLine(trimmed) && firstItemIndent !== -1 && indent !== firstItemIndent) {
181
+ if (indent < firstItemIndent && indent > baseIndent && currentItem !== null && !isSimpleArray) {
182
+ items.push(currentItem);
183
+ const itemContent = parseArrayItemLine(trimmed);
184
+ currentItem = {};
185
+ const kv = parseKeyValue(itemContent);
186
+ if (kv) {
187
+ currentItem[kv.key] = parseValue(kv.value);
188
+ }
189
+ firstItemIndent = indent;
190
+ i++;
191
+ continue;
192
+ }
193
+ if (indent > firstItemIndent && currentItem !== null && !isSimpleArray) {
194
+ items.push(currentItem);
195
+ const itemContent = parseArrayItemLine(trimmed);
196
+ currentItem = {};
197
+ const kv = parseKeyValue(itemContent);
198
+ if (kv) {
199
+ currentItem[kv.key] = parseValue(kv.value);
200
+ }
201
+ firstItemIndent = indent;
202
+ i++;
203
+ continue;
204
+ }
151
205
  i++;
152
206
  continue;
153
207
  }
@@ -159,9 +213,14 @@ function parseArraySection(lines, startIndex, baseIndent) {
159
213
  currentItem.children = childItems;
160
214
  i = nextIndex;
161
215
  continue;
162
- } else {
163
- currentItem[kv.key] = parseValue(kv.value);
164
216
  }
217
+ if (kv.key === "data" && kv.value === "") {
218
+ const { items: nestedData, nextIndex } = parseArraySection(lines, i + 1, indent);
219
+ currentItem.data = nestedData;
220
+ i = nextIndex;
221
+ continue;
222
+ }
223
+ currentItem[kv.key] = parseValue(kv.value);
165
224
  }
166
225
  }
167
226
  i++;
@@ -186,26 +245,80 @@ function parse(syntax) {
186
245
  const isSectionHeader = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(trimmed) && indent === 0 && isKnownSection(trimmed);
187
246
  if (isSectionHeader) {
188
247
  if (ARRAY_SECTIONS.has(trimmed)) {
189
- const { items, nextIndex } = parseArraySection(lines, i + 1, indent);
248
+ const sectionName = trimmed;
249
+ const nextIndex = i + 1;
250
+ let hasSubSections = false;
251
+ if (nextIndex < lines.length && lines[nextIndex].indent > indent) {
252
+ const nextTrimmed = lines[nextIndex].trimmed;
253
+ hasSubSections = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(nextTrimmed) && !isArrayItemLine(nextTrimmed);
254
+ }
255
+ if (hasSubSections) {
256
+ const dataObj = {};
257
+ i++;
258
+ while (i < lines.length && lines[i].indent > indent) {
259
+ const subTrimmed = lines[i].trimmed;
260
+ const subIndent = lines[i].indent;
261
+ if (/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(subTrimmed) && !isArrayItemLine(subTrimmed)) {
262
+ const { items: subItems, nextIndex: subNext } = parseArraySection(
263
+ lines,
264
+ i + 1,
265
+ subIndent
266
+ );
267
+ dataObj[subTrimmed] = subItems;
268
+ i = subNext;
269
+ } else {
270
+ i++;
271
+ }
272
+ }
273
+ result[sectionName] = dataObj;
274
+ continue;
275
+ }
276
+ let isTreeRoot = false;
277
+ if (nextIndex < lines.length && lines[nextIndex].indent > indent) {
278
+ const firstTrimmed = lines[nextIndex].trimmed;
279
+ if (!isArrayItemLine(firstTrimmed) && !hasSubSections) {
280
+ isTreeRoot = true;
281
+ }
282
+ }
283
+ if (isTreeRoot) {
284
+ const { node, nextIndex: treeNext } = parseTreeNode(lines, i + 1, indent);
285
+ result[sectionName] = node;
286
+ i = treeNext;
287
+ continue;
288
+ }
289
+ const { items, nextIndex: arrNext } = parseArraySection(lines, i + 1, indent);
190
290
  if (items.length > 0) {
191
- result[trimmed] = items;
291
+ result[sectionName] = items;
192
292
  }
193
- i = nextIndex;
293
+ i = arrNext;
194
294
  continue;
195
295
  } else if (OBJECT_SECTIONS.has(trimmed)) {
196
296
  const sectionName = trimmed;
197
- result[sectionName] = {};
297
+ const sectionObj = {};
298
+ result[sectionName] = sectionObj;
299
+ const sectionIndent = indent;
198
300
  i++;
199
301
  while (i < lines.length) {
200
302
  const { trimmed: innerTrimmed, indent: innerIndent } = lines[i];
201
- if (innerIndent === 0) {
303
+ if (innerIndent <= sectionIndent) {
202
304
  break;
203
305
  }
306
+ if (isArrayItemLine(innerTrimmed)) {
307
+ i++;
308
+ continue;
309
+ }
204
310
  const kv = parseKeyValue(innerTrimmed);
205
311
  if (kv) {
206
- result[sectionName][kv.key] = parseMultipleValues(
207
- kv.value
208
- );
312
+ if (kv.value === "" && i + 1 < lines.length) {
313
+ const nextLine = lines[i + 1];
314
+ if (nextLine.indent > innerIndent && isArrayItemLine(nextLine.trimmed)) {
315
+ const { items, nextIndex } = parseArraySection(lines, i + 1, innerIndent);
316
+ sectionObj[kv.key] = items;
317
+ i = nextIndex;
318
+ continue;
319
+ }
320
+ }
321
+ sectionObj[kv.key] = parseValue(kv.value);
209
322
  }
210
323
  i++;
211
324
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Resolve a container parameter to an HTMLElement.
3
+ * Supports CSS selectors (e.g., '#container', '.my-chart') and direct HTMLElement references.
4
+ */
5
+ export declare function resolveContainer(container: string | HTMLElement): HTMLElement;