@opendata-ai/openchart-engine 6.17.0 → 6.18.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/dist/index.d.ts +1 -0
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/compiler/normalize.ts +1 -0
- package/src/sankey/compile-sankey.ts +2 -0
- package/src/sankey/layout.ts +14 -0
- package/src/sankey/types.ts +1 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6530,6 +6530,7 @@ function normalizeSankeySpec(spec, _warnings) {
|
|
|
6530
6530
|
iterations: spec.iterations ?? 6,
|
|
6531
6531
|
linkStyle: spec.linkStyle ?? "gradient",
|
|
6532
6532
|
nodeLabelAlign: spec.nodeLabelAlign ?? "auto",
|
|
6533
|
+
nodeSort: spec.nodeSort,
|
|
6533
6534
|
chrome: normalizeChrome(spec.chrome),
|
|
6534
6535
|
legend: spec.legend,
|
|
6535
6536
|
theme: spec.theme ?? {},
|
|
@@ -9345,7 +9346,7 @@ var ALIGN_MAP = {
|
|
|
9345
9346
|
right,
|
|
9346
9347
|
center
|
|
9347
9348
|
};
|
|
9348
|
-
function computeSankeyLayout(data, sourceField, targetField, valueField, area, nodeWidth, nodePadding, nodeAlign, iterations) {
|
|
9349
|
+
function computeSankeyLayout(data, sourceField, targetField, valueField, area, nodeWidth, nodePadding, nodeAlign, iterations, nodeSort) {
|
|
9349
9350
|
const nodeSet = /* @__PURE__ */ new Set();
|
|
9350
9351
|
for (const row of data) {
|
|
9351
9352
|
nodeSet.add(String(row[sourceField]));
|
|
@@ -9366,6 +9367,13 @@ function computeSankeyLayout(data, sourceField, targetField, valueField, area, n
|
|
|
9366
9367
|
[area.x, area.y],
|
|
9367
9368
|
[area.x + area.width, area.y + area.height]
|
|
9368
9369
|
]).iterations(iterations);
|
|
9370
|
+
if (nodeSort && nodeSort.length > 0) {
|
|
9371
|
+
const orderMap = new Map(nodeSort.map((id, i) => [id, i]));
|
|
9372
|
+
const fallback = nodeSort.length;
|
|
9373
|
+
generator.nodeSort(
|
|
9374
|
+
(a, b) => (orderMap.get(a.id) ?? fallback) - (orderMap.get(b.id) ?? fallback)
|
|
9375
|
+
);
|
|
9376
|
+
}
|
|
9369
9377
|
const graph = generator({
|
|
9370
9378
|
nodes,
|
|
9371
9379
|
links
|
|
@@ -9581,7 +9589,8 @@ function compileSankey(spec, options) {
|
|
|
9581
9589
|
sankeySpec.nodeWidth,
|
|
9582
9590
|
sankeySpec.nodePadding,
|
|
9583
9591
|
sankeySpec.nodeAlign,
|
|
9584
|
-
sankeySpec.iterations
|
|
9592
|
+
sankeySpec.iterations,
|
|
9593
|
+
sankeySpec.nodeSort
|
|
9585
9594
|
);
|
|
9586
9595
|
const nodeLabelAlign = sankeySpec.nodeLabelAlign ?? "auto";
|
|
9587
9596
|
const maxDepthFirst = nodes.reduce((max4, n) => Math.max(max4, n.depth ?? 0), 0);
|
|
@@ -9614,7 +9623,8 @@ function compileSankey(spec, options) {
|
|
|
9614
9623
|
sankeySpec.nodeWidth,
|
|
9615
9624
|
sankeySpec.nodePadding,
|
|
9616
9625
|
sankeySpec.nodeAlign,
|
|
9617
|
-
sankeySpec.iterations
|
|
9626
|
+
sankeySpec.iterations,
|
|
9627
|
+
sankeySpec.nodeSort
|
|
9618
9628
|
));
|
|
9619
9629
|
}
|
|
9620
9630
|
const nodeColorMap = buildNodeColorMap(
|