Skip to content

Commit

Permalink
fix: fix calculateNodeValue() in vgrammar-hierrachy to support stri…
Browse files Browse the repository at this point in the history
…ng value, fix #433
  • Loading branch information
xile611 committed Apr 18, 2024
1 parent 54c0c28 commit 054376d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vgrammar-hierarchy/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isNil } from '@visactor/vutils';
import { isNil, toValidNumber } from '@visactor/vutils';
import type { HierarchicalDatum, HierarchicalNodeElement } from './interface';

export const calculateNodeValue = <Datum extends HierarchicalDatum, NodeElement extends HierarchicalNodeElement<Datum>>(
Expand Down Expand Up @@ -37,13 +37,13 @@ export const calculateNodeValue = <Datum extends HierarchicalDatum, NodeElement
node,
getNodeKey
);
node.value = isNil(datum.value) ? res.sum : Math.max(res.sum, node.value);
node.value = isNil(datum.value) ? res.sum : Math.max(res.sum, toValidNumber(datum.value));

prevFlattenIndex = res.flattenIndex;
maxDepth = Math.max(res.maxDepth, maxDepth);
} else {
node.isLeaf = true;
node.value = isNil(datum.value) ? 0 : datum.value;
node.value = toValidNumber(datum.value);
}

sum += Math.abs(node.value);
Expand Down

0 comments on commit 054376d

Please sign in to comment.