mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-02-16 18:14:23 +01:00
Added cumulative graph
This commit is contained in:
parent
97b4bb1b8b
commit
7a73e20929
4 changed files with 31 additions and 6 deletions
|
@ -61,7 +61,7 @@ class StatsController extends ApiControllerBase
|
||||||
array_push($output, $set);
|
array_push($output, $set);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::json(['playStats' => $output], 200);
|
return Response::json(['playStats' => $output, 'type' => 'Hourly'], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTrackStatsDaily($id)
|
public function getTrackStatsDaily($id)
|
||||||
|
@ -96,7 +96,7 @@ class StatsController extends ApiControllerBase
|
||||||
array_push($output, $set);
|
array_push($output, $set);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::json(['playStats' => $output], 200);
|
return Response::json(['playStats' => $output, 'type' => 'Daily'], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTrackStats($id) {
|
public function getTrackStats($id) {
|
||||||
|
|
|
@ -5,4 +5,5 @@
|
||||||
<canvas id="line" class="chart chart-line" chart-data="playsData"
|
<canvas id="line" class="chart chart-line" chart-data="playsData"
|
||||||
chart-labels="playsLabels" chart-legend="true" chart-series="series">
|
chart-labels="playsLabels" chart-legend="true" chart-series="series">
|
||||||
</canvas>
|
</canvas>
|
||||||
|
<button class="btn btn-primary" ng-class="{ selected: totalSelected }" ng-click="totalClick()">Cumulative</button> <button class="btn btn-primary" ng-class="{ selected: !totalSelected }" ng-click="dailyClick()">{{ dailyText }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,24 +15,44 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
module.exports = angular.module('ponyfm').controller "track-stats", [
|
module.exports = angular.module('ponyfm').controller 'track-stats', [
|
||||||
'$scope', '$state', 'track-stats'
|
'$scope', '$state', 'track-stats'
|
||||||
($scope, $state, statsService) ->
|
($scope, $state, statsService) ->
|
||||||
$scope.trackId = parseInt($state.params.id)
|
$scope.trackId = parseInt($state.params.id)
|
||||||
|
|
||||||
statsLoaded = (stats) ->
|
|
||||||
console.log(stats)
|
|
||||||
|
|
||||||
labelArray = []
|
labelArray = []
|
||||||
dataArray = []
|
dataArray = []
|
||||||
|
cumArray = []
|
||||||
|
|
||||||
|
statsLoaded = (stats) ->
|
||||||
|
console.log(stats)
|
||||||
|
|
||||||
for key, value of stats.playStats
|
for key, value of stats.playStats
|
||||||
labelArray.push value.hour || value.days
|
labelArray.push value.hour || value.days
|
||||||
dataArray.push value.plays
|
dataArray.push value.plays
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while i < dataArray.length
|
||||||
|
if i == 0
|
||||||
|
cumArray[i] = dataArray[0]
|
||||||
|
else
|
||||||
|
cumArray[i] = cumArray[i - 1] + dataArray[i]
|
||||||
|
i++
|
||||||
|
|
||||||
$scope.playsLabels = labelArray
|
$scope.playsLabels = labelArray
|
||||||
$scope.playsData = dataArray
|
$scope.playsData = dataArray
|
||||||
$scope.series = ['Plays']
|
$scope.series = ['Plays']
|
||||||
|
$scope.totalSelected = false
|
||||||
|
|
||||||
|
$scope.dailyText = stats.type
|
||||||
|
|
||||||
|
$scope.totalClick = () ->
|
||||||
|
$scope.playsData = cumArray
|
||||||
|
$scope.totalSelected = true
|
||||||
|
|
||||||
|
$scope.dailyClick = () ->
|
||||||
|
$scope.playsData = dataArray
|
||||||
|
$scope.totalSelected = false
|
||||||
|
|
||||||
statsService.loadStats($scope.trackId).done statsLoaded
|
statsService.loadStats($scope.trackId).done statsLoaded
|
||||||
]
|
]
|
||||||
|
|
|
@ -212,6 +212,10 @@ html body {
|
||||||
color: #eee;
|
color: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn.selected {
|
||||||
|
background: #7A4F7D;
|
||||||
|
}
|
||||||
|
|
||||||
.ui-datepicker {
|
.ui-datepicker {
|
||||||
.border-radius(0px);
|
.border-radius(0px);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue