Skip to content

Commit 1ebe2bc

Browse files
committed
Added guard and documentation for OnBeforeZoom and OnBeforeResetZoom
1 parent 44f2b44 commit 1ebe2bc

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

docs/BlazorApexCharts.Docs/Components/Events/BeforeResetZoom/BeforeResetZoom.razor

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@
33
<DocExamples Title="Before Reset Zoom">
44

55
<Description>
6-
Click the home icon on the chart to reset the zoom
6+
7+
<Alert BackgroundColor=TablerColor.Danger>
8+
<div class="d-flex">
9+
<div class="me-2">
10+
<Icon TextColor=TablerColor.Danger IconType=@Icons.Alert_triangle Size=40 />
11+
</div>
12+
<div>
13+
<h4 class="alert-title">Only supported in Blazor WebAssembly!</h4>
14+
<div class="text-muted">Event 'OnBeforeResetZoom' is only supported in web assembly</div>
15+
</div>
16+
</div>
17+
</Alert>
18+
19+
<h3>Click the home icon on the chart to reset the zoom</h3>
20+
21+
722
</Description>
823

924
<ChildContent>

docs/BlazorApexCharts.Docs/Components/Events/BeforeZoom/BeforeZoom.razor

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
<DocExamples Title="Before Zoom">
44

5+
<Description>
6+
<Alert BackgroundColor=TablerColor.Danger>
7+
<div class="d-flex">
8+
<div class="me-2">
9+
<Icon TextColor=TablerColor.Danger IconType=@Icons.Alert_triangle Size=40 />
10+
</div>
11+
<div>
12+
<h4 class="alert-title">Only supported in Blazor WebAssembly!</h4>
13+
<div class="text-muted">Event 'OnBeforeZoom' is only supported in web assembly</div>
14+
</div>
15+
</div>
16+
</Alert>
17+
</Description>
18+
519
<ChildContent>
620
<CodeSnippet Title="Basic" ClassName=@typeof(Basic).ToString()>
721
<Snippet>

docs/BlazorApexCharts.Docs/Components/Methods/UpdateSeries/Basic.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
@code {
3838
private List<WeatherForecast> forecasts { get; set; }
3939
private ApexChart<WeatherForecast> chart;
40-
private string message;
41-
40+
4241
protected override async Task OnInitializedAsync()
4342
{
4443
await LoadDataAsync();

src/Blazor-ApexCharts/ApexChart.razor.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ public virtual async Task HideSeriesAsync(string seriesName)
813813

814814
private void PrepareChart()
815815
{
816+
CheckChart();
816817
SetSeries();
817818
SetSeriesColors();
818819
SetSeriesStroke();
@@ -823,6 +824,23 @@ private void PrepareChart()
823824
SetCustomTooltip();
824825
}
825826

827+
private void CheckChart()
828+
{
829+
var jsInProcess = JSRuntime is IJSInProcessRuntime;
830+
if (OnBeforeZoom != null && !jsInProcess)
831+
{
832+
throw new NotSupportedException("Event 'OnBeforeZoom' is not suported in blazor server");
833+
}
834+
835+
if (OnBeforeResetZoom != null && !jsInProcess)
836+
{
837+
throw new NotSupportedException("Event 'OnBeforeResetZoom' is not suported in blazor server");
838+
}
839+
840+
841+
}
842+
843+
826844
private void SetCustomTooltip()
827845
{
828846
if (ApexPointTooltip == null) { return; }

0 commit comments

Comments
 (0)