diff --git a/src/api/static/js/dashboard.js b/src/api/static/js/dashboard.js index e75b727..0bbbdfb 100644 --- a/src/api/static/js/dashboard.js +++ b/src/api/static/js/dashboard.js @@ -357,9 +357,7 @@ monitor.folders.init = function () { var httpclient = HttpClient.instance() httpclient.get('/folders', function (x) { var r = JSON.parse(x.responseText) - r = jx.utils.patterns.visitor(r, function (row) { - return row[0] - }) + r = r[0] monitor.folders.render.init(r) }) } @@ -368,6 +366,39 @@ monitor.folders.render.init = function (data) { monitor.folders.render.summary(data) } monitor.folders.render.details = function (data) { + // + // We need to normalize the data at this point so as to be able to show it all in the same chart + // jx.math.scale + // + var m = jx.utils.vector(['x','y'],data.age) + var x_max_age = jx.math.max(m[0]) + var y_max_age = jx.math.max(m[1]) + m = jx.math.scale(m) + data.age = jx.utils.patterns.visitor(m,function(row){ + + return {x:parseFloat(row[0].toFixed(3)),y:parseFloat(row[1].toFixed(3))} + }) + + var m = jx.utils.vector(['x','y'],data.size) + var x_max_size = jx.math.max(m[0]) + var y_max_size = jx.math.max(m[1]) + + m = jx.math.scale(m) + data.size = jx.utils.patterns.visitor(m,function(row){ + return {x:parseFloat(row[0].toFixed(3)),y:parseFloat(row[1].toFixed(3))} + }) + + // + // The datasets need to be sorted by x ... + // + var Fn = function(a,b){ + return a.x - b.x + } + data.age = data.age.sort(Fn) + data.size= data.size.sort(Fn) + +// data.size = data.size.splice(0,data.age.length) + var context = jx.dom.get.instance('CANVAS') var frame = $('#chartfolder') jx.dom.set.value('chartfolder', '') @@ -379,23 +410,44 @@ monitor.folders.render.details = function (data) { conf.options = { legend: { position: 'bottom' } } conf.options.scales = {} conf.options.scales.yAxes = [ - {id:'0',scaleLabel:{display:true,labelString:'Age In Days'},ticks:{min:0,beginAtZero:true},gridLines: {display:false}}, - {id:'1',scaleLabel:{display:true,labelString:'Size in MB'},ticks:{min:0,beginAtZero:true},gridLines: {display:false}} + {id:'0',scaleLabel:{display:true,labelString:'% DAYS/MB'},ticks:{min:0,beginAtZero:true},gridLines: {display:false}} + ] - conf.options.scales.xAxes = [{gridLines: {display:false}}] + conf.options.scales.xAxes = [{ ticks:{min:0,max:1},gridLines: {display:false}}] + conf.options.tooltips = {} + conf.options.tooltips.callbacks = {} + conf.options.tooltips.callbacks.label = function(item,rec){ + +// var r = data.datasets[item.datasetIndex].data[item.index] + if(item.datasetIndex == 0){ + + r = data.age[item.index] + xmax = x_max_age + ymax = y_max_age + units = "DAYS" + }else{ + r = data.size[item.index] + xmax = x_max_size + ymax = y_max_size + units = "MB" + } + console.log(r) + + return 'WTF' + } var age = {yAxisID:'0', label: 'File Age (Days)', data:data.age ,borderColor:COLORS[187],fill:true,borderWidth:1} - var size = {yAxisID:'1',label : 'File Size (MB)',data:data.size,borderColor:COLORS[32],fill:true,borderWidth:1} - // age.data = [{ x: 10, y: 30 }, {x:20,y:60}] + var size = {yAxisID:'0',label : 'File Size (MB)',data:data.size,borderColor:COLORS[32],fill:true,borderWidth:1} +// // age.data = [{ x: 10, y: 30 }, {x:20,y:60}] // size.data= data.size age.data = data.age x_ = jx.utils.vector('x', age.data) z_ = jx.utils.vector('x',size.data) - conf.data.labels = jx.utils.unique(jx.math.sets.union(x_,z_)) - conf.data.datasets = [age,size] + conf.data.labels = jx.utils.unique(jx.math.sets.union(x_,z_)).sort() + conf.data.datasets = [age,size]//,age] + - console.log(conf) jx.dom.append('chartfolder',context) var chart = new Chart(context,conf) @@ -423,8 +475,6 @@ monitor.folders.render.summary = function (data) { } options.rowClick = function(args){ var item = args.item - var yu = jx.math.mean(jx.utils.vector('0', item.details.age)) - var yr = jx.math.sd(jx.utils.vector('0', item.details.age)) age = jx.utils.patterns.visitor(item.details.age, function (row) { return {y:row[0],x:row[1]} }) @@ -434,11 +484,12 @@ monitor.folders.render.summary = function (data) { monitor.folders.render.details({age:age,size:size}) } - + // + // @TODO Add the units in days just in case options.autoload = true options.fields = [ { name: 'label', type: 'text', title: "Folder Name", headercss: "small bold", css: "small"}, - { name: "summary.age", type: "number", title: "Age (Days)", headercss: "small bold" , width:'64px'}, + { name: "summary.age", type: "number", title: "Age (DAYS)", headercss: "small bold" , width:'64px'}, { name: "summary.size", type: "number", title: "Size (MB)", type: "number", headercss: "small bold" }, { name: "summary.count", type: "number", title: "File Count", type: "number", headercss: "small bold" } ] diff --git a/src/api/templates/dashboard.html b/src/api/templates/dashboard.html index 8dfbad8..5d2b12d 100644 --- a/src/api/templates/dashboard.html +++ b/src/api/templates/dashboard.html @@ -19,8 +19,9 @@ iMonitor @@ -74,11 +75,11 @@
-
+
-
+
Smart Folder Analysis/Monitoring
Powered By Machine Learning