feat: backoffice 사이트 트래픽 통계(방문·봇 크롤링) 추가
This commit is contained in:
1 parent
3854aef320
commit
01dd8e7522
33 files changed
+2253
-57
No files matched your search
@@ -0,0 +1,71 @@
|
||||
{% extends "sqladmin/layout.html" %}
|
||||
|
||||
{% block content_header %}
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<h2 class="page-title">{{ title }}</h2>
|
||||
<div class="page-pretitle">{{ subtitle }}</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="btn-group" role="group" aria-label="기간">
|
||||
{% for d in days_options %}
|
||||
<a href="?days={{ d }}" class="btn btn-sm {{ 'btn-primary' if d == period.days else 'btn-outline-primary' }}"
|
||||
{% if d == period.days %}aria-current="page"{% endif %}>{{ d }}일</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block tail %}
|
||||
<style>
|
||||
.traffic-chart { position: relative; height: 280px; }
|
||||
.traffic-num { font-variant-numeric: tabular-nums; }
|
||||
</style>
|
||||
<script type="application/json" id="traffic-charts">{{ charts | tojson }}</script>
|
||||
<script src="{{ chart_js_url }}"></script>
|
||||
<script>
|
||||
(function () {
|
||||
var el = document.getElementById("traffic-charts");
|
||||
if (!el || !window.Chart) return;
|
||||
var charts = JSON.parse(el.textContent);
|
||||
var ink = "#52514e", grid = "#e8e7e3", surface = "#ffffff";
|
||||
Chart.defaults.color = ink;
|
||||
Chart.defaults.font.family = getComputedStyle(document.body).fontFamily;
|
||||
|
||||
charts.forEach(function (c) {
|
||||
var canvas = document.getElementById(c.id);
|
||||
if (!canvas) return;
|
||||
var stacked = c.type === "stacked";
|
||||
var datasets = c.datasets.map(function (d) {
|
||||
if (stacked) {
|
||||
// 누적 막대: 조각 사이 2px 배경색 틈
|
||||
return { label: d.label, data: d.data, backgroundColor: d.color, borderColor: surface,
|
||||
borderWidth: { top: 2 }, borderSkipped: "bottom", maxBarThickness: 32 };
|
||||
}
|
||||
return { label: d.label, data: d.data, borderColor: d.color, backgroundColor: d.color,
|
||||
borderWidth: 2, pointRadius: 0, pointHoverRadius: 4, pointHitRadius: 12, tension: 0 };
|
||||
});
|
||||
new Chart(canvas, {
|
||||
type: stacked ? "bar" : "line",
|
||||
data: { labels: c.labels, datasets: datasets },
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
interaction: { mode: "index", intersect: false },
|
||||
plugins: {
|
||||
// 범례 키: 선 그래프는 짧은 선, 막대는 사각형
|
||||
legend: { position: "top", align: "start",
|
||||
labels: { usePointStyle: true, pointStyle: stacked ? "rect" : "line", pointStyleWidth: 18 } },
|
||||
tooltip: { mode: "index", intersect: false }
|
||||
},
|
||||
scales: {
|
||||
x: { stacked: stacked, grid: { display: false } },
|
||||
y: { stacked: stacked, beginAtZero: true, grid: { color: grid }, ticks: { precision: 0 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user