I am working on making a barchart that shows running hours. The intended display would be 3 hours and 10 minutes
Using the default tooltip label would mean that this would be shown as 3.1667 hours
, which isn't user friendly way of displaying the data.
Since Blazorise 1.7 it is possible to do this using the ChartTooltipCallback
however I can't seem to make it work.
If I look at the class itself
Callbacks = new ChartTooltipCallbacks
{
Label = x => "Hello world"
}
should work but I get an SystemArgumentException
Unhandled exception rendering component: The expression must return a FormattableString. (Parameter 'expression')
System.ArgumentException: The expression must return a FormattableString. (Parameter 'expression')
at Blazorise.Utilities.ExpressionConverter.ToTemplatedStringLiteral(LambdaExpression expression)
at Blazorise.Utilities.Converters.<ToDictionary>g__ProcessValue|1_0(Object value, Boolean emitDefaultValue, <>c__DisplayClass1_0&)
at Blazorise.Utilities.Converters.ToDictionary(Object source, Boolean addEmptyObjects, Boolean forceCamelCase)
at Blazorise.Utilities.Converters.<ToDictionary>g__ProcessValue|1_0(Object value, Boolean emitDefaultValue, <>c__DisplayClass1_0&)
at Blazorise.Utilities.Converters.ToDictionary(Object source, Boolean addEmptyObjects, Boolean forceCamelCase)
at Blazorise.Utilities.Converters.<ToDictionary>g__ProcessValue|1_0(Object value, Boolean emitDefaultValue, <>c__DisplayClass1_0&)
at Blazorise.Utilities.Converters.ToDictionary(Object source, Boolean addEmptyObjects, Boolean forceCamelCase)
at Blazorise.Utilities.Converters.<ToDictionary>g__ProcessValue|1_0(Object value, Boolean emitDefaultValue, <>c__DisplayClass1_0&)
at Blazorise.Utilities.Converters.ToDictionary(Object source, Boolean addEmptyObjects, Boolean forceCamelCase)
at Blazorise.Charts.BaseChart`4.SetOptions(TOptions options)
I've had a look at Difference between String, FormattableString, IFormattable which explains the formattable string, but even if I change it to
Callbacks = new ChartTooltipCallbacks
{
Label = x=> $"Hello world {x.FormattedValue}"
}
the same exception gets thrown.