новый график

This commit is contained in:
Володя 2023-05-19 22:50:30 +03:00
parent 7a3284eb75
commit 200d4af5d9
6 changed files with 92 additions and 18 deletions

View File

@ -157,5 +157,28 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic
var actList = list.Select(g => new TopersViewModel { Name = _student.ReadElement(new StudentSearchModel { Id = g.Key }).Name, Count = g.Value }).ToList();
return actList;
}
}
public List<TopersViewModel> GetTopInterests(int StudentId)
{
var interests = _interest.ReadList(new InterestSearchModel { StudentId = StudentId });
var products = _product.ReadList(new ProductSearchModel { StudentId = StudentId });
var diyes = _diy.ReadList(new DiySearchModel { StudentId = StudentId });
Dictionary<IInterest, int> list = new Dictionary<IInterest, int>();
foreach(var interest in interests)
{
list.Add(interest, 0);
foreach(var product in products)
{
if (product.ProductInterests.ContainsKey(interest.Id))
list[interest] += 1;
}
foreach (var diy in diyes)
{
if (diy.DiyInterests.ContainsKey(interest.Id))
list[interest] += 1;
}
}
var actList = list.Select(g => new TopersViewModel { Name = g.Key.Title, Count = g.Value }).ToList();
return actList;
}
}
}

View File

@ -11,7 +11,8 @@ namespace SchoolAgainStudyContracts.BusinessLogicContracts
{
public (int Products, int Diyes) GetDifferenceInCount(int StudentId);
public List<ActivityChartViewModel> GetActivitys(int StudentId);
public List<TopersViewModel> GetTopMaterials(int TeacherId);
public List<TopersViewModel> GetTopInterests(int StudentId);
public List<TopersViewModel> GetTopMaterials(int TeacherId);
public List<TopersViewModel> GetTopStudents(int TeacherId);
}
}

View File

@ -517,6 +517,20 @@ namespace StudentWebClient.Controllers
NullValueHandling = NullValueHandling.Ignore});
return View();
}
[HttpGet]
public IActionResult TopInterests()
{
if (APIClient.Student == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.DataPoints = JsonConvert.SerializeObject(_chart.GetTopInterests(APIClient.Student.Id),
new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore
});
return View();
}
}

View File

@ -6,28 +6,28 @@
for (var i = 0; i < result.length; i++) {
dataPoints.push({ label: result[i].dateOf, y: result[i].count });
}
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
theme: "theme2",
animationEnabled: true,
title: {
text: "Отслеживание работы за послдений месяц"
text: "Отслеживание работы за послдений месяц"
},
data: [
{
// change type to bar, line, area, pie, etc.
{
// change type to bar, line, area, pie, etc.
type: "column",
dataPoints: dataPoints
}
]
});
chart.render();
};
</script>
dataPoints: dataPoints
}
]
});
chart.render();
};
</script>
<body>
<div id="chartContainer">
</div>
<div id="chartContainer">
</div>
</body>

View File

@ -0,0 +1,33 @@
@using SchoolAgainStudyContracts.ViewModel;
@model List<TopersViewModel>
<script type="text/javascript">
var result = @Html.Raw(ViewBag.DataPoints);
var dataPoints = [];
for (var i = 0; i < result.length; i++) {
dataPoints.push({ label: result[i].Name, y: result[i].Count });
}
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
theme: "theme2",
animationEnabled: true,
title: {
text: "Общее развитие интересов"
},
data: [
{
// change type to bar, line, area, pie, etc.
type: "pie",
dataPoints: dataPoints
}
]
});
chart.render();
};
</script>
<body>
<div id="chartContainer">
</div>
</body>

View File

@ -51,6 +51,9 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ActivityCharts">Отслеживание</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="TopInterests">ТопИнтересов</a>
</li>
</ul>
</div>