Skip to content

Commit

Permalink
Merge pull request #366 from LayTec-AG/release/3.0.0
Browse files Browse the repository at this point in the history
Release/3.0.0
  • Loading branch information
sean-mcl authored Oct 12, 2023
2 parents 06c5563 + 54b5ada commit e6097c3
Show file tree
Hide file tree
Showing 43 changed files with 3,538 additions and 1,915 deletions.
81 changes: 81 additions & 0 deletions Plotly.Blazor.Examples/Components/Click.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@using Plotly.Blazor.Interop
@using Plotly.Blazor.LayoutLib
@using Plotly.Blazor.Traces.ScatterLib

<PlotlyChart style="height: 60vh; min-height: 350px"
@bind-Config="config" @bind-Layout="layout" @bind-Data="data" @ref="chart"
ClickAction="ClickAction" AfterRender="SubscribeEvents" />

@if (ClickInfos != null && ClickInfos.Any())
{
<MudText>Current X: @ClickInfos.First().X</MudText>
<MudText>Current Y: @ClickInfos.FirstOrDefault(d => d.TraceIndex == 0)?.Y</MudText>
<MudText>Current Y2: @ClickInfos.FirstOrDefault(d => d.TraceIndex == 1)?.Y</MudText>
}

@code
{
[CascadingParameter]
private MudTheme Theme { get; set; }

private PlotlyChart chart;
private Config config;
private Layout layout;
private IList<ITrace> data;
private IEnumerable<EventDataPoint> ClickInfos { get; set; }

/// <inheritdoc />
protected override void OnInitialized()
{
config = new Config
{
Responsive = true
};

layout = new Layout
{
Title = new Title
{
Text = GetType().Name
},
PaperBgColor = Theme.PaletteDark.Surface.ToString(),
PlotBgColor = Theme.PaletteDark.Surface.ToString(),
Font = new Font
{
Color = Theme.PaletteDark.TextPrimary.ToString()
},
HoverMode = HoverModeEnum.XUnified
};

data = new List<ITrace>
{
new Scatter
{
Name = "ScatterTrace",
Mode = ModeFlag.Markers,
X = Enumerable.Range(0, 30).Cast<object>().ToList(),
Y = Helper.GenerateData(0, 30).Y
},
new Scatter
{
Name = "ScatterTrace 2",
Mode = ModeFlag.Markers,
X = Enumerable.Range(0, 30).Cast<object>().ToList(),
Y = Helper.GenerateData(0, 30).Y
}
};

base.OnInitialized();
}

public void ClickAction(IEnumerable<EventDataPoint> eventData)
{
ClickInfos = eventData;
StateHasChanged();
}

public async void SubscribeEvents()
{
await chart.SubscribeClickEvent();
}
}
4 changes: 2 additions & 2 deletions Plotly.Blazor.Examples/Components/Hover.razor
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
private Config config;
private Layout layout;
private IList<ITrace> data;
private IEnumerable<HoverEventDataPoint> HoverInfos { get; set; }
private IEnumerable<EventDataPoint> HoverInfos { get; set; }

/// <inheritdoc />
protected override void OnInitialized()
Expand Down Expand Up @@ -68,7 +68,7 @@
base.OnInitialized();
}

public void HoverAction(IEnumerable<HoverEventDataPoint> eventData)
public void HoverAction(IEnumerable<EventDataPoint> eventData)
{
HoverInfos = eventData;
StateHasChanged();
Expand Down
17 changes: 16 additions & 1 deletion Plotly.Blazor.Examples/Components/MapChart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@using Plotly.Blazor.LayoutLib.GeoLib.ProjectionLib
@using Plotly.Blazor.Traces.ScatterGeoLib
@using System.Globalization
@using Plotly.Blazor.Interop
@inject NavigationManager MyNavigationManager

@if (!IsInitialized)
Expand All @@ -12,7 +13,13 @@
</MudPaper>
}

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

@if (HoverInfos != null && HoverInfos.Any())
{
<MudText>Current Lat: @HoverInfos.First().Lat</MudText>
<MudText>Current Lon: @HoverInfos.First().Lon</MudText>
}

@code
{
Expand All @@ -23,6 +30,7 @@
private Config config;
private Layout layout;
private IList<ITrace> data;
private IEnumerable<EventDataPoint> HoverInfos { get; set; }

private bool IsInitialized { get; set; }

Expand Down Expand Up @@ -108,6 +116,12 @@
}).Cast<ITrace>().ToList();
}

public void HoverAction(IEnumerable<EventDataPoint> eventData)
{
HoverInfos = eventData;
StateHasChanged();
}

private void LoadData()
{
Task.Run(async () =>
Expand All @@ -119,6 +133,7 @@
await Task.Delay(10);
}
IsInitialized = true;
await chart.SubscribeHoverEvent();
await InvokeAsync(StateHasChanged);
});
}
Expand Down
2 changes: 1 addition & 1 deletion Plotly.Blazor.Examples/Components/PieChart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
//var v = value.ToString();
}

public void HoverAction(IEnumerable<HoverEventDataPoint> eventData)
public void HoverAction(IEnumerable<EventDataPoint> eventData)
{
// Use the values if needed
//var first = eventData.First();
Expand Down
23 changes: 20 additions & 3 deletions Plotly.Blazor.Examples/Components/SurfaceChart.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@using Plotly.Blazor.LayoutLib
@using System.Globalization
@using Plotly.Blazor.Interop
@inject NavigationManager MyNavigationManager

@if (!IsInitialized)
Expand All @@ -9,7 +10,14 @@
</MudPaper>
}

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

@if (HoverInfos != null && HoverInfos.Any())
{
<MudText>Current X: @HoverInfos.First().X</MudText>
<MudText>Current Y: @HoverInfos.First().Y</MudText>
<MudText>Current Z: @HoverInfos.First().Z</MudText>
}

@code
{
Expand All @@ -21,6 +29,8 @@
private Layout layout;
private IList<ITrace> data;

private IEnumerable<EventDataPoint> HoverInfos { get; set; }

private bool IsInitialized { get; set; }

/// <inheritdoc />
Expand Down Expand Up @@ -63,18 +73,25 @@
{
Task.Run(async () =>
{
foreach (var trace in await GetMapData())
foreach (var trace in await GetSurfaceData())
{
await InvokeAsync(async () => await chart.AddTrace(trace));
// Add the delay to keep the UI responsive
await Task.Delay(10);
}
IsInitialized = true;
await chart.SubscribeHoverEvent();
await InvokeAsync(StateHasChanged);
});
}

async Task<IList<ITrace>> GetMapData()
public void HoverAction(IEnumerable<EventDataPoint> eventData)
{
HoverInfos = eventData;
StateHasChanged();
}

async Task<IList<ITrace>> GetSurfaceData()
{
IList<ITrace> mapData = new List<ITrace>();

Expand Down
5 changes: 5 additions & 0 deletions Plotly.Blazor.Examples/Pages/ClickPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@page "/click"

<Example Title="Scatter Chart with Click-Event" Url="Plotly.Blazor.Examples/Components/Click.razor">
<Click/>
</Example>
46 changes: 1 addition & 45 deletions Plotly.Blazor.Examples/Shared/Example.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,4 @@

[Parameter]
public RenderFragment ChildContent { get; set; }
}



@*<h1>@Title</h1>
@*<Tabs SelectedTab="@selectedTab" SelectedTabChanged="@OnSelectedTabChanged">
<Items>
<Tab Name="example">Example</Tab>
<Tab Name="code">Code</Tab>
</Items>
<Content>
<TabPanel Name="example">
<Container Fluid="true">
<br/>
@ChildContent
</Container>
</TabPanel>
<TabPanel Name="code">
<Container Fluid="true">
<br/>
<CodeSnippet Url="@Url"/>
</Container>
</TabPanel>
</Content>
</Tabs>
@code{
string selectedTab = "example";
[Parameter]
public string Title { get; set; }
[Parameter]
public string Url { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
private void OnSelectedTabChanged(string name)
{
selectedTab = name;
}
}*@
}
1 change: 1 addition & 0 deletions Plotly.Blazor.Examples/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<MudNavLink Match="NavLinkMatch.All" Href="@($"{NavManager.BaseUri}indicator")">Indicator</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="@($"{NavManager.BaseUri}smith")">Smith</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="@($"{NavManager.BaseUri}hover")">HoverEvent</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="@($"{NavManager.BaseUri}click")">ClickEvent</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="@($"{NavManager.BaseUri}relayout")">RelayoutEvent</MudNavLink>
</MudNavMenu>
</MudDrawer>
6 changes: 5 additions & 1 deletion Plotly.Blazor.Generator/CustomDic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,8 @@ backoffsrc=backoffSrc
standoffsrc=standoffSrc
stepsrc=stepSrc
minreducedheight=minReducedHeight
minreducedwidth=minReducedWidth
minreducedwidth=minReducedWidth
quartiles=quartiles
sdmultiple=sdMultiple
autorangeoptions=autoRangeOptions
includesrc=includeSrc
8 changes: 6 additions & 2 deletions Plotly.Blazor.Generator/Plotly.Blazor.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
<Compile Remove="src\EnumConverter.cs" />
<Compile Remove="src\Extensions.cs" />
<Compile Remove="src\ImageFormat.cs" />
<Compile Remove="src\Interop\HoverEventDataPoint.cs" />
<Compile Remove="src\Interop\EventDataPoint.cs" />
<Compile Remove="src\Interop\RelayoutEventData.cs" />
<Compile Remove="src\PlotlyChart.razor.cs" />
<Compile Remove="src\PlotlyConverter.cs" />
<Compile Remove="src\PlotlyJsInterop.cs" />
<Compile Remove="src\PolymorphicConverter.cs" />
Expand Down Expand Up @@ -86,12 +87,15 @@
<None Include="src\ImageFormat.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="src\Interop\HoverEventDataPoint.cs">
<None Include="src\Interop\EventDataPoint.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="src\Interop\RelayoutEventData.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="src\PlotlyChart.razor.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="src\PlotlyConverter.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 1 addition & 1 deletion Plotly.Blazor.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Plotly.Blazor.Generator
internal class Program
{
private const string NAMESPACE = "Plotly.Blazor";
private const string PLOTLY_JS_URL = "https://cdn.plot.ly/plotly-2.25.1.min.js";
private const string PLOTLY_JS_URL = "https://cdn.plot.ly/plotly-2.26.2.min.js";

private static SchemaRoot _schema;
private static StubbleVisitorRenderer _stubble;
Expand Down
Loading

0 comments on commit e6097c3

Please sign in to comment.