made it create by default a dashboard of graphs (all graphs on the same page if possible).
made it create by default a dashboard of graphs (all graphs on the same page if possible).
box@home root committed
Jun 19, 2013 at 21:45 UTC
5ed4e133434b7a89d42ec798f2d4df867f3cffa9
2 files changed
+42
-7
netdata.js
+8
-2
@@ -25,9 +25,15 @@
25
26
var width = charts_widths[index];
27
if(width == 0) width = (window.innerWidth - 50) / 2;
28
- if(width < 10) width = (window.innerWidth - 50) / width;
28
+ if(width <= 10) width = (window.innerWidth - 50) / width;
29
+ if(width < 200) width = 200;
30
30
- 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}});
31
+ var height = charts_heights[index];
32
+ if(height == 0) height = (window.innerHeight - 50) / 2;
33
+ if(height <= 10) height = (window.innerHeight - 50) / height;
34
+ if(height < 100) height = 100;
35
+
36
+ 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}});
37
else console.log('Cannot create chart for ' + charts_urls[index]);
38
}
39
netdata.start
+34
-5
@@ -63,6 +63,38 @@ else
63
echo >&2 "Directory $base/data already exists. Not touching it, however it should be a link '${data}'."
64
fi
65
66
+echo "Finding proper parameters for dashboard..."
67
+
68
+all=`ls "${data}" | grep .json$ | sed "s/\.json$//g"`
69
+count=0
70
+for x in $all
71
+do
72
+ count=$[count + 1]
73
+done
74
+
75
+w=1
76
+h=1
77
+a=1
78
+while [ $a -lt $count ]
79
+do
80
+ if [ $[h+1] -le $w ]
81
+ then
82
+ h=$[h+1]
83
+ else
84
+ w=$[w+1]
85
+ h=$[h-1]
86
+ fi
87
+ a=$[w*h]
88
+done
89
+if [ $w -gt 10 ]
90
+then
91
+ w=10
92
+fi
93
+if [ $h -gt 10 ]
94
+then
95
+ h=10
96
+fi
97
+
98
echo "Generating all.html"
99
cat >all.html <<EOF
100
<!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
117
google.setOnLoadCallback(drawCharts);
118
119
function drawCharts() {
88
- var width = 0; // if zero, auto-adjusts to 50% of screen, 1-10 goes 1/width of screen
89
- var height = 260;
120
+ var width = $w; // if zero, auto-adjusts to 50% of screen, 1-10 goes 1/width of screen
121
+ var height = $h;
122
123
// EDIT: add one line per interface you have
124
// EDIT:
@@ -94,11 +126,8 @@ cat >all.html <<EOF
126
// EDIT: --------------------------------------------------------------------------------
127
EOF
128
97
-all=`ls "${data}" | grep .json$ | sed "s/\.json$//g"`
98
-count=0
129
for x in $all
130
do
101
- count=$[count + 1]
131
cat >>all.html <<EOF2
132
drawChart('${x}', '${x}_div', width, height, "data/${x}.json", "Live Network Usage for ${x}");
133
EOF2