diff --git a/Demos/Blazorise.Demo/Pages/Tests/ChartsDataLabelsPage.razor.cs b/Demos/Blazorise.Demo/Pages/Tests/ChartsDataLabelsPage.razor.cs index e7abd2ae9b..f495aa2183 100644 --- a/Demos/Blazorise.Demo/Pages/Tests/ChartsDataLabelsPage.razor.cs +++ b/Demos/Blazorise.Demo/Pages/Tests/ChartsDataLabelsPage.razor.cs @@ -182,7 +182,8 @@ public partial class ChartsDataLabelsPage BackgroundColor = BackgroundColors[2], BorderColor = BorderColors[2], Align = "center", - Anchor = "center" + Anchor = "center", + SoftCodeFormatter = "function(value, context) { return \"$\" + value; }" } }, }; diff --git a/Source/Extensions/Blazorise.Charts.DataLabels/ChartDataLabelsOptions.cs b/Source/Extensions/Blazorise.Charts.DataLabels/ChartDataLabelsOptions.cs index a7605ce2bc..dbe54a8c6d 100644 --- a/Source/Extensions/Blazorise.Charts.DataLabels/ChartDataLabelsOptions.cs +++ b/Source/Extensions/Blazorise.Charts.DataLabels/ChartDataLabelsOptions.cs @@ -55,6 +55,9 @@ public class ChartDataLabelsOptions [JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )] public ChartMathFormatter? Formatter { get; set; } + [JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )] + public string SoftCodeFormatter { get; set; } + [JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )] public object Labels { get; set; } diff --git a/Source/Extensions/Blazorise.Charts.DataLabels/wwwroot/chart.datalabels.js b/Source/Extensions/Blazorise.Charts.DataLabels/wwwroot/chart.datalabels.js index e95648dcbe..9ff3f4a2cc 100644 --- a/Source/Extensions/Blazorise.Charts.DataLabels/wwwroot/chart.datalabels.js +++ b/Source/Extensions/Blazorise.Charts.DataLabels/wwwroot/chart.datalabels.js @@ -52,7 +52,12 @@ function compileDatasetsOptionsCallbacks(options) { Object.keys(options).forEach(function (key) { if (options[key] && options[key].startsWith("function")) { - options[key] = parseFunction(options[key]); + if (key === 'softCodeFormatter') { + options['formatter'] = parseFunction(options[key]); + } else { + options[key] = parseFunction(options[key]); + } + } });