Open vasyl-bratushka opened 4 years ago
Ran into the same problem. Even seems to affect the demo at https://doc.gdb.tools/smilesDrawer/sd/example/index_svg.html
This error is caused by the SvgDrawer module using the same method for "drawAromaticityRing" as the CanvasDrawer - it looks like the authors copy/pasted the code from the canvas version to the svg version and didn't test the SvgDrawer with aromatic molecules. It can be fixed by:
drawAromaticityRing(ring) {
let preprocessor = this.preprocessor,
opts = preprocessor.opts,
radius = MathHelper.apothemFromSideLength(opts.bondLength, ring.getSize()),
svgWrapper = this.svgWrapper;
if(!preprocessor.bridgedRing)
svgWrapper.drawCircle(ring.center.x, ring.center.y, radius - opts.bondSpacing);
}
drawCircle(cx, cy, radius) {
let offsetX = this.offsetX,
offsetY = this.offsetY,
circle = document.createElementNS("http://www.w3.org/2000/svg", 'circle');
circle.setAttributeNS(null, 'cx', cx + offsetX);
circle.setAttributeNS(null, 'cy', cy + offsetY);
circle.setAttributeNS(null, 'r', radius);
circle.setAttributeNS(null, 'style', 'fill: none; stroke: black; stroke-width: 1px;'); //This ignores the theme set by preprocessor, which should be trivial to implement
this.paths.push(circle);
}
looking through the source code, it looks like this issue is only present in the published minified version of the script. The code of this repo itself correctly implements an SVG version of drawAromaticityRing, calling svgWrapper.drawCircle.
Looks like you've forgotten to import the
MathHelper
in theSvgDrawer.js
, which throws theReferenceError
.