Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions src/ChartJs.Blazor/ChartJS/ChartJsInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,9 @@ public static class ChartJsInterop
/// <returns></returns>
public static ValueTask<bool> SetupChart(this IJSRuntime jsRuntime, ConfigBase chartConfig)
{
try
{
dynamic dynParam = StripNulls(chartConfig);
Dictionary<string, object> param = ConvertExpandoObjectToDictionary(dynParam);
return jsRuntime.InvokeAsync<bool>($"{ChartJsInteropName}.SetupChart", param);
}
catch (Exception exp)
{
Console.WriteLine($"Error while setting up chart: {exp.Message}");
}

return new ValueTask<bool>(false);
dynamic dynParam = StripNulls(chartConfig);
Dictionary<string, object> param = ConvertExpandoObjectToDictionary(dynParam);
return jsRuntime.InvokeAsync<bool>($"{ChartJsInteropName}.SetupChart", param);
}

/// <summary>
Expand Down Expand Up @@ -92,18 +83,9 @@ private static Dictionary<string, object> RecursivelyConvertIDictToDict(IDiction
/// <returns></returns>
public static ValueTask<bool> UpdateChart(this IJSRuntime jsRuntime, ConfigBase chartConfig)
{
try
{
dynamic dynParam = StripNulls(chartConfig);
Dictionary<string, object> param = ConvertExpandoObjectToDictionary(dynParam);
return jsRuntime.InvokeAsync<bool>($"{ChartJsInteropName}.UpdateChart", param);
}
catch (Exception exp)
{
Console.WriteLine($"Error while updating chart: {exp.Message}");
}

return new ValueTask<bool>(false);
dynamic dynParam = StripNulls(chartConfig);
Dictionary<string, object> param = ConvertExpandoObjectToDictionary(dynParam);
return jsRuntime.InvokeAsync<bool>($"{ChartJsInteropName}.UpdateChart", param);
}

/// <summary>
Expand Down
9 changes: 1 addition & 8 deletions src/ChartJs.Blazor/ChartJS/MomentJsInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ public static ValueTask<string[]> GetAvailableLocales(this IJSRuntime jsRuntime)
/// <returns></returns>
public static ValueTask<bool> ChangeLocale(this IJSRuntime jsRuntime, string locale)
{
try
{
return jsRuntime.InvokeAsync<bool>($"{MomentJsInteropName}.changeLocale", locale);
}
catch
{
return new ValueTask<bool>(false);
}
return jsRuntime.InvokeAsync<bool>($"{MomentJsInteropName}.changeLocale", locale);
}
}
}