Skip to content

Commit 6b4de11

Browse files
authored
Merge pull request #459 from LayTec-AG/release/v5.4.0
Bump plotly.js, dependencies and implement Plotly.Update properly
2 parents 802cc1d + c99b292 commit 6b4de11

15 files changed

+261
-112
lines changed

Directory.Packages.props

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,26 @@
1212
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
1313
</ItemGroup>
1414
<ItemGroup>
15-
<PackageVersion Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components" Version="6.0.33" />
16-
<PackageVersion Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components.Web" Version="6.0.33" />
17-
<PackageVersion Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.33" />
18-
<PackageVersion Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.33" PrivateAssets="all" />
15+
<PackageVersion Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components" Version="6.0.36" />
16+
<PackageVersion Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components.Web" Version="6.0.36" />
17+
<PackageVersion Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.36" />
18+
<PackageVersion Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.36" PrivateAssets="all" />
1919
<PackageVersion Condition="'$(TargetFramework)' == 'net7.0'" Include="Microsoft.AspNetCore.Components" Version="7.0.20" />
2020
<PackageVersion Condition="'$(TargetFramework)' == 'net7.0'" Include="Microsoft.AspNetCore.Components.Web" Version="7.0.20" />
2121
<PackageVersion Condition="'$(TargetFramework)' == 'net7.0'" Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.20" />
2222
<PackageVersion Condition="'$(TargetFramework)' == 'net7.0'" Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.20" PrivateAssets="all" />
23-
<PackageVersion Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.AspNetCore.Components" Version="8.0.8" />
24-
<PackageVersion Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.AspNetCore.Components.Web" Version="8.0.8" />
25-
<PackageVersion Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" />
26-
<PackageVersion Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.8" PrivateAssets="all" />
23+
<PackageVersion Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.AspNetCore.Components" Version="8.0.11" />
24+
<PackageVersion Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.AspNetCore.Components.Web" Version="8.0.11" />
25+
<PackageVersion Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.11" />
26+
<PackageVersion Condition="'$(TargetFramework)' == 'net8.0'" Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.11" PrivateAssets="all" />
2727
<PackageVersion Include="MudBlazor" Version="6.20.0" />
28-
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
2928
<PackageVersion Include="PublishSPAforGitHubPages.Build" Version="3.0.0" />
3029
<PackageVersion Include="Stubble.Core" Version="1.10.8" />
31-
<PackageVersion Include="WeCantSpell.Hunspell" Version="5.0.0" />
32-
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
33-
<PackageVersion Include="nunit" Version="4.2.2" />
30+
<PackageVersion Include="WeCantSpell.Hunspell" Version="5.2.1" />
31+
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
32+
<PackageVersion Include="nunit" Version="4.3.0" />
3433
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
35-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
34+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
3635
<PackageVersion Update="GitVersion.MsBuild" Version="6.0.2" />
3736
</ItemGroup>
3837
</Project>

Plotly.Blazor.Examples/Components/LinePolarPlot.razor

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,52 @@
11
@using Plotly.Blazor.LayoutLib
2-
@using Plotly.Blazor.LayoutLib.SceneLib
3-
@using XAxis = Plotly.Blazor.LayoutLib.SceneLib.XAxis
4-
@using YAxis = Plotly.Blazor.LayoutLib.SceneLib.YAxis
5-
@using Newtonsoft.Json.Linq
6-
@using System.Globalization
7-
@using System.ComponentModel
8-
@using Plotly.Blazor.LayoutLib.LegendLib
9-
@using Plotly.Blazor.LayoutLib.PolarLib
10-
@using Plotly.Blazor.LayoutLib.PolarLib.RadialAxisLib
112
@using Plotly.Blazor.Traces.ScatterPolarLib
12-
@using Font = Plotly.Blazor.LayoutLib.Font
133
@inject NavigationManager MyNavigationManager
144

155
<PlotlyChart style="height: 60vh; min-height: 350px" @bind-Layout="layout" @bind-Data="data" @ref="chart"/>
166

177
@code
188
{
19-
[CascadingParameter]
20-
private MudTheme Theme { get; set; }
9+
[CascadingParameter] private MudTheme Theme { get; set; }
2110

2211
private PlotlyChart chart;
2312
private Layout layout;
2413
private IList<ITrace> data;
2514

2615
private bool IsInitialized { get; set; }
27-
16+
2817
protected override void OnInitialized()
2918
{
30-
layout = new Layout
19+
layout = new()
3120
{
32-
Title = new Title
21+
Title = new()
3322
{
3423
Text = "Line Polar Plot"
3524
},
3625
PaperBgColor = Theme.PaletteDark.Surface.ToString(),
3726
PlotBgColor = Theme.PaletteDark.Surface.ToString(),
38-
Font = new Font
27+
Font = new()
3928
{
4029
Color = Theme.PaletteDark.TextPrimary.ToString()
4130
},
4231
ShowLegend = true,
43-
Polar = new List<Polar>()
32+
Polar = new List<Polar>
4433
{
45-
new Polar()
34+
new()
4635
{
4736
BgColor = Theme.PaletteDark.Surface.ToString(),
48-
RadialAxis = new RadialAxis()
37+
RadialAxis = new()
4938
{
5039
Visible = true,
5140
Color = Theme.PaletteDark.TextPrimary.ToString(),
52-
Range = new []{0.0,1.0}.OfType<object>().ToList()
41+
Range = new[] { 0.0, 1.0 }.OfType<object>().ToList()
5342
}
5443
}
5544
},
56-
Legend = new List<Legend>()
45+
Legend = new List<Legend>
5746
{
58-
new Legend()
47+
new()
5948
{
60-
Title = new LayoutLib.LegendLib.Title()
49+
Title = new()
6150
{
6251
Text = "Mic Patterns"
6352
}
@@ -72,7 +61,7 @@
7261
264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360
7362
};
7463

75-
var trace1 = new ScatterPolar()
64+
var trace1 = new ScatterPolar
7665
{
7766
R = new[]
7867
{
@@ -84,25 +73,25 @@
8473
Theta = theta.OfType<object>().ToList(),
8574
Mode = ModeFlag.Lines,
8675
Name = "Figure 8",
87-
Line = new Line() { Color = "Peru" }
76+
Line = new() { Color = "Peru" }
8877
};
89-
var trace2 = new ScatterPolar()
78+
var trace2 = new ScatterPolar
9079
{
91-
R = new []
80+
R = new[]
9281
{
93-
1, 0.997, 0.989, 0.976, 0.957, 0.933, 0.905, 0.872, 0.835, 0.794, 0.75, 0.703, 0.655, 0.604, 0.552, 0.5, 0.448,
94-
0.396, 0.345, 0.297, 0.25, 0.206, 0.165, 0.128, 0.095, 0.067, 0.043, 0.024, 0.011, 0.003, 0, 0.003, 0.011, 0.024,
95-
0.043, 0.067, 0.095, 0.128, 0.165, 0.206, 0.25, 0.297, 0.345, 0.396, 0.448, 0.5, 0.552, 0.604, 0.655, 0.703, 0.75,
82+
1, 0.997, 0.989, 0.976, 0.957, 0.933, 0.905, 0.872, 0.835, 0.794, 0.75, 0.703, 0.655, 0.604, 0.552, 0.5, 0.448,
83+
0.396, 0.345, 0.297, 0.25, 0.206, 0.165, 0.128, 0.095, 0.067, 0.043, 0.024, 0.011, 0.003, 0, 0.003, 0.011, 0.024,
84+
0.043, 0.067, 0.095, 0.128, 0.165, 0.206, 0.25, 0.297, 0.345, 0.396, 0.448, 0.5, 0.552, 0.604, 0.655, 0.703, 0.75,
9685
0.794, 0.835, 0.872, 0.905, 0.933, 0.957, 0.976, 0.989, 0.997, 1
9786
}.OfType<object>().ToList(),
9887
Theta = theta.OfType<object>().ToList(),
9988
Mode = ModeFlag.Lines,
10089
Name = "Cardioid",
101-
Line = new Line(){Color = "darkviolet"}
90+
Line = new() { Color = "darkviolet" }
10291
};
103-
var trace3 = new ScatterPolar()
92+
var trace3 = new ScatterPolar
10493
{
105-
R = new []
94+
R = new[]
10695
{
10796
1, 0.996, 0.984, 0.963, 0.935, 0.9, 0.857, 0.807, 0.752, 0.691, 0.625, 0.555, 0.482, 0.406, 0.328, 0.25, 0.172, 0.094,
10897
0.018, 0.055, 0.125, 0.191, 0.252, 0.307, 0.357, 0.4, 0.435, 0.463, 0.484, 0.496, 0.5, 0.496, 0.484, 0.463, 0.435, 0.4,
@@ -112,25 +101,25 @@
112101
Theta = theta.OfType<object>().ToList(),
113102
Mode = ModeFlag.Lines,
114103
Name = "Hypercardioid",
115-
Line = new Line(){Color = "deepskyblue"}
104+
Line = new() { Color = "deepskyblue" }
116105
};
117-
var trace4 = new ScatterPolar()
106+
var trace4 = new ScatterPolar
118107
{
119-
R = new []
108+
R = new[]
120109
{
121-
1, 0.998, 0.993, 0.985, 0.974, 0.96, 0.943, 0.923, 0.901, 0.876, 0.85, 0.822, 0.793, 0.762, 0.731, 0.7, 0.669, 0.638, 0.607,
122-
0.578, 0.55, 0.524, 0.499, 0.477, 0.457, 0.44, 0.426, 0.415, 0.407, 0.402, 0.4, 0.402, 0.407, 0.415, 0.426, 0.44, 0.457, 0.477,
110+
1, 0.998, 0.993, 0.985, 0.974, 0.96, 0.943, 0.923, 0.901, 0.876, 0.85, 0.822, 0.793, 0.762, 0.731, 0.7, 0.669, 0.638, 0.607,
111+
0.578, 0.55, 0.524, 0.499, 0.477, 0.457, 0.44, 0.426, 0.415, 0.407, 0.402, 0.4, 0.402, 0.407, 0.415, 0.426, 0.44, 0.457, 0.477,
123112
0.499, 0.524, 0.55, 0.578, 0.607, 0.638, 0.669, 0.7, 0.731, 0.762, 0.793, 0.822, 0.85, 0.876, 0.901, 0.923, 0.943, 0.96, 0.974,
124113
0.985, 0.993, 0.998, 1
125114
}.OfType<object>().ToList(),
126115
Theta = theta.OfType<object>().ToList(),
127116
Mode = ModeFlag.Lines,
128117
Name = "Subcardioid",
129-
Line = new Line(){Color = "orangered"}
118+
Line = new() { Color = "orangered" }
130119
};
131-
var trace5 = new ScatterPolar()
120+
var trace5 = new ScatterPolar
132121
{
133-
R = new []
122+
R = new[]
134123
{
135124
1, 0.997, 0.986, 0.969, 0.946, 0.916, 0.88, 0.838, 0.792, 0.74, 0.685, 0.626, 0.565, 0.501, 0.436, 0.37, 0.304, 0.239, 0.175, 0.114, 0.055,
136125
0, 0.052, 0.098, 0.14, 0.176, 0.206, 0.229, 0.246, 0.257, 0.26, 0.257, 0.246, 0.229, 0.206, 0.176, 0.14, 0.098, 0.052, 0, 0.055, 0.114, 0.175,
@@ -139,17 +128,17 @@
139128
Theta = theta.OfType<object>().ToList(),
140129
Mode = ModeFlag.Lines,
141130
Name = "Supercardioid",
142-
Marker = new Marker()
131+
Marker = new()
143132
{
144133
Color = "none",
145-
Line = new Traces.ScatterPolarLib.MarkerLib.Line()
134+
Line = new()
146135
{
147136
Color = "green"
148137
}
149138
}
150139
};
151140

152-
data = new List<ITrace>() { trace1 , trace2, trace3, trace4, trace5 };
141+
data = new List<ITrace> { trace1, trace2, trace3, trace4, trace5 };
153142

154143
base.OnInitialized();
155144
}

Plotly.Blazor.Examples/Components/RibbonChart.razor

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
@using Plotly.Blazor.LayoutLib
1+
@using System.Text.Json.Nodes
2+
@using MudBlazor
3+
@using Plotly.Blazor.LayoutLib
24
@using Plotly.Blazor.LayoutLib.SceneLib
5+
@using System.Text.Json
6+
@using Plotly.Blazor.Traces
37
@using XAxis = Plotly.Blazor.LayoutLib.SceneLib.XAxis
48
@using YAxis = Plotly.Blazor.LayoutLib.SceneLib.YAxis
5-
@using Newtonsoft.Json.Linq
69
@using Plotly.Blazor.Interop
710
@using Plotly.Blazor.Examples.Components.Display
811
@inject NavigationManager MyNavigationManager
912

1013
@if (!IsInitialized)
1114
{
1215
<MudPaper>
13-
<MudProgressLinear Color="Color.Primary" Indeterminate="true"/>
16+
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
1417
</MudPaper>
1518
}
1619

17-
<PlotlyChart style="height: 60vh; min-height: 350px" @bind-Config="config" @bind-Layout="layout" @bind-Data="data" @ref="chart"
18-
ClickAction="ClickAction" HoverAction="HoverAction" AfterRender="LoadData"/>
20+
<PlotlyChart style="height: 60vh; min-height: 350px" @bind-Config="config" @bind-Layout="layout" @bind-Data="data" @ref="chart"
21+
ClickAction="ClickAction" HoverAction="HoverAction" AfterRender="LoadData" />
1922

20-
<HoverClickDisplay ClickInfos="@ClickInfos" HoverInfos="@HoverInfos"/>
23+
<HoverClickDisplay ClickInfos="@ClickInfos" HoverInfos="@HoverInfos" />
2124

2225
@code
2326
{
@@ -39,35 +42,35 @@
3942
protected override void OnInitialized()
4043
{
4144
config = new Config
42-
{
43-
ShowLink = false,
44-
Responsive = true,
45-
DisplayLogo = false
46-
};
45+
{
46+
ShowLink = false,
47+
Responsive = true,
48+
DisplayLogo = false
49+
};
4750

4851
layout = new Layout
49-
{
50-
Title = new Title
51-
{
52-
Text = GetType().Name
53-
},
54-
PaperBgColor = Theme.PaletteDark.Surface.ToString(),
55-
PlotBgColor = Theme.PaletteDark.Surface.ToString(),
56-
Font = new Font
57-
{
58-
Color = Theme.PaletteDark.TextPrimary.ToString()
59-
},
60-
ShowLegend = false,
61-
Scene = new[]
6252
{
53+
Title = new Title
54+
{
55+
Text = GetType().Name
56+
},
57+
PaperBgColor = Theme.PaletteDark.Surface.ToString(),
58+
PlotBgColor = Theme.PaletteDark.Surface.ToString(),
59+
Font = new Font
60+
{
61+
Color = Theme.PaletteDark.TextPrimary.ToString()
62+
},
63+
ShowLegend = false,
64+
Scene = new[]
65+
{
6366
new Scene
6467
{
6568
XAxis = new XAxis { Title = new LayoutLib.SceneLib.XAxisLib.Title { Text = "Sample #" } },
6669
YAxis = new YAxis { Title = new LayoutLib.SceneLib.YAxisLib.Title { Text = "Wave length" } },
6770
ZAxis = new ZAxis { Title = new LayoutLib.SceneLib.ZAxisLib.Title { Text = "OD" } }
6871
}
6972
}
70-
};
73+
};
7174

7275
data = new List<ITrace>();
7376
base.OnInitialized();
@@ -82,13 +85,23 @@
8285
BaseAddress = new Uri(MyNavigationManager.BaseUri)
8386
};
8487

88+
var options = new JsonSerializerOptions
89+
{
90+
PropertyNameCaseInsensitive = true
91+
};
92+
8593
var jsonResponse = await client.GetStringAsync(Url);
86-
var jsonObject = JObject.Parse(jsonResponse);
87-
var results = jsonObject["data"]?.Children().ToList();
8894

89-
if (!results?.Any() ?? true) return;
95+
var jsonDocument = JsonDocument.Parse(jsonResponse);
96+
var results = jsonDocument.RootElement
97+
.GetProperty("data")
98+
.EnumerateArray()
99+
.Select(element => element.Deserialize<Ribbon>(options))
100+
.ToList();
101+
102+
if (results == null || !results.Any()) return;
90103

91-
foreach (var ribbon in results.Select(obj => obj.ToObject<Ribbon>()))
104+
foreach (var ribbon in results)
92105
{
93106
await InvokeAsync(async () => await chart.AddTrace(new Surface
94107
{
@@ -102,19 +115,20 @@
102115
// Add the delay to keep the UI responsive
103116
await Task.Delay(10);
104117
}
118+
105119
IsInitialized = true;
106120
await InvokeAsync(StateHasChanged);
107121
});
108-
122+
109123
SubscribeEvents();
110124
}
111-
125+
112126
public void ClickAction(IEnumerable<EventDataPoint> eventData)
113127
{
114128
ClickInfos = eventData;
115129
StateHasChanged();
116130
}
117-
131+
118132
public void HoverAction(IEnumerable<EventDataPoint> eventData)
119133
{
120134
HoverInfos = eventData;

0 commit comments

Comments
 (0)