Random Bits of Open Code

Check-in [b6626cc112]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Got colors better, removed grid lines, and got charts onto a single line
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b6626cc112e856a76ba8c61e3f21b91562fbf821
User & Date: jmoon18 2019-04-01 23:49:33
Context
2019-04-02
01:25
Made colors consistent between graphs, everything sorted by cores check-in: 9c7965f210 user: jmoon18 tags: trunk
2019-04-01
23:49
Got colors better, removed grid lines, and got charts onto a single line check-in: b6626cc112 user: jmoon18 tags: trunk
22:45
Initial charts working in cstats check-in: 16897f5b92 user: jmoon18 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ringchart/cstats.scm.

197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291

292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
	  (conc uid ".html")
	(lambda ()
	  (print "<!DOCTYPE html><html><head>"
		 "<title>" uid " data.</title>"
		 "</head><body>\n")
      ;;(print "<script src=canvasjs.min.js></script>")
      (print "<script src=Chart.bundle.min.js></script>")
	  (print "<h2>" uid "</h2>"
		 "<p>Totals: " (to-int my-disk) " GB, cores: " (to-int my-cores) " (includes managers direct usage).</p>"
		 "<table>")
	  (print "<tr><th>Manager</th><th>Storage (GB)</th><th>Cores (normalized)</th></tr>")
      (print "<tr><td>" uid "</td><td>" (to-int my-actual-disk) "</td><td>" (to-int my-actual-cores) "</th></tr>")
	  (for-each
	   (lambda (rec)
         ;;(print "Rec is: " rec)
	     (match
................................................................................
		     (create-datafiles db e-id))
		 ;; emit record to this file 
		 (if (or (> disk-tot 0)(> cpu-tot 0))
		     (print "<tr><td>"
			    (if has-emps (conc "<a href=\"" e-uid ".html\">" e-uid "</a>") e-uid)
			    "</td><td>" disk-tot "</td><td>" cpu-tot "</td></tr>"))))
	      (else (print "ERROR: bad record " rec))))
	   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=? ;") id )))
	  (print "</table>")
(print "<div id='canvas-holder' style='width: 40%'><canvas id='myChart' style='width: 250px; height: 250px'></canvas></div>")
(print "<script>")
(print "var ctx = document.getElementById('myChart').getContext('2d');")
(print "var myChart = new Chart(ctx, {")
(print "    type: 'pie',")
(print "    data: {")
(print "        labels: [")
(print "'" uid"',")
................................................................................
      (let (
	     (disk-tot (to-int e-total))
	     (cpu-tot  (to-int e-cpu-tot))
	     )
	 (if (or (> disk-tot 0)(> cpu-tot 0))
	     (print "'" e-uid "',")
     )))))
   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=?;") id)))
  
;;'Bob', 'Fred', 'Jan', 'Julia', 'Fran', 'Orange'
(print "],")
(print "        datasets: [{")
(print "            label: '# of Votes',")
(print "            data: [")
(print "'" (to-int my-actual-disk) "',")
(for-each
  (lambda (rec)
................................................................................
      (let (
	     (disk-tot (to-int e-total))
	     (cpu-tot  (to-int e-cpu-tot))
	     )
	 (if (or (> disk-tot 0)(> cpu-tot 0))
	     (print "'" disk-tot "',")
     )))))
   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=?;") id)))
;;12, 19, 3, 5, 2, 3
(print "],")
(print "            backgroundColor: [")
(print "                'rgba(255, 0, 0, 0.2)',")
(print "                'rgba(255, 255, 0, 0.2)',")
(print "                'rgba(255, 0, 255, 0.2)',")
(print "                'rgba(255, 128, 0, 0.2)',")
(print "                'rgba(255, 0, 128, 0.2)',")
(print "                'rgba(255, 128, 128, 0.2)',")
(print "                'rgba(128, 0, 0, 0.2)',")
(print "                'rgba(128, 255, 0,  0.2)',")
(print "                'rgba(128, 0, 255, 0.2)',")
(print "                'rgba(128, 128, 0, 0.2)',")
(print "                'rgba(128, 0, 128, 0.2)',")
(print "                'rgba(0,  0, 255, 0.2)',")
(print "                'rgba(0,  255, 255, 0.2)',")
(print "                'rgba(0,  128, 0, 0.2)',")
(print "                'rgba(0,  0, 128, 0.2)',")
(print "                'rgba(0,  128, 128, 0.2)',")
(print "                'rgba(0, 255, 0, 0.2)'")
(print "            ],")

(print "            borderWidth: 1")
(print "        }]")
(print "    },")
(print "    options: {")
(print "        scales: {")
(print "            yAxes: [{")
(print "                ticks: {")
(print "                    beginAtZero: true")
(print "                }")
(print "            }]")
(print "        }")
(print "    }")
(print "});")
(print "</script>")
(print "<div id='canvas-holder2' style='width: 40%'><canvas id='myChart2' style='width: 250px; height: 250px'></canvas></div>")
(print "<script>")
(print "var ctx = document.getElementById('myChart2').getContext('2d');")
(print "var myChart = new Chart(ctx, {")
(print "    type: 'pie',")
(print "    data: {")
(print "        labels: [")
(print "'" uid"',")
................................................................................
	     )
	 (if (or (> disk-tot 0)(> cpu-tot 0))
	     (print "'" e-uid "',")
     )))))
   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=?;") id)))
(print "],")

;;'Bob', 'Fred', 'Jan', 'Julia', 'Fran', 'Orange'],")
(print "        datasets: [{")
(print "            label: '# of Votes',")
(print "            data: [")
(print "'" (to-int my-actual-cores) "',")
(for-each
  (lambda (rec)
    (match
................................................................................
	     (cpu-tot  (to-int e-cpu-tot))
	     )
	 (if (or (> disk-tot 0)(> cpu-tot 0))
	     (print "'" cpu-tot "',")
     )))))
   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=?;") id)))
(print "],")
;;12, 19, 3, 5, 2, 3],")
(print "            backgroundColor: [")
(print "                'rgba(255, 0, 0, 0.2)',")
(print "                'rgba(255, 255, 0, 0.2)',")
(print "                'rgba(255, 0, 255, 0.2)',")
(print "                'rgba(255, 128, 0, 0.2)',")
(print "                'rgba(255, 0, 128, 0.2)',")
(print "                'rgba(255, 128, 128, 0.2)',")
(print "                'rgba(128, 0, 0, 0.2)',")
(print "                'rgba(128, 255, 0,  0.2)',")
(print "                'rgba(128, 0, 255, 0.2)',")
(print "                'rgba(128, 128, 0, 0.2)',")
(print "                'rgba(128, 0, 128, 0.2)',")
(print "                'rgba(0,  0, 255, 0.2)',")
(print "                'rgba(0,  255, 255, 0.2)',")
(print "                'rgba(0,  128, 0, 0.2)',")
(print "                'rgba(0,  0, 128, 0.2)',")
(print "                'rgba(0,  128, 128, 0.2)',")
(print "                'rgba(0, 255, 0, 0.2)'")
(print "            ],")
(print "            borderWidth: 1")
(print "        }]")
(print "    },")
(print "    options: {")
(print "        scales: {")
(print "            yAxes: [{")
(print "                ticks: {")
(print "                    beginAtZero: true")
(print "                }")
(print "            }]")
(print "        }")
(print "    }")
(print "});")
(print "</script>")
      (print "</body></html>")
	  )))
     (else
      (print "ERROR: Bad record! " my-rec)))







|
|







 







|

|







 







|

<







 







|
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>


<
<
<
<
<
<
<
<
<



|







 







<







 







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


<
<
<
<
<
<
<
<
<







197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
...
243
244
245
246
247
248
249
250
251

252
253
254
255
256
257
258
...
262
263
264
265
266
267
268
269

270



















271
272
273









274
275
276
277
278
279
280
281
282
283
284
...
293
294
295
296
297
298
299

300
301
302
303
304
305
306
...
311
312
313
314
315
316
317
318



















319
320









321
322
323
324
325
326
327
	  (conc uid ".html")
	(lambda ()
	  (print "<!DOCTYPE html><html><head>"
		 "<title>" uid " data.</title>"
		 "</head><body>\n")
      ;;(print "<script src=canvasjs.min.js></script>")
      (print "<script src=Chart.bundle.min.js></script>")
	  (print "<h1>" uid "</h1>"
		 "<h2>Totals: " (to-int my-disk) " GB, cores: " (to-int my-cores) " (includes managers direct usage).</h2>"
		 "<table>")
	  (print "<tr><th>Manager</th><th>Storage (GB)</th><th>Cores (normalized)</th></tr>")
      (print "<tr><td>" uid "</td><td>" (to-int my-actual-disk) "</td><td>" (to-int my-actual-cores) "</th></tr>")
	  (for-each
	   (lambda (rec)
         ;;(print "Rec is: " rec)
	     (match
................................................................................
		     (create-datafiles db e-id))
		 ;; emit record to this file 
		 (if (or (> disk-tot 0)(> cpu-tot 0))
		     (print "<tr><td>"
			    (if has-emps (conc "<a href=\"" e-uid ".html\">" e-uid "</a>") e-uid)
			    "</td><td>" disk-tot "</td><td>" cpu-tot "</td></tr>"))))
	      (else (print "ERROR: bad record " rec))))
	   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=? order by cores_tot desc;") id )))
	  (print "</table>")
(print "<div id='canvas-holder' style='width: 25%; position: absolute; top: 120px; left: 300px'><canvas id='myChart' style='width: 250px; height: 250px'></canvas></div>")
(print "<script>")
(print "var ctx = document.getElementById('myChart').getContext('2d');")
(print "var myChart = new Chart(ctx, {")
(print "    type: 'pie',")
(print "    data: {")
(print "        labels: [")
(print "'" uid"',")
................................................................................
      (let (
	     (disk-tot (to-int e-total))
	     (cpu-tot  (to-int e-cpu-tot))
	     )
	 (if (or (> disk-tot 0)(> cpu-tot 0))
	     (print "'" e-uid "',")
     )))))
   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=? order by total desc;") id)))
  

(print "],")
(print "        datasets: [{")
(print "            label: '# of Votes',")
(print "            data: [")
(print "'" (to-int my-actual-disk) "',")
(for-each
  (lambda (rec)
................................................................................
      (let (
	     (disk-tot (to-int e-total))
	     (cpu-tot  (to-int e-cpu-tot))
	     )
	 (if (or (> disk-tot 0)(> cpu-tot 0))
	     (print "'" disk-tot "',")
     )))))
   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=? order by total desc;") id)))

(print "],")



















(print " backgroundColor: [\"#0074D9\", \"#FF4136\", \"#2ECC40\", \"#FF851B\", \"#7FDBFF\", \"#B10DC9\", \"#FFDC00\", \"#001f3f\", \"#39CCCC\", \"#01FF70\", \"#85144b\", \"#F012BE\", \"#3D9970\", \"#111111\", \"#AAAAAA\"],")
(print "            borderWidth: 1")
(print "        }]")









(print "    }")
(print "});")
(print "</script>")
(print "<div id='canvas-holder2' style='width: 25%; position: absolute; top: 120px; left: 800px'><canvas id='myChart2' style='width: 250px; height: 250px'></canvas></div>")
(print "<script>")
(print "var ctx = document.getElementById('myChart2').getContext('2d');")
(print "var myChart = new Chart(ctx, {")
(print "    type: 'pie',")
(print "    data: {")
(print "        labels: [")
(print "'" uid"',")
................................................................................
	     )
	 (if (or (> disk-tot 0)(> cpu-tot 0))
	     (print "'" e-uid "',")
     )))))
   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=?;") id)))
(print "],")


(print "        datasets: [{")
(print "            label: '# of Votes',")
(print "            data: [")
(print "'" (to-int my-actual-cores) "',")
(for-each
  (lambda (rec)
    (match
................................................................................
	     (cpu-tot  (to-int e-cpu-tot))
	     )
	 (if (or (> disk-tot 0)(> cpu-tot 0))
	     (print "'" cpu-tot "',")
     )))))
   (delete-duplicates (query fetch-rows (sql db "SELECT id,uid,pid,total,cores_tot FROM rollup WHERE pid=?;") id)))
(print "],")
(print " backgroundColor: [\"#0074D9\", \"#FF4136\", \"#2ECC40\", \"#FF851B\", \"#7FDBFF\", \"#B10DC9\", \"#FFDC00\", \"#001f3f\", \"#39CCCC\", \"#01FF70\", \"#85144b\", \"#F012BE\", \"#3D9970\", \"#111111\", \"#AAAAAA\"],")



















(print "            borderWidth: 1")
(print "        }]")









(print "    }")
(print "});")
(print "</script>")
      (print "</body></html>")
	  )))
     (else
      (print "ERROR: Bad record! " my-rec)))