graph
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="stylesheet" href="/bootstrap.min.css" />
|
||||
<script src="/bootstrap.bundle.min.css"></script>
|
||||
<script src="/bootstrap.bundle.min.js"></script>
|
||||
<title>Index</title>
|
||||
</head>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="stylesheet" href="/bootstrap.min.css" />
|
||||
<script src="/bootstrap.bundle.min.css"></script>
|
||||
<script src="/bootstrap.bundle.min.js"></script>
|
||||
<title>Index</title>
|
||||
</head>
|
||||
|
||||
|
||||
@ -5,18 +5,67 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="stylesheet" href="/bootstrap.min.css" />
|
||||
<script src="/bootstrap.bundle.min.css"></script>
|
||||
<script src="/bootstrap.bundle.min.js"></script>
|
||||
<script src="/chart.js"></script>
|
||||
<title>Person <%= person.name %></title>
|
||||
</head>
|
||||
|
||||
<body data-bs-theme="dark">
|
||||
<a href="/">Index</a>
|
||||
<a href="/gamble/<%= person.personId %>">gamble</a>
|
||||
<p>
|
||||
Name: <%= person.name %>
|
||||
</p>
|
||||
<p>
|
||||
Points: <%= person.pointsTotal %>
|
||||
</p>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col col-12 col-lg-4">
|
||||
<div class="h-100 d-flex flex-column justify-content-center">
|
||||
<div class="border rounded p-3 m-1">
|
||||
Name: <%= person.name %>
|
||||
</div>
|
||||
<div class="border rounded p-3 m-1">
|
||||
Points: <%= person.pointsTotal %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-12 col-lg-8 text-center">
|
||||
<canvas id="chart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
Chart.defaults.borderColor = '#777';
|
||||
Chart.defaults.color = '#fff';
|
||||
|
||||
const rawPoints = <%- points %>;
|
||||
let points = {
|
||||
0: 0
|
||||
};
|
||||
let runningSum = 0;
|
||||
for (let i = 0; i < rawPoints.length; i++) {
|
||||
runningSum += rawPoints[i].points;
|
||||
points[i+1] = runningSum;
|
||||
}
|
||||
|
||||
console.log(points);
|
||||
const ctx = document.getElementById('chart');
|
||||
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [{
|
||||
label: 'Body',
|
||||
data: points,
|
||||
borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user