From e39515074e0636b399a9ebf2992bb1a88997d2d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Malo=C5=A1t=C3=ADk?= <malostik@cesnet.cz> Date: Thu, 16 Feb 2023 17:53:01 +0200 Subject: [PATCH] Fix: remove duplicities when rerendering charts --- .../blueprints/design_bs3/templates/_macros_chart.html | 2 ++ lib/hawat/static/js/hawat-charts.js | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/hawat/blueprints/design_bs3/templates/_macros_chart.html b/lib/hawat/blueprints/design_bs3/templates/_macros_chart.html index db855675b..68219b7c1 100644 --- a/lib/hawat/blueprints/design_bs3/templates/_macros_chart.html +++ b/lib/hawat/blueprints/design_bs3/templates/_macros_chart.html @@ -439,6 +439,8 @@ {%- macro _snippet_ecbks_timeline(chart_id, cfg_params, with_full = False) %} // Enable necessary event callbacks to appropriate DOM elements. $(document).ready(function () { + // unbind click event listener + $("#{{ chart_id }}_toggle").off('click'); // Event handler for toggling dataset table. $("#{{ chart_id }}_toggle").click(function () { $("#{{ chart_id }}_content").toggleClass("col-md-12 col-md-6"); diff --git a/lib/hawat/static/js/hawat-charts.js b/lib/hawat/static/js/hawat-charts.js index 91ced1e36..9c74d1929 100644 --- a/lib/hawat/static/js/hawat-charts.js +++ b/lib/hawat/static/js/hawat-charts.js @@ -562,6 +562,9 @@ function render_table_timeline_multi(tid, table_columns, table_data, data_stats) var value_formatter = table_value_formatter(GLOBALIZER.numberFormatter()); var date_formatter = table_value_formatter(GLOBALIZER.dateFormatter()); + // remove the existing table + d3.select(`#${tid} > table`).remove(); + var table = d3.select('#' + tid).append('table') var thead = table.append('thead') var tbody = table.append('tbody'); @@ -722,6 +725,9 @@ function render_table_dict(tid, table_columns, table_data, data_stats, action_li }) ); + // remove the existing table + d3.select(`#${tid} > table`).remove(); + var table = d3.select('#' + tid).append('table') var thead = table.append('thead') var tbody = table.append('tbody'); @@ -899,6 +905,9 @@ function render_table_mdict(tid, table_columns, table_data, data_stats, total = }) ); + // remove the existing table + d3.select(`#${tid} > table`).remove(); + var table = d3.select('#' + tid).append('table') var thead = table.append('thead') var tbody = table.append('tbody'); -- GitLab