You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Inventario_tienda/Inventario/templates/grafico_chartjs.html

36 lines
1.1 KiB

<!DOCTYPE html>
<html>
<head>
<title>Gráfico Interactivo</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<h1>Gráfico de cantidad de productos</h1>
<canvas id="grafico" width="400" height="200"></canvas>
<script>
const ctx = document.getElementById('grafico').getContext('2d');
const myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: {{ productos|safe }}, // Nombres de los productos
datasets: [{
label: 'Cantidad de Productos',
data: {{ cantidades|safe }}, // Cantidades de productos
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
<a href="{% url 'inventario_vista' %}" class="btn btn-secondary">volver</a>
</body>
</html>