summaryrefslogtreecommitdiffstats
path: root/web/gui/dashboard.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/gui/dashboard.js')
-rw-r--r--web/gui/dashboard.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/web/gui/dashboard.js b/web/gui/dashboard.js
index 49357a32..e7d99a15 100644
--- a/web/gui/dashboard.js
+++ b/web/gui/dashboard.js
@@ -4194,6 +4194,23 @@ NETDATA.peityChartCreate = function (state, data) {
return true;
};
+// ----------------------------------------------------------------------------------------------------------------
+// "Text-only" chart - Just renders the raw value to the DOM
+
+NETDATA.textOnlyCreate = function(state, data) {
+ var decimalPlaces = NETDATA.dataAttribute(state.element, 'textonly-decimal-places', 1);
+ var prefix = NETDATA.dataAttribute(state.element, 'textonly-prefix', '');
+ var suffix = NETDATA.dataAttribute(state.element, 'textonly-suffix', '');
+
+ // Round based on number of decimal places to show
+ var precision = Math.pow(10, decimalPlaces);
+ var value = Math.round(data.result[0] * precision) / precision;
+
+ state.element.textContent = prefix + value + suffix;
+ return true;
+}
+
+NETDATA.textOnlyUpdate = NETDATA.textOnlyCreate;
// Charts Libraries Registration
NETDATA.chartLibraries = {
@@ -4631,6 +4648,48 @@ NETDATA.chartLibraries = {
void(state);
return 'netdata-container-gauge';
}
+ },
+ "textonly": {
+ autoresize: function (state) {
+ void(state);
+ return false;
+ },
+ container_class: function (state) {
+ void(state);
+ return 'netdata-container';
+ },
+ create: NETDATA.textOnlyCreate,
+ enabled: true,
+ format: function (state) {
+ void(state);
+ return 'array';
+ },
+ initialized: true,
+ initialize: function (callback) {
+ callback();
+ },
+ legend: function (state) {
+ void(state);
+ return null;
+ },
+ max_updates_to_recreate: function (state) {
+ void(state);
+ return 5000;
+ },
+ options: function (state) {
+ void(state);
+ return 'absolute';
+ },
+ pixels_per_point: function (state) {
+ void(state);
+ return 3;
+ },
+ track_colors: function (state) {
+ void(state);
+ return false;
+ },
+ update: NETDATA.textOnlyUpdate,
+ xssRegexIgnore: new RegExp('^/api/v1/data\.result$'),
}
};