summaryrefslogtreecommitdiffstats
path: root/web/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'web/gui/src')
-rw-r--r--web/gui/src/dashboard.js/charting.js42
-rw-r--r--web/gui/src/dashboard.js/charting/_c3.js114
-rw-r--r--web/gui/src/dashboard.js/charting/_morris.js81
-rw-r--r--web/gui/src/dashboard.js/charting/_raphael.js48
-rw-r--r--web/gui/src/dashboard.js/charting/textonly.js18
5 files changed, 303 insertions, 0 deletions
diff --git a/web/gui/src/dashboard.js/charting.js b/web/gui/src/dashboard.js/charting.js
index e2e44b715..1035ff069 100644
--- a/web/gui/src/dashboard.js/charting.js
+++ b/web/gui/src/dashboard.js/charting.js
@@ -436,6 +436,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$'),
}
};
diff --git a/web/gui/src/dashboard.js/charting/_c3.js b/web/gui/src/dashboard.js/charting/_c3.js
new file mode 100644
index 000000000..6688bbcce
--- /dev/null
+++ b/web/gui/src/dashboard.js/charting/_c3.js
@@ -0,0 +1,114 @@
+
+// DEPRECATED: will be removed!
+
+// c3
+
+NETDATA.c3Initialize = function(callback) {
+ if (typeof netdataNoC3 === 'undefined' || !netdataNoC3) {
+
+ // C3 requires D3
+ if (!NETDATA.chartLibraries.d3.initialized) {
+ if (NETDATA.chartLibraries.d3.enabled) {
+ NETDATA.d3Initialize(function() {
+ NETDATA.c3Initialize(callback);
+ });
+ } else {
+ NETDATA.chartLibraries.c3.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+ } else {
+ NETDATA._loadCSS(NETDATA.c3_css);
+
+ $.ajax({
+ url: NETDATA.c3_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('c3', NETDATA.c3_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.c3.enabled = false;
+ NETDATA.error(100, NETDATA.c3_js);
+ })
+ .always(function() {
+ if (typeof callback === "function")
+ return callback();
+ });
+ }
+ } else {
+ NETDATA.chartLibraries.c3.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+};
+
+NETDATA.c3ChartUpdate = function(state, data) {
+ state.c3_instance.destroy();
+ return NETDATA.c3ChartCreate(state, data);
+
+ //state.c3_instance.load({
+ // rows: data.result,
+ // unload: true
+ //});
+
+ //return true;
+};
+
+NETDATA.c3ChartCreate = function(state, data) {
+
+ state.element_chart.id = 'c3-' + state.uuid;
+ // console.log('id = ' + state.element_chart.id);
+
+ state.c3_instance = c3.generate({
+ bindto: '#' + state.element_chart.id,
+ size: {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ },
+ color: {
+ pattern: state.chartColors()
+ },
+ data: {
+ x: 'time',
+ rows: data.result,
+ type: (state.chart.chart_type === 'line')?'spline':'area-spline'
+ },
+ axis: {
+ x: {
+ type: 'timeseries',
+ tick: {
+ format: function(x) {
+ return NETDATA.dateTime.xAxisTimeString(x);
+ }
+ }
+ }
+ },
+ grid: {
+ x: {
+ show: true
+ },
+ y: {
+ show: true
+ }
+ },
+ point: {
+ show: false
+ },
+ line: {
+ connectNull: false
+ },
+ transition: {
+ duration: 0
+ },
+ interaction: {
+ enabled: true
+ }
+ });
+
+ // console.log(state.c3_instance);
+
+ return true;
+};
diff --git a/web/gui/src/dashboard.js/charting/_morris.js b/web/gui/src/dashboard.js/charting/_morris.js
new file mode 100644
index 000000000..30789e4e2
--- /dev/null
+++ b/web/gui/src/dashboard.js/charting/_morris.js
@@ -0,0 +1,81 @@
+
+// DEPRECATED: will be removed!
+
+// morris
+
+NETDATA.morrisInitialize = function(callback) {
+ if (typeof netdataNoMorris === 'undefined' || !netdataNoMorris) {
+
+ // morris requires raphael
+ if (!NETDATA.chartLibraries.raphael.initialized) {
+ if (NETDATA.chartLibraries.raphael.enabled) {
+ NETDATA.raphaelInitialize(function() {
+ NETDATA.morrisInitialize(callback);
+ });
+ } else {
+ NETDATA.chartLibraries.morris.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+ } else {
+ NETDATA._loadCSS(NETDATA.morris_css);
+
+ $.ajax({
+ url: NETDATA.morris_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('morris', NETDATA.morris_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.morris.enabled = false;
+ NETDATA.error(100, NETDATA.morris_js);
+ })
+ .always(function() {
+ if (typeof callback === "function")
+ return callback();
+ });
+ }
+ } else {
+ NETDATA.chartLibraries.morris.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+};
+
+NETDATA.morrisChartUpdate = function(state, data) {
+ state.morris_instance.setData(data.result.data);
+ return true;
+};
+
+NETDATA.morrisChartCreate = function(state, data) {
+
+ state.morris_options = {
+ element: state.element_chart.id,
+ data: data.result.data,
+ xkey: 'time',
+ ykeys: data.dimension_names,
+ labels: data.dimension_names,
+ lineWidth: 2,
+ pointSize: 3,
+ smooth: true,
+ hideHover: 'auto',
+ parseTime: true,
+ continuousLine: false,
+ behaveLikeLine: false
+ };
+
+ if (state.chart.chart_type === 'line')
+ state.morris_instance = new Morris.Line(state.morris_options);
+
+ else if (state.chart.chart_type === 'area') {
+ state.morris_options.behaveLikeLine = true;
+ state.morris_instance = new Morris.Area(state.morris_options);
+ }
+ else // stacked
+ state.morris_instance = new Morris.Area(state.morris_options);
+
+ return true;
+};
diff --git a/web/gui/src/dashboard.js/charting/_raphael.js b/web/gui/src/dashboard.js/charting/_raphael.js
new file mode 100644
index 000000000..2d89a22a8
--- /dev/null
+++ b/web/gui/src/dashboard.js/charting/_raphael.js
@@ -0,0 +1,48 @@
+
+// DEPRECATED: will be removed!
+
+// raphael
+
+NETDATA.raphaelInitialize = function(callback) {
+ if (typeof netdataStopRaphael === 'undefined' || !netdataStopRaphael) {
+ $.ajax({
+ url: NETDATA.raphael_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('raphael', NETDATA.raphael_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.raphael.enabled = false;
+ NETDATA.error(100, NETDATA.raphael_js);
+ })
+ .always(function() {
+ if (typeof callback === "function")
+ return callback();
+ });
+ } else {
+ NETDATA.chartLibraries.raphael.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+};
+
+NETDATA.raphaelChartUpdate = function(state, data) {
+ $(state.element_chart).raphael(data.result, {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ });
+
+ return false;
+};
+
+NETDATA.raphaelChartCreate = function(state, data) {
+ $(state.element_chart).raphael(data.result, {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ });
+
+ return false;
+};
diff --git a/web/gui/src/dashboard.js/charting/textonly.js b/web/gui/src/dashboard.js/charting/textonly.js
new file mode 100644
index 000000000..e7b9aa93a
--- /dev/null
+++ b/web/gui/src/dashboard.js/charting/textonly.js
@@ -0,0 +1,18 @@
+
+// ----------------------------------------------------------------------------------------------------------------
+// "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; \ No newline at end of file