the_espada / templates /feed_back.html
HEMANTH
static json and templates
45a65b7
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Progress</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #000; /* Black background */
background-image: url('pexels-pranjall-kumar-150768-7849087.jpg'); /* Optional: Add your background image here */
background-size: cover; /* Cover the entire page */
background-position: center;
color: #fff; /* White text for contrast */
margin: 0;
padding: 20px;
}
.container {
max-width: 900px;
margin: auto;
text-align: center;
}
h1 {
color: #fff;
}
canvas {
max-width: 100%;
height: 200px; /* Smaller pie charts */
margin-top: 20px;
}
.chart-container {
display: inline-block;
width: 250px; /* Smaller pie chart size */
margin: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>User Progress</h1>
<!-- Daily Pie Chart -->
<div class="chart-container">
<h3>Daily Rest vs. Workout Time</h3>
<canvas id="dailyPieChart"></canvas>
</div>
<!-- Weekly Pie Chart -->
<div class="chart-container">
<h3>Weekly Rest vs. Workout Time</h3>
<canvas id="weeklyPieChart"></canvas>
</div>
<!-- Daily Progress Bar Chart -->
<h3>Daily Progress</h3>
<canvas id="dailyProgressChart"></canvas>
</div>
<script>
// Fetch the data from feedback.json
fetch('static/feedback.json')
.then(response => response.json())
.then(data => {
const dailyProgress = data.daily_progress;
const weeklySummary = data.weekly_summary;
// Daily Pie Chart (Rest vs. Workout)
const dailyRestTime = dailyProgress.map(item => item.rest_time);
const dailyWorkoutTime = dailyProgress.map(item => item.workout_time);
const ctxDailyPie = document.getElementById('dailyPieChart').getContext('2d');
new Chart(ctxDailyPie, {
type: 'pie',
data: {
labels: ['Rest Time', 'Workout Time'],
datasets: [{
data: [
dailyRestTime.reduce((a, b) => a + b, 0),
dailyWorkoutTime.reduce((a, b) => a + b, 0)
],
backgroundColor: ['#ffa500', '#9E9E9E'] /* Orange and Grey */
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
labels: {
color: '#fff' /* White text for legend */
}
}
}
}
});
// Weekly Pie Chart (Rest vs. Workout)
const ctxWeeklyPie = document.getElementById('weeklyPieChart').getContext('2d');
new Chart(ctxWeeklyPie, {
type: 'pie',
data: {
labels: ['Rest Time', 'Workout Time'],
datasets: [{
data: [weeklySummary.rest_time, weeklySummary.workout_time],
backgroundColor: ['#ffa500', '#9E9E9E'] /* Orange and Grey */
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
labels: {
color: '#fff' /* White text for legend */
}
}
}
}
});
// Daily Progress Bar Chart (with points touching)
const labels = dailyProgress.map(item => item.day);
const progressData = dailyProgress.map(item => item.progress);
const ctxBar = document.getElementById('dailyProgressChart').getContext('2d');
new Chart(ctxBar, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Daily Progress (%)',
data: progressData,
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1,
fill: true,
tension: 0.4, // Smooth the line
pointBackgroundColor: 'rgba(75, 192, 192, 1)', // Points will touch the line
pointBorderWidth: 2
}]
},
options: {
scales: {
y: {
beginAtZero: true,
ticks: {
stepSize: 10
},
grid: {
color: '#9E9E9E' /* Grey grid lines */
}
},
x: {
grid: {
color: '#9E9E9E' /* Grey grid lines */
}
}
},
plugins: {
legend: {
labels: {
color: '#fff' /* White legend text */
}
}
}
}
});
})
.catch(error => console.error('Error loading the feedback data:', error));
</script>
</body>
</html>