js-sequence-diagrams
js-sequence-diagrams copied to clipboard
Scale SVG to fit in container?
It seems to create a fixed width svg. If there isn't, how about adding an option to make it scale to the width of the container?
I'm having the same issue, the images it creates are too big and don't respect the width of the container in css
I managed to fix this issue like this:
$('svg').removeAttr('viewBox');
$('svg').each(function () {
let svg = $(this)[0];
let bbox = svg.getBBox();
svg.setAttribute("viewBox", bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height);
});
$('svg').css('width', '500px');
$('svg').css('height', 'auto');
of course this doesn't work if you run this before the SVGs have finished loading...