Skip to content

Commit

Permalink
KPI widget for Panorama #427
Browse files Browse the repository at this point in the history
  • Loading branch information
Rello committed Jan 8, 2025
1 parent 1494e1b commit 15c4ace
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,12 @@ div.dt-container .dt-paging .dt-paging-button {
}

.kpiWidgetTitel {
font-size: 1.2rem;
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 0.5rem;
}

.kpiWidgetValue {
font-size: 3.5rem;
font-weight: 500;
font-weight: 400;
}
13 changes: 12 additions & 1 deletion js/visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,18 @@ OCA.Analytics.Visualization = {
buildKpiDisplay: function (domTarget, jsondata, ordering = true, uniqueId) {
domTarget.innerHTML = '';
let kpi = jsondata.data[0][0];
let value = jsondata.data[0][1];

let rawValue = parseFloat(jsondata.data[0][1]);
let value;

if (rawValue % 1 === 0) {
// If the number is an integer, format without decimals
value = rawValue.toLocaleString();
} else {
// Otherwise, format with decimals
value = rawValue.toLocaleString(undefined, { minimumFractionDigits: 2 });
}

let thresholdColor = OCA.Analytics.Visualization.validateThreshold(kpi, value, jsondata.thresholds);

// Create the KPI content dynamically
Expand Down

0 comments on commit 15c4ace

Please sign in to comment.