diff --git a/data/interfaces/default/graphs.html b/data/interfaces/default/graphs.html
index 6c83dfd3..37b85f93 100644
--- a/data/interfaces/default/graphs.html
+++ b/data/interfaces/default/graphs.html
@@ -341,6 +341,14 @@
var music_visible = (${config['music_logging_enable']} == 1 ? true : false);
+
+ function dataSecondsToHours(data) {
+ $.each(data.series, function (i, series) {
+ series.data = $.map(series.data, function (value) {
+ return value / 60 / 60;
+ });
+ });
+ }
function loadGraphsTab1(time_range, yaxis) {
$('#days-selection').show();
@@ -354,18 +362,19 @@
dataType: "json",
success: function(data) {
var dateArray = [];
- for (var i = 0; i < data.categories.length; i++) {
- dateArray.push(moment(data.categories[i], 'YYYY-MM-DD').valueOf());
+ $.each(data.categories, function (i, day) {
+ dateArray.push(moment(day, 'YYYY-MM-DD').valueOf());
// Highlight the weekend
- if ((moment(data.categories[i], 'YYYY-MM-DD').format('ddd') == 'Sat') ||
- (moment(data.categories[i], 'YYYY-MM-DD').format('ddd') == 'Sun')) {
+ if ((moment(day, 'YYYY-MM-DD').format('ddd') == 'Sat') ||
+ (moment(day, 'YYYY-MM-DD').format('ddd') == 'Sun')) {
hc_plays_by_day_options.xAxis.plotBands.push({
from: i-0.5,
to: i+0.5,
color: 'rgba(80,80,80,0.3)'
});
}
- }
+ });
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_day_options.yAxis.min = 0;
hc_plays_by_day_options.xAxis.categories = dateArray;
hc_plays_by_day_options.series = data.series;
@@ -380,6 +389,7 @@
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_dayofweek_options.xAxis.categories = data.categories;
hc_plays_by_dayofweek_options.series = data.series;
hc_plays_by_dayofweek_options.series[2].visible = music_visible;
@@ -393,6 +403,7 @@
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_hourofday_options.xAxis.categories = data.categories;
hc_plays_by_hourofday_options.series = data.series;
hc_plays_by_hourofday_options.series[2].visible = music_visible;
@@ -406,6 +417,7 @@
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_platform_options.xAxis.categories = data.categories;
hc_plays_by_platform_options.series = data.series;
hc_plays_by_platform_options.series[2].visible = music_visible;
@@ -419,6 +431,7 @@
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_user_options.xAxis.categories = data.categories;
hc_plays_by_user_options.series = data.series;
hc_plays_by_user_options.series[2].visible = music_visible;
@@ -439,18 +452,19 @@
dataType: "json",
success: function(data) {
var dateArray = [];
- for (var i = 0; i < data.categories.length; i++) {
- dateArray.push(moment(data.categories[i], 'YYYY-MM-DD').valueOf());
+ $.each(data.categories, function (i, day) {
+ dateArray.push(moment(day, 'YYYY-MM-DD').valueOf());
// Highlight the weekend
- if ((moment(data.categories[i], 'YYYY-MM-DD').format('ddd') == 'Sat') ||
- (moment(data.categories[i], 'YYYY-MM-DD').format('ddd') == 'Sun')) {
- hc_plays_by_stream_type_options.xAxis.plotBands.push({
+ if ((moment(day, 'YYYY-MM-DD').format('ddd') == 'Sat') ||
+ (moment(day, 'YYYY-MM-DD').format('ddd') == 'Sun')) {
+ hc_plays_by_day_options.xAxis.plotBands.push({
from: i-0.5,
to: i+0.5,
color: 'rgba(80,80,80,0.3)'
});
}
- }
+ });
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_stream_type_options.yAxis.min = 0;
hc_plays_by_stream_type_options.xAxis.categories = dateArray;
hc_plays_by_stream_type_options.series = data.series;
@@ -464,6 +478,7 @@
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_source_resolution_options.xAxis.categories = data.categories;
hc_plays_by_source_resolution_options.series = data.series;
var hc_plays_by_source_resolution = new Highcharts.Chart(hc_plays_by_source_resolution_options);
@@ -476,6 +491,7 @@
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_stream_resolution_options.xAxis.categories = data.categories;
hc_plays_by_stream_resolution_options.series = data.series;
var hc_plays_by_stream_resolution = new Highcharts.Chart(hc_plays_by_stream_resolution_options);
@@ -488,6 +504,7 @@
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_platform_by_stream_type_options.xAxis.categories = data.categories;
hc_plays_by_platform_by_stream_type_options.series = data.series;
var hc_plays_by_platform_by_stream_type = new Highcharts.Chart(hc_plays_by_platform_by_stream_type_options);
@@ -500,6 +517,7 @@
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_user_by_stream_type_options.xAxis.categories = data.categories;
hc_plays_by_user_by_stream_type_options.series = data.series;
var hc_plays_by_user_by_stream_type = new Highcharts.Chart(hc_plays_by_user_by_stream_type_options);
@@ -518,6 +536,7 @@
data: { y_axis: yaxis, user_id: selected_user_id },
dataType: "json",
success: function(data) {
+ if (yaxis === 'duration') { dataSecondsToHours(data); }
hc_plays_by_month_options.yAxis.min = 0;
hc_plays_by_month_options.xAxis.categories = data.categories;
hc_plays_by_month_options.series = data.series;
@@ -610,56 +629,55 @@
if (type === 'plays') {
yaxis_format = function() { return this.value; };
tooltip_format = function() {
- if (moment(this.x, 'X').isValid() && (this.x > 946684800)) {
- var s = ''+ moment(this.x).format("ddd MMM D") +'';
- } else {
- var s = ''+ this.x +'';
- }
- if (this.points.length > 1) {
- var total = 0;
- $.each(this.points, function(i, point) {
- s += '
'+point.series.name+': '+point.y;
- total += point.y;
- });
- s += '
Total: '+total+'';
- } else {
- $.each(this.points, function(i, point) {
- s += '
'+point.series.name+': '+point.y;
- });
- }
- return s;
- }
+ if (moment(this.x, 'X').isValid() && (this.x > 946684800)) {
+ var s = ''+ moment(this.x).format('ddd MMM D') +'';
+ } else {
+ var s = ''+ this.x +'';
+ }
+ if (this.points.length > 1) {
+ var total = 0;
+ $.each(this.points, function(i, point) {
+ s += '
'+point.series.name+': '+point.y;
+ total += point.y;
+ });
+ s += '
Total: '+total+'';
+ } else {
+ $.each(this.points, function(i, point) {
+ s += '
'+point.series.name+': '+point.y;
+ });
+ }
+ return s;
+ }
stack_labels_format = function() {
- return this.total;
- }
-
+ return this.total;
+ }
$('.yaxis-text').html('Play count');
} else {
- yaxis_format = function() { return moment.duration(this.value, 'seconds').format("H [h] m [m]"); };
+ yaxis_format = function() { return moment.duration(this.value, 'hours').format('H [h] m [m]'); };
tooltip_format = function() {
- if (moment(this.x, 'X').isValid() && (this.x > 946684800)) {
- var s = ''+ moment(this.x).format("ddd MMM D") +'';
- } else {
- var s = ''+ this.x +'';
- }
- if (this.points.length > 1) {
- var total = 0;
- $.each(this.points, function(i, point) {
- s += '
'+point.series.name+': '+moment.duration(point.y, 'seconds').format('D [days] H [hrs] m [mins]');
- total += point.y;
- });
- s += '
Total: '+moment.duration(total, 'seconds').format('D [days] H [hrs] m [mins]')+'';
- } else {
- $.each(this.points, function(i, point) {
- s += '
'+point.series.name+': '+moment.duration(point.y, 'seconds').format('D [days] H [hrs] m [mins]');
- });
- }
- return s;
- }
+ if (moment(this.x, 'X').isValid() && (this.x > 946684800)) {
+ var s = ''+ moment(this.x).format('ddd MMM D') +'';
+ } else {
+ var s = ''+ this.x +'';
+ }
+ if (this.points.length > 1) {
+ var total = 0;
+ $.each(this.points, function(i, point) {
+ s += '
'+point.series.name+': '+moment.duration(point.y, 'hours').format('D [days] H [hrs] m [mins]');
+ total += point.y;
+ });
+ s += '
Total: '+moment.duration(total, 'hours').format('D [days] H [hrs] m [mins]')+'';
+ } else {
+ $.each(this.points, function(i, point) {
+ s += '
'+point.series.name+': '+moment.duration(point.y, 'hours').format('D [days] H [hrs] m [mins]');
+ });
+ }
+ return s;
+ }
stack_labels_format = function() {
- var s = moment.duration(this.total, 'seconds').format("H [hrs] m [mins]");
- return s;
- }
+ var s = moment.duration(this.total, 'hours').format('H [h] m [m]');
+ return s;
+ }
$('.yaxis-text').html('Play duration');
}