@fengwk/kchart 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/NOTICE.md +11 -0
- package/README.md +68 -2
- package/README.zh-CN.md +69 -0
- package/dist/LICENSE +21 -0
- package/dist/NOTICE.md +11 -0
- package/dist/assets/ICONS-LICENSE.txt +53 -0
- package/dist/assets/maps/LICENSE.md +75 -0
- package/dist/assets/maps/METADATA.md +9 -0
- package/dist/assets/maps/REGIONS.md +28 -0
- package/dist/assets/maps/us-states.geojson +1 -0
- package/dist/assets/maps/world.geojson +1 -0
- package/dist/esm/_virtual/_kchart-families.js +48 -0
- package/dist/esm/_virtual/_rolldown/runtime.js +12 -0
- package/dist/esm/assets/icons.js +11 -0
- package/dist/esm/assets/maps/us-states.js +3 -0
- package/dist/esm/assets/maps/world.js +3 -0
- package/dist/esm/assets/themes/claude.js +69 -0
- package/dist/esm/assets/themes/cloudmusic.js +62 -0
- package/dist/esm/assets/themes/kanagawa.js +67 -0
- package/dist/esm/assets/themes/obsidian.js +67 -0
- package/dist/esm/assets/themes/paper.js +61 -0
- package/dist/esm/assets/themes/terminal.js +60 -0
- package/dist/esm/assets/themes/tokyo.js +62 -0
- package/dist/esm/chart/basic.js +1313 -0
- package/dist/esm/chart/catalog.js +476 -0
- package/dist/esm/chart/composition.js +844 -0
- package/dist/esm/chart/context.js +189 -0
- package/dist/esm/chart/distribution.js +442 -0
- package/dist/esm/chart/fields.js +67 -0
- package/dist/esm/chart/maps.js +563 -0
- package/dist/esm/chart/mindmap.js +629 -0
- package/dist/esm/chart/multivariate.js +1229 -0
- package/dist/esm/chart/registry.js +108 -0
- package/dist/esm/chart/relations.js +949 -0
- package/dist/esm/chart/spec.js +1415 -0
- package/dist/esm/chart/stat-compare.js +302 -0
- package/dist/esm/chart/stat-trend.js +181 -0
- package/dist/esm/chart/statistics.js +1007 -0
- package/dist/esm/chart/unit-variants.js +645 -0
- package/dist/esm/chart/variants.js +552 -0
- package/dist/esm/core/color.js +197 -0
- package/dist/esm/core/context.js +256 -0
- package/dist/esm/core/diagnostics.js +23 -0
- package/dist/esm/core/format.js +167 -0
- package/dist/esm/core/geometry.js +130 -0
- package/dist/esm/core/icon-data.js +5 -0
- package/dist/esm/core/icons.js +173 -0
- package/dist/esm/core/scale.js +112 -0
- package/dist/esm/core/scene.js +234 -0
- package/dist/esm/core/svg.js +89 -0
- package/dist/esm/core/text.js +184 -0
- package/dist/esm/core/theme.js +318 -0
- package/dist/esm/diagram/agentflow.js +596 -0
- package/dist/esm/diagram/architecture.js +729 -0
- package/dist/esm/diagram/block.js +988 -0
- package/dist/esm/diagram/blocks.js +687 -0
- package/dist/esm/diagram/c4.js +1002 -0
- package/dist/esm/diagram/class.js +1158 -0
- package/dist/esm/diagram/cynefin.js +749 -0
- package/dist/esm/diagram/emphasis.js +7 -0
- package/dist/esm/diagram/er.js +657 -0
- package/dist/esm/diagram/eventmodeling.js +948 -0
- package/dist/esm/diagram/gantt-date.js +323 -0
- package/dist/esm/diagram/gantt.js +661 -0
- package/dist/esm/diagram/gitgraph.js +472 -0
- package/dist/esm/diagram/graph-layout.js +4046 -0
- package/dist/esm/diagram/graph-parse.js +1366 -0
- package/dist/esm/diagram/graph-route.js +490 -0
- package/dist/esm/diagram/graph.js +553 -0
- package/dist/esm/diagram/ishikawa.js +496 -0
- package/dist/esm/diagram/journey.js +512 -0
- package/dist/esm/diagram/kanban.js +280 -0
- package/dist/esm/diagram/label.js +56 -0
- package/dist/esm/diagram/layers.js +385 -0
- package/dist/esm/diagram/map-label.js +44 -0
- package/dist/esm/diagram/mindmap.js +277 -0
- package/dist/esm/diagram/numeric-composition.js +78 -0
- package/dist/esm/diagram/numeric-model.js +86 -0
- package/dist/esm/diagram/numeric-parse.js +205 -0
- package/dist/esm/diagram/numeric-radar.js +355 -0
- package/dist/esm/diagram/numeric-sankey.js +201 -0
- package/dist/esm/diagram/numeric-xy.js +422 -0
- package/dist/esm/diagram/packet.js +175 -0
- package/dist/esm/diagram/presentation.js +252 -0
- package/dist/esm/diagram/quadrant.js +297 -0
- package/dist/esm/diagram/railroad-parse.js +465 -0
- package/dist/esm/diagram/railroad.js +294 -0
- package/dist/esm/diagram/registry.js +296 -0
- package/dist/esm/diagram/relations.js +966 -0
- package/dist/esm/diagram/requirement.js +341 -0
- package/dist/esm/diagram/sequence.js +1228 -0
- package/dist/esm/diagram/shapes.js +366 -0
- package/dist/esm/diagram/source.js +538 -0
- package/dist/esm/diagram/support.js +153 -0
- package/dist/esm/diagram/swimlane-mermaid.js +140 -0
- package/dist/esm/diagram/swimlane.js +1186 -0
- package/dist/esm/diagram/time.js +748 -0
- package/dist/esm/diagram/timeline.js +376 -0
- package/dist/esm/diagram/tree-family-icon.js +22 -0
- package/dist/esm/diagram/treeview.js +293 -0
- package/dist/esm/diagram/usecase.js +852 -0
- package/dist/esm/diagram/venn.js +1038 -0
- package/dist/esm/diagram/wardley.js +838 -0
- package/dist/esm/index.d.ts +133 -0
- package/dist/esm/index.js +92 -0
- package/dist/esm/interaction.js +561 -0
- package/dist/esm/mermaid.d.ts +28 -0
- package/dist/esm/mermaid.js +70 -0
- package/dist/esm/node.d.ts +68 -0
- package/dist/esm/node.js +373 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/page-api.js +65 -0
- package/dist/esm/runtime.js +352 -0
- package/dist/esm/src/families.js +209 -0
- package/dist/page-api.js +1 -0
- package/dist/units/chart/basic.js +1 -0
- package/dist/units/chart/catalog.js +1 -0
- package/dist/units/chart/composition.js +1 -0
- package/dist/units/chart/context.js +1 -0
- package/dist/units/chart/distribution.js +1 -0
- package/dist/units/chart/fields.js +1 -0
- package/dist/units/chart/maps.js +1 -0
- package/dist/units/chart/mindmap.js +1 -0
- package/dist/units/chart/multivariate.js +1 -0
- package/dist/units/chart/registry.js +1 -0
- package/dist/units/chart/relations.js +1 -0
- package/dist/units/chart/spec.js +3 -0
- package/dist/units/chart/stat-compare.js +1 -0
- package/dist/units/chart/stat-trend.js +1 -0
- package/dist/units/chart/statistics.js +1 -0
- package/dist/units/chart/unit-variants.js +1 -0
- package/dist/units/chart/variants.js +1 -0
- package/dist/units/core/color.js +1 -0
- package/dist/units/core/context.js +1 -0
- package/dist/units/core/diagnostics.js +1 -0
- package/dist/units/core/format.js +1 -0
- package/dist/units/core/geometry.js +1 -0
- package/dist/units/core/icon-data.js +1 -0
- package/dist/units/core/icons.js +1 -0
- package/dist/units/core/scale.js +1 -0
- package/dist/units/core/scene.js +1 -0
- package/dist/units/core/svg.js +1 -0
- package/dist/units/core/text.js +2 -0
- package/dist/units/core/theme.js +1 -0
- package/dist/units/diagram/agentflow.js +12 -0
- package/dist/units/diagram/architecture.js +4 -0
- package/dist/units/diagram/block.js +2 -0
- package/dist/units/diagram/blocks.js +2 -0
- package/dist/units/diagram/c4.js +6 -0
- package/dist/units/diagram/class.js +5 -0
- package/dist/units/diagram/cynefin.js +4 -0
- package/dist/units/diagram/emphasis.js +1 -0
- package/dist/units/diagram/er.js +9 -0
- package/dist/units/diagram/eventmodeling.js +5 -0
- package/dist/units/diagram/gantt-date.js +1 -0
- package/dist/units/diagram/gantt.js +3 -0
- package/dist/units/diagram/gitgraph.js +2 -0
- package/dist/units/diagram/graph-layout.js +4 -0
- package/dist/units/diagram/graph-parse.js +9 -0
- package/dist/units/diagram/graph-route.js +1 -0
- package/dist/units/diagram/graph.js +1 -0
- package/dist/units/diagram/ishikawa.js +2 -0
- package/dist/units/diagram/journey.js +5 -0
- package/dist/units/diagram/kanban.js +2 -0
- package/dist/units/diagram/label.js +4 -0
- package/dist/units/diagram/layers.js +1 -0
- package/dist/units/diagram/map-label.js +1 -0
- package/dist/units/diagram/mindmap.js +2 -0
- package/dist/units/diagram/numeric-composition.js +1 -0
- package/dist/units/diagram/numeric-model.js +1 -0
- package/dist/units/diagram/numeric-parse.js +2 -0
- package/dist/units/diagram/numeric-radar.js +3 -0
- package/dist/units/diagram/numeric-sankey.js +2 -0
- package/dist/units/diagram/numeric-xy.js +2 -0
- package/dist/units/diagram/packet.js +2 -0
- package/dist/units/diagram/presentation.js +2 -0
- package/dist/units/diagram/quadrant.js +2 -0
- package/dist/units/diagram/railroad-parse.js +4 -0
- package/dist/units/diagram/railroad.js +1 -0
- package/dist/units/diagram/registry.js +2 -0
- package/dist/units/diagram/relations.js +3 -0
- package/dist/units/diagram/requirement.js +3 -0
- package/dist/units/diagram/sequence.js +2 -0
- package/dist/units/diagram/shapes.js +60 -0
- package/dist/units/diagram/source.js +20 -0
- package/dist/units/diagram/support.js +3 -0
- package/dist/units/diagram/swimlane-mermaid.js +3 -0
- package/dist/units/diagram/swimlane.js +2 -0
- package/dist/units/diagram/time.js +3 -0
- package/dist/units/diagram/timeline.js +2 -0
- package/dist/units/diagram/tree-family-icon.js +1 -0
- package/dist/units/diagram/treeview.js +2 -0
- package/dist/units/diagram/usecase.js +3 -0
- package/dist/units/diagram/venn.js +2 -0
- package/dist/units/diagram/wardley.js +4 -0
- package/dist/units/interaction.js +1 -0
- package/dist/units/runtime.js +1 -0
- package/dist/units.json +712 -0
- package/package.json +30 -4
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { error, warning } from "./support.js";
|
|
3
|
+
import { numericLabel, renderWith, validateWith } from "./numeric-model.js";
|
|
4
|
+
import "../chart/multivariate.js";
|
|
5
|
+
// src/diagram/numeric-radar.js
|
|
6
|
+
var numeric_radar_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
honoredConfig: () => honoredConfig,
|
|
8
|
+
implementations: () => implementations
|
|
9
|
+
});
|
|
10
|
+
var limit = 24;
|
|
11
|
+
var MIN_AXES = 3;
|
|
12
|
+
var MAX_AXES = 6;
|
|
13
|
+
var MIN_RINGS = 2;
|
|
14
|
+
var MAX_RINGS = 8;
|
|
15
|
+
var DEFAULT_RINGS = 5;
|
|
16
|
+
var unquote = (value) => {
|
|
17
|
+
const text = String(value).trim();
|
|
18
|
+
return text.startsWith("\"") && text.endsWith("\"") || text.startsWith("'") && text.endsWith("'") ? text.slice(1, -1).replace(/\\([\\"'])/g, "$1") : text;
|
|
19
|
+
};
|
|
20
|
+
var number = (value) => /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(String(value).trim()) ? Number(value) : null;
|
|
21
|
+
var issue = (info, line, zh, en, fixZh = "修正 Mermaid radar 语法", fixEn = "Correct the Mermaid radar syntax") => error(info.lang, line, zh, en, fixZh, fixEn);
|
|
22
|
+
var hint = (info, line, zh, en, fixZh, fixEn) => warning("DIAGRAM_HINT", info.lang, line, zh, en, fixZh, fixEn);
|
|
23
|
+
function statements(source, firstLine) {
|
|
24
|
+
const out = [];
|
|
25
|
+
let buffer = null, start = 0, depth = 0;
|
|
26
|
+
String(source).split("\n").forEach((raw, index) => {
|
|
27
|
+
const text = raw.trim();
|
|
28
|
+
if (buffer === null && (!text || text.startsWith("%%"))) return;
|
|
29
|
+
if (buffer === null) {
|
|
30
|
+
start = firstLine + index;
|
|
31
|
+
buffer = "";
|
|
32
|
+
}
|
|
33
|
+
buffer += (buffer ? "\n" : "") + text;
|
|
34
|
+
depth = Math.max(0, depth + (text.match(/\{/g) || []).length - (text.match(/\}/g) || []).length);
|
|
35
|
+
if (depth) return;
|
|
36
|
+
out.push({
|
|
37
|
+
text: buffer,
|
|
38
|
+
line: start
|
|
39
|
+
});
|
|
40
|
+
buffer = null;
|
|
41
|
+
});
|
|
42
|
+
if (buffer !== null) out.push({
|
|
43
|
+
text: buffer,
|
|
44
|
+
line: start
|
|
45
|
+
});
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
function splitTop(text) {
|
|
49
|
+
const parts = [];
|
|
50
|
+
let current = "", quote = "", depth = 0;
|
|
51
|
+
for (const char of text) {
|
|
52
|
+
if (quote) {
|
|
53
|
+
current += char;
|
|
54
|
+
if (char === quote) quote = "";
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (char === "\"" || char === "'") {
|
|
58
|
+
quote = char;
|
|
59
|
+
current += char;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (char === "[" || char === "{") depth += 1;
|
|
63
|
+
if (char === "]" || char === "}") depth -= 1;
|
|
64
|
+
if (char === "," && depth === 0) {
|
|
65
|
+
parts.push(current.trim());
|
|
66
|
+
current = "";
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
current += char;
|
|
70
|
+
}
|
|
71
|
+
parts.push(current.trim());
|
|
72
|
+
return parts;
|
|
73
|
+
}
|
|
74
|
+
var LABEL = "(?:\\[\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|'((?:[^'\\\\]|\\\\.)*)'|([^\\]]*))\\s*\\])?";
|
|
75
|
+
var ID = "[\\p{L}\\p{N}_][\\p{L}\\p{N}_.-]*";
|
|
76
|
+
var AXIS = new RegExp(`^(${ID})\\s*${LABEL}$`, "u");
|
|
77
|
+
var CURVE = new RegExp(`^(${ID})\\s*${LABEL}\\s*\\{([\\s\\S]*)\\}$`, "u");
|
|
78
|
+
var ENTRY = new RegExp(`^(${ID})\\s*:?\\s*([-+]?(?:\\d+(?:\\.\\d*)?|\\.\\d+))$`, "u");
|
|
79
|
+
var labelOf = (match, id) => {
|
|
80
|
+
const raw = [
|
|
81
|
+
match[2],
|
|
82
|
+
match[3],
|
|
83
|
+
match[4]
|
|
84
|
+
].find((value) => value !== void 0);
|
|
85
|
+
return (raw === void 0 ? id : unquote(raw)) || id;
|
|
86
|
+
};
|
|
87
|
+
function headerError(info) {
|
|
88
|
+
const rest = String(info.params || "").replace(/\s*:\s*$/, "").trim();
|
|
89
|
+
if (rest) return issue(info, info.headerLine || info.firstLine, `radar-beta 不支持头行选项「${rest}」`, `radar-beta does not accept header options: ${rest}`, "把选项写成独立语句(max、min、ticks、showLegend、graticule)", "Write options as their own statements");
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
function readAxes(info, text, line, axes, errors) {
|
|
93
|
+
for (const part of splitTop(text.replace(/^axis\s+/i, ""))) {
|
|
94
|
+
const match = AXIS.exec(part);
|
|
95
|
+
if (!match) {
|
|
96
|
+
errors.push(issue(info, line, `无法识别 radar 维度「${part}」`, `Unrecognized radar axis "${part}"`, "使用 `axis 名称` 或 `axis 名称[\"显示名\"]`", "Use `axis name` or `axis name[\"Label\"]`"));
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const id = match[1];
|
|
100
|
+
if (axes.some((axis) => axis.id === id)) {
|
|
101
|
+
errors.push(issue(info, line, `radar 维度「${id}」重复`, `Duplicate radar axis "${id}"`, "每个维度只声明一次", "Declare each axis once"));
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
axes.push({
|
|
105
|
+
id,
|
|
106
|
+
label: numericLabel(labelOf(match, id), info, line, errors),
|
|
107
|
+
line
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function readCurves(info, text, line, curves, errors) {
|
|
112
|
+
for (const part of splitTop(text.replace(/^curve\s+/i, ""))) {
|
|
113
|
+
const match = CURVE.exec(part);
|
|
114
|
+
if (!match) {
|
|
115
|
+
errors.push(issue(info, line, `无法识别 radar 曲线「${part}」`, `Unrecognized radar curve "${part}"`, "使用 `curve 名称[\"显示名\"]{值, 值}` 或 `curve 名称{维度: 值}`", "Use `curve name[\"Label\"]{value, value}` or `curve name{axis: value}`"));
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const id = match[1], entries = [], items = match[5].split(/[,\n]/).map((item) => item.trim()).filter(Boolean);
|
|
119
|
+
let broken = false;
|
|
120
|
+
for (const item of items) {
|
|
121
|
+
const value = number(item);
|
|
122
|
+
if (value !== null) {
|
|
123
|
+
entries.push({
|
|
124
|
+
axis: null,
|
|
125
|
+
value
|
|
126
|
+
});
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const pair = ENTRY.exec(item);
|
|
130
|
+
if (!pair) {
|
|
131
|
+
errors.push(issue(info, line, `radar 曲线「${id}」的值「${item}」无效`, `Invalid value "${item}" in radar curve "${id}"`, "曲线值必须是数值,或 `维度名: 数值`", "Curve values must be numbers or `axis: number` pairs"));
|
|
132
|
+
broken = true;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
entries.push({
|
|
136
|
+
axis: pair[1],
|
|
137
|
+
value: Number(pair[2])
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (!broken) curves.push({
|
|
141
|
+
id,
|
|
142
|
+
label: numericLabel(labelOf(match, id), info, line, errors),
|
|
143
|
+
entries,
|
|
144
|
+
line
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function resolveCurves(info, curves, axes, errors) {
|
|
149
|
+
return curves.flatMap((curve) => {
|
|
150
|
+
const referenced = curve.entries.filter((entry) => entry.axis !== null);
|
|
151
|
+
if (!referenced.length) return [{
|
|
152
|
+
...curve,
|
|
153
|
+
values: curve.entries.map((entry) => entry.value)
|
|
154
|
+
}];
|
|
155
|
+
if (referenced.length !== curve.entries.length) {
|
|
156
|
+
errors.push(issue(info, curve.line, `radar 曲线「${curve.label}」不能混用按位和按维度取值`, `Radar curve "${curve.label}" mixes positional and named values`, "整条曲线统一使用一种写法", "Use one value form for the whole curve"));
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
const unknown = referenced.filter((entry) => !axes.some((axis) => axis.id === entry.axis));
|
|
160
|
+
if (unknown.length) {
|
|
161
|
+
errors.push(issue(info, curve.line, `radar 曲线「${curve.label}」引用了未声明的维度「${unknown[0].axis}」`, `Radar curve "${curve.label}" references undeclared axis "${unknown[0].axis}"`, "先声明该维度,或删去这一项", "Declare the axis first, or remove that entry"));
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
164
|
+
const missing = axes.filter((axis) => !referenced.some((entry) => entry.axis === axis.id));
|
|
165
|
+
if (missing.length) {
|
|
166
|
+
errors.push(issue(info, curve.line, `radar 曲线「${curve.label}」缺少维度「${missing.map((axis) => axis.id).join("、")}」的值`, `Radar curve "${curve.label}" is missing values for ${missing.map((axis) => axis.id).join(", ")}`, "为每个维度各写一个 `维度名: 数值`", "Give one `axis: number` entry per axis"));
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
return [{
|
|
170
|
+
...curve,
|
|
171
|
+
values: axes.map((axis) => referenced.find((entry) => entry.axis === axis.id).value)
|
|
172
|
+
}];
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function readOption(info, text, line, options, errors) {
|
|
176
|
+
for (const part of splitTop(text)) {
|
|
177
|
+
const match = /^(showLegend|ticks|max|min|graticule)\s+(\S+)$/i.exec(part);
|
|
178
|
+
if (!match) {
|
|
179
|
+
errors.push(issue(info, line, `无法识别 radar 语句「${part}」`, `Unrecognized radar statement "${part}"`, "支持 axis、curve、max、min、ticks、showLegend、graticule", "Supported: axis, curve, max, min, ticks, showLegend, graticule"));
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const name = match[1].toLowerCase(), value = match[2];
|
|
183
|
+
if (name === "showlegend") {
|
|
184
|
+
if (!/^(true|false)$/i.test(value)) {
|
|
185
|
+
errors.push(issue(info, line, "showLegend 只接受 true 或 false", "showLegend accepts only true or false"));
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
options.showLegend = value.toLowerCase() === "true";
|
|
189
|
+
options.line ??= line;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (name === "graticule") {
|
|
193
|
+
if (!/^(circle|polygon)$/i.test(value)) {
|
|
194
|
+
errors.push(issue(info, line, "graticule 只接受 circle 或 polygon", "graticule accepts only circle or polygon"));
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
options.graticule = value.toLowerCase();
|
|
198
|
+
options.line ??= line;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const numericValue = number(value);
|
|
202
|
+
if (numericValue === null) {
|
|
203
|
+
errors.push(issue(info, line, `radar ${name} 值「${value}」无效`, `Invalid radar ${name} value "${value}"`));
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
options[name] = numericValue;
|
|
207
|
+
options.line ??= line;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
var configValue = (config, name) => {
|
|
211
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) return void 0;
|
|
212
|
+
const key = Object.keys(config).find((candidate) => candidate.toLowerCase() === name.toLowerCase());
|
|
213
|
+
return key === void 0 ? void 0 : config[key];
|
|
214
|
+
};
|
|
215
|
+
var configFlag = (config, name) => {
|
|
216
|
+
const value = configValue(config, name);
|
|
217
|
+
return typeof value === "boolean" ? value : void 0;
|
|
218
|
+
};
|
|
219
|
+
var configNumber = (config, name) => {
|
|
220
|
+
const value = configValue(config, name);
|
|
221
|
+
const parsed = typeof value === "number" ? value : number(value ?? "");
|
|
222
|
+
return parsed !== null && Number.isFinite(parsed) ? parsed : void 0;
|
|
223
|
+
};
|
|
224
|
+
function parseRadar(source, info) {
|
|
225
|
+
const errors = [], axes = [], curves = [], options = {};
|
|
226
|
+
const header = headerError(info);
|
|
227
|
+
if (header) errors.push(header);
|
|
228
|
+
let title = null, titleLine = null, axisLine = null;
|
|
229
|
+
for (const item of statements(source, info.firstLine)) {
|
|
230
|
+
if (/^title\s+/i.test(item.text)) {
|
|
231
|
+
if (title !== null) {
|
|
232
|
+
errors.push(issue(info, item.line, "radar 只能有一个 title"));
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
title = numericLabel(unquote(item.text.replace(/^title\s+/i, "")), info, item.line, errors);
|
|
236
|
+
titleLine = item.line;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (/^axis\s+/i.test(item.text)) {
|
|
240
|
+
axisLine ??= item.line;
|
|
241
|
+
readAxes(info, item.text, item.line, axes, errors);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (/^curve\s+/i.test(item.text)) {
|
|
245
|
+
readCurves(info, item.text, item.line, curves, errors);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
readOption(info, item.text, item.line, options, errors);
|
|
249
|
+
}
|
|
250
|
+
const radarConfig = configValue(info.config, "radar");
|
|
251
|
+
const ticks = configNumber(radarConfig, "ticks") ?? options.ticks ?? DEFAULT_RINGS;
|
|
252
|
+
const min = configNumber(radarConfig, "min") ?? options.min ?? 0;
|
|
253
|
+
const declaredMax = configNumber(radarConfig, "max") ?? options.max ?? null;
|
|
254
|
+
const showLegend = configFlag(radarConfig, "showLegend") ?? options.showLegend ?? true;
|
|
255
|
+
const graticule = String(configValue(radarConfig, "graticule") ?? options.graticule ?? "circle").toLowerCase();
|
|
256
|
+
if (axes.length < MIN_AXES || axes.length > MAX_AXES) errors.push(issue(info, axisLine || info.firstLine, `radar 需要 ${MIN_AXES}–${MAX_AXES} 个维度,当前 ${axes.length} 个`, `Radar needs ${MIN_AXES}–${MAX_AXES} axes, got ${axes.length}`, `维度必须在 ${MIN_AXES}–${MAX_AXES} 个之间;合并维度或拆分图表`, `Keep axes between ${MIN_AXES} and ${MAX_AXES}; merge dimensions or split the chart`));
|
|
257
|
+
if (!curves.length && !errors.length) errors.push(issue(info, info.firstLine, "radar 至少需要一条 curve", "Radar needs at least one curve"));
|
|
258
|
+
if (declaredMax !== null && declaredMax <= min) errors.push(issue(info, options.line || info.firstLine, "radar max 必须大于 min", "Radar max must be greater than min"));
|
|
259
|
+
const resolved = resolveCurves(info, curves, axes, errors);
|
|
260
|
+
const kept = resolved.filter((curve) => {
|
|
261
|
+
if (curve.values.length === axes.length) return true;
|
|
262
|
+
errors.push(hint(info, curve.line, `radar 曲线「${curve.label}」有 ${curve.values.length} 个值、${axes.length} 个维度,已跳过`, `Radar curve "${curve.label}" has ${curve.values.length} values for ${axes.length} axes and was skipped`, "为每个维度写一个值", "Give one value per axis"));
|
|
263
|
+
return false;
|
|
264
|
+
});
|
|
265
|
+
if (resolved.length > limit) errors.push(issue(info, resolved[limit].line, `radar 安全上限为 ${limit} 条曲线,当前 ${resolved.length} 条`, `radar safety cap is ${limit} curves; got ${resolved.length}`, `将曲线合并到 ${limit} 条以内,或拆成多张图`, `Merge curves to stay within ${limit}, or split the chart`));
|
|
266
|
+
const values = kept.flatMap((curve) => curve.values).filter(Number.isFinite);
|
|
267
|
+
const dataMax = values.length ? Math.max(...values) : 0, dataMin = values.length ? Math.min(...values) : 0;
|
|
268
|
+
let top = declaredMax ?? Math.max(dataMax, min + 1), bottom = min;
|
|
269
|
+
if (!(top > bottom)) top = bottom + 1;
|
|
270
|
+
if (dataMax > top) {
|
|
271
|
+
errors.push(hint(info, options.line || info.firstLine, `radar max ${top} 小于数据最大值 ${dataMax},已扩展到 ${dataMax}`, `Radar max ${top} is below the data maximum ${dataMax}; extended to ${dataMax}`, `把 max 改为不小于 ${dataMax}`, `Set max to at least ${dataMax}`));
|
|
272
|
+
top = dataMax;
|
|
273
|
+
}
|
|
274
|
+
if (dataMin < bottom) {
|
|
275
|
+
errors.push(hint(info, options.line || info.firstLine, `radar min ${bottom} 大于数据最小值 ${dataMin},已扩展到 ${dataMin}`, `Radar min ${bottom} is above the data minimum ${dataMin}; extended to ${dataMin}`, `把 min 改为不大于 ${dataMin}`, `Set min to no more than ${dataMin}`));
|
|
276
|
+
bottom = dataMin;
|
|
277
|
+
}
|
|
278
|
+
const rings = Math.max(MIN_RINGS, Math.min(MAX_RINGS, Math.round(ticks)));
|
|
279
|
+
if (rings !== ticks) errors.push(hint(info, options.line || info.firstLine, `radar ticks ${ticks} 超出 ${MIN_RINGS}–${MAX_RINGS} 环的可读范围,按 ${rings} 环绘制`, `Radar ticks ${ticks} is outside the readable ${MIN_RINGS}–${MAX_RINGS} rings; drawing ${rings}`, `把 ticks 设为 ${MIN_RINGS}–${MAX_RINGS} 之间的整数`, `Set ticks to an integer within ${MIN_RINGS}–${MAX_RINGS}`));
|
|
280
|
+
const fields = axes.map((axis, index) => ({
|
|
281
|
+
name: `d${index}`,
|
|
282
|
+
label: axis.label
|
|
283
|
+
}));
|
|
284
|
+
const rows = kept.map((curve) => Object.fromEntries([["label", curve.label], ...fields.map((field, index) => [field.name, curve.values[index]])]));
|
|
285
|
+
return {
|
|
286
|
+
model: {
|
|
287
|
+
chart: "radar",
|
|
288
|
+
title,
|
|
289
|
+
titleLine,
|
|
290
|
+
axisLine,
|
|
291
|
+
axes,
|
|
292
|
+
fields,
|
|
293
|
+
rows,
|
|
294
|
+
domain: [bottom, top],
|
|
295
|
+
rings,
|
|
296
|
+
graticule,
|
|
297
|
+
showLegend,
|
|
298
|
+
curveLines: kept.map((curve) => curve.line),
|
|
299
|
+
optionsLine: options.line || axisLine || info.firstLine
|
|
300
|
+
},
|
|
301
|
+
errors
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function toSpec(model) {
|
|
305
|
+
return {
|
|
306
|
+
chart: "radar",
|
|
307
|
+
...model.title ? { title: model.title } : {},
|
|
308
|
+
data: model.rows,
|
|
309
|
+
encode: {
|
|
310
|
+
label: "label",
|
|
311
|
+
dimensions: model.fields.map((field) => field.name)
|
|
312
|
+
},
|
|
313
|
+
fields: Object.fromEntries(model.fields.map((field) => [field.name, {
|
|
314
|
+
label: field.label,
|
|
315
|
+
domain: model.domain
|
|
316
|
+
}])),
|
|
317
|
+
rings: model.rings,
|
|
318
|
+
graticule: model.graticule,
|
|
319
|
+
legend: model.showLegend
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function lineFor(model, detail) {
|
|
323
|
+
const path = String(detail?.path || "").split("/").slice(1).map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
324
|
+
const row = Number(path[1]);
|
|
325
|
+
if (path[0] === "title") return model.titleLine;
|
|
326
|
+
if (path[0] === "data" && Number.isInteger(row) && model.curveLines[row]) return model.curveLines[row];
|
|
327
|
+
if (path[0] === "fields" || path[0] === "encode") return model.axisLine;
|
|
328
|
+
if ([
|
|
329
|
+
"rings",
|
|
330
|
+
"graticule",
|
|
331
|
+
"legend"
|
|
332
|
+
].includes(path[0])) return model.optionsLine;
|
|
333
|
+
return model.axisLine || model.curveLines[0] || model.optionsLine;
|
|
334
|
+
}
|
|
335
|
+
var validate = (model, info) => validateWith(toSpec(model), info, (detail) => lineFor(model, detail));
|
|
336
|
+
var layout = (model, options, info) => {
|
|
337
|
+
const result = renderWith(toSpec(model), options, info, (detail) => lineFor(model, detail));
|
|
338
|
+
if (result.scene && (model.rows.length > 12 || result.width > options.width * 2)) result.errors.push(warning("LARGE_DIAGRAM", info.lang, model.curveLines[0] || model.optionsLine, `radar 有 ${model.rows.length} 条曲线,图表较大,可滚动查看`, `The radar chart has ${model.rows.length} curves and is large; scroll to view`, "按主题拆分为多张雷达图", "Split the curves into smaller radar charts by topic"));
|
|
339
|
+
return result;
|
|
340
|
+
};
|
|
341
|
+
var honoredConfig = Object.freeze([
|
|
342
|
+
"radar.ticks",
|
|
343
|
+
"radar.min",
|
|
344
|
+
"radar.max",
|
|
345
|
+
"radar.showLegend",
|
|
346
|
+
"radar.graticule"
|
|
347
|
+
]);
|
|
348
|
+
var implementations = { "radar-beta": {
|
|
349
|
+
parse: parseRadar,
|
|
350
|
+
validate,
|
|
351
|
+
layout,
|
|
352
|
+
optionMode: "raw",
|
|
353
|
+
honoredConfig
|
|
354
|
+
} };
|
|
355
|
+
export { honoredConfig, implementations, numeric_radar_exports };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { error, warning } from "./support.js";
|
|
3
|
+
import { numericLabel, renderWith, validateWith } from "./numeric-model.js";
|
|
4
|
+
import { presentation } from "./presentation.js";
|
|
5
|
+
import { sankeyPresentation } from "../chart/relations.js";
|
|
6
|
+
import { createRegistry, layouts } from "../chart/registry.js";
|
|
7
|
+
import { sizeBudget, validate as validate$1 } from "../chart/spec.js";
|
|
8
|
+
// src/diagram/numeric-sankey.js
|
|
9
|
+
var numeric_sankey_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
honoredConfig: () => honoredConfig,
|
|
11
|
+
implementations: () => implementations
|
|
12
|
+
});
|
|
13
|
+
var MAX_NODES = 600;
|
|
14
|
+
var MAX_EDGES = 500;
|
|
15
|
+
var LARGE_NODES = 60;
|
|
16
|
+
var LARGE_EDGES = 120;
|
|
17
|
+
var issue = (info, line, zh, en, fixZh = "修正 Mermaid sankey 语法", fixEn = "Correct the Mermaid sankey syntax") => error(info.lang, line, zh, en, fixZh, fixEn);
|
|
18
|
+
var csv = (text) => {
|
|
19
|
+
const cells = [];
|
|
20
|
+
let value = "", quoted = false, after = false;
|
|
21
|
+
for (let i = 0; i < text.length; i++) {
|
|
22
|
+
const char = text[i];
|
|
23
|
+
if (quoted) {
|
|
24
|
+
if (char === "\"" && text[i + 1] === "\"") {
|
|
25
|
+
value += "\"";
|
|
26
|
+
i += 1;
|
|
27
|
+
} else if (char === "\"") {
|
|
28
|
+
quoted = false;
|
|
29
|
+
after = true;
|
|
30
|
+
} else value += char;
|
|
31
|
+
} else if (char === "\"") {
|
|
32
|
+
if (value.trim() || after) return null;
|
|
33
|
+
value = "";
|
|
34
|
+
quoted = true;
|
|
35
|
+
} else if (char === ",") {
|
|
36
|
+
cells.push(value.trim());
|
|
37
|
+
value = "";
|
|
38
|
+
after = false;
|
|
39
|
+
} else if (after && !/\s/.test(char)) return null;
|
|
40
|
+
else value += char;
|
|
41
|
+
}
|
|
42
|
+
if (quoted) return null;
|
|
43
|
+
cells.push(value.trim());
|
|
44
|
+
return cells;
|
|
45
|
+
};
|
|
46
|
+
var value = (text) => {
|
|
47
|
+
const parsed = Number.parseFloat(text);
|
|
48
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
49
|
+
};
|
|
50
|
+
var configValue = (config, name) => {
|
|
51
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) return void 0;
|
|
52
|
+
const key = Object.keys(config).find((candidate) => candidate.toLowerCase() === name.toLowerCase());
|
|
53
|
+
return key === void 0 ? void 0 : config[key];
|
|
54
|
+
};
|
|
55
|
+
var configFlag = (config, name) => {
|
|
56
|
+
const found = configValue(config, name);
|
|
57
|
+
return typeof found === "boolean" ? found : void 0;
|
|
58
|
+
};
|
|
59
|
+
function parseSankey(source, info) {
|
|
60
|
+
const errors = [], rows = [], nodes = [];
|
|
61
|
+
const look = presentation({ lang: info.lang });
|
|
62
|
+
const header = String(info.params || Object.keys(info.options || {}).join(" ")).replace(/\s*:\s*$/, "").trim();
|
|
63
|
+
if (header) errors.push(issue(info, info.headerLine || info.firstLine, `sankey 不支持头行选项「${header}」`, `sankey does not accept header options: ${header}`, "把配置写在前言区 sankey: 下", "Put options under front matter sankey:"));
|
|
64
|
+
String(source).split("\n").forEach((raw, index) => {
|
|
65
|
+
const text = raw.trim(), line = info.firstLine + index;
|
|
66
|
+
if (!text || text.startsWith("%%") || look.accept(text, line)) return;
|
|
67
|
+
const cells = csv(text);
|
|
68
|
+
if (!cells) {
|
|
69
|
+
errors.push(issue(info, line, "sankey CSV 引号格式错误", "Malformed sankey CSV quoting", "用成对的 \" 包住含逗号的名称,字段内引号写作 \"\"", "Wrap names that contain commas in \" and write inner quotes as \"\""));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (cells.length !== 3) {
|
|
73
|
+
errors.push(issue(info, line, `sankey 每行必须是 Source,Target,Value 三列,本行 ${cells.length} 列`, `Each sankey row needs exactly 3 columns, got ${cells.length}`, "每行只写来源、目标、数值三列", "Write source, target and value only"));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const [from, to] = [cells[0], cells[1]], amount = value(cells[2]);
|
|
77
|
+
if (!from || !to) {
|
|
78
|
+
errors.push(issue(info, line, "sankey 来源与目标不能为空", "Sankey source and target must not be empty"));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (amount === null || amount <= 0) {
|
|
82
|
+
errors.push(issue(info, line, `sankey 流量必须为正有限数,本行「${cells[2]}」`, `Sankey value must be a positive finite number, got "${cells[2]}"`, "把数值改为大于 0 的有限数", "Use a positive finite number"));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const id of [from, to]) if (!nodes.includes(id)) nodes.push(id);
|
|
86
|
+
rows.push({
|
|
87
|
+
id: `edge-${rows.length + 1}`,
|
|
88
|
+
source: from,
|
|
89
|
+
target: to,
|
|
90
|
+
value: amount,
|
|
91
|
+
line
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
if (!rows.length && !errors.length) errors.push(issue(info, info.firstLine, "sankey 至少需要一条有效流量 CSV 记录", "Sankey needs at least one valid CSV flow record"));
|
|
95
|
+
if (nodes.length > MAX_NODES) errors.push(issue(info, info.firstLine, `sankey 超过安全上限 ${MAX_NODES} 个节点(当前 ${nodes.length})`, `Sankey exceeds the safety cap of ${MAX_NODES} nodes (got ${nodes.length})`, "拆分图表后重试", "Split the diagram and try again"));
|
|
96
|
+
if (rows.length > MAX_EDGES) errors.push(issue(info, info.firstLine, `sankey 超过 Mermaid maxEdges 安全上限 ${MAX_EDGES} 条流量(当前 ${rows.length})`, `Sankey exceeds the Mermaid maxEdges safety cap of ${MAX_EDGES} flows (got ${rows.length})`, "拆分图表后重试", "Split the diagram and try again"));
|
|
97
|
+
const showValues = configFlag(configValue(info.config, "sankey"), "showValues") ?? true;
|
|
98
|
+
return {
|
|
99
|
+
model: {
|
|
100
|
+
chart: "sankey",
|
|
101
|
+
nodes: nodes.map((id) => ({
|
|
102
|
+
id,
|
|
103
|
+
label: numericLabel(id, info, rows.find((e) => e.source === id || e.target === id)?.line, errors),
|
|
104
|
+
[sankeyPresentation]: {
|
|
105
|
+
status: look.statusOf(id),
|
|
106
|
+
link: look.linkOf(id)
|
|
107
|
+
}
|
|
108
|
+
})),
|
|
109
|
+
edges: rows.map((edge, index) => ({
|
|
110
|
+
...edge,
|
|
111
|
+
[sankeyPresentation]: look.edgeStatusOf(index)
|
|
112
|
+
})),
|
|
113
|
+
showValues,
|
|
114
|
+
unit: unitOf(info)
|
|
115
|
+
},
|
|
116
|
+
errors: [...errors, ...look.diagnostics()]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function unitOf(info) {
|
|
120
|
+
const config = configValue(info.config, "sankey");
|
|
121
|
+
const prefix = configValue(config, "prefix"), suffix = configValue(config, "suffix");
|
|
122
|
+
if (prefix === void 0 && suffix === void 0) return void 0;
|
|
123
|
+
const text = (value) => value === void 0 || value === null ? "" : String(value);
|
|
124
|
+
const [pre, post] = [text(prefix), text(suffix)];
|
|
125
|
+
return /^[\p{L}\p{Sc}%‰°]*\p{Sc}?[\p{L}\p{Sc}%‰°]*$/u.test(`${pre}${post}`) && `${pre}${post}` ? `${pre}${post}` : void 0;
|
|
126
|
+
}
|
|
127
|
+
function toSpec(model) {
|
|
128
|
+
return {
|
|
129
|
+
chart: "sankey",
|
|
130
|
+
tolerant: true,
|
|
131
|
+
[sankeyPresentation]: true,
|
|
132
|
+
[sizeBudget]: {
|
|
133
|
+
nodes: MAX_NODES,
|
|
134
|
+
edges: MAX_EDGES
|
|
135
|
+
},
|
|
136
|
+
data: {
|
|
137
|
+
nodes: model.nodes,
|
|
138
|
+
edges: model.edges.map(({ line, ...edge }) => edge)
|
|
139
|
+
},
|
|
140
|
+
layout: "right",
|
|
141
|
+
showValues: model.showValues,
|
|
142
|
+
...model.unit ? { unit: model.unit } : {}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function lineFor(model, detail) {
|
|
146
|
+
const path = String(detail?.path || "").split("/").slice(1).map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
147
|
+
const indexAt = (key) => path[path.indexOf(key) + 1];
|
|
148
|
+
const edgeIndex = Number(indexAt("edges"));
|
|
149
|
+
if (Number.isInteger(edgeIndex) && model.edges[edgeIndex]) return model.edges[edgeIndex].line;
|
|
150
|
+
const nodeIndex = Number(indexAt("nodes"));
|
|
151
|
+
if (Number.isInteger(nodeIndex) && model.nodes[nodeIndex]) {
|
|
152
|
+
const id = model.nodes[nodeIndex].id;
|
|
153
|
+
return model.edges.find((edge) => edge.source === id || edge.target === id)?.line;
|
|
154
|
+
}
|
|
155
|
+
return model.edges[0]?.line;
|
|
156
|
+
}
|
|
157
|
+
function validate(model, info) {
|
|
158
|
+
const errors = validateWith(toSpec(model), info, (detail) => lineFor(model, detail));
|
|
159
|
+
if (errors.length || model.nodes.length <= LARGE_NODES && model.edges.length <= LARGE_EDGES) return errors;
|
|
160
|
+
const indegree = new Map(model.nodes.map((node) => [node.id, 0]));
|
|
161
|
+
const outgoing = new Map(model.nodes.map((node) => [node.id, []]));
|
|
162
|
+
const stage = new Map(model.nodes.map((node) => [node.id, 0]));
|
|
163
|
+
for (const { source, target } of model.edges) {
|
|
164
|
+
outgoing.get(source).push(target);
|
|
165
|
+
indegree.set(target, indegree.get(target) + 1);
|
|
166
|
+
}
|
|
167
|
+
const queue = model.nodes.map((node) => node.id).filter((id) => !indegree.get(id));
|
|
168
|
+
for (const id of queue) for (const target of outgoing.get(id)) {
|
|
169
|
+
stage.set(target, Math.max(stage.get(target), stage.get(id) + 1));
|
|
170
|
+
indegree.set(target, indegree.get(target) - 1);
|
|
171
|
+
if (!indegree.get(target)) queue.push(target);
|
|
172
|
+
}
|
|
173
|
+
const cap = 1e3;
|
|
174
|
+
let segments = 0;
|
|
175
|
+
for (const { source, target, line } of model.edges) {
|
|
176
|
+
segments += stage.get(target) - stage.get(source);
|
|
177
|
+
if (segments > cap) return [issue(info, line, `桑基图最多支持 ${cap} 个跨阶段流量分段`, `Sankey supports at most ${cap} flow segments across stages`, "请按阶段拆分图表", "Split the chart by stage")];
|
|
178
|
+
}
|
|
179
|
+
return errors;
|
|
180
|
+
}
|
|
181
|
+
var sankeyRegistry = createRegistry(validate$1);
|
|
182
|
+
sankeyRegistry.register("sankey", layouts.get("sankey"));
|
|
183
|
+
var layout = (model, options, info) => {
|
|
184
|
+
const result = renderWith(toSpec(model), options, info, (detail) => lineFor(model, detail), sankeyRegistry.layout);
|
|
185
|
+
if (result.scene && (result.width > options.width * 2 || model.nodes.length > LARGE_NODES || model.edges.length > LARGE_EDGES)) result.errors.push(warning("LARGE_DIAGRAM", info.lang, info.headerLine, "桑基图较大,可滚动查看", "Large Sankey diagram; scroll to view it", "考虑拆分图表", "Consider splitting the diagram"));
|
|
186
|
+
return result;
|
|
187
|
+
};
|
|
188
|
+
var honoredConfig = Object.freeze([
|
|
189
|
+
"sankey.showValues",
|
|
190
|
+
"sankey.prefix",
|
|
191
|
+
"sankey.suffix"
|
|
192
|
+
]);
|
|
193
|
+
var implementations = { sankey: {
|
|
194
|
+
parse: parseSankey,
|
|
195
|
+
validate,
|
|
196
|
+
layout,
|
|
197
|
+
optionMode: "raw",
|
|
198
|
+
acceptsPresentation: true,
|
|
199
|
+
honoredConfig
|
|
200
|
+
} };
|
|
201
|
+
export { honoredConfig, implementations, numeric_sankey_exports };
|