Skip to content

Commit

Permalink
- table: number formatting and string alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Rello committed Nov 23, 2024
1 parent 830925a commit 4ef5c68
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Fixed
- wrong info link in data load screen
- own data options not working #413
- table: number formatting and string alignment

## 5.0.1 - 2024-09-16
### Fixed
Expand Down
29 changes: 18 additions & 11 deletions js/visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var myMoment = moment;
* @namespace OCA.Analytics.Visualization
*/
OCA.Analytics.Visualization = {
defaultColorPalette: ["#1A366C","#EA6A47","#a3acb9","#6AB187","#39a7db","#c85200","#57606c","#a3cce9","#ffbc79","#c8d0d9"],
defaultColorPalette: ["#1A366C", "#EA6A47", "#a3acb9", "#6AB187", "#39a7db", "#c85200", "#57606c", "#a3cce9", "#ffbc79", "#c8d0d9"],

// *************
// *** table ***
Expand Down Expand Up @@ -126,11 +126,18 @@ OCA.Analytics.Visualization = {

if (!layoutConfig || Object.keys(layoutConfig).length === 0) {
// No special layout is defined: display all data in rows
columns = header.map((header, index) => ({title: header, className: index === 0 ? '' : 'dt-right'}));

// create the columns. default alignment is left
columns = header.map((header, index) => ({title: header, className: ''}));
data = originalData.map(row =>
row.map((value, index) =>
index === row.length - 1 && !isNaN(parseFloat(value)) ? parseFloat(value).toLocaleString() : value
)
row.map((value, index) => {
if (!isNaN(parseFloat(value))) {
// Any number gets aligned to the right and formated with locales
columns[index].className = 'dt-right';
return parseFloat(value).toLocaleString();
}
return value;
})
);
} else if (layoutConfig.rows && !layoutConfig.columns.length && !layoutConfig.measures.length) {
// If only the row array is filled, it means that all data is in the rows, but just the sequence was changed
Expand Down Expand Up @@ -660,12 +667,12 @@ OCA.Analytics.Visualization = {
},

toggleFullscreen: function () {
document.getElementById('header').classList.toggle('analyticsFullscreen');
document.getElementById('app-navigation').classList.toggle('analyticsFullscreen');
document.getElementById('content').classList.toggle('analyticsFullscreen');
document.getElementById('byAnalytics').classList.toggle('analyticsFullscreen');
document.getElementById('header').classList.toggle('analyticsFullscreen');
document.getElementById('app-navigation').classList.toggle('analyticsFullscreen');
document.getElementById('content').classList.toggle('analyticsFullscreen');
document.getElementById('byAnalytics').classList.toggle('analyticsFullscreen');

document.getElementById('fullscreenToggle').classList.toggle('icon-analytics-fullscreen');
document.getElementById('fullscreenToggle').classList.toggle('icon-analytics-fullscreenExit');
document.getElementById('fullscreenToggle').classList.toggle('icon-analytics-fullscreen');
document.getElementById('fullscreenToggle').classList.toggle('icon-analytics-fullscreenExit');
},
}

0 comments on commit 4ef5c68

Please sign in to comment.