mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 07:19:41 +02:00
Fixes after review
This commit is contained in:
@@ -43,12 +43,11 @@ class SankeyNode {
|
||||
|
||||
const findOrCreateNode = (ID: string): SankeyNode => {
|
||||
ID = common.sanitizeText(ID, configApi.getConfig());
|
||||
if (nodesMap[ID]) {
|
||||
return nodesMap[ID];
|
||||
}
|
||||
|
||||
if (!nodesMap[ID]) {
|
||||
nodesMap[ID] = new SankeyNode(ID);
|
||||
nodes.push(nodesMap[ID]);
|
||||
}
|
||||
return nodesMap[ID];
|
||||
};
|
||||
|
||||
|
@@ -20,6 +20,17 @@ import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||
import { Uid } from '../../rendering-util/uid.js';
|
||||
import { SankeyLinkColor, SankeyNodeAlignment } from '../../config.type.js';
|
||||
|
||||
// Map config options to alignment functions
|
||||
const alignmentsMap: Record<
|
||||
SankeyNodeAlignment,
|
||||
(node: d3SankeyNode<object, object>, n: number) => number
|
||||
> = {
|
||||
[SankeyNodeAlignment.left]: d3SankeyLeft,
|
||||
[SankeyNodeAlignment.right]: d3SankeyRight,
|
||||
[SankeyNodeAlignment.center]: d3SankeyCenter,
|
||||
[SankeyNodeAlignment.justify]: d3SankeyJustify,
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws Sankey diagram.
|
||||
*
|
||||
@@ -73,16 +84,7 @@ export const draw = function (text: string, id: string, _version: string, diagOb
|
||||
// @ts-ignore TODO: db should be coerced to sankey DB type
|
||||
const graph = diagObj.db.getGraph();
|
||||
|
||||
// Map config options to alignment functions
|
||||
const alignmentsMap: Record<
|
||||
SankeyNodeAlignment,
|
||||
(node: d3SankeyNode<object, object>, n: number) => number
|
||||
> = {
|
||||
[SankeyNodeAlignment.left]: d3SankeyLeft,
|
||||
[SankeyNodeAlignment.right]: d3SankeyRight,
|
||||
[SankeyNodeAlignment.center]: d3SankeyCenter,
|
||||
[SankeyNodeAlignment.justify]: d3SankeyJustify,
|
||||
};
|
||||
// Get alignment function
|
||||
const nodeAlign = alignmentsMap[nodeAlignment];
|
||||
|
||||
// Construct and configure a Sankey generator
|
||||
|
@@ -138,6 +138,7 @@ function sidebarSyntax() {
|
||||
{ text: 'Mindmaps 🔥', link: '/syntax/mindmap' },
|
||||
{ text: 'Timeline 🔥', link: '/syntax/timeline' },
|
||||
{ text: 'Zenuml 🔥', link: '/syntax/zenuml' },
|
||||
{ text: 'Sankey 🔥', link: '/syntax/sankey' },
|
||||
{ text: 'Other Examples', link: '/syntax/examples' },
|
||||
],
|
||||
},
|
||||
|
Reference in New Issue
Block a user