gui.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. define([ "chroma-js", "map", "sidebar", "tabs", "container", "meshstats",
  2. "linklist", "nodelist", "simplenodelist", "infobox/main",
  3. "proportions" ],
  4. function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist,
  5. Nodelist, SimpleNodelist, Infobox, Proportions) {
  6. return function (config, router) {
  7. var self = this
  8. var dataTargets = []
  9. var linkScale = chroma.scale(chroma.interpolate.bezier(["green", "yellow", "red"])).domain([1, 5])
  10. var sidebar = new Sidebar(document.body)
  11. var infobox = new Infobox(config, sidebar, router)
  12. var tabs = new Tabs()
  13. var overview = new Container()
  14. var map = new Map(linkScale, sidebar, router)
  15. document.body.insertBefore(map.div, document.body.firstChild)
  16. var meshstats = new Meshstats()
  17. var newnodeslist = new SimpleNodelist(config, "new", "firstseen", router, "Neue Knoten")
  18. var lostnodeslist = new SimpleNodelist(config, "lost", "lastseen", router, "Verschwundene Knoten")
  19. var nodelist = new Nodelist(router)
  20. var linklist = new Linklist(linkScale, router)
  21. var statistics = new Proportions()
  22. dataTargets.push(map)
  23. dataTargets.push(meshstats)
  24. dataTargets.push(newnodeslist)
  25. dataTargets.push(lostnodeslist)
  26. dataTargets.push(nodelist)
  27. dataTargets.push(linklist)
  28. dataTargets.push(statistics)
  29. overview.add(meshstats)
  30. overview.add(newnodeslist)
  31. overview.add(lostnodeslist)
  32. sidebar.add(tabs)
  33. tabs.add("Übersicht", overview)
  34. tabs.add("Alle Knoten", nodelist)
  35. tabs.add("Verbindungen", linklist)
  36. tabs.add("Statistiken", statistics)
  37. router.addTarget(infobox)
  38. router.addTarget(map)
  39. self.setData = function (data) {
  40. dataTargets.forEach(function (d) {
  41. d.setData(data)
  42. })
  43. }
  44. return self
  45. }
  46. })