-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Wtower/dashboard-graph
Dashboard graph
- Loading branch information
Showing
11 changed files
with
199 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
105 changes: 105 additions & 0 deletions
105
gentelella/ga-dashboard-graph-flot/ga-dashboard-graph-flot.component.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// /** | ||
// * Created by gkarak on 23/11/2016. | ||
// */ | ||
|
||
angular | ||
.module('gaDashboardGraphFlot') | ||
.component('gaDashboardGraphFlot', { | ||
templateUrl: 'static/ng-gentelella/ga-dashboard-graph-flot/ga-dashboard-graph-flot.template.html', | ||
bindings: { | ||
graphTitle: '@', | ||
graphSubTitle: '@', | ||
graphRange: '@', | ||
graphId: '@', | ||
graphLegendTitle: '@', | ||
graphData: '<' | ||
}, | ||
transclude: true, | ||
controller: [ | ||
function GaGraphFlotController() { | ||
var self = this; | ||
|
||
// Initialise | ||
self.$onInit = function () { | ||
if (!self.graphId) self.graphId = 'main-graph'; | ||
self.plotted = false; | ||
}; | ||
|
||
// Run on every digest cycle | ||
// The only suitable event, because the id in template is set after any other event | ||
// This is why we call plot only once with self.plotted | ||
self.$doCheck = function () { | ||
var canvas = $('.' + self.graphId); | ||
|
||
if (!self.plotted && self.graphData && canvas.length) { | ||
|
||
// Transform mongo data to flot data | ||
var data = []; | ||
self.graphData.forEach(function (row) { | ||
var series = []; | ||
row.forEach(function (val) { | ||
series.push([ | ||
gd(val._id.year, val._id.month, val._id.day), | ||
val.count | ||
]); | ||
}); | ||
data.push(series); | ||
}); | ||
|
||
function gd(year, month, day) { | ||
return new Date(year, month - 1, day + 1).getTime(); | ||
} | ||
|
||
// PLOT | ||
// !self.plotted && self.graphData && canvas.length && $.plot(canvas, self.graphData, { | ||
$.plot(canvas, data, { | ||
series: { | ||
lines: { | ||
show: false, | ||
fill: true | ||
}, | ||
splines: { | ||
show: true, | ||
tension: 0.4, | ||
lineWidth: 1, | ||
fill: 0.4 | ||
}, | ||
points: { | ||
radius: 0, | ||
show: true | ||
}, | ||
shadowSize: 2 | ||
}, | ||
grid: { | ||
verticalLines: true, | ||
hoverable: true, | ||
clickable: true, | ||
tickColor: "#d5d5d5", | ||
borderWidth: 1, | ||
color: '#fff' | ||
}, | ||
colors: ["rgba(38, 185, 154, 0.38)", "rgba(3, 88, 106, 0.38)"], | ||
xaxis: { | ||
tickColor: "rgba(51, 51, 51, 0.06)", | ||
mode: "time", | ||
tickSize: [1, "day"], | ||
//tickLength: 10, | ||
axisLabel: "Date", | ||
axisLabelUseCanvas: true, | ||
axisLabelFontSizePixels: 12, | ||
axisLabelFontFamily: 'Verdana, Arial', | ||
axisLabelPadding: 10 | ||
}, | ||
yaxis: { | ||
ticks: 8, | ||
tickColor: "rgba(51, 51, 51, 0.06)" | ||
}, | ||
tooltip: false | ||
}); | ||
|
||
self.plotted = true; | ||
} | ||
}; | ||
} | ||
] | ||
}); |
3 changes: 3 additions & 0 deletions
3
gentelella/ga-dashboard-graph-flot/ga-dashboard-graph-flot.component.spec.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** | ||
* Created by gkarak on 23/11/2016. | ||
*/ |
6 changes: 6 additions & 0 deletions
6
gentelella/ga-dashboard-graph-flot/ga-dashboard-graph-flot.module.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Created by gkarak on 23/11/2016. | ||
*/ | ||
|
||
angular.module('gaDashboardGraphFlot', [ | ||
]); |
30 changes: 30 additions & 0 deletions
30
gentelella/ga-dashboard-graph-flot/ga-dashboard-graph-flot.template.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="dashboard_graph"> | ||
<div class="row x_title"> | ||
<div class="col-md-6"> | ||
<h3>{{ $ctrl.graphTitle }} <small>{{ $ctrl.graphSubTitle }}</small></h3> | ||
</div> | ||
<div class="col-md-6"> | ||
<div class="report-range pull-right"> | ||
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i> | ||
<span>{{ $ctrl.graphRange }}</span> <b class="caret hidden"></b> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="col-md-9 col-sm-9 col-xs-12"> | ||
<div class="canvas-wrapper"> | ||
<div ng-class="$ctrl.graphId" class="demo-placeholder canvas"></div> | ||
</div> | ||
</div> | ||
<div class="col-md-3 col-sm-3 col-xs-12 bg-white"> | ||
<div class="x_title"> | ||
<h2>{{ $ctrl.graphLegendTitle }}</h2> | ||
<div class="clearfix"></div> | ||
</div> | ||
|
||
<div ng-transclude></div> | ||
</div> | ||
|
||
<div class="clearfix"></div> | ||
</div> | ||
<br> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Created by gkarak on 25/11/2016. | ||
*/ | ||
|
||
angular | ||
.module('gaProgress') | ||
.component('gaProgress', { | ||
templateUrl: 'static/ng-gentelella/ga-progress/ga-progress.template.html', | ||
bindings: { | ||
progressSize: '@', | ||
progressValue: '<' | ||
} | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** | ||
* Created by gkarak on 25/11/2016. | ||
*/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Created by gkarak on 25/11/2016. | ||
*/ | ||
|
||
angular.module('gaProgress', [ | ||
]); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="progress progress_{{ $ctrl.progressSize || 'sm' }}"> | ||
<div class="progress-bar bg-green" | ||
data-transitiongoal="{{ $ctrl.progressValue }}" | ||
aria-valuenow="{{ $ctrl.progressValue }}" | ||
ng-style="{width: $ctrl.progressValue + '%'}"></div> | ||
</div> |
This file contains 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
This file contains 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