]> arthur.barton.de Git - netdata.git/commitdiff
made it create by default a dashboard of graphs (all graphs on the same
authorbox@home root <costa@tsaousis.gr>
Wed, 19 Jun 2013 18:45:38 +0000 (21:45 +0300)
committerbox@home root <costa@tsaousis.gr>
Wed, 19 Jun 2013 18:45:38 +0000 (21:45 +0300)
page if possible).

netdata.js
netdata.start

index b37ed7133dad47d14ee30604740fce489d4b506d..ac8c63d3b8601679b1d7a3274600a4ddbb79a964 100644 (file)
                
                var width = charts_widths[index];
                if(width == 0) width = (window.innerWidth - 50) / 2;
-               if(width < 10) width = (window.innerWidth - 50) / width;
+               if(width <= 10) width = (window.innerWidth - 50) / width;
+               if(width < 200) width = 200;
                
-               if(charts[index]) charts[index].draw(charts_data[index], {width: width, height: charts_heights[index], title: charts_titles[index], hAxis: {title: "Time of Day"}, vAxis: {title: "Bandwidth in kbps", minValue: 200}});
+               var height = charts_heights[index];
+               if(height == 0) height = (window.innerHeight - 50) / 2;
+               if(height <= 10) height = (window.innerHeight - 50) / height;
+               if(height < 100) height = 100;
+               
+               if(charts[index]) charts[index].draw(charts_data[index], {width: width, height: height, title: charts_titles[index], hAxis: {title: "Time of Day"}, vAxis: {title: "Bandwidth in kbps", minValue: 200}});
                else console.log('Cannot create chart for ' + charts_urls[index]);
        }
        
index 556f4e446b662935e6d177224ba9d273839eec79..2a0cedd7547f63e2f4bfeb2f478b163feb19f27c 100755 (executable)
@@ -63,6 +63,38 @@ else
        echo >&2 "Directory $base/data already exists. Not touching it, however it should be a link '${data}'."
 fi
 
+echo "Finding proper parameters for dashboard..."
+
+all=`ls "${data}" | grep .json$ | sed "s/\.json$//g"`
+count=0
+for x in $all
+do
+       count=$[count + 1]
+done
+
+w=1
+h=1
+a=1
+while [ $a -lt $count ]
+do
+       if [ $[h+1] -le $w ]
+       then
+               h=$[h+1]
+       else
+               w=$[w+1]
+               h=$[h-1]
+       fi
+       a=$[w*h]
+done
+if [ $w -gt 10 ]
+then
+       w=10
+fi
+if [ $h -gt 10 ]
+then
+       h=10
+fi
+
 echo "Generating all.html"
 cat >all.html <<EOF
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -85,8 +117,8 @@ cat >all.html <<EOF
        google.setOnLoadCallback(drawCharts);
 
        function drawCharts() {
-               var width = 0; // if zero, auto-adjusts to 50% of screen, 1-10 goes 1/width of screen
-               var height = 260;
+               var width = $w; // if zero, auto-adjusts to 50% of screen, 1-10 goes 1/width of screen
+               var height = $h;
                
                // EDIT: add one line per interface you have
                // EDIT: 
@@ -94,11 +126,8 @@ cat >all.html <<EOF
                // EDIT: --------------------------------------------------------------------------------
 EOF
 
-all=`ls "${data}" | grep .json$ | sed "s/\.json$//g"`
-count=0
 for x in $all
 do
-       count=$[count + 1]
        cat >>all.html <<EOF2
                drawChart('${x}', '${x}_div', width, height, "data/${x}.json", "Live Network Usage for ${x}");
 EOF2