]> arthur.barton.de Git - netdata.git/blobdiff - web/index.html
added internal plugin for reading /proc/loadavg and disables charts.d/load_average...
[netdata.git] / web / index.html
old mode 100644 (file)
new mode 100755 (executable)
index 817589d..71a0d03
 <!DOCTYPE html>
 <html lang="en">
 <head>
+       <title>netdata dashboard</title>
+
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <meta name="apple-mobile-web-app-capable" content="yes">
-    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
-    <meta name="description" content="">
-    <meta name="author" content="costa@tsaousis.gr">
-       <title>NetData</title>
-
-       <!-- Google AJAX API -->
-       <script type="text/javascript" src="https://www.google.com/jsapi"></script>
-       <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
-
-       <!-- Bootstrap -->
-       <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
-       <!-- <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"> -->
-       <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
-       <link href="/file/theme.css" rel="stylesheet">
-
-       <!-- NetData -->
-       <script type="text/javascript" src="/file/netdata.js"></script>
-       <script type="text/javascript" src="/file/jquery.visible.js"></script>
-       <script type="text/javascript">
-       
-       // Set a callback to run when the Google Visualization API is loaded.
-       google.setOnLoadCallback(initCharts);
+       <meta charset="utf-8">
+       <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+       <meta name="viewport" content="width=device-width, initial-scale=1">
+       <meta name="apple-mobile-web-app-capable" content="yes">
+       <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+       <meta name="author" content="costa@tsaousis.gr">
+
+       <link rel="shortcut icon" href="images/seo-performance-multi-size.ico">
        
-       var TARGET_THUMB_GRAPH_WIDTH = 500;             // thumb charts width will range from 0.5 to 1.5 of that
-       var MINIMUM_THUMB_GRAPH_WIDTH = 400;    // thumb chart will generally try to be wider than that
-       var TARGET_THUMB_GRAPH_HEIGHT = 220;    // the height of the thumb charts
-       var THUMBS_MAX_TIME_TO_SHOW = 600;              // how much time the thumb charts will present?
-
-       var MAINCHART_MAX_TIME_TO_SHOW = 600;   // how much time the main chart will present by default?
-       var MAINCHART_POINTS_DIVISOR = 10;              // how much detailed will the main chart be by default? 1 = finest, higher is faster
-       var MAINCHART_CONTROL_HEIGHT = 75;              // how tall the control chart will be
-       var MAINCHART_CONTROL_DIVISOR = 2;              // how much detailed will the control chart be? 1 = finest, higher is faster
-
-       var MODE_THUMBS = 1;
-       var MODE_MAIN = 2;
-       var MODE_GROUP_THUMBS = 3;
-       var mode; // one of the MODE_* values
-
-       var mycharts = new Array();
-       var mainchart;
-
-       // html for the main menu
-       var mainmenu = "";
-
-
-       // ------------------------------------------------------------------------
-       // common HTML generation
-
-       function chartIsLoadingHTML(name, width, height) { return "<table><tr><td align=\"center\" width=\"" + width + "\" height=\"" + height + "\" style=\"vertical-align:middle\"><h4><span class=\"glyphicon glyphicon-refresh\"></span><br/><br/>loading " + name + "<br/><br/><span class=\"label label-default\">Please wait...</span></h4></td></tr></table>"; }
-
-       function showChartIsLoading(id, name, width, height) {
-               //mylog('adding loading chart html in div with id ' + id);
-               document.getElementById(id).innerHTML = chartIsLoadingHTML(name, width, height);
+       <link rel="apple-touch-icon" href="images/seo-performance-72.png">
+       <link rel="apple-touch-icon" sizes="72x72" href="images/seo-performance-72.png">
+       <link rel="apple-touch-icon" sizes="114x114" href="images/seo-performance-114.png">
+
+       <link rel="icon" type="image/png" sizes="512x512" href="images/seo-performance-512.png">
+       <link rel="icon" type="image/png" sizes="256x256" href="images/seo-performance-256.png">
+       <link rel="icon" type="image/png" sizes="128x128" href="images/seo-performance-128.png">
+       <link rel="icon" type="image/png" sizes="64x64" href="images/seo-performance-64.png">
+       <link rel="icon" type="image/png" sizes="48x48" href="images/seo-performance-48.png">
+       <link rel="icon" type="image/png" sizes="32x32" href="images/seo-performance-32.png">
+       <link rel="icon" type="image/png" sizes="24x24" href="images/seo-performance-24.png">
+       <link rel="icon" type="image/png" sizes="16x16" href="images/seo-performance-16.png">
+
+       <style>
+
+       /* prevent body from hidding under the navbar */
+       body {
+               padding-top: 50px;
        }
 
-       function thumbChartActions(i, c, nogroup) {
-               var name = c.name;
-               if(!nogroup) name = c.group_tag;
-
-               var refinfo = "the chart is drawing ";
-               if(c.group == 1) refinfo += "every single point collected.";
-               else refinfo += ((c.group_method == "average")?"the average":"the max") + " value for every " + (c.group * c.update_every) + " seconds of data";
-
-               var html = "<div class=\"btn-group btn-group\" data-toggle=\"tooltip\" title=\"" + refinfo + "\">"
-               +               "<button type=\"button\" class=\"btn btn-default\" onclick=\"javascript: return;\"><span class=\"glyphicon glyphicon-info-sign\"></span></button>"
-               +       "</div>"
-               +       "<div class=\"btn-group btn-group\"><button type=\"button\" class=\"btn btn-default disabled\"><small>&nbsp;&nbsp; " + name + "</small></button>";
-
-               if(!nogroup) {
-                       var ingroup = 0;
-                       var ingroup_detail = 0;
-
-                       $.each(mycharts, function(i, d) {
-                               if(d.group_tag == c.group_tag) {
-                                       ingroup++;
-                                       if(d.isdetail) ingroup_detail++;
-                               }
-                       });
-
-                       var hidden = "";
-                       if(ingroup_detail) hidden = ", including " + ingroup_detail + " charts not shown now";
-
-                       html += "<button type=\"button\" data-toggle=\"tooltip\" title=\"Show all " + ingroup + " charts in group '" + c.group_tag + "'" + hidden + "\" class=\"btn btn-default\" onclick=\"initGroupGraphs('" + c.group_tag +"');\"><span class=\"glyphicon glyphicon-th-large\"></span></button>";
-               }
-
-               html += "<button type=\"button\" data-toggle=\"tooltip\" title=\"show chart '" + c.name + "' in fullscreen\" class=\"btn btn-default\" onclick=\"initMainChartIndex(" + i +");\"><span class=\"glyphicon glyphicon-resize-full\"></span></button>"
-               +               "<button type=\"button\" data-toggle=\"tooltip\" title=\"set options for chart '" + c.name + "'\" class=\"btn btn-default disabled\" onclick=\"alert('Not implemented yet!');\"><span class=\"glyphicon glyphicon-cog\"></span></button>"
-               +               "<button type=\"button\" data-toggle=\"tooltip\" title=\"ignore chart '" + c.name + "'\" class=\"btn btn-default\" onclick=\"disableChart(" + i + ");\"><span class=\"glyphicon glyphicon-trash\"></span></button>"
-               +       "</div>";
-
-               return html;
+       .modal-wide .modal-dialog {
+               width: 80%;
        }
 
-       function mylog(txt) {
-               console.log(txt);
+       /* fix # anchors scrolling under the navbar
+          https://github.com/twbs/bootstrap/issues/1768#issuecomment-46519033
+        */
+       h1 {
+               position: relative;
+               z-index: -1;
        }
-
-       function chartssort(a, b) {
-               if(a.userpriority < b.userpriority) return -1;
-               return 1;
+       h2 {
+               position: relative;
+               z-index: -2;
        }
-
-
-       // ------------------------------------------------------------------------
-       // MAINGRAPH = fullscreen view of 1 graph
-
-       function calculateChartGroup(c, divisor, maxtime, group) {
-               var before = c.before?c.before:new Date().getTime() / 1000;
-               var after = c.after?c.after:c.first_entry_t;
-
-               var dt = before - after;
-               if(dt > c.entries * c.update_every) dt = c.entries * c.update_every;
-
-               if(maxtime) dt = maxtime;
-
-               var data_points = Math.round(dt / c.update_every);
-               var screen_points = Math.round(c.chartOptions.width / divisor);
-               //mylog('screen = ' + screen_points + ', data = ' + data_points + ', divisor = ' + divisor);
-
-               if(group <= 0) {
-                       if(screen_points > data_points) {
-                               c.group = 1;
-                               c.points_to_show = data_points;
-                               //mylog("rendering at full detail");
-                       }
-                       else {
-                               c.group = Math.round(data_points / screen_points);
-
-                               if(group >= 0) {
-                                            if(c.group > 60) c.group = 60;
-                                       else if(c.group > 45) c.group = 45;
-                                       else if(c.group > 30) c.group = 30;
-                                       else if(c.group > 20) c.group = 20;
-                                       else if(c.group > 15) c.group = 15;
-                                       else if(c.group > 10) c.group = 10;
-                                       else if(c.group > 5) c.group = 5;
-                                       else if(c.group > 2) c.group = 2;
-                                       else c.group = 1;
-                               }
-
-                               c.points_to_show = Math.round(data_points / c.group);
-                               //mylog("rendering adaptive");
-                       }
-               }
-               else {
-                       c.group = group;
-                       c.points_to_show = Math.round(data_points / group);
-                       //mylog("rendering with given group");
-               }
-               //mylog('group = ' + c.group + ', points = ' + c.points_to_show);
-
-               if(mainchart.chartType == 'LineChart') {
-                       if(mainchart.group <= 2) mainchart.chartOptions.lineWidth = 1;
-                       else mainchart.chartOptions.lineWidth = 2;
-               }
+       h1:before, h2:before { 
+               display: block; 
+               content: " "; 
+               margin-top: -70px;
+               height: 70px;
+               visibility: hidden; 
        }
 
-       // copy the chart c to mainchart
-       // switch to main graphs screen
-       function initMainChart(c) {
-               if(mainchart) cleanThisChart(mainchart);
-
-               mainchart = $.extend(true, {}, c);
-               mainchart.refreshCount = 0;
-               mainchart.last_updated = 0;
-               mainchart.chartOptions.explorer = null;
-               mainchart.chart = null;
+       .p {
+               display: block;
+               margin-top: 15px;
+       }
 
-               mainchart.chartOptions.width = screenWidth();
-               mainchart.chartOptions.height = $(window).height() - 150 - MAINCHART_CONTROL_HEIGHT;
-               if(mainchart.chartOptions.height < 300) mainchart.chartOptions.height = 300;
-               //mainchart.chartOptions.chartArea = {'width': '80%'};
+       .option-row,
+       .option-control {
+               vertical-align: top;
+               padding: 10px;
+               padding-top: 30px;
+               padding-left: 30px;
+       }
 
-               mainchart.div = 'maingraph';
-               calculateChartGroup(mainchart, MAINCHART_POINTS_DIVISOR, MAINCHART_MAX_TIME_TO_SHOW, 0);
+       .option-info {
+               padding: 10px;
+       }
 
-               // copy it to the hidden chart
-               mainchart.hiddenchart = $.extend(true, {}, mainchart);
-               mainchart.hiddenchart.chartOptions.height = MAINCHART_CONTROL_HEIGHT;
-               mainchart.hiddenchart.div = 'maingraph_control';
+       .chart-message {
+               display: block; 
+               margin-top: 10px;
+       }
 
-               // initialize the div
-               showChartIsLoading(mainchart.div, mainchart.name, mainchart.chartOptions.width, mainchart.chartOptions.height);
+       .container {
+               width: 90% !important;
+       }
 
-               // set the radio buttons
-               setMainChartGroupMethod(mainchart.group_method, 'no-refresh');
-               setMainChartMax('normal');
+       #masthead h1 {
+               /*font-size: 30px;*/
+               line-height: 1;
+               padding-top: 30px;
+       }
 
-               $('#group' + mainchart.group).trigger('click');
-               setMainChartGroup(mainchart.group, 'no-refresh');
+       #masthead .well {
+               margin-top:4%;
+       }
 
-               switchToMainGraph();
+       /* fix the navbar shifting when a modal is open */
+       /* https://github.com/twbs/bootstrap/issues/14040#issuecomment-159891033 */
+       body.modal-open{
+               width: 100% !important;
+               padding-right: 0 !important;
+/*             overflow-y: scroll !important; */
+/*             position: fixed !important;*/
+               overflow: visible;
        }
 
-       function refreshHiddenChart(doNext) {
-               if(refresh_mode == REFRESH_PAUSED && mainchart.hiddenchart.last_updated != 0) {
-                       if(typeof doNext == "function") doNext();
-                       return;
-               }
+       /*
+        * Side navigation
+        *
+        * Scrollspy and affixed enhanced navigation to highlight sections and secondary
+        * sections of docs content.
+        */
+
+       .affix {
+               position: static;
+               top: 70px !important;
+               /*width: 220px;*/
+       }
 
-               // is it too soon for a refresh?
-               var now = new Date().getTime();
-               if((now - mainchart.hiddenchart.last_updated) < (mainchart.hiddenchart.group * mainchart.hiddenchart.update_every * 1000)) {
-                       if(typeof doNext == "function") doNext();
-                       return;
-               }
+       .affix-top {
+               /*width: 220px;*/
+       }
 
-               if(mainchart.dashboard && mainchart.hiddenchart.refreshCount > 50) {
-                       mainchart.dashboard.clear();
-                       mainchart.control_wrapper.clear();
-                       mainchart.hidden_wrapper.clear();
+       .dashboard-sidebar {
+               max-height: calc(100% - 70px) !important;
+               overflow-y: auto;
+               /*width: 220px !important;*/
+       }
 
-                       mainchart.dashboard = null;
-                       mainchart.control_wrapper = null;
-                       mainchart.hidden_wrapper = null;
-               }
+       /* By default it's not affixed in mobile views, so undo that */
+       .dashboard-sidebar.affix {
+               position: static;
+       }
 
-               if(!mainchart.dashboard) {
-                       var controlopts = $.extend(true, {}, mainchart.chartOptions, {
-                               lineWidth: 1,
-                               height: mainchart.hiddenchart.chartOptions.height,
-                               chartArea: {'width': '98%'},
-                               hAxis: {'baselineColor': 'none'},
-                               vAxis: {'title': null},
-                       });
-
-                       mainchart.dashboard = new google.visualization.Dashboard(document.getElementById('maingraph_dashboard'));
-                       mainchart.control_wrapper = new google.visualization.ControlWrapper({
-                               controlType: 'ChartRangeFilter',
-                               containerId: 'maingraph_control',
-                               options: {
-                                       filterColumnIndex: 0,
-                                       ui: {
-                                               chartType: mainchart.chartType,
-                                               chartOptions: controlopts,
-                                               minRangeSize: (MAINCHART_MAX_TIME_TO_SHOW * 1000 * mainchart.update_every) / MAINCHART_POINTS_DIVISOR,
-                                       }
-                               },
-                       });
-                       mainchart.hidden_wrapper = new google.visualization.ChartWrapper({
-                               chartType: mainchart.chartType,
-                               containerId: 'maingraph_hidden',
-                               options: {
-                                       isStacked: mainchart.chartOptions.isStacked,
-                                       width: mainchart.hiddenchart.chartOptions.width,
-                                       height: mainchart.hiddenchart.chartOptions.height,
-                                       //chartArea: {'height': '80%', 'width': '100%'},
-                                       //hAxis: {'slantedText': false},
-                                       //legend: {'position': 'none'}
-                               },
-                       });
-
-                       mainchart.hiddenchart.refreshCount = 0;
+       @media (min-width: 768px) {
+               .dashboard-sidebar {
+                       padding-left: 20px;
                }
-
-               // load the data for the control and the hidden wrappers
-               // calculate the group and points to show for the control chart
-               calculateChartGroup(mainchart.hiddenchart, MAINCHART_CONTROL_DIVISOR, 0, -1);
-
-               $.ajax({
-                       url: generateChartURL(mainchart.hiddenchart),
-                       dataType:"json",
-                       cache: false
-               })
-               .done(function(jsondata) {
-                       if(!jsondata || jsondata.length == 0) return;
-
-                       mainchart.control_data = new google.visualization.DataTable(jsondata);
-
-                       if(mainchart.hiddenchart.last_updated == 0) {
-                               google.visualization.events.addListener(mainchart.control_wrapper, 'ready', mainchartControlReadyEvent);
-                               mainchart.dashboard.bind(mainchart.control_wrapper, mainchart.hidden_wrapper);
-                       }
-                       if(refresh_mode != REFRESH_PAUSED)
-                               mainchart.control_wrapper.setState({range: {
-                                       start: new Date((Math.round(new Date().getTime() / 1000) - MAINCHART_MAX_TIME_TO_SHOW) * 1000),
-                                       end: new Date()
-                               }});
-
-                       mainchart.dashboard.draw(mainchart.control_data);
-                       mainchart.hiddenchart.last_updated = new Date().getTime();
-                       mainchart.hiddenchart.refreshCount++;
-               })
-               .always(function() {
-                       if(typeof doNext == "function") doNext();
-               });
        }
 
-       function mainchartControlReadyEvent() {
-               google.visualization.events.addListener(mainchart.control_wrapper, 'statechange', mainchartControlStateHandler);
-               //mylog(mainchart);
+       /* First level of nav */
+       .dashboard-sidenav {
+               margin-top: 20px;
+               margin-bottom: 20px;
        }
 
-       function mainchartControlStateHandler() {
-               // setMainChartPlay('pause');
-
-               var state = mainchart.control_wrapper.getState();
-               mainchart.after = Math.round(state.range.start.getTime() / 1000);
-               mainchart.before = Math.round(state.range.end.getTime() / 1000);
-
-               calculateChartGroup(mainchart, MAINCHART_POINTS_DIVISOR, 0, 0);
-               //mylog('group = ' + mainchart.group + ', points_to_show = ' + mainchart.points_to_show + ', dt = ' + (mainchart.before - mainchart.after));
-
-               $('#group' + mainchart.group).trigger('click');
-               mainchart.last_updated = 0;
-
-               if(refresh_mode != REFRESH_PAUSED) pauseGraphs();
+       /* All levels of nav */
+       .dashboard-sidebar .nav > li > a {
+               display: block;
+               padding: 4px 20px;
+               font-size: 13px;
+               font-weight: 500;
+               color: #767676;
+       }
+       .dashboard-sidebar .nav > li > a:hover,
+       .dashboard-sidebar .nav > li > a:focus {
+               padding-left: 19px;
+               color: #563d7c;
+               text-decoration: none;
+               background-color: transparent;
+               border-left: 1px solid #563d7c;
+       }
+       .dashboard-sidebar .nav > .active > a,
+       .dashboard-sidebar .nav > .active:hover > a,
+       .dashboard-sidebar .nav > .active:focus > a {
+               padding-left: 18px;
+               font-weight: bold;
+               color: #563d7c;
+               background-color: transparent;
+               border-left: 2px solid #563d7c;
        }
 
-       function initMainChartIndex(i) {
-               if(mode == MODE_GROUP_THUMBS) 
-                       initMainChart(group_charts[i]);
-
-               else if(mode == MODE_THUMBS)
-                       initMainChart(mycharts[i]);
+       /* Nav: second level (shown on .active) */
+       .dashboard-sidebar .nav .nav {
+               display: none; /* Hide by default, but at >768px, show it */
+               padding-bottom: 10px;
+       }
+       .dashboard-sidebar .nav .nav > li > a {
+               padding-top: 1px;
+               padding-bottom: 1px;
+               padding-left: 30px;
+               font-size: 12px;
+               font-weight: normal;
+       }
+       .dashboard-sidebar .nav .nav > li > a:hover,
+       .dashboard-sidebar .nav .nav > li > a:focus {
+               padding-left: 29px;
+       }
+       .dashboard-sidebar .nav .nav > .active > a,
+       .dashboard-sidebar .nav .nav > .active:hover > a,
+       .dashboard-sidebar .nav .nav > .active:focus > a {
+               padding-left: 28px;
+               font-weight: 500;
        }
 
-       var last_main_chart_max='normal';
-       function setMainChartMax(m) {
-               if(!mainchart) return;
+       /* Back to top (hidden on mobile) */
+       .back-to-top,
+       .dashboard-theme-toggle {
+               display: none;
+               padding: 4px 10px;
+               margin-top: 10px;
+               margin-left: 10px;
+               font-size: 12px;
+               font-weight: 500;
+               color: #999;
+       }
+       .back-to-top:hover,
+       .dashboard-theme-toggle:hover {
+               color: #563d7c;
+               text-decoration: none;
+       }
+       .dashboard-theme-toggle {
+               margin-top: 0;
+       }
 
-               if(m == 'toggle') {
-                       if(last_main_chart_max == 'maximized') m = 'normal';
-                       else m = 'maximized';
+       @media (min-width: 768px) {
+               .back-to-top,
+               .dashboard-theme-toggle {
+                       display: block;
                }
 
-               if(m == "maximized") {
-                       mainchart.chartOptions.theme = 'maximized';
-                       //mainchart.chartOptions.axisTitlesPosition = 'in';
-                       //mainchart.chartOptions.legend = {position: 'none'};
-                       //mainchart.chartOptions.hAxis.title = null;
-                       mainchart.chartOptions.hAxis.viewWindowMode = 'maximized';
-                       mainchart.chartOptions.vAxis.viewWindowMode = 'maximized';
+               /* Widen the fixed sidebar */
+               .dashboard-sidebar.affix,
+               .dashboard-sidebar.affix-top,
+               .dashboard-sidebar.affix-bottom {
+                       width: 200px !important;
                }
-               else {
-                       mainchart.chartOptions.theme = null;
-                       mainchart.chartOptions.hAxis.viewWindowMode = null;
-                       mainchart.chartOptions.vAxis.viewWindowMode = null;
-               }
-               $('.mainchart_max_button').button(m);
-               last_main_chart_max = m;
-               mainchart.last_updated = 0;
-       }
-
-       function setMainChartGroup(g, norefresh) {
-               if(!mainchart) return;
 
-               mainchart.group = g;
-
-               if(!mainchart.before && !mainchart.after)
-                       calculateChartGroup(mainchart, MAINCHART_POINTS_DIVISOR, MAINCHART_MAX_TIME_TO_SHOW, mainchart.group);
-               else
-                       calculateChartGroup(mainchart, MAINCHART_POINTS_DIVISOR, 0, mainchart.group);
-
-               if(!norefresh) {
-                       mainchart.last_updated = 0;
+               .dashboard-sidebar.affix {
+                       position: fixed; /* Undo the static from mobile first approach */
+                       top: 20px;
                }
-       }
-
-       var last_main_chart_avg = null;
-       function setMainChartGroupMethod(g, norefresh) {
-               if(!mainchart) return;
 
-               if(g == 'toggle') {
-                       if(last_main_chart_avg == 'max') g = 'average';
-                       else g = 'max';
+               .dashboard-sidebar.affix-bottom {
+                       position: absolute; /* Undo the static from mobile first approach */
                }
 
-               mainchart.group_method = g;
-
-               $('.mainchart_avg_button').button(g);
-
-               if(!norefresh) {
-                       mainchart.last_updated = 0;
+               .dashboard-sidebar.affix-bottom .dashboard-sidenav,
+               .dashboard-sidebar.affix .dashboard-sidenav {
+                       margin-top: 0;
+                       margin-bottom: 0;
                }
-
-               last_main_chart_avg = g;
        }
 
-       function setMainChartPlay(p) {
-               if(!mainchart) return;
-
-               if(p == 'toggle') {
-                       if(refresh_mode != REFRESH_ALWAYS) p = 'play';
-                       else p = 'pause';
+       /* Show and affix the side nav when space allows it */
+       @media (min-width: 992px) {
+               .dashboard-sidebar .nav > .active > ul {
+                       display: block;
                }
 
-               if(p == 'play') {
-                       //mainchart.chartOptions.explorer = null;
-                       mainchart.after = 0;
-                       mainchart.before = 0;
-                       calculateChartGroup(mainchart, MAINCHART_POINTS_DIVISOR, MAINCHART_MAX_TIME_TO_SHOW, 0);
-                       $('#group' + mainchart.group).trigger('click');
-                       mainchart.last_updated = 0;
-                       playGraphs();
+               /* Widen the fixed sidebar */
+               .dashboard-sidebar.affix,
+               .dashboard-sidebar.affix-top,
+               .dashboard-sidebar.affix-bottom {
+                       width: 200px !important;
                }
-               else {
-                       //mainchart.chartOptions.explorer = {
-                       //      'axis': 'horizontal',
-                       //      'maxZoomOut': 1,
-                       //};
-                       //mainchart.last_updated = 0;
-                       
-                       //if(!refreshChart(mainchart, pauseGraphs))
-                       pauseGraphs();
-               }
-       }
-
-
-       // ------------------------------------------------------------------------
-       // Chart resizing
-
-       function screenWidth() {
-               return (($(window).width() * 0.95) - 50);
-       }
-
-       // calculate the proper width for the thumb charts
-       function thumbWidth() {
-               var cwidth = screenWidth();
-               var items = Math.round(cwidth / TARGET_THUMB_GRAPH_WIDTH);
-               if(items < 1) items = 1;
-
-               if(items > 1 && (cwidth / items) < MINIMUM_THUMB_GRAPH_WIDTH) items--;
-
-               return Math.round(cwidth / items) - 1;
-       }
-
-       function groupChartSizes() {
-               var s = { width: screenWidth() / 2, height: ($(window).height() - 130) / 3 - 10};
-               if(s.width < MINIMUM_THUMB_GRAPH_WIDTH * 1.5) s.width = screenWidth();
-
-               var count = 0;
-               if(group_charts) $.each(group_charts, function(i, c) {
-                       if(c.enabled) count++;
-               });
-
-               if(count == 0) {
-                       s.width = TARGET_THUMB_GRAPH_WIDTH;
-                       s.height = TARGET_THUMB_GRAPH_HEIGHT;
+               .dashboard-sidebar.affix {
+                       position: fixed; /* Undo the static from mobile first approach */
+                       top: 20px;
                }
-               if(count < 4) {
-                       s.width = screenWidth();
-                       s.height = ($(window).height() - 130) / count - 10;
+               .dashboard-sidebar.affix-bottom {
+                       position: absolute; /* Undo the static from mobile first approach */
                }
-               else if(count == 4) {
-                       s.height = ($(window).height() - 130) / 2 - 10;
+               .dashboard-sidebar.affix-bottom .dashboard-sidenav,
+               .dashboard-sidebar.affix .dashboard-sidenav {
+                       margin-top: 0;
+                       margin-bottom: 0;
                }
-
-               if(s.height < TARGET_THUMB_GRAPH_HEIGHT * 1.5)
-                       s.height = TARGET_THUMB_GRAPH_HEIGHT * 1.5;
-
-               return s;
        }
 
-       // resize all charts
-       // if the thumb charts need resize in their width, reset them
-       function resizeCharts() {
-               var width = screenWidth();
-
-               if(mainchart) {
-                       mainchart.chartOptions.width = width;
-                       mainchart.chartOptions.height = $(window).height() - 150 - MAINCHART_CONTROL_HEIGHT;
-                       mainchart.last_updated = 0;
-
-                       mainchart.hidden_wrapper.setOption('width', width);
-                       mainchart.control_wrapper.setOption('ui.chartOptions.width', width);
-                       mainchart.hiddenchart.chartOptions.width = width;
-                       mainchart.hiddenchart.last_updated = 0;
+       @media (min-width: 1200px) {
+               /* Widen the fixed sidebar again */
+               .dashboard-sidebar.affix-bottom,
+               .dashboard-sidebar.affix-top,
+               .dashboard-sidebar.affix {
+                       width: 263px;
                }
-
-               width = thumbWidth();
-               $.each(mycharts, function(i, c) {
-                       if(c.enabled && c.chartOptions.width != width) {
-                               cleanThisChart(c);
-                               c.chartOptions.width = width;
-                               showChartIsLoading(c.div, c.name, c.chartOptions.width, c.chartOptions.height);
-                               c.last_updated = 0;
-                       }
-               });
-
-               if(group_charts) $.each(group_charts, function(i, c) {
-                       var sizes = groupChartSizes();
-
-                       if(c.enabled && (c.chartOptions.width != sizes.width || c.chartOptions.height != sizes.height)) {
-                               cleanThisChart(c);
-                               c.chartOptions.width = sizes.width;
-                               c.chartOptions.height = sizes.height;
-                               showChartIsLoading(c.div, c.name, c.chartOptions.width, c.chartOptions.height);
-                               c.last_updated = 0;
-                       }
-               });
        }
+       </style>
 
-       var resize_request = false;
-       window.onresize = function(event) {
-               resize_request = true;
-       };
-
+       <!-- 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> -->
 
-       // ------------------------------------------------------------------------
-       // Core of the thread refreshing the charts
+       <!-- load the dashboard manager - it will do the rest -->
+       <script>var netdataTheme = 'slate';</script>
+       <script type="text/javascript" src="dashboard.js?v25"></script>
+</head>
 
-       var REFRESH_PAUSED = 0;
-       var REFRESH_ALWAYS = 1;
+<body data-spy="scroll" data-target="#sidebar">
+       <nav class="navbar navbar-default navbar-fixed-top" role="banner">
+               <div class="container">
+                       <div class="navbar-header">
+                               <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse">
+                                       <span class="sr-only">Toggle navigation</span>
+                                       <span class="icon-bar"></span>
+                                       <span class="icon-bar"></span>
+                                       <span class="icon-bar"></span>
+                               </button>
+                               <a href="/" class="navbar-brand" id="hostname">netdata</a>
+                       </div>
+                       <nav class="collapse navbar-collapse navbar-right" role="navigation">
+                               <ul class="nav navbar-nav">
+                                       <li><a href="#" class="btn" data-toggle="modal" data-target="#optionsModal"><i class="fa fa-cog"></i> settings</a></li>
+                                       <li><a href="https://github.com/firehol/netdata/wiki" class="btn" target="_blank"><i class="fa fa-github"></i> community</a></li>
+<!--                                   <li><a href="old/" class="btn" target="_blank"><i class="fa fa-step-backward"></i> old dashboard</a></li> -->
+                                       <li><a href="#" class="btn" data-toggle="modal" data-target="#helpModal"><i class="fa fa-question-circle"></i> help</a></li>
+<!--                                   <li><a href="#sec">Visualize</a></li>
+                                       <li><a href="#sec">Prototype</a></li>
+-->                            </ul>
+                       </nav>
+               </div>
+       </nav>
+
+       <div id="masthead" style="display: none;">
+               <div class="container">
+                       <div class="row">
+                               <div class="col-md-7">
+                                       <h1>Netdata
+                                               <p class="lead">Real-time performance monitoring, in the greatest possible detail</p>
+                                       </h1>
+                               </div>
+                               <div class="col-md-5">
+                                       <div class="well well-lg">
+                                               <div class="row">
+                                               <div class="col-md-6">
+                                                       <b>Drag</b> charts to pan.
+                                                       <b>Shift + wheel</b> on them, to zoom in and out.
+                                                       <b>Double-click</b> on them, to reset.
+                                                       <b>Hover</b> on them too!
+                                                       </div>
+                                               <div class="col-md-6">
+                                                       <div data-netdata="system.intr" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-dygraph-type="line" data-dygraph-strokewidth="3" data-dygraph-smooth="true" data-dygraph-highlightcirclesize="6" data-after="-90" data-height="60px" data-colors="#C66"></div>
+                                                       </div>
+                                               </div>
+                                       </div>
+                               </div>
+                       </div>
+               </div>
+       </div>
 
-       var refresh_mode = REFRESH_PAUSED;
-       var last_refresh = 0;
-       function playGraphs() {
-               if(refresh_mode == REFRESH_ALWAYS) return;
+       <div class="container">
+               <div class="row">
+                       <div class="col-md-10" role="main">
+                               <div id="charts_div"></div>
+                       </div>
+                       <div class="col-md-2" role="complementary">
+                               <nav class="dashboard-sidebar hidden-print hidden-xs hidden-sm" id="sidebar" role="menu"></nav>
+                       </div>
+               </div>
+       </div>
 
-               //mylog('PlayGraphs()');
-               refresh_mode = REFRESH_ALWAYS;
-               $('.mainchart_play_button').button('play');
+       <div id="footer" class="container" style="display: none;">
+               <div class="row">
+                       <div class="col-md-10" role="main">
+                               <div class="p">
+                                       <big><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></big><br/>
+                                       <i class="fa fa-copyright"></i> Copyright 2016, Costa Tsaousis.<br/>
+                                       Released under <a href="http://www.gnu.org/licenses/gpl-3.0.en.html" target="_blank">GPL v3 or later</a>.<br/>
+                               </div>
+                               <div class="p">
+                                       <small>
+                                               <a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a> re-distributes these software tools:
 
-               // check if the thread died due to a javascript error
-               var now = new Date().getTime();
-               if((now - last_refresh) > 5000) {
-                       // it died or never started
-                       //mylog('It seems the refresh thread died. Restarting it.');
-                       chartsRefresh();
-               }
-       }
+                                               <i class="fa fa-circle"></i> The excellent <a href="http://dygraphs.com/" target="_blank">Dygraphs.com</a> web chart library,
+                                               <i class="fa fa-copyright"></i> Copyright 2009, Dan Vanderkam, <a href="http://dygraphs.com/legal.html" target="_blank">MIT License</a>
 
-       function pauseGraphs() {
-               if(refresh_mode == REFRESH_PAUSED) return;
+                                               <i class="fa fa-circle"></i> <a href="http://omnipotent.net/jquery.sparkline/" target="_blank">jQuery Sparklines</a> web chart library,
+                                               <i class="fa fa-copyright"></i> Copyright 2009-2012, Splunk Inc., <a href="http://opensource.org/licenses/BSD-3-Clause" target="_blank">New BSD License</a>
 
-               //mylog('PauseGraphs()');
-               refresh_mode = REFRESH_PAUSED;
-               $('.mainchart_play_button').button('pause');
-       }
+                                               <i class="fa fa-circle"></i> <a href="http://benpickles.github.io/peity/" target="_blank">Peity</a> web chart library,
+                                               <i class="fa fa-copyright"></i> Copyright 2009-2015, Ben Pickles, <a href="https://github.com/benpickles/peity/blob/master/MIT-LICENCE" target="_blank">MIT License</a>
 
-       // refresh the proper chart
-       // this is an internal function.
-       // never call it directly, or new javascript threads will be spawn
-       var timeout;
-       function chartsRefresh() {
-               if(resize_request) {
-                       resizeCharts();
-                       resize_request = false;
-                       // refresh_mode = REFRESH_ALWAYS;
-               }
+                                               <i class="fa fa-circle"></i> <a href="https://rendro.github.io/easy-pie-chart/" target="_blank">Easy Pie Chart</a> web chart library,
+                                               <i class="fa fa-copyright"></i> Copyright 2013, Robert Fleischmann, <a href="https://github.com/rendro/easy-pie-chart/blob/master/LICENSE" target="_blank">MIT License</a>
 
-               last_refresh = new Date().getTime();
+                                               <i class="fa fa-circle"></i> <a href="http://bernii.github.io/gauge.js/" target="_blank">Gauge.js</a> web chart library,
+                                               <i class="fa fa-copyright"></i> Copyright, Bernard Kobos, <a href="http://bernii.github.io/gauge.js/" target="_blank">MIT License</a>
 
-               if(refresh_mode == REFRESH_PAUSED) {
-                       if(mode == MODE_MAIN && mainchart.last_updated == 0)
-                               mainChartRefresh();
-                       else
-                               timeout = setTimeout(chartsRefresh, 500);
+                                               <i class="fa fa-circle"></i> <a href="https://jquery.org/" target="_blank">jQuery</a>,
+                                               <i class="fa fa-copyright"></i> Copyright 2015, jQuery Foundation, <a href="https://jquery.org/license/" target="_blank">MIT License</a>
 
-                       return;
-               }
+                                               <i class="fa fa-circle"></i> <a href="http://getbootstrap.com/getting-started/" target="_blank">Bootstrap</a>,
+                                               <i class="fa fa-copyright"></i> Copyright 2015, Twitter, <a href="http://getbootstrap.com/getting-started/#license-faqs" target="_blank">MIT License</a>
 
-                    if(mode == MODE_THUMBS)            thumbChartsRefresh();
-               else if(mode == MODE_GROUP_THUMBS)  groupChartsRefresh();
-               else if(mode == MODE_MAIN)              mainChartRefresh();
-               else                                    timeout = setTimeout(triggerRefresh, 500);
-       }
+                                               <i class="fa fa-circle"></i> <a href="http://www.bootstraptoggle.com/" target="_blank">Bootstrap Toggle</a>,
+                                               <i class="fa fa-copyright"></i> Copyright (c) 2011-2014 Min Hur, The New York Times Company, <a href="https://github.com/minhur/bootstrap-toggle/blob/master/LICENSE" target="_blank">MIT License</a>
 
-       // callback for refreshing the charts later
-       // this is an internal function.
-       // never call it directly, or new javascript threads will be spawn
-       function triggerRefresh() {
-               //mylog('triggerRefresh()');
-
-               // cleanup has to take place when the charts are not refreshed
-               // since the refreshing thread is in this function, it means
-               // nothing is being refreshed.
-               cleanupCharts();
-
-                    if(mode == MODE_THUMBS)            timeout = setTimeout(chartsRefresh, 200);
-               else if(mode == MODE_GROUP_THUMBS)      timeout = setTimeout(chartsRefresh, 200);
-               else if(mode == MODE_MAIN)              timeout = setTimeout(chartsRefresh, 200);
-               else                                    timeout = setTimeout(triggerRefresh, 500);
-       }
+                                               <i class="fa fa-circle"></i> <a href="https://jamesflorentino.github.io/nanoScrollerJS/" target="_blank">NanoScroller</a>,
+                                               <i class="fa fa-copyright"></i> Copyright 2012, James Florentino, <a href="https://github.com/jamesflorentino/nanoScrollerJS/blob/master/LICENSE" target="_blank">MIT License</a>
 
-       // refresh the main chart
-       // make sure we don't loose the refreshing thread
-       function mainChartRefresh() {
-               //mylog('mainChartRefresh()');
+                                               <i class="fa fa-circle"></i> <a href="https://github.com/marcj/css-element-queries" target="_blank">CSS Element Queries</a>,
+                                               <i class="fa fa-copyright"></i> Copyright Marc J. Schmidt, <a href="https://github.com/marcj/css-element-queries/blob/master/LICENSE" target="_blank">MIT License</a>
 
-               if(mode != MODE_MAIN || !mainchart) {
-                       triggerRefresh();
-                       return;
-               }
+                                               <i class="fa fa-circle"></i> <a href="https://fortawesome.github.io/Font-Awesome/" target="_blank">FontAwesome</a>,
+                                               <i class="fa fa-copyright"></i> Created by Dave Gandy, Font: <a href="http://scripts.sil.org/OFL" target="_blank">SIL OFL 1.1 License</a>, CSS: <a href="http://opensource.org/licenses/mit-license.html" target="_blank">MIT License</a>
 
-               if(!refreshChart(mainchart, hiddenChartRefresh))
-                       hiddenChartRefresh();
-       }
+                                               <i class="fa fa-circle"></i> <a href="http://www.iconsdb.com/soylent-red-icons/seo-performance-icon.html" target="_blank">IconsDB.com Icons</a>, Icons provided as CC0 1.0 Universal (CC0 1.0) Public Domain Dedication.
 
-       function hiddenChartRefresh() {
-               refreshHiddenChart(triggerRefresh);
-       }
+                                               <i class="fa fa-circle"></i> <a href="http://morrisjs.github.io/morris.js/" target="_blank">morris.js</a>,
+                                               <i class="fa fa-copyright"></i> Copyright 2013, Olly Smith, <a href="http://morrisjs.github.io/morris.js/" target="_blank">Simplified BSD License</a>
 
-       function roundRobinRefresh(charts, startat) {
-               var refreshed = false;
+                                               <i class="fa fa-circle"></i> <a href="http://raphaeljs.com/" target="_blank">Raphaël</a>,
+                                               <i class="fa fa-copyright"></i> Copyright 2008, Dmitry Baranovskiy, <a href="http://raphaeljs.com/license.html" target="_blank">MIT License</a>
 
-               // find a chart to refresh
-               var all = charts.length;
-               var cur = startat;
-               var count = 0;
+                                               <i class="fa fa-circle"></i> <a href="http://C3js.org/" target="_blank">C3</a>,
+                                               <i class="fa fa-copyright"></i> Copyright 2013, Masayuki Tanaka, <a href="https://github.com/masayuki0812/c3/blob/master/LICENSE" target="_blank">MIT License</a>
 
-               for(count = 0; count < all ; count++, cur++) {
-                       if(cur >= all) cur = 0;
+                                               <i class="fa fa-circle"></i> <a href="http://D3js.org/" target="_blank">D3</a>,
+                                               <i class="fa fa-copyright"></i> Copyright 2015, Mike Bostock, <a href="http://opensource.org/licenses/BSD-3-Clause" target="_blank">BSD License</a>
 
-                       if(charts[cur].enabled) {
-                               //mylog('going to refresh chart ' + charts[cur].name);
-                               refreshed = refreshChart(charts[cur], chartsRefresh);
-                               if(refreshed) break;
-                       }
-               }
+                                       </small>
+                               </div>
+                       </div>
+               </div>
+       </div>
 
-               if(!refreshed) triggerRefresh();
-               return cur;
-       }
+       <div class="modal fade" id="welcomeModal" tabindex="-1" role="dialog" aria-labelledby="welcomeModalLabel">
+               <div class="modal-dialog modal-lg" role="document">
+                       <div class="modal-content">
+                               <div class="modal-header">
+                                       <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                                       <h4 class="modal-title" id="welcomeModalLabel">Welcome!</h4>
+                               </div>
+                               <div class="modal-body">
+                                               <div class="p">
+                                               <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> is the fastest way to visualize metrics. It is a resource efficient, highly optimized system for collecting and visualizing any type of realtime timeseries data, from CPU usage, disk activity, SQL queries, API calls, web site visitors, etc.
+                                               </div>
+                                               <div class="p">
+                                               <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> tries to visualize the truth of <b>now</b>, in its <b>greatest detail</b>, so that you can get insights of what is happening now and what just happened, on your systems and applications.
+                                               </div>
+                                               <div class="p">
+                                               To make a chart in <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b>, you just need a <b>number</b>. Just a number you can read somehow. <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> will turn this number to a real time, interactive, web chart. For collecting these numbers, it supports <a href="https://github.com/firehol/netdata/wiki/External-Plugins" target="_blank">external plugins</a>, even <a href="https://github.com/firehol/netdata/wiki/General-Info---charts.d" target="_blank">shell</a> or <a href="https://github.com/firehol/netdata/wiki/General-Info---charts.d" target="_blank">node.js</a> plugins. Any computer program, in any language, that can print a few lines of text on its standard output, can be a netdata data collector.
+                                               </div>
+                                               <div class="p">
+                                               <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> can embed charts everywhere, like this one <div data-netdata="system.cpu" data-dimensions="system" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-show-value-of-system-at="system.cpu.system.modal.1"></div> (my CPU system usage which is <span id="system.cpu.system.modal.1" style="display: inline-block; width: 40px; text-align: right;"></span>%),
+                                               or this one <div data-netdata="ipv4.tcppackets" data-dimensions="received" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-show-value-of-received-at="ipv4.tcppackets.received.modal.1"></div> (my IPv4 received TCP packets, which are <span id="ipv4.tcppackets.received.modal.1" style="display: inline-block; width: 60px; text-align: right;"></span>/second).
+                                               </div>
+                                               <div class="p">
+                                               You can have <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> charts on your site too. Just give it a <code>div</code> and a real time chart, zoomable and draggable will appear (try it even on these tiny ones - <b>drag</b> them to pan horizontally, <b>shift + drag</b> to zoom in, on <b>chrome shift + mouse wheel</b> to zoom in/out, <b>double click</b> on them to reset them - don't be afraid of <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> performance - <a href="https://github.com/firehol/netdata/wiki/Performance" target="_blank">a raspberry pi 2 can sustain 300 charts updates per second</a>!).
+                                               </div>
+                                               <div class="p">
+                                               For more information please refer to the <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata wiki</a></b>.
+                                               </div>
+                               </div>
+                               <div class="modal-footer">
+                                       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                               </div>
+                       </div>
+               </div>
+       </div>
 
-       // refresh the thumb charts
-       // make sure we don't loose the refreshing thread
-       var last_thumb_updated = 0;
-       function thumbChartsRefresh() {
-               //mylog('thumbChartsRefresh()');
+       <div class="modal fade" id="helpModal" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel">
+               <div class="modal-dialog modal-lg" role="document">
+                       <div class="modal-content">
+                               <div class="modal-header">
+                                       <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                                       <h4 class="modal-title" id="helpModalLabel">Dashboard Help</h4>
+                               </div>
+                               <div class="modal-body">
+
+                                       <h4>Dygraphs (line, area and stacked area charts)</h4>
+
+                                       <!-- Nav tabs -->
+                                       <ul class="nav nav-tabs" role="tablist">
+                                               <li role="presentation" class="active"><a href="#help_mouse" aria-controls="help_mouse" role="tab" data-toggle="tab">Mouse Interface</a></li>
+                                               <li role="presentation"><a href="#help_touch" aria-controls="help_touch" role="tab" data-toggle="tab">Touch Interface</a></li>
+                                       </ul>
+
+                                       <!-- Tab panes -->
+                                       <div class="tab-content">
+                                               <div role="tabpanel" class="tab-pane active" id="help_mouse">
+                                                       <div class="p">
+                                                               <h4>Mouse Over / Hover</h4>
+                                                               Mouse over on a chart to show, at its legend, the values for the timestamp under the mouse (the chart will also highlight the point at the chart).
+                                                               <br/>
+                                                               All the other visible charts will also show and highlight their values for the same timestamp.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>Trag Chart Contents</h4>
+                                                               Trag the contents of a chart to pan it horizontally.
+                                                               <br/>
+                                                               All the charts will follow soon after you let the chart alone (this little delay is by design: it speeds up your browser and lets you focus on what you are exploring).
+                                                               <br/>
+                                                               Once a chart is panned, auto refreshing stops for all charts. To enable it again, <b>double click</b> a panned chart.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>Double Click</h4>
+                                                               Double Click a chart to reset all the charts to their default auto-refreshing state.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>SHIFT + Trag</h4>
+                                                               While pressing the shift key, select with the mouse and area of a chart, to zoom in. The other charts will follow too. Zooming is performed in two phases:
+                                                               <ul>
+                                                                       <li>The already loaded chart contents are zoomed (low resolution)</li>
+                                                                       <li>New data are transfered from the netdata server, to refresh the chart with possibly more detail.</li>
+                                                               </ul>
+                                                               Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>SHIFT + Mouse Wheel <small>(does not work on firefox and IE/Edge)</small></h4>
+                                                               While pressing the shift key and the mouse pointer is over the contents of a chart, scroll the mouse wheel to zoom in or out. This kind of zooming is aligned to center below the mouse pointer. The other charts will follow too.
+                                                               <br/>
+                                                               Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>Legend Operations</h4>
+                                                               Click on the label or value of a dimension, will select / unselect this dimension.
+                                                               <br/>
+                                                               You can press any of the shift or control keys and the click on legend labels or values, to select / unselect multiple dimensions.
+                                                       </div>
+                                               </div>
+                                               <div role="tabpanel" class="tab-pane" id="help_touch">
+                                                       <div class="p">
+                                                               <h4>Single Tap</h4>
+                                                               Single Tap on the contents of a chart to show, at its legend, the values for the timestamp tapped (the chart will also highlight the point at the chart).
+                                                               <br/>
+                                                               All the other visible charts will also show and highlight their values for the same timestamp.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>Trag Chart Contents</h4>
+                                                               Touch and Trag the contents of a chart to pan it horizontally.
+                                                               <br/>
+                                                               All the charts will follow soon after you let the chart alone (this little delay is by design: it speeds up your browser and lets you focus on what you are exploring).
+                                                               <br/>
+                                                               Once a chart is panned, auto refreshing stops for all charts. To enable it again, <b>double tap</b> a panned chart.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>Double Tap</h4>
+                                                               Double tap a chart to reset all the charts to their default auto-refreshing state.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>Zoom <small>(does not work on firefox and IE/Edge)</small></h4>
+                                                               With two fingers, zoom in or out.
+                                                               <br/>
+                                                               Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
+                                                       </div>
+                                                       <hr/>
+                                                       <div class="p">
+                                                               <h4>Legend Operations</h4>
+                                                               Tap on the label or value of a dimension, will select / unselect this dimension.
+                                                       </div>
+                                               </div>
+                                       </div>
+                               </div>
+                               <div class="modal-footer">
+                                       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                               </div>
+                       </div>
+               </div>
+       </div>
 
-               if(mycharts.length == 0 || mode != MODE_THUMBS) {
-                       triggerRefresh();
-                       return;
-               }
+       <div class="modal fade" id="optionsModal" tabindex="-1" role="dialog" aria-labelledby="optionsModalLabel">
+               <div class="modal-dialog modal-lg" role="document">
+                       <div class="modal-content">
+                               <div class="modal-header">
+                                       <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                                       <h4 class="modal-title" id="optionsModalLabel">netdata dashboard options</h4>
+                               </div>
+                               <div class="modal-body">
+                                       <center>
+                                               <small style="color: #BBBBBB;">Settings take effect immediately and are saved permanently to browser local storage (except the refresh on focus / always option).
+                                               <br/>
+                                               To reset all options (including charts sizes) to their defaults, click <a href="#" onclick="NETDATA.resetOptions(); return false;">here</a>.</small>
+                                       </center>
+                                       <div style="padding: 10px;"></div>
+
+                                       <!-- Nav tabs -->
+                                       <ul class="nav nav-tabs" role="tablist">
+                                               <li role="presentation" class="active"><a href="#settings_performance" aria-controls="settings_performance" role="tab" data-toggle="tab">Performance</a></li>
+                                               <li role="presentation"><a href="#settings_sync" aria-controls="settings_sync" role="tab" data-toggle="tab">Synchronization</a></li>
+                                               <li role="presentation"><a href="#settings_visual" aria-controls="settings_visual" role="tab" data-toggle="tab">Visual</a></li>
+                                       </ul>
+
+                                       <!-- Tab panes -->
+                                       <div class="tab-content">
+                                               <div role="tabpanel" class="tab-pane active" id="settings_performance">
+                                                       <form id="optionsForm" method="get" class="form-horizontal">
+                                                               <div class="form-group">
+                                                                       <table>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control"><input id="stop_updates_when_focus_is_lost" type="checkbox" checked data-toggle="toggle" data-offstyle="danger" data-onstyle="success" data-on="On Focus" data-off="Always" data-width="110px"></td>
+                                                                               <td class="option-info"><strong>When to refresh the charts?</strong><br/>
+                                                                                       <small>When set to <b>On Focus</b>, the charts will stop being updated if the page / tab does not have the focus of the user. When set to <b>Always</b>, the charts will always be refreshed. Set it to <b>On Focus</b> it to lower the CPU requirements of the browser (and extend the battery of laptops and tablets) when this page does not have your focus. Set to <b>Always</b> to work on another window (i.e. change the settings of something) and have the charts auto-refresh in this window.</small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control">
+                                                                               <input id="eliminate_zero_dimensions" type="checkbox" checked data-toggle="toggle" data-on="Non Zero" data-off="All" data-width="110px">
+                                                                               </td>
+                                                                               <td class="option-info"><strong>Which dimensions to show?</strong><br/>
+                                                                                       <small>When set to <b>Non Zero</b>, dimensions that have all their values (within the current view) set to zero will not be transfered from the netdata server (except if all dimensions of the chart are zero, in which case this setting does nothing - all dimensions are transfered and shown). When set to <b>All</b>, all dimensions will always be shown. Set it to <b>Non Zero</b> to lower the data transfered between netdata and your browser, lower the CPU requirements of your browser (fewer lines to draw) and increase the focus on the legends (fewer entries at the legends).</small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control"><input id="destroy_on_hide" type="checkbox" data-toggle="toggle" data-on="Destroy" data-off="Hide" data-width="110px"></td>
+                                                                               <td class="option-info"><strong>How to handle hidden charts?</strong><br/>
+                                                                                       <small>When set to <b>Destroy</b>, charts that are not in the current viewport of the browser (are above, or below the visible area of the page), will be destroyed and re-created if and when they become visible again. When set to <b>Hide</b>, the not-visible charts will be just hidden, to simplify the DOM and speed up your browser. Set it to <b>Destroy</b>, to lower the memory requirements of your browser. Set it to <b>Hide</b> for smoother page scrolling.</small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       </table>
+                                                               </div>
+                                                       </form>
+                                               </div>
+                                               <div role="tabpanel" class="tab-pane" id="settings_sync">
+                                                       <form id="optionsForm" method="get" class="form-horizontal">
+                                                               <div class="form-group">
+                                                                       <table>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control"><input id="parallel_refresher" type="checkbox" checked data-toggle="toggle" data-on="Parallel" data-off="Sequencial" data-width="110px"></td>
+                                                                               <td class="option-info"><strong>Which chart refresh policy to use?</strong><br/>
+                                                                                       <small>When set to <b>parallel</b>, visible charts are refreshed in parallel (all queries are sent to netdata server in parallel) and are rendered asynchronously. When set to <b>sequencial</b> charts are refreshed one after another. Set it to parallel if your browser can cope with it (most modern browsers do), set it to sequencial if you work on an older/slower computer.</small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       <tr class="option-row" id="concurrent_refreshes_row">
+                                                                               <td class="option-control"></td>
+                                                                               <td class="option-info">
+                                                                                       <table>
+                                                                                       <tr class="option-row">
+                                                                                       <td class="option-control">
+                                                                                       <input id="concurrent_refreshes" type="checkbox" checked data-toggle="toggle" data-on="Resync" data-off="Best Effort" data-width="110px">
+                                                                                       </td>
+                                                                                       <td class="option-info">
+                                                                                       <strong>Shall we re-sync chart refreshes?</strong><br/>
+                                                                                       <small>When set to <b>Resync</b>, the dashboard will attempt to re-synchronize all the charts so that they are refreshed concurrently. When set to <b>Best Effort</b>, each chart may be refreshed with a little time difference to the others. Normally, the dashboard starts refreshing them in parallel, but depending on the speed of your computer and the network latencies, charts start having a slight time difference. Setting this to <b>Resync</b> will attempt to re-synchronize the charts on every update. Setting it to <b>Best Effort</b> may lower the pressure on your browser and the network.</small>
+                                                                                       </td>
+                                                                                       </tr>
+                                                                                       </table>
+                                                                               </td>
+                                                                               </tr>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control"><input id="sync_selection" type="checkbox" checked data-toggle="toggle" data-on="Sync" data-off="Don't Sync" data-onstyle="success" data-offstyle="danger" data-width="110px"></td>
+                                                                               <td class="option-info"><strong>Sync hover selection on all charts?</strong><br/>
+                                                                                       <small>When enabled, a selection on one chart will automatically select the same time on all other visible charts and the legends of all visible charts will be updated to show the selected values. When disabled, only the chart getting the user's attention will be selected. Enable it to get better insights of the data. Disable it if you are on a very slow computer that cannot actually do it.</small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control"><input id="sync_pan_and_zoom" type="checkbox" checked data-toggle="toggle"  data-on="Sync" data-off="Don't Sync" data-onstyle="success" data-offstyle="danger" data-width="110px"></td>
+                                                                               <td class="option-info"><strong>Sync pan and zoom on all charts?</strong><br/>
+                                                                                       <small>When enabled, pan and zoom operations on a chart will be replicated to all charts (even the ones that are not currently visible - of course only when they will become visible). When disabled, pan and zoom operations will not be propagated to other charts.</small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       </table>
+                                                               </div>
+                                                       </form>
+                                               </div>
+                                               <div role="tabpanel" class="tab-pane" id="settings_visual">
+                                                       <form id="optionsForm" method="get" class="form-horizontal">
+                                                               <div class="form-group">
+                                                                       <table>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control"><input id="pan_and_zoom_data_padding" type="checkbox" checked data-toggle="toggle"  data-on="Pad" data-off="Don't Pad" data-width="110px"></td>
+                                                                               <td class="option-info"><strong>Enable data padding when panning and zooming?</strong><br/>
+                                                                                       <small>When set to <b>Pad</b> the charts will be padded with more data, both before and after the visible area, thus giving the impression the whole database is loaded. This padding will happen only after the first pan or zoom operation on the chart (initially all charts have only the visible data). When set to <b>Don't Pad</b> only the visible data will be transfered from the netdata server, even after the first pan and zoom operation.</small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control"><input id="smooth_plot" type="checkbox" checked data-toggle="toggle"  data-on="Smooth" data-off="Rough" data-width="110px"></td>
+                                                                               <td class="option-info"><strong>Enable Bézier lines on charts?</strong><br/>
+                                                                                       <small>When set to <b>Smooth</b> the charts libraries that support it, will plot smooth curves instead of simple straight lines to connect the points.</small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       </table>
+                                                               </div>
+                                                       </form>
+                                               </div>
+                                       </div>
+                               </div>
+                               <div class="modal-footer">
+                                       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                               </div>
+                       </div>
+               </div>
+       </div>
 
-               last_thumb_updated = roundRobinRefresh(mycharts, last_thumb_updated);
+</body>
+</html>
+<script>
+
+var demo_hostname = 'netdata.firehol.org';
+// var demo_hostname = 'box';
+
+if(document.location.hostname === demo_hostname) {
+       document.getElementById('masthead').style.display = 'block';
+}
+
+var options = {
+       sparklines_registry: {},
+       submenu_names: {},
+       data: null,
+       hostname: 'netdata_server', // will be overwritten by the netdata server
+       categories: new Array(),
+       categories_idx: {},
+       families: new Array(),
+       families_idx: {},
+
+       chartsPerRow: 0,
+       chartsMinWidth: 1450,
+       chartsHeight: 180,
+       sparklinesHeight: 60
+};
+
+// generate a sparkline
+// used in the documentation
+function sparkline(chart, dimension, units) {
+       var key = chart + '.' + dimension;
+
+       if(typeof units === 'undefined')
+               units = '';
+
+       if(typeof options.sparklines_registry[key] === 'undefined')
+               options.sparklines_registry[key] = { count: 1 };
+       else
+               options.sparklines_registry[key].count++;
+
+       key = key + '.' + options.sparklines_registry[key].count;
+
+       var h = '<div data-netdata="' + chart + '" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-dimensions="' + dimension + '" data-show-value-of-' + dimension + '-at="' + key + '"></div> (<span id="' + key + '" style="display: inline-block; min-width: 50px; text-align: right;">X</span>' + units + ')';
+
+       return h;
+}
+
+function chartsPerRow(total) {
+       if(options.chartsPerRow === 0) {
+               width = Math.floor(total / options.chartsMinWidth);
+               if(width === 0) width = 1;
+               return width;
        }
-
-       // refresh the group charts
-       // make sure we don't loose the refreshing thread
-       var last_group_updated = 0;
-       function groupChartsRefresh() {
-               //mylog('groupChartsRefresh()');
-
-               if(!group_charts || group_charts.length == 0 || mode != MODE_GROUP_THUMBS) {
-                       //mylog('cannot refresh charts');
-                       triggerRefresh();
-                       return;
+       else return options.chartsPerRow;
+}
+
+function prioritySort(a, b) {
+       if(a.priority < b.priority) return -1;
+       if(a.priority > b.priority) return 1;
+       if(a.name < b.name) return -1;
+       return 1;
+}
+
+function sortObjectByPriority(object) {
+       var idx = {};
+       var sorted = new Array();
+
+       for(var i in object) {
+               if(typeof idx[i] === 'undefined') {
+                       idx[i] = object[i];
+                       sorted.push(i);
                }
-
-               last_group_updated = roundRobinRefresh(group_charts, last_group_updated);
        }
 
+       sorted.sort(function(a, b) {
+               if(idx[a].priority < idx[b].priority) return -1;
+               if(idx[a].priority > idx[b].priority) return 1;
+               if(a < b) return -1;
+               return 1;
+       });
 
-       // ------------------------------------------------------------------------
-       // switch the screen between views
-       // these should be called only from initXXXX()
-
-       function disableChart(i) {
-               //mylog('disableChart(' + i + ')');
-
-               var chart = null;
-
-               var count = 0;
-               if(mode == MODE_GROUP_THUMBS && group_charts) {
-                       $.each(group_charts, function(i, c) {
-                               if(c.enabled) count++;
-                       });
-
-                       if(i < group_charts.length) chart = group_charts[i];
-               }
-               else if(mode == MODE_THUMBS) {
-                       $.each(mycharts, function(i, c) {
-                               if(c.enabled) count++;
-                       });
-
-                       if(i < mycharts.length) chart = mycharts[i];
-               }
-
-               if(!chart) return;
+       return sorted;
+}
 
-               if(count <= 1) {
-                       alert('Cannot close the last chart shown.');
-                       return;
-               }
+// ----------------------------------------------------------------------------
 
-               if(chart) {
-                       //mylog("disabling chart " + chart.name);
-                       chart.disablethisplease = true;
-               }
+function gaugeChart(title, width, dimensions, colors) {
+       if(typeof colors === 'undefined')
+               colors = '';
+       
+       if(typeof dimensions === 'undefined')
+               dimensions = '';
+       
+       return '<div data-netdata="CHART_UNIQUE_ID"'
+                                                       + ' data-dimensions="' + dimensions + '"'
+                                                       + ' data-chart-library="gauge"'
+                                                       + ' data-gauge-adjust="width"'
+                                                       + ' data-title="' + title + '"'
+                                                       + ' data-width="' + width + '"'
+                                                       + ' data-before="0"'
+                                                       + ' data-after="-CHART_DURATION"'
+                                                       + ' data-points="CHART_DURATION"'
+                                                       + ' data-colors="' + colors + '"'
+                                                       + ' role="application"></div>';
+}
+
+// ----------------------------------------------------------------------------
+
+var menuData = {
+       'system': {
+               title: 'System Overview',
+               info: 'Overview of the key system metrics.'
+       },
+
+       'ap': {
+               title: 'Access Points',
+               info: undefined
+       },
+
+       'tc': {
+               title: 'Quality of Service',
+               info: 'Netdata collects and visualizes tc class utilization using its <a href="https://github.com/firehol/netdata/blob/master/plugins.d/tc-qos-helper.sh" target="_blank">tc-helper plugin</a>. If you also use <a href="http://firehol.org/#fireqos" target="_blank">FireQOS</a> for setting up QoS, netdata automatically collects interface and class names. If your QoS configuration includes overheads calculation, the values shown here will include these overheads (the total bandwidth for the same interface as reported in the Network Interfaces section, will be lower than the total bandwidth reported here). Also, data collection may have a slight time difference compared to the interface (QoS data collection is implemented with a BASH script, so a shift in data collection of a few milliseconds should be justified).'
+       },
+
+       'net': {
+               title: 'Network Interfaces',
+               info: 'Per network interface statistics collected from <code>/proc/net/dev</code>.'
+       },
+
+       'ipv4': {
+               title: 'IPv4 Networking',
+               info: undefined
+       },
+
+       'ipvs': {
+               title: 'IP Virtual Server',
+               info: undefined
+       },
+
+       'netfilter': {
+               title: 'Firewall (netfilter)',
+               info: undefined
+       },
+
+       'cpu': {
+               title: 'CPUs',
+               info: undefined
+       },
+
+       'mem': {
+               title: 'Memory',
+               info: undefined
+       },
+
+       'disk': {
+               title: 'Disks',
+               info: undefined
+       },
+
+       'sensors': {
+               title: 'Sensors',
+               info: undefined
+       },
+
+       'nfsd': {
+               title: 'File Server (nfsd)',
+               info: undefined
+       },
+
+       'apps': {
+               title: 'Applications',
+               info: 'Per application statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics for applications of interest, defined in <code>/etc/netdata/apps_groups.conf</code> (the default is <a href="https://github.com/firehol/netdata/blob/master/conf.d/apps_groups.conf" target="_blank">here</a>). The plugin internaly builds a process tree (much like <code>ps fax</code> does), and groups processes together (evaluating both child and parent processes) so that the result is always a chart with a predefined set of dimensions (of course, only application groups found running are reported).<br/><b>IMPORTANT</b>: The values shown here are not 100% accurate. They only include values for the processes running. If an application is spawning childs continiously, which are terminated in just a few milliseconds (like shell scripts do), the values reported will be inaccurate. Linux does report the values for the exited childs of a process. However, these values are reported to the parent process <b>only when the child exits</b>. If these values, of the exited child processes, were also aggregated in the charts below, the charts would have been full of spikes, presenting unrealisting utilization for each process group. So, we decided to ignore these values and present only the utilization of <b>the currently running processes</b>.',
+               height: 1.5
+       },
+
+       'netdata': {
+               title: 'Netdata Monitoring',
+               info: undefined
+       },
+
+       'example': {
+               title: 'Example Charts',
+               info: undefined
+       },
+};
+
+var submenuData = {
+       'mem.ksm': {
+               title: 'Memory Deduper',
+               info: 'Kernel Same-page Merging (KSM) is the kernel memory de-duper.'
        }
-
-       function cleanThisChart(chart, emptydivs) {
-               //mylog('cleanThisChart(' + chart.name + ', ' + emptydivs +')');
-
-               if(chart.dashboard) {
-                       chart.dashboard.clear();
-                       chart.dashboard = null;
-
-                       if(chart.control_wrapper) {
-                               chart.control_wrapper.clear();
-                               chart.control_wrapper = null;
-                       }
-
-                       if(chart.hidden_wrapper) {
-                               chart.hidden_wrapper.clear();
-                               chart.hidden_wrapper = null;
-                       }
-
-                       chart.control_data = null;
-               }
-
-               if(chart.chart) chart.chart.clearChart();
-               chart.chart = null;
-
-               if(emptydivs) {
-                       var div = document.getElementById(chart.div);
-                       if(div) {
-                               div.style.display = 'none';
-                               div.innerHTML = "";
+};
+
+var chartData = {
+       'system.cpu': {
+               info: 'Total CPU utilization (all cores). 100% here means there is no CPU idle time at all. You can get per core usage at the <a href="#cpu">CPUs</a> section and per application usage at the <a href="#apps">Applications Monitoring</a> section.<br/>Keep an eye on <b>iowait</b> ' + sparkline('system.cpu', 'iowait', '%') + '. If it is constantly high, your disks are a bottleneck and they slow your system down.<br/>Another important metric worth monitoring, is <b>softirq</b> ' + sparkline('system.cpu', 'softirq', '%') + '. A constantly high percentage of softirq may indicate network drivers issues.'
+       },
+
+       'system.load': {
+               info: 'Current system load read from <code>/proc/loadavg</code>.',
+               height: 0.7
+       },
+
+       'system.io': {
+               info: 'Total Disk I/O, for all disks, read from <code>/proc/vmstat</code>. You can get detailed information about each disk at the <a href="#disk">Disks</a> section and per application Disk usage at the <a href="#apps">Applications Monitoring</a> section.'
+       },
+
+       'system.swapio': {
+               info: 'Total Swap I/O, read from <code>/proc/vmstat</code>. (netdata measures both <code>in</code> and <code>out</code>. If either of them is not shown in the chart, it is because it is zero - you can change the page settings to always render all the available dimensions on all charts).'
+       },
+
+       'system.pgfaults': {
+               info: 'Total page faults, read from <code>/proc/vmstat</code>. <b>Major page faults</b> indicates that the system is using its swap. You can find which applications use the swap at the <a href="#apps">Applications Monitoring</a> section.'
+       },
+
+       'system.entropy': {
+               colors: '#CC22AA',
+               info: '<a href="https://en.wikipedia.org/wiki/Entropy_(computing)" target="_blank">Entropy</a>, read from <code>/proc/sys/kernel/random/entropy_avail</code>, is like a pool of random numbers that are mainly used in cryptography. It is advised that the pool remains always <a href="https://blog.cloudflare.com/ensuring-randomness-with-linuxs-random-number-generator/" target="_blank">above 200</a>. If the pool of entropy gets empty, you risk your security to be predictable and you should install a user-space random numbers generating daemon, like <a href="http://www.issihosts.com/haveged/" target="_blank">haveged</a>, to keep the pool in healthy levels.'
+       },
+
+       'system.forks': {
+               colors: '#5555DD',
+               info: 'The number of new processes created per second, read from <code>/proc/stat</code>.'
+       },
+
+       'system.intr': {
+               colors: '#DD5555',
+               info: 'Total number of CPU interrupts, read from <code>/proc/stat</code>. Check <code>system.interrupts</code> that gives more detail about each interrupt and also the <a href="#cpu">CPUs</a> section where interrupts are analyzed per CPU core.'
+       },
+
+       'system.interrupts': {
+               info: 'CPU interrupts in detail, read from <code>/proc/interrupts</code>. At the <a href="#cpu">CPUs</a> section, interrupts are analyzed per CPU core.'
+       },
+
+       'system.softirqs': {
+               info: 'CPU softirqs in detail, read from <code>/proc/softirqs</code>. At the <a href="#cpu">CPUs</a> section, softirqs are analyzed per CPU core.'
+       },
+
+       'system.processes': {
+               info: 'System processes, read from <code>/proc/stat</code>. <b>Blocked</b> are processes that are willing to execute but they cannot, e.g. because they wait for disk activity.'
+       },
+
+       'system.active_processes': {
+               info: 'All system active processes, read from <code>/proc/loadavg</code>.'
+       },
+
+       'system.ctxt': {
+               info: '<a href="https://en.wikipedia.org/wiki/Context_switch" target="_blank">Context Switches</a>, read from <code>/proc/stat</code>, is the switching of the CPU from one process, task or thread to another. If there are many processes or threads willing to execute and very few CPU cores available to handle them, the system is making more context switching to balance the CPU resources among them. The whole process is computationally intensive. The more the context switches, the slower the system gets.'
+       },
+
+       'system.idlejitter': {
+               colors: '#5555AA',
+               info: 'Idle jitter is calculated by netdata. A thread is spawned that requests to sleep for a few microseconds. When the system wakes it up, it measures how many microseconds have passed. The different between the requested and the actual duration of the sleep, is the <b>idle jitter</b>. This number is useful in realtime environments, where CPU jitter can affect the quality of the service (like VoIP media gateways).'
+       },
+
+       'system.ipv4': {
+               info: 'Total IPv4 Traffic, read from <code>/proc/net/netstat</code>. This includes <code>lo</code> device traffic.'
+       },
+
+       'system.ram': {
+               info: 'System memory, read from <code>/proc/meminfo</code>.'
+       },
+
+       'system.swap': {
+               info: 'System swap memory, read from <code>/proc/meminfo</code>.'
+       },
+
+       'mem.committed': {
+               colors: NETDATA.colors[3]
+       },
+
+       'apps.cpu': {
+               height: 2.0
+       },
+
+       'apps.preads': {
+               height: 2.0
+       },
+
+       'apps.pwrites': {
+               height: 2.0
+       },
+
+       'tc.qos': {
+               heads: [
+                       function(id) {
+                               if(id.match(/.*-ifb$/))
+                                       return gaugeChart('Inbound', '12%', '', '#5555AA');
+                               else
+                                       return gaugeChart('Outbound', '12%', '', '#AA9900');
                        }
-
-                       div = document.getElementById(chart.div + "_parent");
-                       if(div) {
-                               div.style.display = 'none';
-                               div.innerHTML = "";
+               ]
+       },
+
+       'net.net': {
+               heads: [
+                       gaugeChart('Received', '12%', 'received'),
+                       gaugeChart('Sent', '12%', 'sent')
+               ]
+       },
+
+       'disk.util': {
+               colors: '#FF5588',
+               heads: [
+                       gaugeChart('Utilization', '12%', '', '#FF5588')
+               ]
+       },
+
+       'disk.backlog': {
+               colors: '#0099CC'
+       },
+
+       'disk.io': {
+               heads: [
+                       gaugeChart('Read', '12%', 'reads'),
+                       gaugeChart('Write', '12%', 'writes')
+               ]
+       },
+
+       'netfilter.sockets': {
+               colors: '#88AA00',
+               heads: [
+                       gaugeChart('Active Connections', '12%', '', '#88AA00')
+               ]
+       },
+
+       'netfilter.new': {
+               heads: [
+                       gaugeChart('New Connections', '12%', 'new', '#5555AA')
+               ]
+       },
+
+       'disk.iotime': {
+               height: 0.5
+       },
+       'disk.mops': {
+               height: 0.5
+       },
+       'disk.svctm': {
+               height: 0.5
+       },
+       'disk.avgsz': {
+               height: 0.5
+       },
+       'disk.await': {
+               height: 0.5
+       },
+
+       'apache.connections': {
+               colors: NETDATA.colors[4],
+               mainheads: [
+                       gaugeChart('Connections', '12%', '', NETDATA.colors[4])
+               ]
+       },
+
+       'apache.requests': {
+               colors: NETDATA.colors[0],
+               mainheads: [
+                       gaugeChart('Connections', '12%', '', NETDATA.colors[0])
+               ]
+       },
+
+       'apache.net': {
+               colors: NETDATA.colors[3],
+               mainheads: [
+                       gaugeChart('Bandwidth', '12%', '', NETDATA.colors[3])
+               ]
+       },
+
+       'apache.workers': {
+               mainheads: [
+                       function(id) {
+                               return  '<div data-netdata="' + id + '"'
+                                       + ' data-dimensions="busy"'
+                                       + ' data-append-options="percentage"'
+                                       + ' data-gauge-max-value="100"'
+                                       + ' data-chart-library="gauge"'
+                                       + ' data-title="Workers Utilization"'
+                                       + ' data-units="percentage %"'
+                                       + ' data-gauge-adjust="width"'
+                                       + ' data-width="12%"'
+                                       + ' data-before="0"'
+                                       + ' data-after="-CHART_DURATION"'
+                                       + ' data-points="CHART_DURATION"'
+                                       + ' role="application"></div>';
                        }
-               }
-
-               //mylog("chart " + chart.name + " cleaned with option " + emptydivs);
+               ]
+       },
+
+       'apache.bytesperreq': {
+               colors: NETDATA.colors[3],
+               height: 0.5
+       },
+
+       'apache.reqpersec': {
+               colors: NETDATA.colors[4],
+               height: 0.5
+       },
+
+       'apache.bytespersec': {
+               colors: NETDATA.colors[6],
+               height: 0.5
+       },
+
+       'nginx.connections': {
+               colors: NETDATA.colors[4],
+               mainheads: [
+                       gaugeChart('Connections', '12%', '', NETDATA.colors[4])
+               ]
+       },
+
+       'nginx.requests': {
+               colors: NETDATA.colors[0],
+               mainheads: [
+                       gaugeChart('Requests', '12%', '', NETDATA.colors[0])
+               ]
        }
+};
 
-       // cleanup the previously shown charts
-       function cleanupCharts() {
-               //mylog('cleanupCharts()');
-
-               if(mode != MODE_MAIN && mainchart) {
-                       if(mainchart.chart) cleanThisChart(mainchart);
-                       mainchart = null;
-               }
-
-               if(mode != MODE_GROUP_THUMBS && group_charts) {
-                       clearGroupGraphs();
-               }
-
-               // cleanup the disabled charts
-               $.each(mycharts, function(i, c) {
-                       if(c.disablethisplease && c.enabled) {
-                               cleanThisChart(c, 'emptydivs');
-                               c.disablethisplease = false;
-                               c.enabled = false;
-                               resize_request = true;
-                               //mylog("disabled chart " + c.name + " removed");
-                       }
-               });
-
-               if(group_charts) $.each(group_charts, function(i, c) {
-                       if(c.disablethisplease && c.enabled) {
-                               cleanThisChart(c, 'emptydivs');
-                               c.disablethisplease = false;
-                               c.enabled = false;
-                               resize_request = true;
-                               //mylog("disabled chart " + c.name + " removed");
-                       }
-               });
-
-               // we never cleanup the thumb charts
+function anyAttribute(obj, attr, key, def) {
+       if(typeof obj[key] !== 'undefined') {
+               if(typeof obj[key][attr] !== 'undefined')
+                       return obj[key][attr];
        }
-
-       function updateUI() {
-               $('[data-toggle="tooltip"]').tooltip({'placement': 'top', 'container': 'body', 'html': true});
-
-               $('[data-spy="scroll"]').each(function () {
-                       var $spy = $(this).scrollspy('refresh')
-               })
+       return def;
+}
+
+function menuTitle(menu) {
+       return anyAttribute(menuData, 'title', menu, menu);
+}
+
+function menuInfo(menu) {
+       return anyAttribute(menuData, 'title', menu, null);
+}
+
+function menuHeight(menu, relative) {
+       return anyAttribute(menuData, 'height', menu, 1.0) * relative;
+}
+
+function submenuTitle(menu, submenu) {
+       var key = menu + '.' + submenu;
+       return anyAttribute(submenuData, 'title', key, submenu);
+}
+
+function submenuInfo(menu, submenu) {
+       var key = menu + '.' + submenu;
+       return anyAttribute(submenuData, 'info', key, null);
+}
+
+function submenuHeight(menu, submenu, relative) {
+       var key = menu + '.' + submenu;
+       return anyAttribute(submenuData, 'height', key, 1.0) * relative;
+}
+
+
+function chartInfo(id) {
+       if(typeof chartData[id] !== 'undefined' && typeof chartData[id].info !== 'undefined')
+               return '<div class="chart-message netdata-chart-alignment" role="document">' + chartData[id].info + '</div>';
+       else
+               return '';
+}
+
+function chartHeight(id, def) {
+       if(typeof chartData[id] !== 'undefined' && typeof chartData[id].height !== 'undefined')
+               return def * chartData[id].height;
+       else
+               return def;
+}
+
+
+// ----------------------------------------------------------------------------
+
+// enrich the data structure returned by netdata
+// to reflect our menu system and content
+function enrichChartData(chart) {
+       var tmp = chart.type.split('_')[0];
+
+       switch(tmp) {
+               case 'ap':
+               case 'net':
+               case 'disk':
+                       chart.menu = tmp;
+                       break;
+
+               case 'tc':
+                       chart.menu = tmp;
+
+                       // find the interface name from the name
+                       if(typeof options.submenu_names[chart.family] === 'undefined' || options.submenu_names[chart.family] === chart.family)
+                               options.submenu_names[chart.family] = chart.name.split('.')[1].split('_')[0];
+
+                       // increase the priority of IFB devices
+                       if(chart.id.match(/.*-ifb$/))
+                               chart.priority--;
+
+                       break;
+
+               default:
+                       chart.menu = chart.type;
+                       break;
        }
 
-       var thumbsScrollPosition = null;
-       function switchToMainGraph() {
-               //mylog('switchToMainGraph()');
-
-               if(!mainchart) return;
-
-               if(!group_charts) thumbsScrollPosition = window.pageYOffset;
-
-               document.getElementById('maingraph_container').style.display = 'block';
-               document.getElementById('thumbgraphs_container').style.display = 'none';
-               document.getElementById('groupgraphs_container').style.display = 'none';
-
-               document.getElementById("main_menu_div").innerHTML = "<ul class=\"nav navbar-nav\"><li><a href=\"javascript:switchToThumbGraphs();\">Back to Home</a></li><li class=\"active\"><a href=\"#\">" + mainchart.title + "</a></li></ul>";
-
-               window.scrollTo(0, 0);
-
-               mode = MODE_MAIN;
-               playGraphs();
-               updateUI();
+       chart.submenu = chart.family;
+}
+
+// ----------------------------------------------------------------------------
+
+function name2id(s) {
+       return s
+               .replace(' ', '_')
+               .replace('(', '_')
+               .replace(')', '_')
+               .replace('.', '_')
+               .replace('/', '_');
+}
+
+function headMain(charts, duration) {
+       var head = '';
+
+       if(typeof charts['system.swap'] !== 'undefined')
+               head += '<div style="margin-right: 10px;" data-netdata="system.swap"'
+               + ' data-dimensions="free"'
+               + ' data-append-options="percentage"'
+               + ' data-chart-library="easypiechart"'
+               + ' data-title="Free Swap"'
+               + ' data-units="%"'
+               + ' data-easypiechart-max-value="100"'
+               + ' data-width="8%"'
+               + ' data-before="0"'
+               + ' data-after="-' + duration.toString() + '"'
+               + ' data-points="' + duration.toString() + '"'
+               + ' data-colors="#DD4400"'
+               + ' role="application"></div>';
+
+       if(typeof charts['system.io'] !== 'undefined') {
+               head += '<div style="margin-right: 10px;" data-netdata="system.io"'
+               + ' data-dimensions="in"'
+               + ' data-chart-library="easypiechart"'
+               + ' data-title="Disk Read"'
+               + ' data-units="KB / s"'
+               + ' data-width="10%"'
+               + ' data-before="0"'
+               + ' data-after="-' + duration.toString() + '"'
+               + ' data-points="' + duration.toString() + '"'
+               + ' role="application"></div>';
+
+               head += '<div style="margin-right: 10px;" data-netdata="system.io"'
+               + ' data-dimensions="out"'
+               + ' data-chart-library="easypiechart"'
+               + ' data-title="Disk Write"'
+               + ' data-units="KB / s"'
+               + ' data-width="10%"'
+               + ' data-before="0"'
+               + ' data-after="-' + duration.toString() + '"'
+               + ' data-points="' + duration.toString() + '"'
+               + ' role="application"></div>';
        }
 
-       function switchToThumbGraphs() {
-               //mylog('switchToThumbGraphs()');
-
-               document.getElementById('maingraph_container').style.display = 'none';
-               document.getElementById('thumbgraphs_container').style.display = 'block';
-               document.getElementById('groupgraphs_container').style.display = 'none';
-
-               document.getElementById("main_menu_div").innerHTML = mainmenu;
-
-               if(thumbsScrollPosition) window.scrollTo(0, thumbsScrollPosition);
-
-               // switch mode
-               mode = MODE_THUMBS;
-               playGraphs();
-               updateUI();
+       if(typeof charts['system.cpu'] !== 'undefined')
+               head += '<div data-netdata="system.cpu"'
+               + ' data-chart-library="gauge"'
+               + ' data-title="CPU"'
+               + ' data-units="%"'
+               + ' data-gauge-max-value="100"'
+               + ' data-width="18%"'
+               + ' data-after="-' + duration.toString() + '"'
+               + ' data-points="' + duration.toString() + '"'
+               + ' data-colors="' + NETDATA.colors[12] + '"'
+               + ' role="application"></div>';
+
+       if(typeof charts['system.ipv4'] !== 'undefined') {
+               head += '<div style="margin-right: 10px;" data-netdata="system.ipv4"'
+               + ' data-dimensions="received"'
+               + ' data-chart-library="easypiechart"'
+               + ' data-title="IPv4 Inbound"'
+               + ' data-units="kbps"'
+               + ' data-width="10%"'
+               + ' data-before="0"'
+               + ' data-after="-' + duration.toString() + '"'
+               + ' data-points="' + duration.toString() + '"'
+               + ' role="application"></div>';
+
+               head += '<div style="margin-right: 10px;" data-netdata="system.ipv4"'
+               + ' data-dimensions="sent"'
+               + ' data-chart-library="easypiechart"'
+               + ' data-title="IPv4 Outbound"'
+               + ' data-units="kbps"'
+               + ' data-width="10%"'
+               + ' data-before="0"'
+               + ' data-after="-' + duration.toString() + '"'
+               + ' data-points="' + duration.toString() + '"'
+               + ' role="application"></div>';
        }
 
-       function switchToGroupGraphs() {
-               //mylog('switchToGroupGraphs()');
-
-               if(!group_charts) return;
-
-               if(!mainchart) thumbsScrollPosition = window.pageYOffset;
-
-               document.getElementById('maingraph_container').style.display = 'none';
-               document.getElementById('thumbgraphs_container').style.display = 'none';
-               document.getElementById('groupgraphs_container').style.display = 'block';
-
-               document.getElementById("main_menu_div").innerHTML = "<ul class=\"nav navbar-nav\"><li><a href=\"javascript:switchToThumbGraphs();\">Back to Home</a></li><li class=\"active\"><a href=\"#\">" + group_charts[0].group_tag + " charts</a></li></ul>";
-
-               window.scrollTo(0, 0);
-
-               mode = MODE_GROUP_THUMBS;
-               playGraphs();
-               updateUI();
+       if(typeof charts['system.ram'] !== 'undefined')
+               head += '<div style="margin-right: 10px;" data-netdata="system.ram"'
+               + ' data-dimensions="cached|free"'
+               + ' data-append-options="percentage"'
+               + ' data-chart-library="easypiechart"'
+               + ' data-title="Available RAM"'
+               + ' data-units="%"'
+               + ' data-easypiechart-max-value="100"'
+               + ' data-width="8%"'
+               + ' data-after="-' + duration.toString() + '"'
+               + ' data-points="' + duration.toString() + '"'
+               + ' data-colors="' + NETDATA.colors[7] + '"'
+               + ' role="application"></div>';
+
+       return head;
+}
+
+function generateHeadCharts(type, chart, duration) {
+       var head = '';
+       var hcharts = anyAttribute(chartData, type, chart.context, []);
+       if(hcharts.length > 0) {
+               var hi = 0, hlen = hcharts.length;
+               while(hi < hlen) {
+                       if(typeof hcharts[hi] === 'function')
+                               head += hcharts[hi](chart.id).replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
+                       else
+                               head += hcharts[hi].replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
+                       hi++;
+               }
        }
-
-
-       // ------------------------------------------------------------------------
-       // Group Charts
-
-       var group_charts = null;
-       function initGroupGraphs(group) {
-               var count = 0;
-               
-               if(group_charts) clearGroupGraphs();
-               group_charts = new Array();
-
-               var groupbody = "";
-               $.each(mycharts, function(i, c) {
-                       if(c.group_tag == group) {
-                               group_charts[count] = [];
-                               group_charts[count] = $.extend(true, {}, c);
-                               group_charts[count].div += "_group";
-                               group_charts[count].enabled = true;
-                               group_charts[count].chart = null;
-                               group_charts[count].last_updated = 0;
-                               count++;
+       return head;
+}
+
+function renderPage(menus, data) {
+       var div = document.getElementById('charts_div');
+       var pcent_width = Math.floor(100 / chartsPerRow($(div).width()));
+
+       // find the proper duration for per-second updates
+       var duration = Math.round(($(div).width() * pcent_width / 100 * data.update_every / 3) / 60) * 60;
+       var html = '';
+       var sidebar = '<ul class="nav dashboard-sidenav" data-spy="affix" id="sidebar_ul">';
+       var mainhead = headMain(data.charts, duration);
+
+       // sort the menus
+       var main = sortObjectByPriority(menus);
+       var i = 0, len = main.length;
+       while(i < len) {
+               var menu = main[i++];
+
+               // generate an entry at the main menu
+
+               sidebar += '<li class=""><a href="#' + menu + '">' + menus[menu].title + '</a><ul class="nav">';
+               html += '<div role="section"><div role="sectionhead"><h1 id="' + menu + '" role="heading">' + menus[menu].title + '</h1></div><div id="' + menu + '" role="document">';
+
+               if(menus[menu].info !== null)
+                       html += menus[menu].info;
+
+               // console.log(' >> ' + menu + ' (' + menus[menu].priority + '): ' + menus[menu].title);
+
+               var shtml = '';
+               var mhead = '<div style="width: 100%; text-align: center;">' + mainhead;
+               mainhead = '';
+
+               // sort the submenus of this menu
+               var sub = sortObjectByPriority(menus[menu].submenus);
+               var si = 0, slen = sub.length;
+               while(si < slen) {
+                       var submenu = sub[si++];
+
+                       // generate an entry at the submenu
+                       sidebar += '<li class><a href="#' + name2id(menu + '_' + submenu) + '">' + menus[menu].submenus[submenu].title + '</a></li>';
+                       shtml += '<div class="netdata-group-container" id="submenu_' + name2id(menu + '_' + submenu) + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + name2id(menu + '_' + submenu) + '" class="netdata-chart-alignment" role="heading">' + menus[menu].submenus[submenu].title + '</h2>';
+
+                       if(menus[menu].submenus[submenu].info !== null)
+                               shtml += '<div class="chart-message netdata-chart-alignment" role="document">' + menus[menu].submenus[submenu].info + '</div>';
+
+                       var head = '<div style="width: 100%; text-align: center;">';
+                       var chtml = '';
+
+                       // console.log('    \------- ' + submenu + ' (' + menus[menu].submenus[submenu].priority + '): ' + menus[menu].submenus[submenu].title);
+
+                       // sort the charts in this submenu of this menu
+                       menus[menu].submenus[submenu].charts.sort(prioritySort);
+                       var ci = 0, clen = menus[menu].submenus[submenu].charts.length;
+                       while(ci < clen) {
+                               var chart = menus[menu].submenus[submenu].charts[ci++];
+
+                               // generate the submenu heading charts
+                               mhead += generateHeadCharts('mainheads', chart, duration);
+                               head += generateHeadCharts('heads', chart, duration);
+
+                               // generate the chart
+                               chtml += chartInfo(chart.context) + '<div data-netdata="' + chart.id + '"'
+                                       + ' data-width="' + pcent_width.toString() + '%"'
+                                       + ' data-height="' + chartHeight(chart.context, options.chartsHeight).toString() + 'px"'
+                                       + ' data-before="0"'
+                                       + ' data-after="-' + duration.toString() + '"'
+                                       + ' data-id="' + name2id(options.hostname + '/' + chart.id) + '"'
+                                       + ' data-colors="' + anyAttribute(chartData, 'colors', chart.context, '') + '"'
+                                       + ' role="application"></div>';
+
+                               // console.log('         \------- ' + chart.id + ' (' + chart.priority + '): ' + chart.context  + ' height: ' + menus[menu].submenus[submenu].height);
                        }
-               });
-               group_charts.sort(chartssort);
 
-               var sizes = groupChartSizes();
+                       head += '</div>';
+                       shtml += head + chtml + '</div>';
+               }
 
-               var groupbody = "";
-               $.each(group_charts, function(i, c) {
-                       c.chartOptions.width = sizes.width;
-                       c.chartOptions.height = sizes.height;
+               mhead += '</div>';
+               sidebar += '</ul></li>';
+               html += mhead + shtml + '</div></div><hr role="separator"/>';
+       }
 
-                       groupbody += "<div class=\"thumbgraph\" id=\"" + c.div + "_parent\"><table><tr><td><div class=\"thumbgraph\" id=\"" + c.div + "\">" + chartIsLoadingHTML(c.name, c.chartOptions.width, c.chartOptions.height) + "</div></td></tr><tr><td align=\"center\">" + thumbChartActions(i, c, 'nogroup') + "</td></tr></table></div>";
-               });
-               groupbody += "";
+       sidebar += '</ul>';
+       div.innerHTML = html;
+       document.getElementById('sidebar').innerHTML = sidebar;
+       finalizePage();
+}
+
+function renderChartsAndMenu(data) {
+       var menus = {};
+       var charts = data.charts;
+
+       for(var c in charts) {
+               enrichChartData(charts[c]);
+
+               // create the menu
+               if(typeof menus[charts[c].menu] === 'undefined') {
+                       menus[charts[c].menu] = {
+                               priority: charts[c].priority,
+                               submenus: {},
+                               title: menuTitle(charts[c].menu),
+                               info: menuInfo(charts[c].menu),
+                               height: menuHeight(charts[c].menu, options.chartsHeight)
+                       };
+               }
+               
+               if(charts[c].priority < menus[charts[c].menu].priority)
+                       menus[charts[c].menu].priority = charts[c].priority;
+
+               // create the submenu
+               if(typeof menus[charts[c].menu].submenus[charts[c].submenu] === 'undefined') {
+                       menus[charts[c].menu].submenus[charts[c].submenu] = {
+                               priority: charts[c].priority,
+                               charts: new Array(),
+                               title: null,
+                               info: submenuInfo(charts[c].menu, charts[c].submenu),
+                               height: submenuHeight(charts[c].menu, charts[c].submenu, menus[charts[c].menu].height)
+                       };
+               }
+               
+               if(charts[c].priority < menus[charts[c].menu].submenus[charts[c].submenu].priority)
+                       menus[charts[c].menu].submenus[charts[c].submenu].priority = charts[c].priority;
 
-               document.getElementById("groupgraphs").innerHTML = groupbody;
-               switchToGroupGraphs();
+               // index the chart in the menu/submenu
+               menus[charts[c].menu].submenus[charts[c].submenu].charts.push(charts[c]);
        }
 
-       function clearGroupGraphs() {
-               if(group_charts && group_charts.length) {
-                       $.each(group_charts, function(i, c) {
-                               cleanThisChart(c, 'emptydivs');
-                       });
-
-                       group_charts = null;
+       for(var m in menus) {
+               for(var s in menus[m].submenus) {
+                       // set the family using a name
+                       if(typeof options.submenu_names[s] !== 'undefined') {
+                               menus[m].submenus[s].title = s + ' (' + options.submenu_names[s] + ')';
+                       }
+                       else {
+                               menus[m].submenus[s].title = submenuTitle(m, s);
+                       }
                }
-
-               document.getElementById("groupgraphs").innerHTML = "";
        }
 
+       renderPage(menus, data);
+}
 
-       // ------------------------------------------------------------------------
-       // Global entry point
-       // initialize the thumb charts
+function downloadAllCharts(netdata_url) {
+       if(typeof netdata_url === 'undefined' || netdata_url === null)
+               netdata_url = NETDATA.serverDefault;
 
-       // load the charts from the server
-       // generate html for the thumbgraphs to support them
-       function initCharts() {
-               var width = thumbWidth();
-               var height = TARGET_THUMB_GRAPH_HEIGHT;
+       NETDATA.pause(function() {
 
-               loadCharts(null, function(c) {
-                       mycharts = c;
+               // download all the charts the server knows
+               NETDATA.chartRegistry.downloadAll(netdata_url, function(data) {
 
-                       if(mycharts == null || mycharts.length == 0) {
-                               alert("Cannot load data from server.");
-                               return;
-                       }
+                       options.data = data;
+                       options.hostname = data.hostname;
+                       document.getElementById('hostname').innerHTML = options.hostname;
+                       document.getElementById('hostname').href = NETDATA.serverDefault;
+                       document.title = options.hostname + ' dashboard';
+                       
+                       renderChartsAndMenu(data);
 
-                       var thumbsContainer = document.getElementById("thumbgraphs");
-                       if(!thumbsContainer) {
-                               alert("Cannot find the thumbsContainer");
-                               return;
-                       }
+                       // prepare our DOM
+//                     prepareScreen(data);
 
-                       mycharts.sort(chartssort);
-
-                       document.getElementById('hostname_id').innerHTML = mycharts[0].hostname;
-                       document.title = mycharts[0].hostname;
-
-                       // create an array for grouping all same-type graphs together
-                       var categories = new Array();
-                       $.each(mycharts, function(i, c) {
-                               c.chartOptions.width = width;
-                               c.chartOptions.height = height;
-
-                               // calculate how many point to show for each chart
-                               c.points_to_show = Math.round(c.entries / c.group) - 1;
-
-                               // show max 10 mins of data
-                               if(c.points_to_show * c.group > THUMBS_MAX_TIME_TO_SHOW) c.points_to_show = THUMBS_MAX_TIME_TO_SHOW / c.group;
-
-                               if(c.enabled) {
-                                       var j;
-                                       var h = "<div class=\"thumbgraph\" id=\"" + c.div + "_parent\"><table><tr><td><div class=\"thumbgraph\" id=\"" + c.div + "\">" + chartIsLoadingHTML(c.name, c.chartOptions.width, c.chartOptions.height) + "</div></td></tr><tr><td align=\"center\">"
-                                       + thumbChartActions(i, c)
-                                       +       "</td></tr></table></div>";
-
-                                       // find the categories object for this type
-                                       for(j = 0; j < categories.length ;j++) {
-                                               if(categories[j].name == c.type) {
-                                                       categories[j].html += h;
-                                                       categories[j].count++;
-                                                       break;
-                                               }
-                                       }
-
-                                       if(j == categories.length) {
-                                               categories.push({name: c.type, title: c.category, description: '', priority: 0, count: 1, glyphicon: c.glyphicon, html: h});
-                                       }
-                               }
-                       });
-
-                       $.each(categories, function(i, a) {
-                                    if(a.name == "system") a.priority = 1;
-                               else if(a.name == "net") a.priority = 2;
-                               else if(a.name == "tc") a.priority = 3;
-                               else if(a.name == "conntrack") a.priority = 4;
-                               else if(a.name == "ipvs") a.priority = 5;
-                               else if(a.name == "ipv4") a.priority = 6;
-                               else if(a.name == "cpu") a.priority = 7;
-                               else if(a.name == "mem") a.priority = 8;
-                               else if(a.name == "disk") a.priority = 9;
-                               else a.priority = 99;
-
-                               a.html = "<tr><td id=\"" + a.name + "\"><ol class=\"breadcrumb graphs\"><li class=\"active\"><span class=\"glyphicon " + a.glyphicon + "\"></span> &nbsp; <a id=\"" + a.name + "\" href=\"#" + a.name + "\"><b>" + a.title + "</b> " + a.description + " </a></li></ol></td></tr><tr><td><div class=\"thumbgraphs\">" + a.html + "</td></tr>";
-                       });
-
-                       function categoriessort(a, b) {
-                               if(a.priority < b.priority) return -1;
-                               return 1;
-                       }
-                       categories.sort(categoriessort);
-                       
-                       // combine all the htmls into one
-                       var allcategories = "<table width=\"100%\">";
-                       mainmenu = "<ul class=\"nav navbar-nav\"><li><a href=\"#\">Home</a></li>";
-                       $.each(categories, function(i, a) {
-                               allcategories += a.html;
-                               mainmenu += "<li><a href=\"#" + a.name + "\">" + a.title + "</a></li>";
-                       });
-                       allcategories += "</table>";
-                       mainmenu += "</ul>";
-
-                       thumbsContainer.innerHTML = allcategories;
-                       switchToThumbGraphs();
+                       // due to affix issues, prepareScreen() will unpause
+                       // netdata as needed
                });
+       });
+}
+
+// ----------------------------------------------------------------------------
+
+function finalizePage() {
+       // resize all charts - without starting the background thread
+       // this has to be done while NETDATA is paused
+       // if we ommit this, the affix menu will be wrong, since all
+       // the Dom elements are initially zero-sized
+       NETDATA.parseDom();
+
+       // let it run (update the charts)
+       NETDATA.unpause();
+
+       // check if we have to jump to a specific section
+       var hash = location.hash.replace('#','');
+       if(hash != '') {
+               // Clear the hash in the URL
+               // location.hash = '';   // delete front "//" if you want to change the address bar
+               var offset = $(location.hash).offset();
+               if(typeof offset !== 'undefined')
+                       $('html, body').animate({ scrollTop: offset.top }, 0);
        }
 
-       </script>
-</head>
+       /* activate bootstrap sidebar (affix) */
+       $('#sidebar').affix({
+               offset: {
+                       top: (document.location.hostname === demo_hostname)?150:0,
+                       bottom: 0
+               }
+       });
+
+       /* fix scrolling of very long affix lists
+          http://stackoverflow.com/questions/21691585/bootstrap-3-1-0-affix-too-long
+        */
+       $('#sidebar').on('affixed.bs.affix', function() {
+               $(this).removeAttr('style');
+       });
+       
+       /* activate bootstrap scrollspy (needed for sidebar) */
+       $(document.body).scrollspy({
+               target: '#sidebar',
+               offset: $(window).height() / 3 // controls the diff of the <hX> element to the top, to select it
+       });
 
-<body role="document" data-spy="scroll" data-target="#main_menu_div">
-    <nav id="mynav" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
-      <div class="container">
-        <div class="navbar-header">
-          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main_menu_div">
-            <span class="sr-only">Toggle navigation</span>
-            <span class="icon-bar"></span>
-            <span class="icon-bar"></span>
-            <span class="icon-bar"></span>
-          </button>
-          <a class="navbar-brand" href="javascript:switchToThumbGraphs();" id="hostname_id">NetData</a>
-        </div>
-        <div class="collapse navbar-collapse" id="main_menu_div">
-          <ul class="nav navbar-nav">
-            <li><a href="#">Home</a></li>
-          </ul>
-        </div><!--/.nav-collapse -->
-      </div>
-    </nav>
-
-    <div class="container graphs" id="maingraph_container" style="display: none">
-               <table>
-                       <tr><td>
-                       <div class="maingraph">
-                                       <table>
-                                               <tr><td>
-                                               <div class="maingraph" id="maingraph"></div>
-                                               <div id="maingraph_dashboard">
-                                                       <div class="maingraph" id="maingraph_hidden" style="display: none"></div>
-                                                       <div class="maingraph" id="maingraph_control"></div>
-                                               </div>
-                                               </td></tr>
-                                               <tr><td align="center">
-                                                       <div class="btn-group">
-                                                               <form id="mainchartform">
-                                                                       <div class="btn-group btn-group" data-toggle="tooltip" title=" click <span class='glyphicon glyphicon-play'></span> to have the graph auto-refresh, or click <span class='glyphicon glyphicon-pause'></span> to pause the graph. When paused the graph can be zoomed and panned horizontally." >
-                                                                               <button type="button" class="btn btn-primary mainchart_play_button" data-play-text="<span class='glyphicon glyphicon-pause'></span>" data-pause-text="<span class='glyphicon glyphicon-play'></span>" onClick="setMainChartPlay('toggle');">
-                                                                                       <span class="glyphicon glyphicon-pause"></span>
-                                                                               </button>
-                                                                       </div>
-                                                                       <div class="btn-group btn-group" data-toggle="tooltip" title="use the maximum ( <span class='glyphicon glyphicon-signal'></span> ) or the average ( <span class='glyphicon glyphicon-align-justify'></span> ) value of grouped points" >
-                                                                               <button type="button" class="btn btn-primary mainchart_avg_button" data-max-text="<span class='glyphicon glyphicon-signal'></span>" data-average-text="<span class='glyphicon glyphicon-align-justify'></span>" onClick="setMainChartGroupMethod('toggle');">
-                                                                                       <span class="glyphicon glyphicon-signal"></span>
-                                                                               </button>
-                                                                       </div>
-<!--                                                                   <div class="btn-group btn-group" data-toggle="buttons">
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="show the MAX point among all points grouped">
-                                                                                       <input type="radio" name="groupmethod" id="groupmax" onChange="setMainChartGroupMethod('max');">
-                                                                                       <span class="glyphicon glyphicon-signal"></span>
-                                                                               </label>
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="show the AVERAGE of all points grouped">
-                                                                                       <input type="radio" name="groupmethod" id="groupaverage" onChange="setMainChartGroupMethod('average');">
-                                                                                       <span class="glyphicon glyphicon-align-justify"></span>
-                                                                               </label>
-                                                                       </div>
--->                                                                    <div class="btn-group btn-group" data-toggle="buttons" >
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="do not group points, show the raw data">
-                                                                                       <input type="radio" name="group" id="group1" onChange="setMainChartGroup(1);">1
-                                                                               </label>
-                                                                               
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="group in half, show 1 every 2 points of data">
-                                                                                       <input type="radio" name="group" id="group2" onChange="setMainChartGroup(2);">2
-                                                                               </label>
-
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="group every 5 points of data">
-                                                                                       <input type="radio" name="group" id="group5" onChange="setMainChartGroup(5);">5
-                                                                               </label>
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="group every 10 points of data">
-                                                                                       <input type="radio" name="group" id="group10" onChange="setMainChartGroup(10);">10
-                                                                               </label>
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="group every 15 points of data">
-                                                                                       <input type="radio" name="group" id="group15" onChange="setMainChartGroup(15);">15
-                                                                               </label>
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="group every 20 points of data">
-                                                                                       <input type="radio" name="group" id="group20" onChange="setMainChartGroup(20);">20
-                                                                               </label>
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="group every 30 points of data">
-                                                                                       <input type="radio" name="group" id="group30" onChange="setMainChartGroup(30);">30
-                                                                               </label>
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="group every 45 points of data">
-                                                                                       <input type="radio" name="group" id="group45" onChange="setMainChartGroup(45);">45
-                                                                               </label>
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="group every 60 points of data">
-                                                                                       <input type="radio" name="group" id="group60" onChange="setMainChartGroup(60);">60
-                                                                               </label>
-                                                                       </div>
-                                                                       <div class="btn-group btn-group" data-toggle="tooltip" title="maximized ( <span class='glyphicon glyphicon-fullscreen'></span> ) or normal ( <span class='glyphicon glyphicon-resize-small'></span> ) view of the graph" >
-                                                                               <button type="button" class="btn btn-primary mainchart_max_button" data-maximized-text="<span class='glyphicon glyphicon-resize-small'></span>" data-normal-text="<span class='glyphicon glyphicon-fullscreen'></span>" onClick="setMainChartMax('toggle');">
-                                                                                       <span class="glyphicon glyphicon-fullscreen"></span>
-                                                                               </button>
-                                                                       </div>
-<!--                                                                   <div class="btn-group btn-group" data-toggle="buttons" >
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="NORMAL chart size">
-                                                                                       <input type="radio" name="chartmax" id="chartnormal" onChange="setMainChartMax('normal');">
-                                                                                       <span class="glyphicon glyphicon-resize-small"></span>
-                                                                               </label>
-                                                                               <label class="btn btn-primary" data-toggle="tooltip" title="MAXIMIZED chart size">
-                                                                                       <input type="radio" name="chartmax" id="chartmax" onChange="setMainChartMax('maximized');">
-                                                                                       <span class="glyphicon glyphicon-fullscreen"></span>
-                                                                               </label>
-                                                                       </div>
--->                                                            </form>
-                                                       </div>
-                                                       </td></tr>
-                                       </table>
-                          </div><!-- /.maingraph -->
-                       </td></tr>
-               </table>
-       </div>
+       document.getElementById('footer').style.display = 'block';
 
-    <div class="container graphs" id="thumbgraphs_container">
-       <div class="allgraphs" id="thumbgraphs">
-               <table width="100%">
-                       <tr><td id="splash" align="center" style="vertical-align:middle">
-                               <h1>
-                               Welcome to <b>NetData</b>!
-                               <br/><br/>
-                               <span class="glyphicon glyphicon-off"></span>
-                               <br/><br/>
-                               loading charts
-                               <br/><br/>
-                               <span class="label label-default">Please wait...</span>
-                               </h1>
-                       </td></tr>
-               </table>
-       </div>
-       </div>
 
-    <div class="container graphs" id="groupgraphs_container">
-       <div class="allgraphs" id="groupgraphs">
-       </div>
-       </div>
+       var update_options_modal = function() {
+               // console.log('update_options_modal');
 
-    <div class="container graphs" id="groupgraphs_container">
-       &nbsp;<p/>
-       <hr/>
-    <h4>NetData</h4>
-    Realtime System Information over the web for all linux systems.
-    <p/>
-    Distributed under GPL.
-    <p/>
-    (c) 2014 Costa Tsaousis <a href="mailto:costa@tsaousis.gr">costa@tsaousis.gr</a>
-       </div>
+               var sync_option = function(option) {
+                       var self = $('#' + option);
 
-       <script type='text/javascript'>
-               google.load('visualization', '1.1', {packages: ['controls']});
+                       if(self.prop('checked') !== NETDATA.getOption(option)) {
+                               // console.log('switching ' + option.toString());
+                               self.bootstrapToggle(NETDATA.getOption(option)?'on':'off');
+                       }
+               }
 
-               $(document).ready(function(){
-                       document.getElementById('splash').height = $(window).height();
+               sync_option('eliminate_zero_dimensions');
+               sync_option('destroy_on_hide');
+               sync_option('parallel_refresher');
+               sync_option('concurrent_refreshes');
+               sync_option('sync_selection');
+               sync_option('sync_pan_and_zoom');
+               sync_option('stop_updates_when_focus_is_lost');
+               sync_option('smooth_plot');
+               sync_option('pan_and_zoom_data_padding');
+
+               if(NETDATA.getOption('parallel_refresher') === false) {
+                       $('#concurrent_refreshes_row').hide();
+               }
+               else {
+                       $('#concurrent_refreshes_row').show();
+               }
+       };
+       NETDATA.setOption('setOptionCallback', update_options_modal);
+
+       // handle options changes
+       $('#eliminate_zero_dimensions').change(function()       { NETDATA.setOption('eliminate_zero_dimensions', $(this).prop('checked')); });
+       $('#destroy_on_hide').change(function()                 { NETDATA.setOption('destroy_on_hide', $(this).prop('checked')); });
+       $('#parallel_refresher').change(function()              { NETDATA.setOption('parallel_refresher', $(this).prop('checked')); });
+       $('#concurrent_refreshes').change(function()            { NETDATA.setOption('concurrent_refreshes', $(this).prop('checked')); });
+       $('#sync_selection').change(function()                  { NETDATA.setOption('sync_selection', $(this).prop('checked')); });
+       $('#sync_pan_and_zoom').change(function()               { NETDATA.setOption('sync_pan_and_zoom', $(this).prop('checked')); });
+       $('#stop_updates_when_focus_is_lost').change(function() { NETDATA.setOption('stop_updates_when_focus_is_lost', $(this).prop('checked')); });
+       $('#smooth_plot').change(function()                     { NETDATA.setOption('smooth_plot', $(this).prop('checked')); });
+       $('#pan_and_zoom_data_padding').change(function()       { NETDATA.setOption('pan_and_zoom_data_padding', $(this).prop('checked')); });
+       
+       if(document.location.hostname === demo_hostname)
+               setTimeout(function() {
+                       $('#welcomeModal').modal();
+               }, 1000);
+}
 
-                       $(document).on('click','.navbar-collapse.in',function(e) {
-                               if( $(e.target).is('a') ) {
-                                       $(this).collapse('hide');
-                               }
-                       });
-                       
-                       $('body').scrollspy({ target: '#main_menu_div' })
-               });
+downloadAllCharts();
 
-       </script>
-</html>
+</script>