#1295 First draft of generic renderer applied to flowcharts.

This commit is contained in:
Knut Sveidqvist
2020-03-08 09:49:41 +01:00
parent 25e2d78311
commit aa32d454c9
21 changed files with 639 additions and 1087 deletions

View File

@@ -0,0 +1,18 @@
const createLabel = (vertexText, style) => {
const svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text');
svgLabel.setAttribute('style', style.replace('color:', 'fill:'));
const rows = vertexText.split(/<br\s*\/?>/gi);
for (let j = 0; j < rows.length; j++) {
const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
tspan.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve');
tspan.setAttribute('dy', '1em');
tspan.setAttribute('x', '1');
tspan.textContent = rows[j];
svgLabel.appendChild(tspan);
}
return svgLabel;
};
export default createLabel;