2024-02-02 16:42:19 +00:00
|
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/products.css') }}">
|
2024-02-09 22:01:25 +00:00
|
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/stats.css') }}">
|
2024-02-11 15:52:12 +00:00
|
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/loginform.css') }}">
|
2024-02-02 17:43:03 +00:00
|
|
|
|
2024-02-09 22:01:25 +00:00
|
|
|
<div class="stats">
|
|
|
|
<div>
|
|
|
|
<canvas id="myChart" width="800px" height="500px"></canvas>
|
|
|
|
<br >
|
2024-02-11 15:52:12 +00:00
|
|
|
<form method="GET" action='' id="timeframe_form">
|
|
|
|
<div class="input-form-row">
|
|
|
|
<input type="radio" class="hidden" id="7days" name='prev_days' value=7>
|
|
|
|
<label for="7days">1 Week</label><br>
|
|
|
|
<input type="radio" class="hidden" id="14days" name="prev_days" value=14>
|
|
|
|
<label for="14days">2 Weeks</label><br>
|
|
|
|
<input type="radio" class="hidden" id="1month" name="prev_days" value=31>
|
|
|
|
<label for="1month">1 Month</label>
|
|
|
|
</div>
|
2024-02-09 22:01:25 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div>
|
2024-02-11 15:52:12 +00:00
|
|
|
<p><b>Age:</b> {{data['age']}}</p>
|
|
|
|
<p><b>Ranking:</b> {{data['ranking']}}</p>
|
|
|
|
<p><b>Stock Level:</b> {{data['stocklevel']}}</p>
|
|
|
|
<p><b>Total Views:</b> {{data['views']['total']}}</p>
|
2024-02-09 22:01:25 +00:00
|
|
|
</div>
|
2024-02-02 17:43:03 +00:00
|
|
|
</div>
|
|
|
|
|
2024-02-09 22:01:25 +00:00
|
|
|
|
|
|
|
|
2024-02-02 17:43:03 +00:00
|
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
const ctx = document.getElementById('myChart');
|
|
|
|
|
|
|
|
new Chart(ctx, {
|
2024-02-02 21:01:29 +00:00
|
|
|
type: 'line',
|
2024-02-02 17:43:03 +00:00
|
|
|
data: {
|
2024-02-09 22:01:25 +00:00
|
|
|
labels: {{data['views']['headings']|safe}},
|
2024-02-02 21:01:29 +00:00
|
|
|
datasets: [{
|
2024-02-06 19:15:44 +00:00
|
|
|
label: '# of Views',
|
2024-02-09 22:01:25 +00:00
|
|
|
data: {{data['views']['data']}},
|
2024-02-02 21:01:29 +00:00
|
|
|
borderWidth: 1
|
|
|
|
}]
|
2024-02-02 17:43:03 +00:00
|
|
|
},
|
|
|
|
options: {
|
2024-02-02 21:01:29 +00:00
|
|
|
scales: {
|
|
|
|
y: {
|
2024-02-06 19:15:44 +00:00
|
|
|
title: {
|
|
|
|
display: true,
|
|
|
|
text: "Num Views"
|
|
|
|
},
|
2024-02-02 21:01:29 +00:00
|
|
|
beginAtZero: true
|
2024-02-06 19:15:44 +00:00
|
|
|
},
|
|
|
|
x: {
|
|
|
|
title: {
|
|
|
|
display: true,
|
|
|
|
text: "Prev Days"
|
|
|
|
},
|
2024-02-02 21:01:29 +00:00
|
|
|
}
|
2024-02-02 17:43:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2024-02-11 15:52:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Remove the need for a submit button on the graph buttons
|
|
|
|
const form = document.getElementById("timeframe_form");
|
|
|
|
const rbs = form.querySelectorAll("input[type='radio']");
|
|
|
|
console.log(rbs)
|
|
|
|
console.log(form)
|
|
|
|
rbs.forEach((input) => {
|
|
|
|
input.addEventListener("change", () => {
|
|
|
|
form.submit();
|
|
|
|
});
|
|
|
|
});
|
2024-02-09 22:01:25 +00:00
|
|
|
</script>
|