diff --git a/common/changes/@visactor/vlayouts/feat-sankey-nodeHeight-callback_2025-07-07-07-16.json b/common/changes/@visactor/vlayouts/feat-sankey-nodeHeight-callback_2025-07-07-07-16.json new file mode 100644 index 0000000..4753d35 --- /dev/null +++ b/common/changes/@visactor/vlayouts/feat-sankey-nodeHeight-callback_2025-07-07-07-16.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vlayouts", + "comment": " feat: add columns information in sankey nodeHeight callback", + "type": "none" + } + ], + "packageName": "@visactor/vlayouts" +} \ No newline at end of file diff --git a/packages/vlayouts/src/sankey/interface.ts b/packages/vlayouts/src/sankey/interface.ts index 80c8da2..4825a6f 100644 --- a/packages/vlayouts/src/sankey/interface.ts +++ b/packages/vlayouts/src/sankey/interface.ts @@ -46,8 +46,9 @@ export interface SankeyOptions { /** * set the height of node * @since 0.13.0 + * @description add columns information since 1.0.8 */ - nodeHeight?: number | ((node: SankeyNodeElement) => number); + nodeHeight?: number | ((node: SankeyNodeElement, columns?: SankeyNodeElement[][]) => number); /** * set the height of link * @since 0.13.0 diff --git a/packages/vlayouts/src/sankey/layout.ts b/packages/vlayouts/src/sankey/layout.ts index f0f0680..c3118ba 100644 --- a/packages/vlayouts/src/sankey/layout.ts +++ b/packages/vlayouts/src/sankey/layout.ts @@ -709,7 +709,7 @@ export class SankeyLayout { const getNodeHeight = isNumber(this.options.nodeHeight) ? (node: SankeyNodeElement) => this.options.nodeHeight as number : isFunction(this.options.nodeHeight) - ? (this.options.nodeHeight as (node: SankeyNodeElement) => number) + ? (this.options.nodeHeight as (node: SankeyNodeElement, columns: SankeyNodeElement[][]) => number) : forceNodeHeight > 0 ? (node: SankeyNodeElement) => { return forceNodeHeight; @@ -755,7 +755,7 @@ export class SankeyLayout { y += gapY; } - calculatedNodeHeight = getNodeHeight(node); + calculatedNodeHeight = getNodeHeight(node, columns); nodeHeight = Math.min(Math.max(calculatedNodeHeight, minNodeHeight), maxNodeHeight); node.y0 = y;