mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
#11490 calculate font size in treemap
This commit is contained in:
parent
13dbed4327
commit
075cc1d372
@ -506,6 +506,7 @@ function treeMap(recipient, data, width, height, childLinks = false) {
|
|||||||
.attr("width", function(d) {
|
.attr("width", function(d) {
|
||||||
return Math.max(0.01, d.dx);
|
return Math.max(0.01, d.dx);
|
||||||
})
|
})
|
||||||
|
.attr("style", "transition: all 0.5s ease-out;")
|
||||||
.attr("height", headerHeight)
|
.attr("height", headerHeight)
|
||||||
.text(function(d) {
|
.text(function(d) {
|
||||||
return d.name;
|
return d.name;
|
||||||
@ -636,6 +637,29 @@ function treeMap(recipient, data, width, height, childLinks = false) {
|
|||||||
|
|
||||||
zoom(node);
|
zoom(node);
|
||||||
|
|
||||||
|
function calculateSizeText() {
|
||||||
|
$(recipient + " .parent .clip .label").each((key, node) => {
|
||||||
|
const textElement = node;
|
||||||
|
const containerWidth = parseFloat(
|
||||||
|
$(textElement)
|
||||||
|
.parent()
|
||||||
|
.attr("width")
|
||||||
|
);
|
||||||
|
const originalFontSize = 12;
|
||||||
|
|
||||||
|
textElement.style.fontSize = "16px";
|
||||||
|
const textWidth = textElement.getComputedTextLength() + 8;
|
||||||
|
textElement.style.fontSize = originalFontSize;
|
||||||
|
|
||||||
|
const scaleFactor = containerWidth / textWidth;
|
||||||
|
let scaledFontSize = parseFloat(originalFontSize) * scaleFactor;
|
||||||
|
|
||||||
|
scaledFontSize = scaledFontSize > 12 ? 12 : scaledFontSize;
|
||||||
|
|
||||||
|
textElement.style.fontSize = scaledFontSize;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function size(d) {
|
function size(d) {
|
||||||
return d.size;
|
return d.size;
|
||||||
}
|
}
|
||||||
@ -756,6 +780,9 @@ function treeMap(recipient, data, width, height, childLinks = false) {
|
|||||||
if (d3.event) {
|
if (d3.event) {
|
||||||
d3.event.stopPropagation();
|
d3.event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
calculateSizeText();
|
||||||
|
}, transitionDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
function position() {
|
function position() {
|
||||||
|
@ -408,7 +408,7 @@ class GroupsStatusMapWidget extends Widget
|
|||||||
foreach ($level1['children'] as $id_grupo => $group) {
|
foreach ($level1['children'] as $id_grupo => $group) {
|
||||||
$level2['children'][] = [
|
$level2['children'][] = [
|
||||||
'id' => uniqid(),
|
'id' => uniqid(),
|
||||||
'name' => $names[$id_grupo],
|
'name' => io_safe_output($names[$id_grupo]),
|
||||||
'children' => $group,
|
'children' => $group,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user