The node names of the networkmap are reduced if they are too long

This commit is contained in:
Alejandro Gallardo Escobar 2018-05-10 11:46:49 +02:00
parent 3855e4c378
commit 9af7b75e3e
2 changed files with 12 additions and 5 deletions

View File

@ -213,7 +213,7 @@ function update_fictional_node(id_db_node) {
graph.nodes[i].networkmap_id = networkmap_to_link;
$("#id_node_" + i + networkmap_id + " title").html(name);
$("#id_node_" + i + networkmap_id + " tspan").html(name);
$("#id_node_" + i + networkmap_id + " tspan").html(ellipsize(name, 30));
}
});
@ -251,7 +251,7 @@ function update_node_name(id_db_node) {
graph.nodes[i]['raw_text'] = data['raw_text'];
$("#id_node_" + i + networkmap_id + " title").html(data['raw_text']);
$("#id_node_" + i + networkmap_id + " tspan").html(data['raw_text']);
$("#id_node_" + i + networkmap_id + " tspan").html(ellipsize(data['raw_text'], 30));
}
});
@ -773,7 +773,7 @@ function edit_node(data_node, dblClick) {
$("#dialog_node_edit")
.dialog("option", "title",
dialog_node_edit_title.replace("%s", node_selected['text'])); // It doesn't eval the possible XSS so it's ok
dialog_node_edit_title.replace("%s", ellipsize(node_selected['text'], 40))); // It doesn't eval the possible XSS so it's ok
$("#dialog_node_edit").dialog("open");
if (node_selected.id_agent == undefined || node_selected.id_agent == -2) {
@ -3658,7 +3658,7 @@ function draw_elements_graph() {
.append("tspan")
.attr("style", "font-size: " + font_size + "px !important; font-family:Verdana; text-align:center; text-anchor:middle; fill:#000000")
.text(function (d) {
return d.text;
return ellipsize(d.text, 30);
})
.classed('dragable_node', true) //own dragable
.on("click", selected_node)

View File

@ -1562,4 +1562,11 @@ function round_with_decimals (value, multiplier = 1) {
return Math.round(value * multiplier) / multiplier;
}
return round_with_decimals (value, multiplier * 10);
}
}
function ellipsize (str, max, ellipse) {
if (max == null) max = 140;
if (ellipse == null) ellipse = "…";
return str.trim().length > max ? str.substr(0, max).trim() + ellipse : str;
}