Skip to content

Commit d7d16dc

Browse files
authored
Merge pull request #610 from apexcharts/click-issue
Fixed clicked issue
2 parents d682d01 + 29ad7e8 commit d7d16dc

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@page "/issues/click"
2+
<ApexChart TItem="MyData"
3+
Title="Sample Data" OnClick="Click">
4+
5+
<ApexPointSeries TItem="MyData"
6+
Items="Data"
7+
Name="Net Profit"
8+
SeriesType="SeriesType.Bar"
9+
XValue="e => e.Category"
10+
YValue="e=> e.NetProfit" />
11+
12+
<ApexPointSeries TItem="MyData"
13+
Items="Data"
14+
Name="Revenue"
15+
SeriesType="SeriesType.Bar"
16+
XValue="e => e.Category"
17+
YValue="e=> e.Revenue" />
18+
</ApexChart>
19+
20+
@code {
21+
private List<MyData> Data { get; set; } = new();
22+
protected override void OnInitialized()
23+
{
24+
Data.Add(new MyData { Category = "Jan", NetProfit = 12, Revenue = 33 });
25+
Data.Add(new MyData { Category = "Feb", NetProfit = 43, Revenue = 42 });
26+
Data.Add(new MyData { Category = "Mar", NetProfit = 112, Revenue = 23 });
27+
}
28+
29+
public class MyData
30+
{
31+
public string Category { get; set; }
32+
public int NetProfit { get; set; }
33+
public int Revenue { get; set; }
34+
}
35+
36+
private void Click(SelectedData<MyData> obj)
37+
{
38+
Console.WriteLine(obj.DataPointIndex);
39+
}
40+
}

src/Blazor-ApexCharts/Internal/JSLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class JSLoader
1515
/// <param name="path"></param>
1616
public static async Task<IJSObjectReference> LoadAsync(IJSRuntime jsRuntime, string path = null)
1717
{
18-
var javascriptPath = "./_content/Blazor-ApexCharts/js/blazor-apexcharts.js?ver=6.0";
18+
var javascriptPath = "./_content/Blazor-ApexCharts/js/blazor-apexcharts.js?ver=6.0.1";
1919
if (!string.IsNullOrWhiteSpace(path)) { javascriptPath = path; }
2020

2121
// load Module ftom ES6 script

src/Blazor-ApexCharts/wwwroot/js/blazor-apexcharts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,10 @@ window.blazor_apexchart = {
474474
seriesIndex: -1
475475
};
476476

477-
if (config.dataPointIndex >= 0)
478-
selection.dataPointIndex = config.dataPointIndex;
477+
if (config.dataPointIndex >= 0 && config.dataPointIndex !== null)
478+
selection.dataPointIndex = Number(config.dataPointIndex);
479479

480-
if (config.seriesIndex >= 0)
480+
if (config.seriesIndex >= 0 && config.seriesIndex !== null)
481481
selection.seriesIndex = config.seriesIndex;
482482

483483
dotNetObject.invokeMethodAsync('JSClick', selection);

0 commit comments

Comments
 (0)