Commit 3ba58d9d authored by Rajaomaria  Jaona's avatar Rajaomaria Jaona
Browse files

fit text into div

parent a41bad1a
......@@ -452,6 +452,21 @@ class GraphUtils {
return bnd;
}
static textfill(nodeSelector, textContainerSelector, maxFontPixels, alpha = 1){
var fontSize = maxFontPixels;
var ourText = $(textContainerSelector, nodeSelector);
var maxHeight = $(nodeSelector).height();
var maxWidth = $(nodeSelector).width();
var textHeight;
var textWidth;
do {
ourText.css('font-size', fontSize);
textHeight = ourText.height();
textWidth = ourText.width();
fontSize = fontSize - alpha;
} while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 3);
}
}
window.GraphUtils = GraphUtils
class GraphTooltip {
......@@ -1307,13 +1322,16 @@ class RelationGraph extends Graph {
.attr("src", (d) => d.data.img)
.style("width", "100%")
.style("height", "auto")
div
.style("overflow", "visible")
const texts = div
.filter((d) => !d.data.img)
.style("overflow", "visible")
texts.append("xhtml:span")
.style("text-align", "center")
.text(d => d.data.label)
texts.each((d,i,n) => {
GraphUtils.textfill(n[i], 'span', 20);
})
node.attr("x", (d) => d.x).attr("y", (d) => d.y);
const bound = this._rootG.node().getBBox();
const k = this._width / bound.width;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment