<li>You can host your dashboard anywhere.</li>
<li>You can add as many charts as you like.</li>
<li>You can have charts from many different netdata servers (add <pre>data-host="http://another.netdata.server:19999/"</pre> to each chart).</li>
- <li>You can use different chart libraries on the same page: <b>peity</b>, <b>sparkline</b>, <b>dygraph</b>, <b>google</b> (requires some more lines in your html page - view source this one), <b>morris</b></li>
+ <li>You can use different chart libraries on the same page: <b>peity</b>, <b>sparkline</b>, <b>dygraph</b>, <b>google</b>, <b>morris</b></li>
<li>You can customize each chart to your preferences. For each chart library most of their attributes can be given in <b>data-</b> attributes.</li>
<li>Each chart can have each own duration - it is controlled with the <b>data-after</b> attribute to give that many seconds of data.</li>
<li>Depending on the width of the chart and <b>data-after</b> attribute, netdata will automatically refresh the chart when it needs to be updated. For example giving 600 pixels for width for -600 seconds of data, using a chart library that needs 3 pixels per point, will yeld in a chart updated once every 3 seconds.</li>
</body>
</html>
- <!-- You can disable Google Visualization by commenting the following two lines -->
- <script type="text/javascript" src="https://www.google.com/jsapi"></script>
- <script type='text/javascript'>google.load('visualization', '1.1', {'packages':['corechart', 'controls']});</script>
-
<!-- you can set your netdata server globally, by ucommenting this -->
<!-- you can also give a different server per chart, with the attribute: data-host="http://netdata.server:19999" -->
<!-- <script> netdataServer = "http://box:19999"; </script> -->
100: { message: "Cannot load chart library", alert: true },
101: { message: "Cannot load jQuery", alert: true },
402: { message: "Chart library not found", alert: false },
+ 403: { message: "Chart library not enabled/is failed", alert: false },
404: { message: "Chart not found", alert: false }
};
NETDATA.errorLast = {
NETDATA.messageInABox(target, 'chart library "' + library + '" is not found');
NETDATA.validateDomCharts(targets, ++index, callback);
}
+ else if(!NETDATA.chartLibraries[library].enabled) {
+ NETDATA.error(403, library);
+ NETDATA.messageInABox(target, 'chart library "' + library + '" is not enabled');
+ NETDATA.validateDomCharts(targets, ++index, callback);
+ }
+ else if(!NETDATA.chartLibraries[library].initialized) {
+ self.data('prepared', false);
+ NETDATA.chartLibraries[library].initialize(function() {
+ NETDATA.validateDomCharts(targets, index, callback);
+ });
+ }
else {
var url = host + "/api/v1/chart?chart=" + id;
});
}
}
+ else {
+ NETDATA.validateDomCharts(targets, ++index, callback);
+ }
}
}
callback();
})
}
- else if(typeof callback == "function")
- callback();
+ else {
+ NETDATA.chartLibraries.peity.enabled = false;
+ if(typeof callback == "function")
+ callback();
+ }
};
NETDATA.peityChartUpdate = function(element, data) {
NETDATA.peityChartCreate = function(element, data) {
var self = $(element);
- if(!NETDATA.chartLibraries.peity.initialized) {
- if(!NETDATA.chartLibraries.peity.enabled) {
- NETDATA.messageInABox(element, 'peity is disabled.');
- }
- else {
- NETDATA.messageInABox(element, 'peity is initializing...');
-
- }
- }
-
var uuid = NETDATA.guid();
element.innerHTML = '<div id="' + uuid + '">' + data + '</div>';
var instance = document.getElementById(uuid);
callback();
})
}
- else if(typeof callback == "function")
- callback();
+ else {
+ NETDATA.chartLibraries.sparkline.enabled = false;
+ if(typeof callback == "function")
+ callback();
+ }
};
NETDATA.sparklineChartUpdate = function(element, data) {
NETDATA.dygraphInitSync(callback);
})
}
- else if(typeof callback == "function")
- callback();
+ else {
+ NETDATA.chartLibraries.dygraph.enabled = false;
+ if(typeof callback == "function")
+ callback();
+ }
};
NETDATA.dygraphChartUpdate = function(element, data) {
NETDATA.morrisInitialize = function(callback) {
if(typeof netdataStopMorris == 'undefined') {
+
+ // 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")
+ callback();
+ }
+ }
+
var fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
callback();
})
}
- else if(typeof callback == "function")
- callback();
+ else {
+ NETDATA.chartLibraries.morris.enabled = false;
+ if(typeof callback == "function")
+ callback();
+ }
};
NETDATA.morrisChartUpdate = function(element, data) {
callback();
})
}
- else if(typeof callback == "function")
- callback();
+ else {
+ NETDATA.chartLibraries.raphael.enabled = false;
+ if(typeof callback == "function")
+ callback();
+ }
};
NETDATA.raphaelChartUpdate = function(element, data) {
// google charts
NETDATA.googleInitialize = function(callback) {
- if(typeof netdataStopGoogleCharts == 'undefined' && typeof google != 'undefined') {
- NETDATA.registerChartLibrary('google', NETDATA.google_js);
+ if(typeof netdataStopGoogleCharts == 'undefined') {
+ $.getScript(NETDATA.google_js)
+ .done(function() {
+ NETDATA.registerChartLibrary('google', NETDATA.google_js);
+
+ google.load('visualization', '1.1', {
+ 'packages': ['corechart', 'controls'],
+ 'callback': callback
+ });
+ })
+ .fail(function() {
+ NETDATA.error(100, NETDATA.google_js);
+ if(typeof callback == "function")
+ callback();
+ })
+ }
+ else {
+ NETDATA.chartLibraries.google.enabled = false;
if(typeof callback == "function")
callback();
}
- else if(typeof callback == "function")
- callback();
};
NETDATA.googleChartUpdate = function(element, data) {
NETDATA.registerChartLibrary = function(library, url) {
console.log("registering chart library: " + library);
- NETDATA.chartLibraries[library]
- .url = url
- .initialized = new Date().getTime();
+ NETDATA.chartLibraries[library].url = url;
+ NETDATA.chartLibraries[library].initialized = true;
+ NETDATA.chartLibraries[library].enabled = true;
console.log(NETDATA.chartLibraries);
}
NETDATA._loadjQuery(function() {
$.getScript(NETDATA.serverDefault + 'lib/visible.js').then(function() {
- NETDATA.raphaelInitialize(function() {
- NETDATA.morrisInitialize(function() {
- NETDATA.peityInitialize(function() {
- NETDATA.sparklineInitialize(function() {
- NETDATA.dygraphInitialize(function() {
- NETDATA.googleInitialize(function() {
- NETDATA.init();
- }) // google
- }) // dygraph.js
- }) // sparkline.js
- }) // piety.js
- }) // morris.js
- }) // raphael.js
+ NETDATA.init();
})
});