From de4683881101916a88b014144b9aee13fdf3d2f4 Mon Sep 17 00:00:00 2001 From: terrtia Date: Mon, 24 Jun 2024 14:44:47 +0200 Subject: [PATCH] chg: [chord] add parameters to filtersby min and max value --- var/www/static/js/d3/chord_directed_diagram.js | 15 ++++++++++++++- .../templates/correlation/show_relationship.html | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/var/www/static/js/d3/chord_directed_diagram.js b/var/www/static/js/d3/chord_directed_diagram.js index 80c8c8bf..5be3f294 100644 --- a/var/www/static/js/d3/chord_directed_diagram.js +++ b/var/www/static/js/d3/chord_directed_diagram.js @@ -6,7 +6,20 @@ // TODO: - Mouseover object -const create_directed_chord_diagram = (container_id, data, fct_mouseover, fct_mouseout, options) => { +const create_directed_chord_diagram = (container_id, data, min_value= 0, max_value = -1, fct_mouseover, fct_mouseout, options) => { + + // Filter data by value between target and source + if (min_value > 0) { + data.data = data.data.filter(function(value) { + return data.value >= min_value; + }); + } + if (max_value > 0) { + data.data = data.data.filter(function(value) { + return data.value <= max_value; + }); + } + function getMaxCharsToShow(angle, radius) { const approximateCharWidth = 7; // Approximate width of a character in pixels diff --git a/var/www/templates/correlation/show_relationship.html b/var/www/templates/correlation/show_relationship.html index 80ba9e48..bc052505 100644 --- a/var/www/templates/correlation/show_relationship.html +++ b/var/www/templates/correlation/show_relationship.html @@ -386,12 +386,12 @@ $(document).ready(function(){ let url = "{{ url_for('correlation.relationships_chord_graph_json') }}?id={{ dict_object["correlation_id"] }}&type={{ dict_object["object_type"] }}{% if 'type_id' in dict_object["metadata"] %}&subtype={{ dict_object["metadata"]["type_id"] }}{% endif %}" d3.json(url).then(function(data) { - create_directed_chord_diagram('#chart_test', data, mouseover_tooltip_ail_obj, mouseout_tooltip_ail_obj); + create_directed_chord_diagram('#chart_test', data, 0, -1, mouseover_tooltip_ail_obj, mouseout_tooltip_ail_obj); }); let url2 = "{{ url_for('correlation.relationships_chord_mentions_graph_json') }}?id={{ dict_object["correlation_id"] }}&type={{ dict_object["object_type"] }}{% if 'type_id' in dict_object["metadata"] %}&subtype={{ dict_object["metadata"]["type_id"] }}{% endif %}" d3.json(url2).then(function(data) { - create_directed_chord_diagram('#chart_mentions', data, mouseover_tooltip_ail_obj, mouseout_tooltip_ail_obj); + create_directed_chord_diagram('#chart_mentions', data, 0, -1, mouseover_tooltip_ail_obj, mouseout_tooltip_ail_obj); });