diff --git a/App.razor b/App.razor index 6fd3ed1..373eb8f 100644 --- a/App.razor +++ b/App.razor @@ -1,4 +1,4 @@ - +@* @@ -7,6 +7,8 @@ Not found

Sorry, there's nothing at this address.

-
+ -
+
*@ + + \ No newline at end of file diff --git a/DEV.txt b/DEV.txt new file mode 100644 index 0000000..2acd3d5 --- /dev/null +++ b/DEV.txt @@ -0,0 +1,29 @@ + +open CMD or press CTRL+D +dotnet watch run + +TODO use await +https://github.com/IgniteUI/igniteui-react-examples/blob/vnext/samples/charts/financial-chart/multiple-data/src/StocksHistory.ts + +https://stackoverflow.com/questions/12460378/how-to-get-json-from-url-in-javascript +//async function fetchDataAsync(url) { +// const response = await fetch(url); +// console.log(await response.json()); +//} +//fetchDataAsync('paste URL'); + +//fetchData(callback) { +// let url = window.location.protocol + '//' + window.location.host + '/data/bp-extracted-small.json'; +// fetch(url) +// .then(response => response.json()) +// .then(json => callback(null, json)) +// .catch(error => callback(error, null)) +//} +//Then use it like this: + +//fetchData((error, data) => { +// if (error) +// console.log(error) +// else +// console.log(data[0]) +//}); \ No newline at end of file diff --git a/Pages/Chart.razor b/Pages/Chart.razor index 187adb3..f24f538 100644 --- a/Pages/Chart.razor +++ b/Pages/Chart.razor @@ -5,7 +5,7 @@ @inject FAF.WebService WebService @page "/chart" -@page "/" +@*@page "/"*@ @*Index*@ @@ -26,7 +26,7 @@ @* *@ -
+
Hello, Commander! Welcome to Supreme Units Database - -@**@ + \ No newline at end of file diff --git a/Pages/Scripter.Evemts.razor.cs b/Pages/Scripter.Evemts.razor.cs new file mode 100644 index 0000000..8182ee5 --- /dev/null +++ b/Pages/Scripter.Evemts.razor.cs @@ -0,0 +1,8 @@ +using Microsoft.AspNetCore.Components; + +namespace SupremeUnitsApp.Pages +{ + public class ScripterBase2 : ComponentBase + { + } +} diff --git a/Pages/Scripter.razor b/Pages/Scripter.razor new file mode 100644 index 0000000..a66d1f4 --- /dev/null +++ b/Pages/Scripter.razor @@ -0,0 +1,408 @@ + +@using FAF +@using System.Text.Json +@inject IIgniteUIBlazor IgniteUIBlazor +@inject IJSRuntime JSR + +@page "/" +@page "/scripter" + +Chart + +
+ @*

Hello, Test Scripter5!

*@ +
+ @*z-index: 1000*@ + + @*SeriesMouseEnterScript="onSeriesMouseEnter"*@ + + + + + + + + + @* + *@ + @*TrendLineType="TrendLineType.CubicFit"*@ + + + + + @* + *@ + + +
+ +
+ + +
+ + + Orange + Apple + Banana + Mango + + +
+ +
+ @if (UnitTitles == null) + { +

Loading...

+ } + else + { +
X-Axis
+ +
Y-Axis
+ +
Trendline Type
+ +
Marker Type
+ + + @* + *@ + @* ValueKey="" + DisplayKey=""*@ + + @* @foreach (var item in UnitTitles) + { + + } *@ + } +
+
+
+ + +@code { + + + + private IgbLegend legend; + private IgbDataChart chart; + private IgbNumericXAxis xAxis; + private IgbNumericYAxis yAxis; + private IgbScatterSeries trendSeries; + private IgbScatterSeries dataSeries; + private IgbDataToolTipLayer dataToolTipLayer; + private List DataUnits; + + private int DataCount = 100; + private string Factions = "UEF, Cybran, Aeon, Seraphim, Nomads, UNKNOWN"; + private string Brushes = "#1174ed, #eb2c1e, #19d113, #d1bb13, #874b01, #292828"; + + + + // private List? UnitTitles = null; // = new List(); + //private string UnitTitles = ""; + private List _UnitTitles; + public List UnitTitles + { + get { return _UnitTitles; } + set { _UnitTitles = value; StateHasChanged(); } + } + + protected override async Task OnInitializedAsync() + { + // await BindDataAsync(); + } + + + private bool isRefreshCompleted = false; + private void OnRefreshCompleted(IgbRefreshCompletedEventArgs args) + { + //Console.WriteLine("APP OnRefreshCompleted=" + isRefreshCompleted); + if (!isRefreshCompleted) + { + isRefreshCompleted = true; + BindData(); + //Task.Delay(1).ContinueWith((t) => BindDataAsync()); + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + DataTrendLineLookup = new Dictionary(); + foreach(var item in DataTrendLineList) + { + DataTrendLineLookup.Add(item.ToString(), item); + } + + if (firstRender) + { + await GenerateData(); + } + SyncChart(); + //Task.Delay(1).ContinueWith((t) => BindDataAsync()); + // await BindDataAsync(); + } + + private async Task GenerateData() + { + + TaskUtils.Start("Blueprint.Load "); + //await JSR.InvokeVoidAsync("generateData", this.DataCount); + var json = await JSR.InvokeAsync("load"); + // TaskUtils.Stop("Blueprint.Load "); + + //var unit = await JSR.InvokeAsync("getUnit"); + TaskUtils.Start("Blueprint.Deserialize "); + DataUnits = JsonSerializer.Deserialize>(json); + // TaskUtils.Stop("Blueprint.Deserialize "); + + //Console.WriteLine("APP json=" + DataUnits?.Count()); + //Console.WriteLine("APP unit2=" + unit); + + var jsonTitles = await JSR.InvokeAsync("getUnitTitles"); + var listTitles = JsonSerializer.Deserialize>(jsonTitles); + this.UnitTitles = listTitles; //string.Join("\n", listTitles); + + Console.WriteLine("APP titles=" + listTitles.Count); + } + + protected void SyncChart() + { + //Console.WriteLine("FAF SyncChart ..."); + + if (this.DataUnits == null) return; + if (this.DataUnits.Count == 0) return; + + if (this.chart == null) return; + if (this.chart.Series.Count > 0) return; + // if (this.chart.Series.Count >= this.DataUnits.Count) return; + + //if (this.UnitBlueprints == null) return; + //if (this.UnitBlueprints.Count == 0) return; + + // BP.ChartStart = DateTime.Now; + // Console.WriteLine("FAF SyncChart " ); + //Console.WriteLine("FAF SyncChart " + this.DataUnits.Count); + + //foreach (var group in this.DataUnits) + //{ + // AddSeries(group.Units, group.Title); + //} + + AddSeries(DataUnits, "DataUnits"); + + //BP.ChartStop = DateTime.Now; + // Console.WriteLine("FAF SyncChart " + BP.ChartStop.Subtract(BP.ChartStart).TotalMilliseconds); + + //await JSR.InvokeVoidAsync("load"); + + // JSR.InvokeVoidAsync("bindData", this.DataUnits.Count); + + + this.chart.RefreshCompleted += OnRefreshCompleted; + } + + private void BindData() + { + Task.Delay(1).ContinueWith((t) => BindDataAsync()); + } + + private async Task BindDataAsync() + { + // Console.WriteLine("FAF BindDataAsync ..."); + // await IgniteUIBlazor.JsRuntime.InvokeVoidAsync("bindData"); + //await JSR.InvokeVoidAsync("plotUnits"); + await IgniteUIBlazor.JsRuntime.InvokeVoidAsync("plotUnits", this.DataMemberX, this.DataMemberY); + // Console.WriteLine("FAF BindData ... end"); + } + + private async Task UpdateMarkerTypeAsync() + { + await IgniteUIBlazor.JsRuntime.InvokeVoidAsync("updateMarkerType", this.DataMarkerType); + } + + public void AddSeries(List units, string faction) + { + //var units = UnitBlueprints.Where(x => x.General.FactionName == faction).ToList(); + //Console.WriteLine("FAF BP " + faction + "=" + units.Count); + // var Start = DateTime.Now; + TaskUtils.Start("AddSeries"); + + // var first = units[0]; + // first.Economy.BuildTime + + //var scale = new IgbSizeScale(); + //scale.MinimumValue = 10; + //scale.MaximumValue = 50; + + //this.trendSeries.XMemberPath = this.dataSeries.XMemberPath; + //this.trendSeries.YMemberPath = this.dataSeries.YMemberPath; + + //var s = new IgbBubbleSeries(); + var s = this.dataSeries; + //var s = new IgbScatterSeries(); + //s.Name = "Series" + this.chart.Series.Count; + + ////s.XMemberAsLegendLabel = "Build Time"; + ////s.YMemberAsLegendLabel = "Build Cost"; + ////s.RadiusMemberAsLegendLabel = "BuildRate"; + //s.XAxisName = "xAxis"; + //s.YAxisName = "yAxis"; + //// s.XMemberPath = "Economy.BuildTime"; + ////s.XMemberPath = "Economy.BuildTime"; + //s.XMemberPath = "Economy.BuildTime"; + ////s.YMemberPath = "FactionIndex"; + //s.YMemberPath = "Economy.BuildCostMass"; + ////s.YMemberPath = "General.FactionIndex"; + //s.MarkerTemplateScript = "onSeriesMarkerTemplate"; + //s.MaximumMarkers = 1000; + //s.ShowDefaultTooltip = true; + + ////s.XMemberPath = "[EconomyBuildCostMass]"; + ////s.YMemberPath = "[GeneralFactionIndex]"; + //s.XMemberPath = "EconomyBuildCostMass"; + //s.YMemberPath = "GeneralFactionIndex"; + + //s.RadiusMemberPath = "Economy.BuildRate"; + + // s.MarkerType="MarkerType.Circle" + // s.MarkerThickness="2" + //s.MarkerBrush = color; + //s.MarkerOutline = color; + // s.MarkerFillOpacity = 0.5; + // s.ShowDefaultTooltip = true; + // s.Title = faction + " (" + units.Count + ")"; + //s.RadiusScale = scale; + + if (!string.IsNullOrEmpty(s.YMemberPath)) this.yAxis.Title = s.YMemberPath; //.Replace(".", " "); + if (!string.IsNullOrEmpty(s.XMemberPath)) this.xAxis.Title = s.XMemberPath; //.Replace(".", " ") + "2"; + + if (s.YMemberPath == "General.FactionIndex") + { + //this.yAxis.IsLogarithmic = false; + //this.yAxis.MinimumValue = 0; + //this.yAxis.MaximumValue = 6; + //this.yAxis.Interval = 1; + } + else + { + //this.yAxis.IsLogarithmic = false; + //this.yAxis.MinimumValue = double.NaN; + //this.yAxis.MaximumValue = double.NaN; + //this.yAxis.Interval = double.NaN; + } + + if (s.YMemberPath.Contains("Faction") || + s.YMemberPath.Contains("Level")) + { + //this.yAxis.IsLogarithmic = false; + + if (s.YMemberPath == "FactionLevel") + { + //this.yAxis.IsLogarithmic = false; + //this.yAxis.MinimumValue = 0; + //this.yAxis.MaximumValue = 52; + //this.yAxis.Interval = 2; + } + } + + + } +} \ No newline at end of file diff --git a/Pages/Scripter.razor.cs b/Pages/Scripter.razor.cs new file mode 100644 index 0000000..8c762d9 --- /dev/null +++ b/Pages/Scripter.razor.cs @@ -0,0 +1,134 @@ +using IgniteUI.Blazor.Controls; +using Microsoft.AspNetCore.Components; + +namespace SupremeUnitsApp.Pages +{ + public partial class Scripter + { + + private string DataMemberR = ""; + + private string _DataMemberX = "Economy.BuildCostMass"; //Economy.BuildCostTotal"; + public string DataMemberX + { + get { return _DataMemberX; } + set { _DataMemberX = value; StateHasChanged(); } + } + + private string _DataMemberY = "FactionLevel"; + public string DataMemberY + { + get { return _DataMemberY; } + set { _DataMemberY = value; StateHasChanged(); } + } + + public List DataMemberPathsX + { + get { return _DataMemberPathsX; } + set { _DataMemberPathsX = value; StateHasChanged(); } + } + + public List DataMemberPathsY + { + get { return _DataMemberPathsY; } + set { _DataMemberPathsY = value; StateHasChanged(); } + } + private List _DataMemberPathsX = new List { + "Economy.BuildTime", + "Economy.BuildCostMass", + "Economy.BuildCostEnergy", + "Economy.BuildCostTotal", + "FactionLevel", + "TechLevel", + "Index", + }; + private List _DataMemberPathsY = new List { + "Economy.BuildCostMass", + "Economy.BuildTime", + "Economy.BuildCostEnergy", + "Economy.BuildCostTotal", + "FactionLevel", + "TechLevel", + "Index", + }; + + private List DataMarkerTypeList = new List { + "UnitType", + "Circle", + }; + + private string _DataMarkerType = "UnitType"; + public string DataMarkerType + { + get { return _DataMarkerType; } + set { _DataMarkerType = value; StateHasChanged(); } + } + + private Dictionary DataTrendLineLookup = new Dictionary(); + private List DataTrendLineList = new List + { + TrendLineType.PowerLawFit, + TrendLineType.CubicFit, + TrendLineType.CumulativeAverage, + TrendLineType.ExponentialAverage, + TrendLineType.ExponentialFit, + TrendLineType.LinearFit, + TrendLineType.LogarithmicFit, + TrendLineType.ModifiedAverage, + TrendLineType.QuarticFit, + TrendLineType.QuinticFit, + TrendLineType.SimpleAverage, + TrendLineType.WeightedAverage, + TrendLineType.None, + }; + private TrendLineType _DataTrendLine = TrendLineType.PowerLawFit; + public TrendLineType DataTrendLine + { + get { return _DataTrendLine; } + set { _DataTrendLine = value; StateHasChanged(); } + } + + #region Events + + + void onDataMemberX(ChangeEventArgs e) + { + this.DataMemberX = e.Value.ToString(); + Console.WriteLine("DataMemberX: " + DataMemberX); + BindData(); + } + + void onDataMemberY(ChangeEventArgs e) + { + this.DataMemberY = e.Value.ToString(); + Console.WriteLine("DataMemberY: " + DataMemberY); + BindData(); + } + + void onDataTrendLine(ChangeEventArgs e) + { + Console.WriteLine("onDataTrendLine: " + e.Value); + var trendlineName = e.Value.ToString(); + this.DataTrendLine = DataTrendLineLookup[trendlineName]; + //BindData(); + } + + void onDataMarkerType(ChangeEventArgs e) + { + Console.WriteLine("onDataMarkerType: " + e.Value); + var markerType = e.Value.ToString(); + if (this.DataMarkerType == "UnitType") + { + // dataSeries.MarkerTemplateScript = "onSeriesMarkerTemplate"; + } + else { + // dataSeries.MarkerTemplateScript = null; + // dataSeries.MarkerType = MarkerType.Square; + } + this.DataMarkerType = markerType; + + Task.Delay(1).ContinueWith((t) => UpdateMarkerTypeAsync()); + } + #endregion + } +} diff --git a/Program.cs b/Program.cs index 1030253..21eb826 100644 --- a/Program.cs +++ b/Program.cs @@ -16,6 +16,9 @@ // registering Infragistics Blazor builder.Services.AddIgniteUIBlazor( + typeof(IgbSelectModule), + typeof(IgbComboModule), + typeof(IgbSwitchModule), typeof(IgbAnnotationLayerProxyModule), typeof(IgbCrosshairLayerModule), typeof(IgbLegendModule), diff --git a/Shared/MainLayout.razor b/Shared/MainLayout.razor index 3ad470a..963a762 100644 --- a/Shared/MainLayout.razor +++ b/Shared/MainLayout.razor @@ -1,18 +1,22 @@ @inherits LayoutComponentBase -
+
+ @* *@ -
+ @*
+ @Body +
*@ +
@Body -
+
diff --git a/Shared/MainLayout.razor.css b/Shared/MainLayout.razor.css index c865427..0301c8f 100644 --- a/Shared/MainLayout.razor.css +++ b/Shared/MainLayout.razor.css @@ -65,7 +65,7 @@ main { .top-row { position: sticky; top: 0; - z-index: 1; + /*z-index: 1;*/ } .top-row.auth ::deep a:first-child { diff --git a/Shared/NavLayout.razor b/Shared/NavLayout.razor new file mode 100644 index 0000000..2fa2d6d --- /dev/null +++ b/Shared/NavLayout.razor @@ -0,0 +1,17 @@ +@inherits LayoutComponentBase + +
+ + +
+ @Body +
+ +
+ +@code { + + +} diff --git a/Shared/NavLayout.razor.css b/Shared/NavLayout.razor.css new file mode 100644 index 0000000..0301c8f --- /dev/null +++ b/Shared/NavLayout.razor.css @@ -0,0 +1,81 @@ +.page { + position: relative; + display: flex; + flex-direction: column; +} + +main { + flex: 1; +} + +.sidebar { + background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); +} + +.top-row { + background-color: #f7f7f7; + border-bottom: 1px solid #d6d5d5; + justify-content: flex-end; + height: 3.5rem; + display: flex; + align-items: center; +} + + .top-row ::deep a, .top-row ::deep .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + text-decoration: none; + } + + .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { + text-decoration: underline; + } + + .top-row ::deep a:first-child { + overflow: hidden; + text-overflow: ellipsis; + } + +@media (max-width: 640.98px) { + .top-row:not(.auth) { + display: none; + } + + .top-row.auth { + justify-content: space-between; + } + + .top-row ::deep a, .top-row ::deep .btn-link { + margin-left: 0; + } +} + +@media (min-width: 641px) { + .page { + flex-direction: row; + } + + .sidebar { + width: 250px; + height: 100vh; + position: sticky; + top: 0; + } + + .top-row { + position: sticky; + top: 0; + /*z-index: 1;*/ + } + + .top-row.auth ::deep a:first-child { + flex: 1; + text-align: right; + width: 0; + } + + .top-row, article { + padding-left: 2rem !important; + padding-right: 1.5rem !important; + } +} diff --git a/Shared/NavMenu.razor b/Shared/NavMenu.razor index 16bfde1..d1b6cb9 100644 --- a/Shared/NavMenu.razor +++ b/Shared/NavMenu.razor @@ -24,6 +24,11 @@ Counter
+