This commit is contained in:
Knut Sveidqvist
2020-05-27 19:38:30 +02:00
parent 18d3b3545d
commit 39bdf261c6
4 changed files with 136 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
import { logger } from '../logger'; // eslint-disable-line
import createLabel from './createLabel';
import { line, curveBasis } from 'd3';
import { line, curveBasis, select } from 'd3';
import { getConfig } from '../config';
let edgeLabels = {};
@@ -21,7 +21,14 @@ export const insertEdgeLabel = (elem, edge) => {
label.node().appendChild(labelElement);
// Center the label
const bbox = labelElement.getBBox();
let bbox = labelElement.getBBox();
if (getConfig().flowchart.htmlLabels) {
const div = labelElement.children[0];
const dv = select(labelElement);
bbox = div.getBoundingClientRect();
dv.attr('width', bbox.width);
dv.attr('height', bbox.height);
}
label.attr('transform', 'translate(' + -bbox.width / 2 + ', ' + -bbox.height / 2 + ')');
// Make element accessible by id for positioning