diff --git a/resources/docs/widgets/plots.md b/resources/docs/widgets/plots.md index 26dfb7a1..d99d051b 100644 --- a/resources/docs/widgets/plots.md +++ b/resources/docs/widgets/plots.md @@ -281,3 +281,4 @@ Image displays an image from a file path/url or from a base64 encoded image stri - default: `''` - usage : svg xml definition - will be wrapped in a `` element + - `` commands support percent notation diff --git a/src/browser/js/app/widgets/plots/svg.js b/src/browser/js/app/widgets/plots/svg.js index 7163774e..fc46691a 100644 --- a/src/browser/js/app/widgets/plots/svg.js +++ b/src/browser/js/app/widgets/plots/svg.js @@ -59,6 +59,7 @@ class Svg extends Widget { var svg = this.getProp('svg') + svg = svg.replace(/<\/svg>/gi, 'x') svg = svg.replace(/([0-9\.]+%)[\s\n]*,/g, m => (parseFloat(m) * this.width / 100).toFixed(2) + ',') svg = svg.replace(/,[\s\n]*([0-9\.]+%)/g, m => ',' + (parseFloat(m.slice(1)) * this.height / 100).toFixed(2))