Skip to content

Commit

Permalink
fix(sankey): 桑基图节点顺序需要保证原序 (#2897)
Browse files Browse the repository at this point in the history
close: #2825
  • Loading branch information
visiky authored Oct 8, 2021
1 parent cc8fa33 commit 5ad43b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { get, isNumber, filter } from '@antv/util';
import { Data, Datum, Meta, Options } from '../types';
import { NodeLinkData } from '../types/relation-data';
import { Node, NodeLinkData } from '../types/relation-data';
import { LEVEL, log } from './invariant';
import { pick } from './pick';

Expand Down Expand Up @@ -54,7 +54,7 @@ export function transformDataToNodeLinkData(
// const nodes = [];
const links = [];
// 先使用对象方式存储
const nodesMap = {};
const nodesMap: Record<string, Node> = {};
let nodesIndex = -1;
// 数组变换成 chord layout 的数据结构
data.forEach((datum: Datum) => {
Expand Down Expand Up @@ -90,7 +90,8 @@ export function transformDataToNodeLinkData(
});
});
return {
nodes: Object.values(nodesMap),
// 需要按照 id 的顺序
nodes: Object.values(nodesMap).sort((a, b) => a.id - b.id),
links,
};
}
Expand Down

0 comments on commit 5ad43b7

Please sign in to comment.