add graphics
This commit is contained in:
parent
e96c1a10e7
commit
73518b39c8
@ -14,12 +14,16 @@ namespace FurnitureAssemblyStoreKeeperClientApp.Controllers
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IFurnitureStorage _furnitureStorage;
|
||||
private readonly IMaterialStorage _materialStorage;
|
||||
private readonly IReportStorekeeperLogic _report;
|
||||
public HomeController(ILogger<HomeController> logger, IFurnitureStorage furnitureStorage, IReportStorekeeperLogic report)
|
||||
public HomeController(ILogger<HomeController> logger,
|
||||
IFurnitureStorage furnitureStorage, IReportStorekeeperLogic report,
|
||||
IMaterialStorage material)
|
||||
{
|
||||
_logger = logger;
|
||||
_furnitureStorage = furnitureStorage;
|
||||
_report = report;
|
||||
_materialStorage = material;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -570,5 +574,59 @@ namespace FurnitureAssemblyStoreKeeperClientApp.Controllers
|
||||
return new PhysicalFileResult("C:\\temp\\pdf_storekeeper.pdf", "application/pdf");
|
||||
}
|
||||
#endregion
|
||||
[HttpGet]
|
||||
public IActionResult Graphics()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GraphicOrdersByFurnitureAtDate()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
var data = new List<Tuple<string, int>>();
|
||||
_furnitureStorage.GetFullList().GroupBy(x => x.DateCreate.Date.Date).ToList().ForEach(x =>
|
||||
{
|
||||
data.Add(new Tuple<string, int>(x.Key.Date.ToString().Split(" ")[0], x.Count()));
|
||||
});
|
||||
return View(data);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GraphicUsersFurnitures()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
var data = new List<Tuple<string, int>>();
|
||||
_furnitureStorage.GetFullList().GroupBy(x => x.UserName).ToList().ForEach(x =>
|
||||
{
|
||||
data.Add(new Tuple<string, int>(x.Key, x.Count()));
|
||||
});
|
||||
return View(data);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GraphicUsersMaterials()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
var data = new List<Tuple<string, int>>();
|
||||
_materialStorage.GetFullList().GroupBy(x => x.UserName).ToList().ForEach(x =>
|
||||
{
|
||||
data.Add(new Tuple<string, int>(x.Key, x.Count()));
|
||||
});
|
||||
return View(data);
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
builder.Services.AddTransient<IFurnitureStorage, FurnitureStorage> ();
|
||||
builder.Services.AddTransient<IMaterialStorage, MaterialStorage> ();
|
||||
builder.Services.AddTransient<IReportStorekeeperLogic, ReportStorekeeperLogic> ();
|
||||
|
||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveStoreKeeperToExcel>();
|
||||
|
@ -0,0 +1,130 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
@model List<Tuple<string, int>>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Количество заказов в день";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Количество заказов в день</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<div id="chartdiv" style="height: 700px;">
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
|
||||
/**
|
||||
* ---------------------------------------
|
||||
* This demo was created using amCharts 5.
|
||||
*
|
||||
* For more information visit:
|
||||
* https://www.amcharts.com/
|
||||
*
|
||||
* Documentation is available at:
|
||||
* https://www.amcharts.com/docs/v5/
|
||||
* ---------------------------------------
|
||||
*/
|
||||
|
||||
// Create root element
|
||||
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
||||
var root = am5.Root.new("chartdiv");
|
||||
|
||||
|
||||
// Set themes
|
||||
// https://www.amcharts.com/docs/v5/concepts/themes/
|
||||
root.setThemes([
|
||||
am5themes_Animated.new(root)
|
||||
]);
|
||||
|
||||
|
||||
// Create chart
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/
|
||||
var chart = root.container.children.push(am5xy.XYChart.new(root, {
|
||||
panX: false,
|
||||
panY: false,
|
||||
wheelX: "panX",
|
||||
wheelY: "zoomX",
|
||||
layout: root.verticalLayout
|
||||
}));
|
||||
|
||||
|
||||
// Add legend
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/legend-xy-series/
|
||||
var legend = chart.children.push(
|
||||
am5.Legend.new(root, {
|
||||
centerX: am5.p50,
|
||||
x: am5.p50
|
||||
})
|
||||
);
|
||||
|
||||
var data = [
|
||||
{ year: @Model[0].Item1, europe: @Model[0].Item2 },
|
||||
{ year: @Model[1].Item1, europe: @Model[1].Item2 },
|
||||
];
|
||||
|
||||
|
||||
// Create axes
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
|
||||
var xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
|
||||
categoryField: "year",
|
||||
renderer: am5xy.AxisRendererX.new(root, {
|
||||
cellStartLocation: 0.1,
|
||||
cellEndLocation: 0.9
|
||||
}),
|
||||
tooltip: am5.Tooltip.new(root, {})
|
||||
}));
|
||||
|
||||
xAxis.data.setAll(data);
|
||||
|
||||
var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
|
||||
renderer: am5xy.AxisRendererY.new(root, {})
|
||||
}));
|
||||
|
||||
|
||||
// Add series
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
|
||||
function makeSeries(name, fieldName) {
|
||||
var series = chart.series.push(am5xy.ColumnSeries.new(root, {
|
||||
name: name,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
valueYField: fieldName,
|
||||
categoryXField: "year",
|
||||
stacked: true
|
||||
}));
|
||||
|
||||
series.events.on("datavalidated", function () {
|
||||
yAxis.setAll({
|
||||
min: yAxis.getPrivate("min"),
|
||||
max: yAxis.getPrivate("max"),
|
||||
start: 0,
|
||||
end: 1
|
||||
});
|
||||
});
|
||||
|
||||
series.data.setAll(data);
|
||||
series.appear();
|
||||
}
|
||||
|
||||
makeSeries("Europe", "europe");
|
||||
|
||||
chart.set("scrollbarX", am5.Scrollbar.new(root, {
|
||||
orientation: "horizontal"
|
||||
}));
|
||||
|
||||
|
||||
// Make stuff animate on load
|
||||
// https://www.amcharts.com/docs/v5/concepts/animations/
|
||||
chart.appear(1000, 100);
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
@model List<Tuple<string, int>>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Количество заказов в день";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Количество заказов в день</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<div id="chartdiv" style="height: 700px;">
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
|
||||
/**
|
||||
* ---------------------------------------
|
||||
* This demo was created using amCharts 5.
|
||||
*
|
||||
* For more information visit:
|
||||
* https://www.amcharts.com/
|
||||
*
|
||||
* Documentation is available at:
|
||||
* https://www.amcharts.com/docs/v5/
|
||||
* ---------------------------------------
|
||||
*/
|
||||
|
||||
// Create root element
|
||||
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
||||
var root = am5.Root.new("chartdiv");
|
||||
|
||||
|
||||
// Set themes
|
||||
// https://www.amcharts.com/docs/v5/concepts/themes/
|
||||
root.setThemes([
|
||||
am5themes_Animated.new(root)
|
||||
]);
|
||||
|
||||
|
||||
// Create chart
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/
|
||||
var chart = root.container.children.push(am5xy.XYChart.new(root, {
|
||||
panX: false,
|
||||
panY: false,
|
||||
wheelX: "panX",
|
||||
wheelY: "zoomX",
|
||||
layout: root.verticalLayout
|
||||
}));
|
||||
|
||||
|
||||
// Add legend
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/legend-xy-series/
|
||||
var legend = chart.children.push(
|
||||
am5.Legend.new(root, {
|
||||
centerX: am5.p50,
|
||||
x: am5.p50
|
||||
})
|
||||
);
|
||||
|
||||
var data = [
|
||||
{ year: @Model[0].Item1, europe: @Model[0].Item2 },
|
||||
{ year: @Model[1].Item1, europe: @Model[1].Item2 },
|
||||
];
|
||||
|
||||
|
||||
// Create axes
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
|
||||
var xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
|
||||
categoryField: "year",
|
||||
renderer: am5xy.AxisRendererX.new(root, {
|
||||
cellStartLocation: 0.1,
|
||||
cellEndLocation: 0.9
|
||||
}),
|
||||
tooltip: am5.Tooltip.new(root, {})
|
||||
}));
|
||||
|
||||
xAxis.data.setAll(data);
|
||||
|
||||
var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
|
||||
renderer: am5xy.AxisRendererY.new(root, {})
|
||||
}));
|
||||
|
||||
|
||||
// Add series
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
|
||||
function makeSeries(name, fieldName) {
|
||||
var series = chart.series.push(am5xy.ColumnSeries.new(root, {
|
||||
name: name,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
valueYField: fieldName,
|
||||
categoryXField: "year",
|
||||
stacked: true
|
||||
}));
|
||||
|
||||
series.events.on("datavalidated", function () {
|
||||
yAxis.setAll({
|
||||
min: yAxis.getPrivate("min"),
|
||||
max: yAxis.getPrivate("max"),
|
||||
start: 0,
|
||||
end: 1
|
||||
});
|
||||
});
|
||||
|
||||
series.data.setAll(data);
|
||||
series.appear();
|
||||
}
|
||||
|
||||
makeSeries("Europe", "europe");
|
||||
|
||||
chart.set("scrollbarX", am5.Scrollbar.new(root, {
|
||||
orientation: "horizontal"
|
||||
}));
|
||||
|
||||
|
||||
// Make stuff animate on load
|
||||
// https://www.amcharts.com/docs/v5/concepts/animations/
|
||||
chart.appear(1000, 100);
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
@model List<Tuple<string, int>>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Количество заказов в день";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Количество заказов в день</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<div id="chartdiv" style="height: 700px;">
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
|
||||
/**
|
||||
* ---------------------------------------
|
||||
* This demo was created using amCharts 5.
|
||||
*
|
||||
* For more information visit:
|
||||
* https://www.amcharts.com/
|
||||
*
|
||||
* Documentation is available at:
|
||||
* https://www.amcharts.com/docs/v5/
|
||||
* ---------------------------------------
|
||||
*/
|
||||
|
||||
// Create root element
|
||||
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
||||
var root = am5.Root.new("chartdiv");
|
||||
|
||||
|
||||
// Set themes
|
||||
// https://www.amcharts.com/docs/v5/concepts/themes/
|
||||
root.setThemes([
|
||||
am5themes_Animated.new(root)
|
||||
]);
|
||||
|
||||
|
||||
// Create chart
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/
|
||||
var chart = root.container.children.push(am5xy.XYChart.new(root, {
|
||||
panX: false,
|
||||
panY: false,
|
||||
wheelX: "panX",
|
||||
wheelY: "zoomX",
|
||||
layout: root.verticalLayout
|
||||
}));
|
||||
|
||||
|
||||
// Add legend
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/legend-xy-series/
|
||||
var legend = chart.children.push(
|
||||
am5.Legend.new(root, {
|
||||
centerX: am5.p50,
|
||||
x: am5.p50
|
||||
})
|
||||
);
|
||||
|
||||
var data = [
|
||||
{ year: @Model[0].Item1, europe: @Model[0].Item2 },
|
||||
{ year: @Model[1].Item1, europe: @Model[1].Item2 },
|
||||
{ year: @Model[2].Item1, europe: @Model[2].Item2 },
|
||||
];
|
||||
|
||||
|
||||
// Create axes
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
|
||||
var xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
|
||||
categoryField: "year",
|
||||
renderer: am5xy.AxisRendererX.new(root, {
|
||||
cellStartLocation: 0.1,
|
||||
cellEndLocation: 0.9
|
||||
}),
|
||||
tooltip: am5.Tooltip.new(root, {})
|
||||
}));
|
||||
|
||||
xAxis.data.setAll(data);
|
||||
|
||||
var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
|
||||
renderer: am5xy.AxisRendererY.new(root, {})
|
||||
}));
|
||||
|
||||
|
||||
// Add series
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
|
||||
function makeSeries(name, fieldName) {
|
||||
var series = chart.series.push(am5xy.ColumnSeries.new(root, {
|
||||
name: name,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
valueYField: fieldName,
|
||||
categoryXField: "year",
|
||||
stacked: true
|
||||
}));
|
||||
|
||||
series.events.on("datavalidated", function () {
|
||||
yAxis.setAll({
|
||||
min: yAxis.getPrivate("min"),
|
||||
max: yAxis.getPrivate("max"),
|
||||
start: 0,
|
||||
end: 1
|
||||
});
|
||||
});
|
||||
|
||||
series.data.setAll(data);
|
||||
series.appear();
|
||||
}
|
||||
|
||||
makeSeries("Europe", "europe");
|
||||
|
||||
chart.set("scrollbarX", am5.Scrollbar.new(root, {
|
||||
orientation: "horizontal"
|
||||
}));
|
||||
|
||||
|
||||
// Make stuff animate on load
|
||||
// https://www.amcharts.com/docs/v5/concepts/animations/
|
||||
chart.appear(1000, 100);
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Графики";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Графики</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
<div>
|
||||
<a asp-action="GraphicOrdersByFurnitureAtDate">Количество заказов в день</a>
|
||||
<a asp-action="GraphicUsersMaterials">Популярность производителей материалов</a>
|
||||
<a asp-action="GraphicUsersFurnitures">Популярность производителей мебели</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
@ -7,6 +7,9 @@
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/FurnitureAssemblyStoreKeeperClientApp.styles.css" asp-append-version="true" />
|
||||
<script src="//cdn.amcharts.com/lib/5/index.js"></script>
|
||||
<script src="//cdn.amcharts.com/lib/5/xy.js"></script>
|
||||
<script src="//cdn.amcharts.com/lib/5/themes/Animated.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@ -46,7 +49,7 @@
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CreateListMaterials">Список материалов за период</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Graphics">Графики</a>
|
||||
</li>
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user