@antv/gpt-vis 1.0.0-beta.1 → 1.0.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.
- package/README.md +223 -47
- package/README.zh-CN.md +227 -51
- package/dist/cjs/gpt-vis/index.d.ts +8 -1
- package/dist/cjs/gpt-vis/index.js +43 -20
- package/dist/cjs/index.d.ts +15 -2
- package/dist/cjs/index.js +22 -2
- package/dist/cjs/syntax/parser.d.ts +17 -2
- package/dist/cjs/syntax/parser.js +151 -38
- package/dist/cjs/util/container.d.ts +5 -0
- package/dist/cjs/util/container.js +43 -0
- package/dist/cjs/util/theme.d.ts +5 -0
- package/dist/cjs/util/theme.js +9 -2
- package/dist/cjs/vis/area/index.js +2 -1
- package/dist/cjs/vis/bar/index.js +5 -4
- package/dist/cjs/vis/boxplot/index.js +7 -2
- package/dist/cjs/vis/column/index.js +5 -4
- package/dist/cjs/vis/dual-axes/index.js +3 -3
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
- package/dist/cjs/vis/fishbone-diagram/index.js +191 -0
- package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
- package/dist/cjs/vis/flow-diagram/index.js +287 -0
- package/dist/cjs/vis/funnel/index.js +2 -1
- package/dist/cjs/vis/histogram/index.js +3 -7
- package/dist/cjs/vis/indented-tree/index.d.ts +40 -0
- package/dist/cjs/vis/indented-tree/index.js +385 -0
- package/dist/cjs/vis/line/index.js +2 -1
- package/dist/cjs/vis/liquid/index.js +2 -1
- package/dist/cjs/vis/mindmap/index.d.ts +32 -0
- package/dist/cjs/vis/mindmap/index.js +222 -0
- package/dist/cjs/vis/network-graph/index.d.ts +59 -0
- package/dist/cjs/vis/network-graph/index.js +175 -0
- package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
- package/dist/cjs/vis/organization-chart/index.js +200 -0
- package/dist/cjs/vis/pie/index.js +3 -3
- package/dist/cjs/vis/radar/index.d.ts +1 -0
- package/dist/cjs/vis/radar/index.js +10 -9
- package/dist/cjs/vis/sankey/index.js +2 -1
- package/dist/cjs/vis/scatter/index.d.ts +2 -0
- package/dist/cjs/vis/scatter/index.js +9 -4
- package/dist/cjs/vis/summary/index.js +17 -3
- package/dist/cjs/vis/table/index.d.ts +1 -0
- package/dist/cjs/vis/table/index.js +37 -1
- package/dist/cjs/vis/treemap/index.js +2 -1
- package/dist/cjs/vis/venn/index.d.ts +2 -1
- package/dist/cjs/vis/venn/index.js +18 -3
- package/dist/cjs/vis/violin/index.js +2 -1
- package/dist/cjs/vis/waterfall/index.d.ts +6 -9
- package/dist/cjs/vis/waterfall/index.js +29 -6
- package/dist/cjs/vis/word-cloud/index.js +2 -1
- package/dist/cjs/vis-wrapper/icons.js +2 -2
- package/dist/cjs/vis-wrapper/index.d.ts +1 -0
- package/dist/cjs/vis-wrapper/index.js +27 -16
- package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
- package/dist/cjs/vis-wrapper/styles.js +8 -1
- package/dist/esm/gpt-vis/index.d.ts +8 -1
- package/dist/esm/gpt-vis/index.js +47 -26
- package/dist/esm/index.d.ts +15 -2
- package/dist/esm/index.js +7 -1
- package/dist/esm/syntax/parser.d.ts +17 -2
- package/dist/esm/syntax/parser.js +248 -90
- package/dist/esm/util/container.d.ts +5 -0
- package/dist/esm/util/container.js +20 -0
- package/dist/esm/util/theme.d.ts +5 -0
- package/dist/esm/util/theme.js +9 -0
- package/dist/esm/vis/area/index.js +3 -2
- package/dist/esm/vis/bar/index.js +7 -6
- package/dist/esm/vis/boxplot/index.js +17 -4
- package/dist/esm/vis/column/index.js +7 -6
- package/dist/esm/vis/dual-axes/index.js +13 -5
- package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
- package/dist/esm/vis/fishbone-diagram/index.js +219 -0
- package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
- package/dist/esm/vis/flow-diagram/index.js +349 -0
- package/dist/esm/vis/funnel/index.js +3 -2
- package/dist/esm/vis/histogram/index.js +6 -7
- package/dist/esm/vis/indented-tree/index.d.ts +40 -0
- package/dist/esm/vis/indented-tree/index.js +569 -0
- package/dist/esm/vis/line/index.js +3 -2
- package/dist/esm/vis/liquid/index.js +3 -2
- package/dist/esm/vis/mindmap/index.d.ts +32 -0
- package/dist/esm/vis/mindmap/index.js +316 -0
- package/dist/esm/vis/network-graph/index.d.ts +59 -0
- package/dist/esm/vis/network-graph/index.js +242 -0
- package/dist/esm/vis/organization-chart/index.d.ts +64 -0
- package/dist/esm/vis/organization-chart/index.js +271 -0
- package/dist/esm/vis/pie/index.js +4 -8
- package/dist/esm/vis/radar/index.d.ts +1 -0
- package/dist/esm/vis/radar/index.js +20 -4
- package/dist/esm/vis/sankey/index.js +3 -2
- package/dist/esm/vis/scatter/index.d.ts +2 -0
- package/dist/esm/vis/scatter/index.js +15 -4
- package/dist/esm/vis/summary/index.js +25 -4
- package/dist/esm/vis/table/index.d.ts +1 -0
- package/dist/esm/vis/table/index.js +9 -2
- package/dist/esm/vis/treemap/index.js +3 -2
- package/dist/esm/vis/venn/index.d.ts +2 -1
- package/dist/esm/vis/venn/index.js +29 -4
- package/dist/esm/vis/violin/index.js +3 -2
- package/dist/esm/vis/waterfall/index.d.ts +6 -9
- package/dist/esm/vis/waterfall/index.js +33 -13
- package/dist/esm/vis/word-cloud/index.js +3 -2
- package/dist/esm/vis-wrapper/icons.js +2 -2
- package/dist/esm/vis-wrapper/index.d.ts +1 -0
- package/dist/esm/vis-wrapper/index.js +15 -10
- package/dist/esm/vis-wrapper/styles.d.ts +1 -1
- package/dist/esm/vis-wrapper/styles.js +1 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +17 -21
- package/src/gpt-vis/index.ts +0 -283
- package/src/index.ts +0 -44
- package/src/readme.md +0 -37
- package/src/syntax/index.ts +0 -2
- package/src/syntax/parser.ts +0 -411
- package/src/types/index.ts +0 -29
- package/src/util/theme.ts +0 -167
- package/src/vis/area/README.md +0 -143
- package/src/vis/area/index.ts +0 -212
- package/src/vis/bar/README.md +0 -158
- package/src/vis/bar/index.ts +0 -186
- package/src/vis/boxplot/README.md +0 -168
- package/src/vis/boxplot/index.ts +0 -162
- package/src/vis/column/README.md +0 -158
- package/src/vis/column/index.ts +0 -185
- package/src/vis/dual-axes/README.md +0 -191
- package/src/vis/dual-axes/index.ts +0 -218
- package/src/vis/funnel/README.md +0 -143
- package/src/vis/funnel/index.ts +0 -238
- package/src/vis/histogram/README.md +0 -130
- package/src/vis/histogram/index.ts +0 -153
- package/src/vis/line/README.md +0 -138
- package/src/vis/line/index.ts +0 -159
- package/src/vis/liquid/README.md +0 -150
- package/src/vis/liquid/index.ts +0 -130
- package/src/vis/pie/README.md +0 -127
- package/src/vis/pie/index.ts +0 -163
- package/src/vis/radar/README.md +0 -184
- package/src/vis/radar/index.ts +0 -214
- package/src/vis/sankey/README.md +0 -144
- package/src/vis/sankey/index.ts +0 -144
- package/src/vis/scatter/README.md +0 -145
- package/src/vis/scatter/index.ts +0 -147
- package/src/vis/summary/README.md +0 -272
- package/src/vis/summary/index.ts +0 -91
- package/src/vis/table/README.md +0 -174
- package/src/vis/table/index.ts +0 -241
- package/src/vis/treemap/README.md +0 -199
- package/src/vis/treemap/index.ts +0 -167
- package/src/vis/venn/README.md +0 -153
- package/src/vis/venn/index.ts +0 -149
- package/src/vis/violin/README.md +0 -168
- package/src/vis/violin/index.ts +0 -216
- package/src/vis/waterfall/README.md +0 -178
- package/src/vis/waterfall/index.ts +0 -258
- package/src/vis/word-cloud/README.md +0 -137
- package/src/vis/word-cloud/index.ts +0 -137
- package/src/vis-wrapper/README.md +0 -159
- package/src/vis-wrapper/icons.ts +0 -35
- package/src/vis-wrapper/index.ts +0 -276
- package/src/vis-wrapper/styles.ts +0 -195
|
@@ -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
|
-
* -
|
|
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
|
|
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
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
50
|
-
|
|
62
|
+
const matchSpace = text.match(/^([^\s]+)\s+(.*)$/);
|
|
63
|
+
if (matchSpace) {
|
|
64
|
+
return { key: matchSpace[1], value: matchSpace[2] };
|
|
51
65
|
}
|
|
52
|
-
return
|
|
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(/^(\
|
|
80
|
-
|
|
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
|
|
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
|
|
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[
|
|
291
|
+
result[sectionName] = items;
|
|
192
292
|
}
|
|
193
|
-
i =
|
|
293
|
+
i = arrNext;
|
|
194
294
|
continue;
|
|
195
295
|
} else if (OBJECT_SECTIONS.has(trimmed)) {
|
|
196
296
|
const sectionName = trimmed;
|
|
197
|
-
|
|
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
|
|
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
|
-
|
|
207
|
-
|
|
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,43 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/util/container.ts
|
|
20
|
+
var container_exports = {};
|
|
21
|
+
__export(container_exports, {
|
|
22
|
+
resolveContainer: () => resolveContainer
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(container_exports);
|
|
25
|
+
function resolveContainer(container) {
|
|
26
|
+
if (typeof container === "string") {
|
|
27
|
+
if (typeof document === "undefined") {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Container element "${container}" cannot be resolved in a non-browser environment.`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const el = document.querySelector(container);
|
|
33
|
+
if (!el) {
|
|
34
|
+
throw new Error(`Container element "${container}" not found`);
|
|
35
|
+
}
|
|
36
|
+
return el;
|
|
37
|
+
}
|
|
38
|
+
return container;
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
resolveContainer
|
|
43
|
+
});
|
package/dist/cjs/util/theme.d.ts
CHANGED
|
@@ -19,3 +19,8 @@ export declare const getThemeColors: (theme: string) => string[];
|
|
|
19
19
|
* Get background color based on theme.
|
|
20
20
|
*/
|
|
21
21
|
export declare const getBackgroundColor: (theme: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize palette to always return an array.
|
|
24
|
+
* Handles the case where a single color is parsed as a string instead of an array.
|
|
25
|
+
*/
|
|
26
|
+
export declare const normalizePalette: (palette: string | string[] | undefined, theme: string) => string[];
|
package/dist/cjs/util/theme.js
CHANGED
|
@@ -25,7 +25,8 @@ __export(theme_exports, {
|
|
|
25
25
|
getBackgroundColor: () => getBackgroundColor,
|
|
26
26
|
getTheme: () => getTheme,
|
|
27
27
|
getThemeColors: () => getThemeColors,
|
|
28
|
-
getThemeObject: () => getThemeObject
|
|
28
|
+
getThemeObject: () => getThemeObject,
|
|
29
|
+
normalizePalette: () => normalizePalette
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(theme_exports);
|
|
31
32
|
var DEFAULT_COLOR_PALETTE = [
|
|
@@ -170,6 +171,11 @@ var getBackgroundColor = (theme) => {
|
|
|
170
171
|
return "#FFF";
|
|
171
172
|
}
|
|
172
173
|
};
|
|
174
|
+
var normalizePalette = (palette, theme) => {
|
|
175
|
+
if (!palette || Array.isArray(palette) && palette.length === 0)
|
|
176
|
+
return getThemeColors(theme);
|
|
177
|
+
return Array.isArray(palette) ? palette : [palette];
|
|
178
|
+
};
|
|
173
179
|
// Annotate the CommonJS export names for ESM import in node:
|
|
174
180
|
0 && (module.exports = {
|
|
175
181
|
ACADEMY_COLOR_PALETTE,
|
|
@@ -178,5 +184,6 @@ var getBackgroundColor = (theme) => {
|
|
|
178
184
|
getBackgroundColor,
|
|
179
185
|
getTheme,
|
|
180
186
|
getThemeColors,
|
|
181
|
-
getThemeObject
|
|
187
|
+
getThemeObject,
|
|
188
|
+
normalizePalette
|
|
182
189
|
});
|
|
@@ -45,7 +45,7 @@ var Area = (options) => {
|
|
|
45
45
|
}
|
|
46
46
|
const { lineWidth = 2 } = style;
|
|
47
47
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
48
|
-
const colors =
|
|
48
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
49
49
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
50
50
|
const fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR);
|
|
51
51
|
chart = new import_g2.Chart({
|
|
@@ -106,6 +106,7 @@ var Area = (options) => {
|
|
|
106
106
|
];
|
|
107
107
|
}
|
|
108
108
|
const chartOptions = {
|
|
109
|
+
animate: false,
|
|
109
110
|
type: "view",
|
|
110
111
|
data,
|
|
111
112
|
title: title ?? "",
|
|
@@ -28,7 +28,7 @@ var Bar = (options) => {
|
|
|
28
28
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
29
|
let chart = null;
|
|
30
30
|
const render = (config) => {
|
|
31
|
-
var _a
|
|
31
|
+
var _a;
|
|
32
32
|
const {
|
|
33
33
|
data = [],
|
|
34
34
|
theme = chartTheme,
|
|
@@ -43,7 +43,7 @@ var Bar = (options) => {
|
|
|
43
43
|
chart.destroy();
|
|
44
44
|
}
|
|
45
45
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
46
|
-
const colors =
|
|
46
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
47
47
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
48
48
|
chart = new import_g2.Chart({
|
|
49
49
|
container,
|
|
@@ -54,7 +54,7 @@ var Bar = (options) => {
|
|
|
54
54
|
let encode = {};
|
|
55
55
|
let transform = [];
|
|
56
56
|
let radiusStyle = {};
|
|
57
|
-
if (theme
|
|
57
|
+
if (theme !== "academy") {
|
|
58
58
|
radiusStyle = { radiusTopLeft: 4, radiusTopRight: 4 };
|
|
59
59
|
}
|
|
60
60
|
if (hasGroupField && group) {
|
|
@@ -70,9 +70,10 @@ var Bar = (options) => {
|
|
|
70
70
|
}
|
|
71
71
|
const scaleConfig = {
|
|
72
72
|
y: { nice: true },
|
|
73
|
-
...
|
|
73
|
+
...style.palette ? { color: { range: colors } } : {}
|
|
74
74
|
};
|
|
75
75
|
const chartOptions = {
|
|
76
|
+
animate: false,
|
|
76
77
|
type: "interval",
|
|
77
78
|
data,
|
|
78
79
|
title: title ?? "",
|
|
@@ -33,7 +33,7 @@ var Boxplot = (options) => {
|
|
|
33
33
|
if (chart) {
|
|
34
34
|
chart.destroy();
|
|
35
35
|
}
|
|
36
|
-
const colors =
|
|
36
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
37
37
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
38
38
|
const startAtZero = style.startAtZero || false;
|
|
39
39
|
const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
|
|
@@ -59,6 +59,7 @@ var Boxplot = (options) => {
|
|
|
59
59
|
autoFit: true
|
|
60
60
|
});
|
|
61
61
|
const chartOptions = {
|
|
62
|
+
animate: false,
|
|
62
63
|
type: "boxplot",
|
|
63
64
|
data,
|
|
64
65
|
title: title ?? "",
|
|
@@ -77,7 +78,11 @@ var Boxplot = (options) => {
|
|
|
77
78
|
y: { nice: true, zero: startAtZero },
|
|
78
79
|
color: { range: colors }
|
|
79
80
|
},
|
|
80
|
-
|
|
81
|
+
// When hasGroupField is true, set point to false to prevent G2's Boxplot composite mark
|
|
82
|
+
// from splitting into box + point child marks. The point child mark does not inherit
|
|
83
|
+
// the `scale` config, causing legendFilter interaction to throw
|
|
84
|
+
// "Cannot read properties of undefined (reading 'color')" when clicking legend items.
|
|
85
|
+
style: { stroke: "black", ...hasGroupField ? { point: false } : {} },
|
|
81
86
|
legend: {
|
|
82
87
|
color: hasGroupField ? { position: "top" } : false
|
|
83
88
|
},
|
|
@@ -28,7 +28,7 @@ var Column = (options) => {
|
|
|
28
28
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
29
|
let chart = null;
|
|
30
30
|
const render = (config) => {
|
|
31
|
-
var _a
|
|
31
|
+
var _a;
|
|
32
32
|
const {
|
|
33
33
|
data = [],
|
|
34
34
|
theme = chartTheme,
|
|
@@ -43,7 +43,7 @@ var Column = (options) => {
|
|
|
43
43
|
chart.destroy();
|
|
44
44
|
}
|
|
45
45
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
46
|
-
const colors =
|
|
46
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
47
47
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
48
48
|
chart = new import_g2.Chart({
|
|
49
49
|
container,
|
|
@@ -54,7 +54,7 @@ var Column = (options) => {
|
|
|
54
54
|
let encode = {};
|
|
55
55
|
let transform = [];
|
|
56
56
|
let radiusStyle = {};
|
|
57
|
-
if (theme
|
|
57
|
+
if (theme !== "academy") {
|
|
58
58
|
radiusStyle = { radiusTopLeft: 4, radiusTopRight: 4 };
|
|
59
59
|
}
|
|
60
60
|
if (hasGroupField && group) {
|
|
@@ -70,9 +70,10 @@ var Column = (options) => {
|
|
|
70
70
|
}
|
|
71
71
|
const scaleConfig = {
|
|
72
72
|
y: { nice: true },
|
|
73
|
-
...
|
|
73
|
+
...style.palette ? { color: { range: colors } } : {}
|
|
74
74
|
};
|
|
75
75
|
const chartOptions = {
|
|
76
|
+
animate: false,
|
|
76
77
|
type: "interval",
|
|
77
78
|
data,
|
|
78
79
|
title: title ?? "",
|
|
@@ -43,7 +43,7 @@ var DualAxes = (options) => {
|
|
|
43
43
|
chart.destroy();
|
|
44
44
|
}
|
|
45
45
|
const { startAtZero = false } = style;
|
|
46
|
-
const colors =
|
|
46
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
47
47
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
48
48
|
const data = transformData(series, categories);
|
|
49
49
|
chart = new import_g2.Chart({
|
|
@@ -76,8 +76,7 @@ var DualAxes = (options) => {
|
|
|
76
76
|
},
|
|
77
77
|
style: {
|
|
78
78
|
columnWidthRatio: 0.8,
|
|
79
|
-
radiusTopLeft: 4,
|
|
80
|
-
radiusTopRight: 4
|
|
79
|
+
...theme !== "academy" ? { radiusTopLeft: 4, radiusTopRight: 4 } : {}
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
82
|
} else {
|
|
@@ -103,6 +102,7 @@ var DualAxes = (options) => {
|
|
|
103
102
|
}
|
|
104
103
|
});
|
|
105
104
|
const chartOptions = {
|
|
105
|
+
animate: false,
|
|
106
106
|
type: "view",
|
|
107
107
|
data,
|
|
108
108
|
title: 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;
|