From 6c3e24a0ae2d0596e344cbf0b034b66b2d325e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stucke?= Date: Mon, 2 Dec 2024 18:12:46 +0100 Subject: [PATCH] fix: jshint fixes for fact_statistics.js --- .../static/js/fact_statistics.js | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/web_interface/static/js/fact_statistics.js b/src/web_interface/static/js/fact_statistics.js index 657e78773..0ea4667d2 100644 --- a/src/web_interface/static/js/fact_statistics.js +++ b/src/web_interface/static/js/fact_statistics.js @@ -1,13 +1,13 @@ function get_extended_tooltip(element, data){ - var value = data.datasets[element.datasetIndex].data[element.index]; - var sum = data.datasets[element.datasetIndex].data.reduce(function(pv, cv) { return pv + cv; }, 0); - var percent = Math.round((value / sum) * 1000) / 10; + const value = data.datasets[element.datasetIndex].data[element.index]; + const sum = data.datasets[element.datasetIndex].data.reduce(function(pv, cv) { return pv + cv; }, 0); + const percent = Math.round((value / sum) * 1000) / 10; return value + " (" + percent + "%)"; } function get_extended_tooltip_value_percentage_pairs(element, data){ - var percent = _round(data.datasets[element.datasetIndex].percentage[element.index], 2); - var value = data.datasets[element.datasetIndex].data[element.index]; + const percent = _round(data.datasets[element.datasetIndex].percentage[element.index], 2); + const value = data.datasets[element.datasetIndex].data[element.index]; return value + " (" + percent + " %)"; } @@ -27,7 +27,7 @@ function get_full_title(tooltipItems, data) { return data.labels[tooltipItems[0].index]; } -var chart_options = { +let chart_options = { legend: {position: "bottom", display: false}, tooltips: { callbacks: { @@ -41,7 +41,7 @@ var chart_options = { } }; -var chart_options_value_percentage_pairs = { +let chart_options_value_percentage_pairs = { legend: {position: "bottom", display: false}, tooltips: { callbacks: { @@ -62,9 +62,9 @@ function _add(a, b){ function set_links(canvas_id, any_chart, link) { document.getElementById(canvas_id).onclick = function(evt){ - var points = any_chart.getElementsAtEvent(evt); - var label = any_chart.data.labels[points[0]._index]; - if ((points[0] !== undefined) && (label != "rest")) + const points = any_chart.getElementsAtEvent(evt); + const label = any_chart.data.labels[points[0]._index]; + if ((points[0] !== undefined) && (label !== "rest")) window.location = link.replace("PLACEHOLDER", label); }; @@ -73,9 +73,9 @@ function set_links(canvas_id, any_chart, link) { function set_links_from_data(canvas_id, chart, link) { document.getElementById(canvas_id).onclick = function(evt){ - var points = chart.getElementsAtEvent(evt); + const points = chart.getElementsAtEvent(evt); if (chart.data.datasets[0].links !== undefined) { - var key = chart.data.datasets[0].links[points[0]._index]; + const key = chart.data.datasets[0].links[points[0]._index]; window.location = link.replace("PLACEHOLDER", key); } }; @@ -83,7 +83,8 @@ function set_links_from_data(canvas_id, chart, link) { } function create_horizontal_bar_chart(canvas_id, chart_data, link, value_percentage_present_flag = false, links_in_data = false) { - var ctx = document.getElementById(canvas_id); + const ctx = document.getElementById(canvas_id); + let chart_opt, max; if (value_percentage_present_flag) { chart_opt = chart_options_value_percentage_pairs; @@ -94,7 +95,7 @@ function create_horizontal_bar_chart(canvas_id, chart_data, link, value_percenta } chart_opt.scales.xAxes[0].ticks.max = max * 1.05; - var BarChart = new Chart( + let BarChart = new Chart( ctx, { type: "horizontalBar", data: chart_data, @@ -112,9 +113,9 @@ function create_horizontal_bar_chart(canvas_id, chart_data, link, value_percenta } function create_pie_chart(canvas_id, chart_data, link) { - var ctx = document.getElementById(canvas_id); + const ctx = document.getElementById(canvas_id); - var PieChart = new Chart( + let PieChart = new Chart( ctx, { type: "doughnut", data: chart_data, @@ -135,4 +136,3 @@ function create_pie_chart(canvas_id, chart_data, link) { return PieChart; } -