mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 14:59:53 +02:00
Updates after review
This commit is contained in:
@@ -2275,6 +2275,7 @@ const config: Partial<MermaidConfig> = {
|
||||
height: 400,
|
||||
linkColor: SankeyLinkColor.gradient,
|
||||
nodeAlignment: SankeyNodeAlignment.justify,
|
||||
useMaxWidth: false,
|
||||
},
|
||||
fontSize: 16,
|
||||
};
|
||||
|
@@ -10,12 +10,11 @@ import {
|
||||
clear as commonClear,
|
||||
} from '../../commonDb.js';
|
||||
|
||||
// Variables where graph data is stored
|
||||
// Sankey diagram represented by nodes and links between those nodes
|
||||
// We have to track nodes uniqueness (by ID), thats why we need a mapping also
|
||||
//
|
||||
let links: SankeyLink[] = [];
|
||||
// Array of nodes guarantees their order
|
||||
let nodes: SankeyNode[] = [];
|
||||
// We also have to track nodes uniqueness (by ID)
|
||||
let nodesMap: Record<string, SankeyNode> = {};
|
||||
|
||||
const clear = (): void => {
|
||||
|
@@ -31,6 +31,7 @@ import { SankeyLinkColor, SankeyNodeAlignment } from '../../config.type.js';
|
||||
export const draw = function (text: string, id: string, _version: string, diagObj: Diagram): void {
|
||||
// Get Sankey config
|
||||
const { securityLevel, sankey: conf } = configApi.getConfig();
|
||||
const defaultSankeyConfig = configApi!.defaultConfig!.sankey!;
|
||||
|
||||
// TODO:
|
||||
// This code repeats for every diagram
|
||||
@@ -50,10 +51,10 @@ export const draw = function (text: string, id: string, _version: string, diagOb
|
||||
|
||||
// Establish svg dimensions and get width and height
|
||||
//
|
||||
const width = conf?.width || 800;
|
||||
const height = conf?.height || 400;
|
||||
const useMaxWidth = conf?.useMaxWidth || false;
|
||||
const nodeAlignment = conf?.nodeAlignment || SankeyNodeAlignment.justify;
|
||||
const width = conf?.width || defaultSankeyConfig.width!;
|
||||
const height = conf?.height || defaultSankeyConfig.width!;
|
||||
const useMaxWidth = conf?.useMaxWidth || defaultSankeyConfig.useMaxWidth!;
|
||||
const nodeAlignment = conf?.nodeAlignment || defaultSankeyConfig.nodeAlignment!;
|
||||
|
||||
// FIX: using max width prevents height from being set, is it intended?
|
||||
// to add height directly one can use `svg.attr('height', height)`
|
||||
@@ -73,17 +74,16 @@ export const draw = function (text: string, id: string, _version: string, diagOb
|
||||
const graph = diagObj.db.getGraph();
|
||||
|
||||
// Map config options to alignment functions
|
||||
const alignmentsMap: Map<
|
||||
const alignmentsMap: Record<
|
||||
SankeyNodeAlignment,
|
||||
(node: d3SankeyNode<object, object>, n: number) => number
|
||||
> = new Map([
|
||||
[SankeyNodeAlignment.left, d3SankeyLeft],
|
||||
[SankeyNodeAlignment.right, d3SankeyRight],
|
||||
[SankeyNodeAlignment.center, d3SankeyCenter],
|
||||
[SankeyNodeAlignment.justify, d3SankeyJustify],
|
||||
]);
|
||||
// We need fallback because typescript thinks that `get` can result in undefined
|
||||
const nodeAlign = alignmentsMap.get(nodeAlignment) || d3SankeyJustify;
|
||||
> = {
|
||||
[SankeyNodeAlignment.left]: d3SankeyLeft,
|
||||
[SankeyNodeAlignment.right]: d3SankeyRight,
|
||||
[SankeyNodeAlignment.center]: d3SankeyCenter,
|
||||
[SankeyNodeAlignment.justify]: d3SankeyJustify,
|
||||
};
|
||||
const nodeAlign = alignmentsMap[nodeAlignment];
|
||||
|
||||
// Construct and configure a Sankey generator
|
||||
// That will be a function that calculates nodes and links dimensions
|
||||
|
54
pnpm-lock.yaml
generated
54
pnpm-lock.yaml
generated
@@ -15143,6 +15143,49 @@ packages:
|
||||
- terser
|
||||
dev: true
|
||||
|
||||
/vitepress@1.0.0-beta.2(@algolia/client-search@4.14.2)(@types/node@18.16.0)(search-insights@2.6.0):
|
||||
resolution: {integrity: sha512-DBXYjtYbm3W1IPPJ2TiCaK/XK+o/2XmL2+jslOGKm+txcbmG0kbeB+vadC5tCUZA9NdA+9Ywj3M4548c7t/SDg==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@docsearch/css': 3.5.1
|
||||
'@docsearch/js': 3.5.1(@algolia/client-search@4.14.2)(search-insights@2.6.0)
|
||||
'@vitejs/plugin-vue': 4.2.3(vite@4.3.9)(vue@3.3.4)
|
||||
'@vue/devtools-api': 6.5.0
|
||||
'@vueuse/core': 10.1.2(vue@3.3.4)
|
||||
'@vueuse/integrations': 10.1.2(focus-trap@7.4.3)(vue@3.3.4)
|
||||
body-scroll-lock: 4.0.0-beta.0
|
||||
focus-trap: 7.4.3
|
||||
mark.js: 8.11.1
|
||||
minisearch: 6.1.0
|
||||
shiki: 0.14.2
|
||||
vite: 4.3.9(@types/node@18.16.0)
|
||||
vue: 3.3.4
|
||||
transitivePeerDependencies:
|
||||
- '@algolia/client-search'
|
||||
- '@types/node'
|
||||
- '@types/react'
|
||||
- '@vue/composition-api'
|
||||
- async-validator
|
||||
- axios
|
||||
- change-case
|
||||
- drauu
|
||||
- fuse.js
|
||||
- idb-keyval
|
||||
- jwt-decode
|
||||
- less
|
||||
- nprogress
|
||||
- qrcode
|
||||
- react
|
||||
- react-dom
|
||||
- sass
|
||||
- search-insights
|
||||
- sortablejs
|
||||
- stylus
|
||||
- sugarss
|
||||
- terser
|
||||
- universal-cookie
|
||||
dev: true
|
||||
|
||||
/vitepress@1.0.0-beta.3(@algolia/client-search@4.14.2)(@types/node@18.16.0)(search-insights@2.6.0):
|
||||
resolution: {integrity: sha512-GR5Pvr/o343NN1M4Na1shhDYZRrQbjmLq7WE0lla0H8iDPAsHE8agTHLWfu3FWx+3q2KA29sv16+0O9RQKGjlA==}
|
||||
hasBin: true
|
||||
@@ -15808,6 +15851,10 @@ packages:
|
||||
workbox-core: 7.0.0
|
||||
dev: true
|
||||
|
||||
/workbox-core@6.5.4:
|
||||
resolution: {integrity: sha512-OXYb+m9wZm8GrORlV2vBbE5EC1FKu71GGp0H4rjmxmF4/HLbMCoTFws87M3dFwgpmg0v00K++PImpNQ6J5NQ6Q==}
|
||||
dev: true
|
||||
|
||||
/workbox-core@7.0.0:
|
||||
resolution: {integrity: sha512-81JkAAZtfVP8darBpfRTovHg8DGAVrKFgHpOArZbdFd78VqHr5Iw65f2guwjE2NlCFbPFDoez3D3/6ZvhI/rwQ==}
|
||||
dev: true
|
||||
@@ -15882,6 +15929,13 @@ packages:
|
||||
resolution: {integrity: sha512-SWfEouQfjRiZ7GNABzHUKUyj8pCoe+RwjfOIajcx6J5mtgKkN+t8UToHnpaJL5UVVOf5YhJh+OHhbVNIHe+LVA==}
|
||||
dev: true
|
||||
|
||||
/workbox-window@6.5.4:
|
||||
resolution: {integrity: sha512-HnLZJDwYBE+hpG25AQBO8RUWBJRaCsI9ksQJEp3aCOFCaG5kqaToAYXFRAHxzRluM2cQbGzdQF5rjKPWPA1fug==}
|
||||
dependencies:
|
||||
'@types/trusted-types': 2.0.2
|
||||
workbox-core: 6.5.4
|
||||
dev: true
|
||||
|
||||
/workbox-window@7.0.0:
|
||||
resolution: {integrity: sha512-j7P/bsAWE/a7sxqTzXo3P2ALb1reTfZdvVp6OJ/uLr/C2kZAMvjeWGm8V4htQhor7DOvYg0sSbFN2+flT5U0qA==}
|
||||
dependencies:
|
||||
|
Reference in New Issue
Block a user