Skip to content

Commit

Permalink
🆕 feat(ECharts): support for verbatim text of function string (#1449)
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem authored Jul 27, 2023
1 parent 4ea5a6e commit 68bd0ca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Masa.Blazor/Components/ECharts/MECharts.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,18 @@ public async Task SetOption(object? option = null, bool notMerge = true, bool la

if (IncludeFunctionsInOption && IsAnyFunction(option, out var optionJson))
{
// unescape verbatim text
optionJson = Regex.Unescape(optionJson);

// remove the double quotes around the function
optionJson = FormatFunction(optionJson);

// remove the double quotes around the lambda
optionJson = FormatLambda(optionJson);

// convert unicode to string
optionJson = Unicode2String(optionJson);

await _echarts.SetJsonOptionAsync(optionJson, notMerge, lazyUpdate);
}
else
Expand Down Expand Up @@ -232,6 +241,7 @@ public static bool IsAnyFunction(object option, out string optionJson)
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});

// check if the option contains "function" or "=>"
return optionJson.Contains("function") || optionJson.Contains("=\\u003e", StringComparison.OrdinalIgnoreCase);
}

Expand Down

0 comments on commit 68bd0ca

Please sign in to comment.