Skip to content

Commit

Permalink
fix: jshint fixes for fact_statistics.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke committed Dec 2, 2024
1 parent bdd74bd commit 6c3e24a
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/web_interface/static/js/fact_statistics.js
Original file line number Diff line number Diff line change
@@ -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 + " %)";
}

Expand All @@ -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: {
Expand All @@ -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: {
Expand All @@ -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);
};

Expand All @@ -73,17 +73,18 @@ 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);
}
};

}

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;
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -135,4 +136,3 @@ function create_pie_chart(canvas_id, chart_data, link) {

return PieChart;
}

0 comments on commit 6c3e24a

Please sign in to comment.