fixes #4463
parent
691802efad
commit
22f73a8f68
@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
/*global config, define, app, socket, ajaxify, bootbox, templates, Chart, utils */
|
||||
|
||||
define('admin/manage/category-analytics', [], function() {
|
||||
var CategoryAnalytics = {};
|
||||
|
||||
CategoryAnalytics.init = function() {
|
||||
var hourlyCanvas = document.getElementById('pageviews:hourly'),
|
||||
dailyCanvas = document.getElementById('pageviews:daily'),
|
||||
topicsCanvas = document.getElementById('topics:daily'),
|
||||
postsCanvas = document.getElementById('posts:daily'),
|
||||
hourlyLabels = utils.getHoursArray().map(function(text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
}),
|
||||
dailyLabels = utils.getDaysArray().map(function(text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
|
||||
if (utils.isMobile()) {
|
||||
Chart.defaults.global.showTooltips = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
'pageviews:hourly': {
|
||||
labels: hourlyLabels,
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(186,139,175,0.2)",
|
||||
strokeColor: "rgba(186,139,175,1)",
|
||||
pointColor: "rgba(186,139,175,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(186,139,175,1)",
|
||||
data: ajaxify.data.analytics['pageviews:hourly']
|
||||
}
|
||||
]
|
||||
},
|
||||
'pageviews:daily': {
|
||||
labels: dailyLabels,
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(151,187,205,0.2)",
|
||||
strokeColor: "rgba(151,187,205,1)",
|
||||
pointColor: "rgba(151,187,205,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(151,187,205,1)",
|
||||
data: ajaxify.data.analytics['pageviews:daily']
|
||||
}
|
||||
]
|
||||
},
|
||||
'topics:daily': {
|
||||
labels: dailyLabels.slice(-7),
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(171,70,66,0.2)",
|
||||
strokeColor: "rgba(171,70,66,1)",
|
||||
pointColor: "rgba(171,70,66,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(171,70,66,1)",
|
||||
data: ajaxify.data.analytics['topics:daily']
|
||||
}
|
||||
]
|
||||
},
|
||||
'posts:daily': {
|
||||
labels: dailyLabels.slice(-7),
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(161,181,108,0.2)",
|
||||
strokeColor: "rgba(161,181,108,1)",
|
||||
pointColor: "rgba(161,181,108,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(161,181,108,1)",
|
||||
data: ajaxify.data.analytics['posts:daily']
|
||||
}
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
hourlyCanvas.width = $(hourlyCanvas).parent().width();
|
||||
dailyCanvas.width = $(dailyCanvas).parent().width();
|
||||
topicsCanvas.width = $(topicsCanvas).parent().width();
|
||||
postsCanvas.width = $(postsCanvas).parent().width();
|
||||
new Chart(hourlyCanvas.getContext('2d')).Line(data['pageviews:hourly'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
new Chart(dailyCanvas.getContext('2d')).Line(data['pageviews:daily'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
new Chart(topicsCanvas.getContext('2d')).Line(data['topics:daily'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
new Chart(postsCanvas.getContext('2d')).Line(data['posts:daily'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
};
|
||||
|
||||
return CategoryAnalytics;
|
||||
});
|
@ -0,0 +1,53 @@
|
||||
<a class="btn btn-primary" href="{config.relative_path}/admin/manage/categories"><i class="fa fa-fw fa-chevron-left"></i> Back to Categories List</a>
|
||||
|
||||
<h3>Analytics for "{name}" category</h3>
|
||||
<hr />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6 text-center">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div><canvas id="pageviews:hourly" height="250"></canvas></div>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
<div class="panel-footer"><small><strong>Figure 1</strong> – Hourly page views for this category</small></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 text-center">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div><canvas id="pageviews:daily" height="250"></canvas></div>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
<div class="panel-footer"><small><strong>Figure 2</strong> – Daily page views for this category</small></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 text-center">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div><canvas id="topics:daily" height="250"></canvas></div>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
<div class="panel-footer"><small><strong>Figure 3</strong> – Daily topics created in this category</small></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 text-center">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div><canvas id="posts:daily" height="250"></canvas></div>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
<div class="panel-footer"><small><strong>Figure 4</strong> – Daily posts made in this category</small></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue