Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed the tensorboard projector. #193

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/partials/analysis/tools/Projector/main.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
div(ng-controller='ProjectorMainCtrl as mainArea')
div#chart
script(src="https://cdn.jsdelivr.net/gh/lm233/tensorprojector/standalone.js")
2 changes: 2 additions & 0 deletions app/partials/analysis/tools/Projector/sidebar.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
div(ng-controller="ProjectorSidebarCtrl as sidebar")
span Projector
32 changes: 20 additions & 12 deletions app/scripts/App/AppMessageMap.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ module.exports = class AppMessageMap
'app_analysis_powercalc',
'app_analysis_stats',
'app_analysis_classification',
'app_analysis_modeler'
'app_analysis_dimReduction'
'app_analysis_modeler',
'app_analysis_dimReduction',
'app_analysis_projector'
]
msgTo: 'type.inferAll'
scopeTo: ['app_analysis_datalib']
Expand All @@ -37,8 +38,9 @@ module.exports = class AppMessageMap
'app_analysis_powercalc',
'app_analysis_stats',
'app_analysis_classification',
'app_analysis_modeler'
'app_analysis_dimReduction'
'app_analysis_modeler',
'app_analysis_dimReduction',
'app_analysis_projector'
]
,
msgFrom: 'data summary'
Expand All @@ -50,7 +52,8 @@ module.exports = class AppMessageMap
'app_analysis_reliability',
'app_analysis_powercalc',
'app_analysis_classification',
'app_analysis_stats'
'app_analysis_stats',
'app_analysis_projector'
]
msgTo: 'summary'
scopeTo: ['app_analysis_datalib']
Expand All @@ -66,7 +69,8 @@ module.exports = class AppMessageMap
'app_analysis_reliability',
'app_analysis_powercalc',
'app_analysis_classification',
'app_analysis_stats'
'app_analysis_stats',
'app_analysis_projector'
]
,
msgFrom: 'data histogram'
Expand All @@ -76,7 +80,8 @@ module.exports = class AppMessageMap
'app_analysis_cluster',
'app_analysis_charts',
'app_analysis_classification',
'app_analysis_reliability'
'app_analysis_reliability',
'app_analysis_projector'
]
msgTo: 'histogram'
scopeTo: ['app_analysis_datalib']
Expand All @@ -90,7 +95,8 @@ module.exports = class AppMessageMap
'app_analysis_cluster',
'app_analysis_charts',
'app_analysis_classification',
'app_analysis_reliability'
'app_analysis_reliability',
'app_analysis_projector'
]
# ,
# msgFrom: 'upload csv'
Expand Down Expand Up @@ -118,8 +124,9 @@ module.exports = class AppMessageMap
'app_analysis_powercalc',
'app_analysis_stats',
'app_analysis_classification',
'app_analysis_modeler'
'app_analysis_dimReduction'
'app_analysis_modeler',
'app_analysis_dimReduction',
'app_analysis_projector'
]
msgTo: 'get table'
scopeTo: ['app_analysis_database']
Expand All @@ -135,8 +142,9 @@ module.exports = class AppMessageMap
'app_analysis_powercalc',
'app_analysis_stats',
'app_analysis_classification',
'app_analysis_modeler'
'app_analysis_dimReduction'
'app_analysis_modeler',
'app_analysis_dimReduction',
'app_analysis_projector'
]
]

Expand Down
2 changes: 2 additions & 0 deletions app/scripts/App/AppModuleList.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ module.exports = class AppModuleList
require 'scripts/analysis/tools/PowerCalc/PowerCalc.module.coffee'
,
require 'scripts/analysis/tools/Stats/Stats.module.coffee'
,
require 'scripts/analysis/tools/Projector/Projector.module.coffee'
]
]

Expand Down
24 changes: 24 additions & 0 deletions app/scripts/analysis/tools/Projector/Projector.module.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict'
# import module class
Module = require 'scripts/BaseClasses/BaseModule.coffee'
# export instance of new module
module.exports = Projector = new Module
# module id for registration
id: 'app_analysis_projector'
# module components
components:
services:
'app_analysis_projector_initService': require 'scripts/analysis/tools/Projector/ProjectorInit.service.coffee'
'app_analysis_projector_msgService': require 'scripts/analysis/tools/Projector/ProjectorMsgService.service.coffee'
'app_analysis_projector_dataService': require 'scripts/analysis/tools/Projector/ProjectorDataService.service.coffee'

controllers:
'ProjectorMainCtrl': require 'scripts/analysis/tools/Projector/ProjectorMainCtrl.controller.coffee'
'ProjectorSidebarCtrl': require 'scripts/analysis/tools/Projector/ProjectorSidebarCtrl.controller.coffee'


state:
name: 'Projector'
url: '/Projector'
mainTemplate: require 'partials/analysis/tools/Projector/main.jade'
sidebarTemplate: require 'partials/analysis/tools/Projector/sidebar.jade'
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

BaseModuleDataService = require 'scripts/BaseClasses/BaseModuleDataService.coffee'

module.exports = class ProjectorDataService extends BaseModuleDataService
@inject '$q', 'app_analysis_projector_msgService'

# requires renaming message service injection to @msgService
initialize: () ->
@msgManager = @app_analysis_projector_msgService
@getDataRequest = @msgManager.getMsgList().outgoing[0]
@getDataResponse = @msgManager.getMsgList().incoming[0]

13 changes: 13 additions & 0 deletions app/scripts/analysis/tools/Projector/ProjectorInit.service.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'
# import base init service class
BaseModuleInitService = require 'scripts/BaseClasses/BaseModuleInitService.coffee'
# export custom init service class
module.exports = class ProjectorInitService extends BaseModuleInitService
# requires injection of message service as a dependency
@inject 'app_analysis_projector_msgService'
# entry point function:
initialize: ->
# this renaming is required for initialization!
@msgService = @app_analysis_projector_msgService
# required method call to initiate module messaging interface
@setMsgList()
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict'
BaseCtrl = require 'scripts/BaseClasses/BaseController.coffee'
module.exports = class ProjectorMainCtrl extends BaseCtrl
@inject '$timeout', '$scope', 'app_analysis_projector_dataService', 'app_analysis_projector_msgService'
initialize: ->
@text = "Component Demo"
@hello = ""
@handleHello = () ->
@hello = "hello"
@msgManager = @app_analysis_projector_msgService
@dataService = @app_analysis_projector_dataService
@data_y = null
@data = "1\t1\n2\t2"
debugger
console.log(@dataService.getData())
@dataService.getData().then (data) =>
console.log(data.dataFrame.data)
dataStr = ""
i = 0
while i < data.dataFrame.data.length
j = 0
while j < data.dataFrame.data[i].length
if data.dataFrame.data[i][j]
dataStr += data.dataFrame.data[i][j]
if j < data.dataFrame.data[i].length - 1
dataStr += '\t'
j++
if i < data.dataFrame.data.length - 1
dataStr += '\n'
i++
@data = dataStr
projector = document.createElement('vz-projector-app')
projector.setAttribute("serving-mode", "demo")
projector.setAttribute("projector-config-json-path", "standalone_projector_config.json")
projector.setAttribute("data-input", dataStr)
document.getElementById('chart').appendChild(projector)
true
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'
# import base messaging module class
BaseModuleMessageService = require 'scripts/BaseClasses/BaseModuleMessageService.coffee'
# export custom messaging service class
module.exports = class ProjectorMsgService extends BaseModuleMessageService
# required to define module message list
msgList:
outgoing: ['getData']
incoming: ['takeTable']
scope: ['app_analysis_projector']
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict'

BaseCtrl = require 'scripts/BaseClasses/BaseController.coffee'

module.exports = class ProjectorSidebarCtrl extends BaseCtrl