diff --git a/res/include/script/admin.js b/res/include/script/admin.js index 3109fe5..83f6fc1 100644 --- a/res/include/script/admin.js +++ b/res/include/script/admin.js @@ -49,7 +49,8 @@ var graph = new Chart( ticks: { callback: function(value, index, values) { return formatDataVolume(value, 3); - } + }, + beginAtZero: true }, gridLines: { color: "rgba(100, 255, 100, .05)" @@ -63,6 +64,12 @@ var graph = new Chart( display: true, labelString: "Views" }, + ticks: { + callback: function(value, index, values) { + return formatNumber(value, 3); + }, + beginAtZero: true + }, gridLines: { color: "rgba(128, 128, 255, .05)" } diff --git a/res/include/script/dependencies/util.js b/res/include/script/dependencies/util.js index c3c516f..5c0171a 100644 --- a/res/include/script/dependencies/util.js +++ b/res/include/script/dependencies/util.js @@ -57,6 +57,16 @@ function domainURL() { return url; } +function formatNumber(amt, precision) { + if (precision < 3) { precision = 3; } + if (amt >= 1e6) { + return (amt/1e6).toPrecision(precision) + "M"; + } else if (amt >= 1e3) { + return (amt/1e3).toPrecision(precision) + "k"; + } + return amt +} + function formatDataVolume(amt, precision) { if (precision < 3) { precision = 3; } if (amt >= 1e12) { diff --git a/res/include/script/file_viewer/DetailsWindow.js b/res/include/script/file_viewer/DetailsWindow.js index c8d5c26..0ac4890 100644 --- a/res/include/script/file_viewer/DetailsWindow.js +++ b/res/include/script/file_viewer/DetailsWindow.js @@ -124,6 +124,12 @@ DetailsWindow.prototype.renderGraph = function() { display: true, labelString: "Downloads" }, + ticks: { + callback: function(value, index, values) { + return formatNumber(value, 3); + }, + beginAtZero: true + }, gridLines: { color: "rgba(100, 255, 100, .05)" } @@ -136,6 +142,12 @@ DetailsWindow.prototype.renderGraph = function() { display: true, labelString: "Views" }, + ticks: { + callback: function(value, index, values) { + return formatNumber(value, 3); + }, + beginAtZero: true + }, gridLines: { color: "rgba(128, 128, 255, .05)" }