diff --git a/src/attributes.js b/src/attributes.js index 62f462c2d41..352c1f34986 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -32,6 +32,12 @@ Attributes.prototype.get = function(name) { else return this.list[name].join(" "); }; +/** Retrieves an attribute as array*/ +Attributes.prototype.getAsArray = function(name) { + if (typeof this.list[name] === "undefined") return false; + else return this.list[name]; +}; + /** Returns SVG code for attributes */ Attributes.prototype.render = function() { let svg = ""; diff --git a/src/svg.js b/src/svg.js index 7462b0b0c1a..c4789530482 100644 --- a/src/svg.js +++ b/src/svg.js @@ -187,8 +187,17 @@ Svg.prototype.renderPathText = function(path) { }; Svg.prototype.renderText = function(point) { - this.text = point.attributes.get("data-text"); - this.insertText(); + let text = point.attributes.getAsArray("data-text"); + if (text !== false) { + let joint = ""; + for (let string of text) { + this.text = string; + this.insertText(); + joint += this.text + " "; + } + this.text = joint; + this.insertText(); + } point.attributes.set("data-text-x", point.x); point.attributes.set("data-text-y", point.y); let lineHeight = point.attributes.get("data-text-lineheight") || 12;