recalculate graphs arrangement
Costa Tsaousis (ktsaou) committed
Mar 23, 2014 at 18:28 UTC
db34f46ccaf1ec3460d3f898952cbd7275843d61
2 files changed
+17
-5
netdata.js
+3
-2
@@ -48,10 +48,10 @@
48
function drawChart(name, div, width, height, jsonurl, title, vtitle) {
49
var i;
50
51
- for(i = 0; i < charts.length; i++) //>
51
+ for(i = 0; i < charts.length; i++)
52
if(charts[i].name == name) break;
53
54
- if(i >= charts.length) { //>
54
+ if(i >= charts.length) {
55
console.log('Creating new objects for chart ' + name);
56
charts[i] = [];
57
charts[i].chart = null;
@@ -89,6 +89,7 @@
89
if(charts_last_drawn >= charts.length) charts_last_drawn = 0;
90
91
try {
92
+ console.log('Refreshing chart ' + charts[charts_last_drawn].name);
93
refreshChart(charts_last_drawn);
94
}
95
catch(err) {
netdata.start
+14
-3
@@ -91,7 +91,7 @@ cd "$p"
91
92
sleep 1
93
94
-# count all JSON files
94
+# count all graphs
95
all=`wget http://127.0.0.1:19999/list -O - 2>/dev/null`
96
count=0
97
for x in $all
@@ -104,6 +104,8 @@ do
104
fi
105
done
106
107
+echo "We have $count graphs..."
108
+
109
# find the optimal graphs per page
110
w=1
111
h=1
@@ -117,15 +119,23 @@ do
119
w=$[w+1]
120
h=$[h-1]
121
fi
122
+
123
a=$[w*h]
124
done
125
126
+echo "Optimal size is $w x $h..."
127
+
128
# prefer to have wider graphs
129
while [ $w -ge $h ]
130
do
131
w=$[w-1]
132
h=$[h+1]
133
+ a=$[w*h]
134
done
135
+if [ $a -lt $count ]
136
+then
137
+ h=$[h+1]
138
+fi
139
140
# make sure we don't display too small graphs
141
if [ $w -gt 10 ]
@@ -136,6 +146,7 @@ if [ $h -gt 10 ]
146
then
147
h=10
148
fi
149
+echo "Final screen size is $w x $h..."
150
151
cp "${base}/netdata.js" "${data}/"
152
@@ -179,12 +190,12 @@ do
190
vtitle=
191
case "$x" in
192
net.*)
182
- title="Live Network Usage for "
193
+ title="Network Usage for "
194
vtitle="bandwidth in kilobits/s"
195
;;
196
197
disk.*)
187
- title="Live Disk I/O for "
198
+ title="Disk I/O for "
199
vtitle="I/O in kilobytes/s"
200
;;
201