Adjusting size and test

This commit is contained in:
Knut Sveidqvist 2022-08-27 15:11:43 +02:00
parent 2968b400c4
commit 3b93c39249
2 changed files with 5 additions and 5 deletions

View File

@ -745,9 +745,9 @@ export const calculateSvgSizeAttrs = function (height, width, useMaxWidth) {
// attrs.set('height', height); // attrs.set('height', height);
if (useMaxWidth) { if (useMaxWidth) {
attrs.set('width', '100%'); attrs.set('width', '100%');
attrs.set('style', `max-width: ${width * 1.2}px;`); attrs.set('style', `max-width: ${width}px;`);
} else { } else {
attrs.set('width', width * 1.2); attrs.set('width', width);
} }
return attrs; return attrs;
}; };
@ -761,7 +761,7 @@ export const calculateSvgSizeAttrs = function (height, width, useMaxWidth) {
* @param {boolean} useMaxWidth Whether or not to use max-width and set width to 100% * @param {boolean} useMaxWidth Whether or not to use max-width and set width to 100%
*/ */
export const configureSvgSize = function (svgElem, height, width, useMaxWidth) { export const configureSvgSize = function (svgElem, height, width, useMaxWidth) {
const attrs = calculateSvgSizeAttrs(height, width, useMaxWidth); const attrs = calculateSvgSizeAttrs(height, 1.1 * width, useMaxWidth);
d3Attrs(svgElem, attrs); d3Attrs(svgElem, attrs);
}; };
export const setupGraphViewbox = function (graph, svgElem, padding, useMaxWidth) { export const setupGraphViewbox = function (graph, svgElem, padding, useMaxWidth) {

View File

@ -294,13 +294,13 @@ describe('when formatting urls', function () {
describe('when calculating SVG size', function () { describe('when calculating SVG size', function () {
it('should return width 100% when useMaxWidth is true', function () { it('should return width 100% when useMaxWidth is true', function () {
const attrs = utils.calculateSvgSizeAttrs(100, 200, true); 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('style')).toEqual('max-width: 200px;');
expect(attrs.get('width')).toEqual('100%'); expect(attrs.get('width')).toEqual('100%');
}); });
it('should return absolute width when useMaxWidth is false', function () { it('should return absolute width when useMaxWidth is false', function () {
const attrs = utils.calculateSvgSizeAttrs(100, 200, false); const attrs = utils.calculateSvgSizeAttrs(100, 200, false);
expect(attrs.get('height')).toEqual(100); // expect(attrs.get('height')).toEqual(100);
expect(attrs.get('width')).toEqual(200); expect(attrs.get('width')).toEqual(200);
}); });
}); });