Merge pull request #2312 from cm-wada-yusuke/bug/2160-fixed-height-useMaxWith

configureSvgSize should make height 100% when useMaxWidth is true.
This commit is contained in:
Knut Sveidqvist
2021-09-23 19:32:43 +02:00
committed by GitHub
10 changed files with 12 additions and 28 deletions

View File

@@ -778,12 +778,13 @@ const d3Attrs = function (d3Elem, attrs) {
export const calculateSvgSizeAttrs = function (height, width, useMaxWidth) {
let attrs = new Map();
attrs.set('height', height);
if (useMaxWidth) {
attrs.set('width', '100%');
attrs.set('height', '100%');
attrs.set('style', `max-width: ${width}px;`);
} else {
attrs.set('width', width);
attrs.set('height', height);
}
return attrs;
};

View File

@@ -243,7 +243,7 @@ describe('when formatting urls', function() {
describe('when calculating SVG size', function() {
it('should return width 100% when useMaxWidth is true', function () {
const attrs = utils.calculateSvgSizeAttrs(100, 200, true);
expect(attrs.get('height')).toEqual(100);
expect(attrs.get('height')).toEqual('100%');
expect(attrs.get('style')).toEqual('max-width: 200px;');
expect(attrs.get('width')).toEqual('100%');
});