diff --git a/MP.Stats/Components/ChartScarti.razor b/MP.Stats/Components/ChartScarti.razor index f4cde99d..ec627be6 100644 --- a/MP.Stats/Components/ChartScarti.razor +++ b/MP.Stats/Components/ChartScarti.razor @@ -1,24 +1,26 @@ @using MP.Stats.Data +
-
+
+
    + @foreach (var item in @CurrData) + { +
  • + @item.label + @item.value +
  • + } +
+
+
-
-
    - @foreach (var item in @CurrData) - { -
  • - @item.label - @item.value -
  • - } -
-
-
+
+
+ +
-
-
diff --git a/MP.Stats/Components/ChartScarti.razor.cs b/MP.Stats/Components/ChartScarti.razor.cs index f81dea5b..ac07c1ed 100644 --- a/MP.Stats/Components/ChartScarti.razor.cs +++ b/MP.Stats/Components/ChartScarti.razor.cs @@ -37,8 +37,9 @@ namespace MP.Stats.Components } protected BarChart ParetoGuasti; + protected LineChart NumGuasti; - object barChartOptions = new + protected object barChartOptions = new { //Title = new //{ @@ -48,20 +49,20 @@ namespace MP.Stats.Components Scales = new { XAxes = new object[] - { + { new { Display = false } - }, + }, YAxes = new object[] - { + { new { Display = true, ticks= new { suggestedMin = 0 } } - } + } }, Tooltips = new { @@ -82,6 +83,49 @@ namespace MP.Stats.Components AspectRatio = 2.5 }; + protected object lineChartOptions = new + { + //Title = new + //{ + // Display = true, + // Text = "Causali Scarto" + //}, + Scales = new + { + XAxes = new object[] + { + new { + Display = false + } + }, + YAxes = new object[] + { + new { + Display = true, + ticks= new { + suggestedMin = 0 + } + } + } + }, + Tooltips = new + { + Mode = "nearest", + Intersect = false + }, + Hover = new + { + Mode = "nearest", + Intersect = false + }, + //Legend = new + //{ + // Display = true, + // FullWidth = true + //}, + Animation = false, + AspectRatio = 2.5 + }; protected List CurrData { get; set; } = new List(); @@ -99,6 +143,11 @@ namespace MP.Stats.Components await ParetoGuasti.Clear(); await ParetoGuasti.AddLabelsDatasetsAndUpdate(GetBarChartLabels(), GetBarChartDataset()); } + if (NumGuasti != null) + { + await NumGuasti.Clear(); + await NumGuasti.AddLabelsDatasetsAndUpdate(GetLineChartLabels(), GetLineChartDataset()); + } } List GetBarChartLabels() @@ -106,6 +155,11 @@ namespace MP.Stats.Components var answ = CurrData.Select(x => x.label).ToList(); return answ; } + List GetLineChartLabels() + { + var answ = CurrData.Select(x => x.label).ToList(); + return answ; + } BarChartDataset GetBarChartDataset() { @@ -119,6 +173,19 @@ namespace MP.Stats.Components }; return answ; } + LineChartDataset GetLineChartDataset() + { + var answ = new LineChartDataset + { + Label = "Numero Scarti Periodo", + Data = CurrData.Select(x => x.value).ToList(), + BackgroundColor = backgroundColors(CurrData.Count), + Fill = true, + PointRadius = 2, + BorderDash = new List { } + }; + return answ; + } /// /// Genera colori sfondo 33% rosso / arancione / giallo