Commit 935a370a authored by Dexter Sapugay's avatar Dexter Sapugay

s

parent d3b3629f
<html> {% extends 'EmployeeProdDB/base.html' %}
<head>
<title>Bar Chart Example using Chart.js</title> {% block content %}
<!-- Load Chart.js from jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <div>
</head>
<!-- <body>
<canvas id="myChart"></canvas> <canvas id="myChart"></canvas>
<script> </div>
// Get the data from the server using Django templates
const data = JSON.parse('{{ summary_data | safe }}'); <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
// Get the labels and values from the data
const labels = data.map(entry => entry.employee_name);
const values = data.map(entry => entry.prod_score);
// Create a new Chart.js instance <script>
const ctx = document.getElementById('myChart').getContext('2d'); const ctx = document.getElementById('myChart');
const chart = new Chart(ctx, {
new Chart(ctx, {
type: 'bar', type: 'bar',
data: { data: {
labels: labels, labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{ datasets: [{
label: 'Productivity Score', label: '# of Votes',
data: values, data: [12, 19, 3, 5, 2, 3],
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1 borderWidth: 1
}] }]
}, },
options: { options: {
scales: { scales: {
yAxes: [{ y: {
ticks: {
beginAtZero: true beginAtZero: true
} }
}]
} }
} }
}); });
</script> </script>
</body> --> {% endblock %}
</html> \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment