This commit is contained in:
parent
4b35583782
commit
e77051ccc4
1987 changed files with 1147290 additions and 5648 deletions
|
@ -0,0 +1,41 @@
|
|||
import { l as log } from "./config-389b86ff.js";
|
||||
const d3Attrs = function(d3Elem, attrs) {
|
||||
for (let attr of attrs) {
|
||||
d3Elem.attr(attr[0], attr[1]);
|
||||
}
|
||||
};
|
||||
const calculateSvgSizeAttrs = function(height, width, useMaxWidth) {
|
||||
let attrs = /* @__PURE__ */ new Map();
|
||||
if (useMaxWidth) {
|
||||
attrs.set("width", "100%");
|
||||
attrs.set("style", `max-width: ${width}px;`);
|
||||
} else {
|
||||
attrs.set("height", height);
|
||||
attrs.set("width", width);
|
||||
}
|
||||
return attrs;
|
||||
};
|
||||
const configureSvgSize = function(svgElem, height, width, useMaxWidth) {
|
||||
const attrs = calculateSvgSizeAttrs(height, width, useMaxWidth);
|
||||
d3Attrs(svgElem, attrs);
|
||||
};
|
||||
const setupGraphViewbox = function(graph, svgElem, padding, useMaxWidth) {
|
||||
const svgBounds = svgElem.node().getBBox();
|
||||
const sWidth = svgBounds.width;
|
||||
const sHeight = svgBounds.height;
|
||||
log.info(`SVG bounds: ${sWidth}x${sHeight}`, svgBounds);
|
||||
let width = 0;
|
||||
let height = 0;
|
||||
log.info(`Graph bounds: ${width}x${height}`, graph);
|
||||
width = sWidth + padding * 2;
|
||||
height = sHeight + padding * 2;
|
||||
log.info(`Calculated bounds: ${width}x${height}`);
|
||||
configureSvgSize(svgElem, height, width, useMaxWidth);
|
||||
const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${svgBounds.width + 2 * padding} ${svgBounds.height + 2 * padding}`;
|
||||
svgElem.attr("viewBox", vBox);
|
||||
};
|
||||
export {
|
||||
configureSvgSize as c,
|
||||
setupGraphViewbox as s
|
||||
};
|
||||
//# sourceMappingURL=setupGraphViewbox-e35e4124.js.map
|
Loading…
Add table
Add a link
Reference in a new issue