Merge branch 'develop' into issue1981

This commit is contained in:
futzmonitor 2023-12-05 21:56:08 -05:00
commit 03b5c00f03
4 changed files with 8 additions and 7 deletions

View File

@ -10,3 +10,6 @@ stats
.nyc_output .nyc_output
# Autogenerated by `pnpm run --filter mermaid types:build-config` # Autogenerated by `pnpm run --filter mermaid types:build-config`
packages/mermaid/src/config.type.ts packages/mermaid/src/config.type.ts
# Ignore the files creates in /demos/dev except for example.html
demos/dev/**
!/demos/dev/example.html

View File

@ -33,6 +33,7 @@
--- ---
config: config:
sankey: sankey:
useMaxWidth: true
showValues: false showValues: false
width: 1200 width: 1200
height: 600 height: 600

View File

@ -16,7 +16,7 @@ import {
sankeyCenter as d3SankeyCenter, sankeyCenter as d3SankeyCenter,
sankeyJustify as d3SankeyJustify, sankeyJustify as d3SankeyJustify,
} from 'd3-sankey'; } from 'd3-sankey';
import { configureSvgSize } from '../../setupGraphViewbox.js'; import { setupGraphViewbox } from '../../setupGraphViewbox.js';
import { Uid } from '../../rendering-util/uid.js'; import { Uid } from '../../rendering-util/uid.js';
import type { SankeyNodeAlignment } from '../../config.type.js'; import type { SankeyNodeAlignment } from '../../config.type.js';
@ -70,12 +70,6 @@ export const draw = function (text: string, id: string, _version: string, diagOb
const suffix = conf?.suffix ?? defaultSankeyConfig.suffix!; const suffix = conf?.suffix ?? defaultSankeyConfig.suffix!;
const showValues = conf?.showValues ?? defaultSankeyConfig.showValues!; const showValues = conf?.showValues ?? defaultSankeyConfig.showValues!;
// FIX: using max width prevents height from being set, is it intended?
// to add height directly one can use `svg.attr('height', height)`
//
// @ts-ignore TODO: svg type vs selection mismatch
configureSvgSize(svg, height, width, useMaxWidth);
// Prepare data for construction based on diagObj.db // Prepare data for construction based on diagObj.db
// This must be a mutable object with `nodes` and `links` properties: // This must be a mutable object with `nodes` and `links` properties:
// //
@ -208,6 +202,8 @@ export const draw = function (text: string, id: string, _version: string, diagOb
.attr('d', d3SankeyLinkHorizontal()) .attr('d', d3SankeyLinkHorizontal())
.attr('stroke', coloring) .attr('stroke', coloring)
.attr('stroke-width', (d: any) => Math.max(1, d.width)); .attr('stroke-width', (d: any) => Math.max(1, d.width));
setupGraphViewbox(undefined, svg, 0, useMaxWidth);
}; };
export default { export default {

View File

@ -45,6 +45,7 @@ export const configureSvgSize = function (svgElem, height, width, useMaxWidth) {
d3Attrs(svgElem, attrs); d3Attrs(svgElem, attrs);
}; };
// TODO v11: Remove the graph parameter. It is not used.
export const setupGraphViewbox = function (graph, svgElem, padding, useMaxWidth) { export const setupGraphViewbox = function (graph, svgElem, padding, useMaxWidth) {
const svgBounds = svgElem.node().getBBox(); const svgBounds = svgElem.node().getBBox();
const sWidth = svgBounds.width; const sWidth = svgBounds.width;