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 }}');
// Get the labels and values from the data <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
const labels = data.map(entry => entry.employee_name);
const values = data.map(entry => entry.prod_score);
// Create a new Chart.js instance
const ctx = document.getElementById('myChart').getContext('2d'); <script>
const chart = new Chart(ctx, { const ctx = document.getElementById('myChart');
type: 'bar',
data: { new Chart(ctx, {
labels: labels, type: 'bar',
datasets: [{ data: {
label: 'Productivity Score', labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
data: values, datasets: [{
backgroundColor: 'rgba(255, 99, 132, 0.2)', label: '# of Votes',
borderColor: 'rgba(255, 99, 132, 1)', data: [12, 19, 3, 5, 2, 3],
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