Skip to content

Commit d47899c

Browse files
committed
Merge pull request #115 from diydrones/better_plotting_lib
highcharts plotting
2 parents 20efca2 + 5b32328 commit d47899c

File tree

11 files changed

+270
-194
lines changed

11 files changed

+270
-194
lines changed

Diff for: Gruntfile.coffee

+2
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ module.exports = (grunt) ->
334334
'angularFileUpload': 'libs/angular-file-upload.min.js'
335335
'infinite-scroll': 'libs/ng-infinite-scroll.js'
336336
'ngLaddaBootstrap': 'libs/ng-ladda-bootstrap.js'
337+
'highcharts-ng': 'libs/highcharts-ng.js'
337338
]
338339
require: 'NGBOOTSTRAP'
339340
prod:
@@ -373,6 +374,7 @@ module.exports = (grunt) ->
373374
'angularFileUpload': 'libs/angular-file-upload.min.js'
374375
'infinite-scroll': 'libs/ng-infinite-scroll.js'
375376
'ngLaddaBootstrap': 'libs/ng-ladda-bootstrap.js'
377+
'highcharts-ng': 'libs/highcharts-ng.js'
376378
]
377379
require: '<%= shimmer.dev.require %>'
378380

Diff for: bower.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"ngInfiniteScroll": "~1.1.2",
2020
"ngprogress-lite": "~1.0.6",
2121
"ng-ladda-bootstrap": "*",
22-
"spin.js": "~1.3.2"
22+
"spin.js": "~1.3.2",
23+
"highcharts-ng": "~0.0.7"
2324
},
2425
"exportsOverride": {
2526
"angular": {
@@ -87,6 +88,12 @@
8788
},
8889
"ng-ladda-bootstrap": {
8990
"scripts/libs": "dist/ng-ladda-bootstrap.js"
91+
},
92+
"highcharts-ng": {
93+
"scripts/libs": "dist/highcharts-ng.js"
94+
},
95+
"highcharts": {
96+
"scripts/libs": "highcharts.js"
9097
}
9198
},
9299
"resolutions": {

Diff for: src/scripts/controllers/dapiControllers.coffee

+8-25
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,6 @@ class MissionDetailController extends DetailController
454454
# size: 'lg'
455455
windowClass: 'parameters-modal fade'
456456

457-
# Show the data plot modal in the correct location
458-
@show_plot = () =>
459-
@log.info('opening data plot')
460-
dialog = @modal.open
461-
templateUrl: '/views/mission/plot-modal.html'
462-
controller: 'missionPlotController as controller'
463-
# backdrop: 'static'
464-
# windowClass: 'parameters-modal fade'
465-
466457
@show_analysis = () =>
467458
@log.info('opening analysis')
468459
dialog = @modal.open
@@ -529,24 +520,16 @@ class MissionParameterController extends BaseController
529520
p.style = if p.rangeOk then "param-good" else "param-bad"
530521

531522
class MissionPlotController extends BaseController
532-
@$inject: ['$log', '$scope', '$routeParams', 'missionService']
533-
constructor: (@log, scope, @routeParams, @service) ->
523+
@$inject: ['$log', '$scope', '$routeParams', 'missionService', 'authService', 'missionData', 'plotData']
524+
constructor: (@log, scope, @routeParams, @service, @authService, @record, @plotData) ->
534525
super(scope)
535526

536-
@scope.plotOptions =
537-
xaxis :
538-
mode : "time"
539-
timeformat : "%M:%S"
540-
zoom :
541-
interactive : true
542-
pan :
543-
interactive : true
544-
@scope.plotData = {}
545-
546-
@log.debug("Fetching plot data for " + @routeParams.id)
547-
@service.get_plotdata(@routeParams.id).then (httpResp) =>
548-
@log.debug("Setting plot")
549-
@scope.plotData = httpResp.data
527+
@isMine = () =>
528+
me = @authService.getUser()
529+
me.loggedIn && (@record?.userName == me.login)
530+
531+
@scope.record = @record
532+
@scope.series = @plotData
550533

551534
class MissionAnalysisController extends BaseController
552535
@$inject: ['$log', '$scope', '$routeParams', 'missionService']

Diff for: src/scripts/directives/missionPlot.coffee

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
angular.module('app').directive 'missionPlot', ['$log', '$window', ($log, $window) -> return {
2+
restrict: 'A'
3+
controllerAs: 'controller'
4+
templateUrl: '/views/directives/mission-plot.html'
5+
scope:
6+
'series': '='
7+
controller: ['$scope', (@scope) ->
8+
@getPlotWidthHeight = =>
9+
navHeight = ($ 'header[header-nav]').height()
10+
infoHeight = ($ '.plot-info').height()
11+
plotHeight = ($ window).height() - navHeight - infoHeight - 200
12+
plotWidth = ($ '.highcharts-plot').width()
13+
[plotHeight, plotWidth]
14+
15+
size = @getPlotWidthHeight()
16+
17+
@resizeChart = =>
18+
size = @getPlotWidthHeight()
19+
plotHeight = size[0]
20+
plotWidth = size[1]
21+
@scope.$apply =>
22+
@scope.chartConfig.size.width = plotWidth
23+
@scope.chartConfig.size.height = plotHeight
24+
25+
@scope.chartConfig =
26+
options:
27+
chart:
28+
type: 'line'
29+
zoomType: 'x'
30+
xAxis:
31+
ordinal: false
32+
type: 'datetime'
33+
tickInterval: 2 * 60 * 1000
34+
labels:
35+
rotation: -45
36+
dateTimeLabelFormats:
37+
day: '%H:%M'
38+
hour: '%I %p'
39+
minute: '%I:%M %p'
40+
41+
title:
42+
text: 'Param Plot'
43+
series: ({name: option.label, data: option.data} for option in @scope.series)
44+
size:
45+
height: size[0]
46+
width: size[1]
47+
48+
return @
49+
]
50+
link: ($scope, element, attributes, controller) ->
51+
($ window).resize controller.resizeChart
52+
#controller.resizeChart(false)
53+
}]

Diff for: src/scripts/routes.coffee

+11-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@ class Config
5151
templateUrl: '/views/mission/analysis-window.html'
5252
.when '/doarama/:id',
5353
templateUrl: '/views/mission/doarama-window.html'
54-
.when '/plot/:id',
54+
.when '/mission/:id/plot',
55+
title: 'Plot'
5556
templateUrl: '/views/mission/plot-window.html'
57+
controller: 'missionPlotController as controller'
58+
resolve:
59+
missionData: ['$route', 'missionService', ($route, missionService) ->
60+
missionService.getId($route.current.params.id).then missionService.fixMissionRecord
61+
]
62+
plotData: ['$route', 'missionService', ($route, missionService) ->
63+
missionService.get_plotdata($route.current.params.id).then (response) ->
64+
response.data
65+
]
5666
.when '/github/:id',
5767
controller: 'gitHubController'
5868
.when '/admin',

Diff for: src/styles/styles.less

+18
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,21 @@ p {
553553
}
554554
}
555555
}
556+
557+
.mission-detail-plot {
558+
.contact-card {
559+
img {
560+
margin-right: 10px;
561+
}
562+
}
563+
.plot-area {
564+
margin-top: 25px;
565+
padding-top: 25px;
566+
margin-bottom: 25px;
567+
padding-bottom: 25px;
568+
background-color: #fff;
569+
.highcharts-plot {
570+
height: auto;
571+
}
572+
}
573+
}

Diff for: src/views/directives/mission-plot.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<highchart class='highcharts-plot' config="chartConfig"></highchart>

0 commit comments

Comments
 (0)