From 52703b9f23700d113ba0375526e248d66e135e34 Mon Sep 17 00:00:00 2001 From: Igor Octaviano Date: Thu, 11 Mar 2021 12:35:11 -0300 Subject: [PATCH] fix: Resolve toFixed errors in viewport overlay after dcmjs server changes (#115) --- src/ViewportOverlay/ViewportOverlay.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ViewportOverlay/ViewportOverlay.js b/src/ViewportOverlay/ViewportOverlay.js index 3c5125d..edd6b49 100644 --- a/src/ViewportOverlay/ViewportOverlay.js +++ b/src/ViewportOverlay/ViewportOverlay.js @@ -38,8 +38,14 @@ function getCompression(imageId) { class ViewportOverlay extends PureComponent { static propTypes = { scale: PropTypes.number.isRequired, - windowWidth: PropTypes.number.isRequired, - windowCenter: PropTypes.number.isRequired, + windowWidth: PropTypes.oneOfType([ + PropTypes.number.isRequired, + PropTypes.string.isRequired, + ]), + windowCenter: PropTypes.oneOfType([ + PropTypes.number.isRequired, + PropTypes.string.isRequired, + ]), imageId: PropTypes.string.isRequired, imageIndex: PropTypes.number.isRequired, stackSize: PropTypes.number.isRequired, @@ -77,7 +83,9 @@ class ViewportOverlay extends PureComponent { const frameRate = formatNumberPrecision(1000 / frameTime, 1); const compression = getCompression(imageId); - const wwwc = `W: ${windowWidth.toFixed(0)} L: ${windowCenter.toFixed(0)}`; + const wwwc = `W: ${ + windowWidth.toFixed ? windowWidth.toFixed(0) : windowWidth + } L: ${windowWidth.toFixed ? windowCenter.toFixed(0) : windowCenter}`; const imageDimensions = `${columns} x ${rows}`; const { imageIndex, stackSize } = this.props;