@using Rms.Risk.Mango.Pivot.Core
@*
* dbMango
*
* Copyright 2025 Deutsche Bank AG
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*@
@if ( _pivot != null )
{
@if ( _pivot.Make2DPivot )
{
}
@if ( _pivot.MakeLineChart )
{
}
}
@code {
[Parameter] public string Class { get; set; } = "";
[Parameter]
public PivotDefinition? Pivot
{
get => _pivot;
set
{
if (_pivot == value)
return;
_pivot = value;
InvokeAsync(StateHasChanged);
}
}
private PivotDefinition? _pivot;
private string _rowClass = "";
private string RenameColumns
{
get => string.Join(
"\n",
(_pivot?.RenameColumn ?? new Dictionary(StringComparer.OrdinalIgnoreCase))
.Select(x => new { Key = x.Key?.Trim(), Value = x.Value?.Trim() })
.Where(x => !string.IsNullOrWhiteSpace(x.Key) && !string.IsNullOrWhiteSpace(x.Value))
.Select(x => $"{x.Key}={x.Value}")
);
set
{
if (_pivot == null || ColumnOrder == value)
return;
_pivot.RenameColumn = (value ?? "")
.Replace("\r", "")
.Split("\n")
.Select(x => x.Split("="))
.Where(x => x.Length == 2 && !string.IsNullOrWhiteSpace(x[0]) && !string.IsNullOrWhiteSpace(x[1]))
.ToDictionary(x => x[0].Trim(), x => x[1].Trim())
;
}
}
private string ColumnOrder
{
get => string.Join("\n", (_pivot?.ColumnsOrder ?? []).Select(x => x?.Trim()).Where(x => !string.IsNullOrWhiteSpace(x)));
set
{
if (_pivot == null || ColumnOrder == value)
return;
_pivot.ColumnsOrder ??= [];
_pivot.ColumnsOrder.Clear();
_pivot.ColumnsOrder.AddRange((value ?? "")
.Replace("\r", "")
.Split("\n")
.Select(x => x.Trim())
.Where(x => !string.IsNullOrWhiteSpace(x))
);
}
}
private string Pivot2DRows
{
get => string.Join("\n", (_pivot?.Pivot2DRows ?? []).Select(x => x?.Trim()).Where(x => !string.IsNullOrWhiteSpace(x)));
set
{
if (_pivot == null || Pivot2DRows == value)
return;
_pivot.Pivot2DRows ??= [];
_pivot.Pivot2DRows.Clear();
_pivot.Pivot2DRows.AddRange((value ?? "")
.Replace("\r", "")
.Split("\n")
.Select(x => x.Trim())
.Where(x => !string.IsNullOrWhiteSpace(x))
);
}
}
private string Pivot2DCol
{
get => _pivot?.Pivot2DColumn ?? "";
set
{
if (_pivot == null || _pivot.Pivot2DColumn == value)
return;
_pivot.Pivot2DColumn = value;
}
}
private string Pivot2DData
{
get => _pivot?.Pivot2DData ?? "";
set
{
if (_pivot == null || _pivot.Pivot2DData == value)
return;
_pivot.Pivot2DData = value;
}
}
private string Pivot2DDataTypeColumn
{
get => _pivot?.Pivot2DDataTypeColumn ?? "";
set
{
if (_pivot == null || _pivot.Pivot2DDataTypeColumn == value)
return;
_pivot.Pivot2DDataTypeColumn = value;
}
}
private string LineChartXAxis
{
get => _pivot?.LineChartXAxis ?? "";
set
{
if (_pivot == null)
return;
_pivot.LineChartXAxis = value;
}
}
private string LineChartYAxis
{
get => string.Join("\n", _pivot?.LineChartYAxis ?? Enumerable.Empty());
set
{
if (_pivot == null)
return;
_pivot.LineChartYAxis ??= [];
_pivot.LineChartYAxis.Clear();
_pivot.LineChartYAxis.AddRange(value
.Replace("\r", "")
.Split("\n")
.Select(x => x.Trim())
.Where(x => !string.IsNullOrWhiteSpace(x))
);
}
}
private string LineChartAdditionalKeys
{
get => string.Join("\n",_pivot?.LineChartDataSetKeys ?? []);
set
{
if (_pivot == null)
return;
var s = value
.Replace("\r", "")
.Split("\n")
.Select(x => x.Trim())
.Where(x => !string.IsNullOrWhiteSpace(x))
;
_pivot.LineChartDataSetKeys ??= [];
_pivot.LineChartDataSetKeys.Clear();
_pivot.LineChartDataSetKeys.AddRange(s);
}
}
private bool LineChartShowLegend
{
get => _pivot?.LineChartShowLegend ?? false;
set
{
if (_pivot == null)
return;
_pivot.LineChartShowLegend = value;
}
}
private bool LineChartSteppedLine
{
get => _pivot?.LineChartSteppedLine ?? false;
set
{
if (_pivot == null)
return;
_pivot.LineChartSteppedLine = value;
}
}
private bool LineChartFill
{
get => _pivot?.LineChartFill ?? false;
set
{
if (_pivot == null)
return;
_pivot.LineChartFill = value;
}
}
}