Skip to content

Commit 25cee7d

Browse files
committed
refactor: adapt concentric node size
1 parent a9af1af commit 25cee7d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/layout/src/concentric.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
} from './types';
1212
import { cloneFormatData, isArray } from './util';
1313
import { handleSingleNodeGraph } from './util/common';
14+
import { parseSize } from './util/size';
1415

1516
const DEFAULTS_LAYOUT_OPTIONS: Partial<ConcentricLayoutOptions> = {
1617
nodeSize: 30,
@@ -26,7 +27,7 @@ const DEFAULTS_LAYOUT_OPTIONS: Partial<ConcentricLayoutOptions> = {
2627

2728
/**
2829
* <zh/> 同心圆布局
29-
*
30+
*
3031
* <en/> Concentric layout
3132
*/
3233
export class ConcentricLayout implements Layout<ConcentricLayoutOptions> {
@@ -51,7 +52,7 @@ export class ConcentricLayout implements Layout<ConcentricLayoutOptions> {
5152
* To directly assign the positions to the nodes.
5253
*/
5354
async assign(graph: Graph, options?: ConcentricLayoutOptions) {
54-
await this.genericConcentricLayout(true, graph, options);
55+
await this.genericConcentricLayout(true, graph, options);
5556
}
5657

5758
private async genericConcentricLayout(
@@ -112,7 +113,7 @@ export class ConcentricLayout implements Layout<ConcentricLayoutOptions> {
112113
} else if (isFunction(nodeSize)) {
113114
maxNodeSize = -Infinity;
114115
nodes.forEach((node) => {
115-
const currentSize = nodeSize(node);
116+
const currentSize = Math.max(...parseSize(nodeSize(node)));
116117
if (currentSize > maxNodeSize) maxNodeSize = currentSize;
117118
});
118119
} else {

packages/layout/src/util/function.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const formatNodeSizeToNumber = (
115115
}
116116

117117
const func = (d: Node) => {
118-
const nodeSize = nodeSizeFunc(d);
118+
const nodeSize = nodeSizeFunc(d) as Size;
119119
const nodeSpacing = nodeSpacingFunc(d);
120120
return Math.max(...parseSize(nodeSize)) + nodeSpacing;
121121
};

0 commit comments

Comments
 (0)