Fix grafici!!!
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>2.0.2307.2511</Version>
|
||||
<Version>2.0.2307.2517</Version>
|
||||
<Copyright>Egalware 2021+</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
|
||||
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2307.308" />
|
||||
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2307.308" />
|
||||
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2307.2515" />
|
||||
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2307.2515" />
|
||||
<PackageReference Include="It.FattureInCloud.Sdk" Version="2.0.18" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.13" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.13" />
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
<div class="card shadow">
|
||||
<div class="card-header py-1">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h3>Statistiche</h3>
|
||||
<div class="d-flex">
|
||||
<div>
|
||||
<h3>Statistiche</h3>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<button class="btn @CssToggleChart" @onclick="ToggleGraph">
|
||||
<i class="fas fa-chart-area"></i> @ChartTitle
|
||||
@if (ShowCharts)
|
||||
{
|
||||
<i class="fas fa-chevron-down"></i>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fas fa-chevron-up"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<div>
|
||||
@@ -35,6 +50,21 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (ShowCharts)
|
||||
{
|
||||
<div class="row" style="height: 500px;">
|
||||
<div class="col-12">
|
||||
@if (MonthlyDS == null || MonthlyDS.Count == 0)
|
||||
{
|
||||
<LoadingDataSmall></LoadingDataSmall>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ChartMultiLine DataSets="MonthlyDS" ChartLabels="ChartLabels" Id="MonthData"></ChartMultiLine>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<table class="table table-sm table-striped ">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -47,11 +77,11 @@
|
||||
@($"{i:00}")
|
||||
</th>
|
||||
}
|
||||
@if(!showCumSum)
|
||||
{
|
||||
<th class="text-right">
|
||||
Tot
|
||||
</th>
|
||||
@if (!showCumSum)
|
||||
{
|
||||
<th class="text-right">
|
||||
Tot
|
||||
</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using EgwCoreLib.Razor.Data;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using SHERPA.BBM.CORE.DTO;
|
||||
using SHERPA.BBM.UI.Data;
|
||||
using static EgwCoreLib.Razor.Data.chartJsData;
|
||||
|
||||
namespace SHERPA.BBM.UI.Components
|
||||
{
|
||||
@@ -43,11 +45,27 @@ namespace SHERPA.BBM.UI.Components
|
||||
[Inject]
|
||||
protected BBM_EFService BBMService { get; set; } = null!;
|
||||
|
||||
protected List<string>? ChartLabels { get; set; } = null;
|
||||
|
||||
protected string ChartTitle
|
||||
{
|
||||
get => ShowCharts ? "Nascondi Grafici" : "Mostra Grafici";
|
||||
}
|
||||
|
||||
protected string CssToggleChart
|
||||
{
|
||||
get => ShowCharts ? "btn-secondary" : "btn-primary";
|
||||
}
|
||||
|
||||
protected string cumSumMsg
|
||||
{
|
||||
get => showCumSum ? "Cumulato" : "Puntuale";
|
||||
}
|
||||
|
||||
protected List<chartJsData.chartJsDataSetXY>? MonthlyDS { get; set; } = null;
|
||||
|
||||
protected bool ShowCharts { get; set; } = false;
|
||||
|
||||
protected bool ShowCumSum
|
||||
{
|
||||
get => showCumSum;
|
||||
@@ -72,12 +90,20 @@ namespace SHERPA.BBM.UI.Components
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ToggleGraph()
|
||||
{
|
||||
ShowCharts = !ShowCharts;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool showCumSum = false;
|
||||
|
||||
private List<int> yearsList = new List<int>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
@@ -92,13 +118,31 @@ namespace SHERPA.BBM.UI.Components
|
||||
private async Task ReloadData()
|
||||
{
|
||||
MonthStatRecords = new Dictionary<int, List<MonthStatDTO>>();
|
||||
await Task.Delay(1);
|
||||
MonthlyDS = new List<chartJsData.chartJsDataSetXY>();
|
||||
ChartLabels = new List<string>();
|
||||
// fare recupero anni x filtro...
|
||||
int yearMin = 2021;
|
||||
int yearMax = 2023;
|
||||
|
||||
yearsList = await BBMService.NegotYears();
|
||||
// preparo stats annuali
|
||||
List<MonthStatDTO> yearData = new List<MonthStatDTO>();
|
||||
for (int i = yearMax; i >= yearMin; i--)
|
||||
// predispongo colori: anno corrente è verde, gli altri sono azzurri e più trasparenti
|
||||
// man mano vanno indietro
|
||||
string greenBordCol = "rgba(11, 200, 44, 0.9)";
|
||||
string greenBackCol = "rgba(33, 222, 66, 0.1)";
|
||||
string blueBordCol = "rgba(11, 44, 200, ###)";
|
||||
string blueBackCol = "rgba(33, 66, 222, ###)";
|
||||
string cBordCol = "";
|
||||
string cBackCol = "";
|
||||
int anno = DateTime.Today.Year;
|
||||
int delta = 1;
|
||||
int num = 10;
|
||||
int numBord = 9;
|
||||
int numBack = 6;
|
||||
|
||||
for (int iMese = 1; iMese <= 12; iMese++)
|
||||
{
|
||||
ChartLabels.Add($"{iMese:00}");
|
||||
}
|
||||
foreach (var i in yearsList)
|
||||
{
|
||||
switch (statReq)
|
||||
{
|
||||
@@ -137,6 +181,43 @@ namespace SHERPA.BBM.UI.Components
|
||||
break;
|
||||
}
|
||||
MonthStatRecords.Add(i, yearData);
|
||||
// verifico se servono dati x grafici...
|
||||
if (ShowCharts)
|
||||
{
|
||||
List<chartJsXY> currData = yearData.Select(x => new chartJsXY
|
||||
{
|
||||
x = x.Month,
|
||||
y = (int)x.Value
|
||||
}).ToList();
|
||||
|
||||
// in base all'anno decido i colori...
|
||||
if (i == anno)
|
||||
{
|
||||
delta = 0;
|
||||
cBordCol = greenBordCol;
|
||||
cBackCol = greenBackCol;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ogni anno è 0.1 meno...
|
||||
delta = anno - i;
|
||||
num = numBord - delta > 1 ? numBord - delta : 1;
|
||||
cBordCol = blueBordCol.Replace("###", $"{(float)(num) / 10:N1}".Replace(",", "."));
|
||||
num = numBack - delta > 1 ? numBack - delta : 1;
|
||||
cBackCol = blueBackCol.Replace("###", $"{(float)(num) / 10:N1}".Replace(",", "."));
|
||||
}
|
||||
chartJsData.chartJsDataSetXY currChart = new chartJsData.chartJsDataSetXY()
|
||||
{
|
||||
label = $"{i}",
|
||||
data = currData,
|
||||
borderColor = cBordCol,
|
||||
backgroundColor = cBackCol,
|
||||
lineTension = 0,
|
||||
stepped = false,
|
||||
fill = delta == 0 ? "start" : "false"
|
||||
};
|
||||
MonthlyDS.Add(currChart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,5 +45,6 @@
|
||||
|
||||
<script src="_framework/blazor.server.js"></script>
|
||||
<script src="js/external.js"></script>
|
||||
<script src="~/lib/Chart.js/chart.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<UserSecretsId>60fcdaab-6c1e-4bec-9d88-f7727ef1c12c</UserSecretsId>
|
||||
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
|
||||
<Version>2.0.2307.2511</Version>
|
||||
<Version>2.0.2307.2517</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Copyright>Egalware 2021+</Copyright>
|
||||
@@ -165,8 +165,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
|
||||
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2307.308" />
|
||||
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2307.308" />
|
||||
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2307.2515" />
|
||||
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2307.2515" />
|
||||
<PackageReference Include="ElmahCore" Version="2.1.2" />
|
||||
<PackageReference Include="ElmahCore.Common" Version="2.1.2" />
|
||||
<PackageReference Include="ElmahCore.Sql" Version="2.1.2" />
|
||||
|
||||
@@ -18,5 +18,9 @@
|
||||
{
|
||||
"outputFile": "Components/CmpTop.razor.css",
|
||||
"inputFile": "Components/CmpTop.razor.less"
|
||||
},
|
||||
{
|
||||
"outputFile": "wwwroot/lib/Chart.js/chart.es5.js",
|
||||
"inputFile": "wwwroot/lib/Chart.js/chart.js"
|
||||
}
|
||||
]
|
||||
@@ -9,6 +9,11 @@
|
||||
{
|
||||
"library": "bootstrap@4.6.1",
|
||||
"destination": "wwwroot/lib/bootstrap/"
|
||||
},
|
||||
{
|
||||
"provider": "cdnjs",
|
||||
"library": "Chart.js@3.7.1",
|
||||
"destination": "wwwroot/lib/Chart.js/"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
+13
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* Chart.js v3.7.1
|
||||
* https://www.chartjs.org
|
||||
* (c) 2022 Chart.js Contributors
|
||||
* Released under the MIT License
|
||||
*/
|
||||
export { H as HALF_PI, aX as INFINITY, P as PI, aW as PITAU, aZ as QUARTER_PI, aY as RAD_PER_DEG, T as TAU, a_ as TWO_THIRDS_PI, Q as _addGrace, V as _alignPixel, a0 as _alignStartEnd, p as _angleBetween, a$ as _angleDiff, _ as _arrayUnique, a6 as _attachContext, aq as _bezierCurveTo, an as _bezierInterpolation, av as _boundSegment, al as _boundSegments, a3 as _capitalize, ak as _computeSegments, a7 as _createResolver, aH as _decimalPlaces, aP as _deprecated, a8 as _descriptors, af as _elementsEqual, M as _factorize, aJ as _filterBetween, F as _getParentNode, U as _int16Range, ah as _isBetween, ag as _isClickEvent, K as _isDomSupported, z as _isPointInArea, w as _limitValue, aI as _longestText, aK as _lookup, x as _lookupByKey, S as _measureText, aN as _merger, aO as _mergerIf, aw as _normalizeAngle, ao as _pointInLine, ai as _readValueToProps, A as _rlookupByKey, aD as _setMinAndMaxByKey, am as _steppedInterpolation, ap as _steppedLineTo, az as _textX, $ as _toLeftRightCenter, aj as _updateBezierControlPoints, as as addRoundedRectPath, aG as almostEquals, aF as almostWhole, O as callback, ad as clearCanvas, W as clipArea, aM as clone, c as color, h as createContext, ab as debounce, j as defined, aC as distanceBetweenPoints, ar as drawPoint, D as each, e as easingEffects, N as finiteOrDefault, aU as fontString, o as formatNumber, B as getAngleFromPoint, aL as getHoverColor, E as getMaximumSize, y as getRelativePosition, ax as getRtlAdapter, aT as getStyle, b as isArray, g as isFinite, a5 as isFunction, k as isNullOrUndef, q as isNumber, i as isObject, l as listenArrayEvents, L as log10, a2 as merge, a9 as mergeIf, aE as niceNum, aB as noop, ay as overrideTextDirection, G as readUsedSize, X as renderText, r as requestAnimFrame, a as resolve, f as resolveObjectKey, aA as restoreTextDirection, ac as retinaScale, ae as setsEqual, s as sign, aR as splineCurve, aS as splineCurveMonotone, J as supportsEventListenerOptions, I as throttled, R as toDegrees, n as toDimension, Z as toFont, aQ as toFontString, aV as toLineHeight, C as toPadding, m as toPercentage, t as toRadians, at as toTRBL, au as toTRBLCorners, aa as uid, Y as unclipArea, u as unlistenArrayEvents, v as valueOrDefault } from './chunks/helpers.segment.js';
|
||||
@@ -0,0 +1 @@
|
||||
export{H as HALF_PI,aX as INFINITY,P as PI,aW as PITAU,aZ as QUARTER_PI,aY as RAD_PER_DEG,T as TAU,a_ as TWO_THIRDS_PI,Q as _addGrace,V as _alignPixel,a0 as _alignStartEnd,p as _angleBetween,a$ as _angleDiff,_ as _arrayUnique,a6 as _attachContext,aq as _bezierCurveTo,an as _bezierInterpolation,av as _boundSegment,al as _boundSegments,a3 as _capitalize,ak as _computeSegments,a7 as _createResolver,aH as _decimalPlaces,aP as _deprecated,a8 as _descriptors,af as _elementsEqual,M as _factorize,aJ as _filterBetween,F as _getParentNode,U as _int16Range,ah as _isBetween,ag as _isClickEvent,K as _isDomSupported,z as _isPointInArea,w as _limitValue,aI as _longestText,aK as _lookup,x as _lookupByKey,S as _measureText,aN as _merger,aO as _mergerIf,aw as _normalizeAngle,ao as _pointInLine,ai as _readValueToProps,A as _rlookupByKey,aD as _setMinAndMaxByKey,am as _steppedInterpolation,ap as _steppedLineTo,az as _textX,$ as _toLeftRightCenter,aj as _updateBezierControlPoints,as as addRoundedRectPath,aG as almostEquals,aF as almostWhole,O as callback,ad as clearCanvas,W as clipArea,aM as clone,c as color,h as createContext,ab as debounce,j as defined,aC as distanceBetweenPoints,ar as drawPoint,D as each,e as easingEffects,N as finiteOrDefault,aU as fontString,o as formatNumber,B as getAngleFromPoint,aL as getHoverColor,E as getMaximumSize,y as getRelativePosition,ax as getRtlAdapter,aT as getStyle,b as isArray,g as isFinite,a5 as isFunction,k as isNullOrUndef,q as isNumber,i as isObject,l as listenArrayEvents,L as log10,a2 as merge,a9 as mergeIf,aE as niceNum,aB as noop,ay as overrideTextDirection,G as readUsedSize,X as renderText,r as requestAnimFrame,a as resolve,f as resolveObjectKey,aA as restoreTextDirection,ac as retinaScale,ae as setsEqual,s as sign,aR as splineCurve,aS as splineCurveMonotone,J as supportsEventListenerOptions,I as throttled,R as toDegrees,n as toDimension,Z as toFont,aQ as toFontString,aV as toLineHeight,C as toPadding,m as toPercentage,t as toRadians,at as toTRBL,au as toTRBLCorners,aa as uid,Y as unclipArea,u as unlistenArrayEvents,v as valueOrDefault}from"./chunks/helpers.segment.js";
|
||||
Reference in New Issue
Block a user