Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
timebars
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nesstar
timebars
Commits
c29f9255
Commit
c29f9255
authored
Feb 13, 2014
by
Kjetil Thuen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load data from Nesstar rest server.
Massage data untill usable
parent
5c362e1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
src/app/nesstarloader.coffee
src/app/nesstarloader.coffee
+83
-0
No files found.
src/app/nesstarloader.coffee
0 → 100644
View file @
c29f9255
lodash
=
require
'lodash'
getDataDescription
=
()
->
{
host
:
"http://nesstar-dev.nsd.uib.no"
port
:
80
service
:
"touch/hfk/restdata"
cube
:
"Fypr-2014-Bef_C1"
filter
:
{
measures
:
[
"Befolkning"
]
dimensions
:
[
{
"id"
:
"tid"
},
{
"id"
:
"alder"
},
{
"id"
:
"Kjnn"
,
"members"
:
[
"1"
,
"2"
]
},
{
"id"
:
"Framskrivingsalternativ"
"members"
:
[
"1"
]
},
{
"id"
:
"Region"
"members"
:
[
"12"
]
}
]
}
}
fetchData
=
(
url
,
callback
)
->
request
=
new
XMLHttpRequest
()
request
.
onload
=
callback
request
.
open
'GET'
,
url
,
true
request
.
send
()
assembleDataRequest
=
()
->
datadesc
=
getDataDescription
()
datadesc
.
host
+
":"
+
datadesc
.
port
+
"/"
+
datadesc
.
service
+
"/cube/"
+
datadesc
.
cube
+
"/query?q="
+
JSON
.
stringify
(
datadesc
.
filter
)
flattenNesstarData
=
(
cellValue
)
->
flattenedCell
=
lodash
.
object
lodash
.
map
cellValue
.
coordinate
,
(
x
)
->
[
x
.
category
,
x
.
member
]
flattenedCell
.
value
=
cellValue
.
value
[
0
].
value
flattenedCell
prepareFuncFactory
=
(
callback
)
->
prepareDataForTimeBar
=
->
values
=
JSON
.
parse
(
@
response
).
payload
.
values
saneValueStore
=
lodash
.
map
(
values
,
flattenNesstarData
)
men
=
lodash
.
filter
saneValueStore
,
(
cell
)
->
parseInt
(
cell
.
Kjnn
)
is
1
women
=
lodash
.
filter
saneValueStore
,
(
cell
)
->
parseInt
(
cell
.
Kjnn
)
is
2
menByYear
=
lodash
.
groupBy
men
,
(
cell
)
->
parseInt
(
cell
.
tid
)
womenByYear
=
lodash
.
groupBy
women
,
(
cell
)
->
parseInt
(
cell
.
tid
)
restructuredData
=
{
men
:
menByYear
women
:
womenByYear
}
callback
restructuredData
prepareDataForTimeBar
reloadData
=
(
consumerFunc
)
->
prep
=
prepareFuncFactory
consumerFunc
fetchData
assembleDataRequest
(),
prep
window
.
reloadNesstarData
=
reloadData
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment