Skip to content

Commit 5fe6202

Browse files
authored
Merge pull request #17 from macias/main
onmouseout
2 parents b7521d7 + 9d2ce98 commit 5fe6202

5 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/Chart.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@inject IJSRuntime JSRuntime
22

33
<div id="@("chartcontainer" + Config.CanvasId)" class="chart-container @Class"
4-
style="height:@Height; width:@Width; @(Style)">
4+
style="height:@Height; width:@Width; @(Style)"
5+
@onmouseout="async (args) => await OnMouseOut(args)">
56
<canvas id="@Config.CanvasId" style="@(Height != null ? $"height:{Height}" : "") @(Width != null ? $"width:{Width};" : "")"></canvas>
67
</div>

src/Chart.razor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Microsoft.AspNetCore.Components;
33
using Microsoft.JSInterop;
44
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Components.Web;
56

67
namespace PSC.Blazor.Components.Chartjs
78
{
@@ -105,6 +106,14 @@ public void Dispose()
105106
this.oldReference?.Dispose();
106107
}
107108

109+
private ValueTask OnMouseOut(MouseEventArgs mouseEventArgs)
110+
{
111+
if (Config.Options is Options {OnMouseOutAsync: { }} options)
112+
return options.OnMouseOutAsync(mouseEventArgs);
113+
else
114+
return ValueTask.CompletedTask;
115+
}
116+
108117
#region JavaScript invokable functions
109118

110119
[JSInvokable]

src/Models/Common/HoverContext.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace PSC.Blazor.Components.Chartjs.Models.Common
1+
namespace PSC.Blazor.Components.Chartjs.Models.Common
82
{
93
/// <summary>
104
/// Hover Context

src/Models/Common/OnHoverContext.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Models/Common/Options.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Threading.Tasks;
2+
using Microsoft.AspNetCore.Components.Web;
23

34
namespace PSC.Blazor.Components.Chartjs.Models.Common
45
{
@@ -92,5 +93,8 @@ public class Options : IOptions
9293
[JsonPropertyName("scales")]
9394
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
9495
public Dictionary<string, Axis> Scales { get; set; }
96+
97+
[JsonIgnore]
98+
public Func<MouseEventArgs, ValueTask>? OnMouseOutAsync { get; set; }
9599
}
96100
}

0 commit comments

Comments
 (0)