новый график
This commit is contained in:
parent
7a3284eb75
commit
200d4af5d9
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace SchoolAgainStudyContracts.BusinessLogicContracts
|
||||
{
|
||||
public (int Products, int Diyes) GetDifferenceInCount(int StudentId);
|
||||
public List<ActivityChartViewModel> GetActivitys(int StudentId);
|
||||
public List<TopersViewModel> GetTopInterests(int StudentId);
|
||||
public List<TopersViewModel> GetTopMaterials(int TeacherId);
|
||||
public List<TopersViewModel> GetTopStudents(int TeacherId);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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>
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user