[ Launch: formatdata ] 325cbce9ccb517f9a82f by bjorngi
-
-
Save bjorngi/325cbce9ccb517f9a82f to your computer and use it in GitHub Desktop.
formatdata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"formatdata","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.7,"thumbnail":"http://i.imgur.com/Z4ghHZY.png","fullscreen":false,"ajax-caching":true} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "customer": { "alias": "Redacted1", "hotspots": [ { "alias": "hs-redacted1", "id": 28, "logins": [ { "authtype": "open", "friendlyname": "Open", "logins": { "total": 33, "unique": 28 } } ] } ], "id": 24 } }, { "customer": { "alias": "Redacted2", "hotspots": [ { "alias": "hs-redacted2", "id": 60, "logins": [ { "authtype": "radius_external", "friendlyname": "Ekstern RADIUS", "logins": { "total": 56, "unique": 47 } }, { "authtype": "open", "friendlyname": "Open", "logins": { "total": 26, "unique": 23 } } ] }, { "alias": "hs-redacted3", "id": 61, "logins": null } ], "id": 35 } } ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = tributary.data; | |
var authTypes = []; | |
data.map(function(d) { | |
return d.customer.hotspots; | |
}) | |
.map(function(hsA) { | |
return hsA.map(function(hs) { | |
if(hs.logins) { | |
return hs.logins.map(function(logins) { | |
authTypes.push(logins); | |
}) | |
} | |
}) | |
}); | |
var nestetAuthTypes = d3.nest() | |
.key(function(d) { | |
return d.friendlyname; | |
}) | |
.rollup(function(log) { | |
var sum = { | |
'unique': 0, | |
'total': 0 | |
} | |
log.map(function(d) { | |
sum.total += d.logins.total; | |
sum.unique += d.logins.unique; | |
}) | |
return sum; | |
}) | |
.entries(authTypes); | |
console.log(nestetAuthTypes); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment