Coursach/Course/ImplementerApp/Views/Chart/ProductionHistogramm.cshtml

41 lines
1.2 KiB
Plaintext
Raw Normal View History

2024-05-29 22:02:05 +04:00
@using Contracts.ViewModels;
@model List<DetailProductionCountChartViewModel>;
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<div>
2024-05-30 00:37:26 +04:00
<canvas id="Chart" width="400" height="150"></canvas>
2024-05-29 22:02:05 +04:00
</div>
<script>
2024-05-30 00:37:26 +04:00
var ctx = document.getElementById('Chart').getContext('2d');
2024-05-29 22:02:05 +04:00
var data = {
labels: @Html.Raw(Json.Serialize(Model.Select(m => m.DetailName))),
datasets: [{
2024-05-30 00:37:26 +04:00
label: 'Количество производств к деталям',
2024-05-29 22:02:05 +04:00
data: @Html.Raw(Json.Serialize(Model.Select(m => m.ProductionCount))),
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
}]
};
var myChart = new Chart(ctx, {
type: 'bar',
data: data,
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
</body>
</html>