Table in Tooltip in Blazor Chart component: InvalidCastException decimal to double

I had the tooltip customization on previous version 18.3.X working fine.

I updated blazor chart to version 18.4.0.42 and followed the new documentation_

https://blazor.syncfusion.com/documentation/chart/how-to/tool-tip-table/

The problem is that my datasource has type decimal instead of double.

Exception:
blazor.server.js:19 [2021-02-12T10:56:26.758Z] Error: System.InvalidCastException: Unable to cast object of type 'System.Decimal' to type 'System.Double'.
   at Syncfusion.Blazor.Charts.Chart.Internal.ChartTooltip.TriggerTooltipRender(PointData point, Boolean isFirst, String textCollection, String headerText)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__140_0(Object state)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)


TEST CODE (updated from https://blazor.syncfusion.com/documentation/chart/how-to/tool-tip-table/):
---------------------------------------------------------------
@page "/test"

@using Syncfusion.Blazor.Charts

<div class="row">
    <div class="col-md-8">
        <SfChart Title="Profit Comparison of A and B">
            <ChartPrimaryXAxis>
                <ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>
            </ChartPrimaryXAxis>
            <ChartPrimaryYAxis Minimum="0" Maximum="100" Interval="25" Title="Sales">
                <ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>
            </ChartPrimaryYAxis>
            <ChartSeriesCollection>
                <ChartSeries DataSource="@dataSource" Name="Product A" XName="x" Opacity="1" YName="y1" Type="ChartSeriesType.Column">
                </ChartSeries>
                <ChartSeries DataSource="@dataSource" Name="Product B" XName="x" Opacity="1" YName="y2" Type="ChartSeriesType.Column">
                </ChartSeries>
            </ChartSeriesCollection>
            <ChartArea>
                <ChartAreaBorder Width="0"></ChartAreaBorder>
            </ChartArea>
            <ChartTooltipSettings Enable="true">
                <Template>
                    @{
                        var data = context as ChartTooltipInfo;
                        <table>
                            <tr><td>Point Value: </td><td>@data.X : @data.Y</td></tr>
                            <tr><td><div id="chart_cloud"><img src="https://ej2.syncfusion.com/demos/src/chart/images/cloud.png" style="width: 41px; height: 41px" /></div></td></tr>
                        </table>
                    }
                </Template>
            </ChartTooltipSettings>
        </SfChart>
    </div>
</div>

@code
{
    public class ChartTooltipData
    {
        public decimal x { get; set; } // changed from double. I need decimal
        public decimal y1 { get; set; } // changed from double. I need decimal
        public decimal y2 { get; set; } // changed from double. I need decimal
    }
    public class SelectionData
    {
        public decimal x { get; set; } // changed from double. I need decimal
        public decimal y { get; set; } // changed from double. I need decimal
    }

    private Random rnd = new Random();
    public List<ChartTooltipData> dataSource = new List<ChartTooltipData>();

    protected override void OnInitialized()
    {
        for (int i = 0; i < 5; i++)
        {
            dataSource.Add(new ChartTooltipData { x = 1971 + i, y1 = rnd.Next(10, 100), y2 = rnd.Next(10, 100) });
        }
    }
}

---------------------------------------------------------------

The exception occours even with an empty template like this:

     <ChartTooltipSettings Enable="true">
                    <Template>
                        @{
                            var data = context as ChartTooltipInfo;
                            <table>
                               <tr><td>Point Value: </td><td>test</td></tr>
                            </table>
                        }
                    </Template>
                </ChartTooltipSettings>


2 Replies 1 reply marked as answer

DG Durga Gopalakrishnan Syncfusion Team February 15, 2021 12:09 PM UTC

Hi Dario,

Greetings from Syncfusion.

We have validated your reported scenario. We have considered this as a bug and logged a defect report. This fix will be available in our upcoming weekly patch release which is expected to be rolled out on 2nd March 2021. We appreciate your patience until then. You can keep track of the bug from the feedback portal below.


If you have any more specification/precise replication procedure or a scenario to be tested, you can add it as a comment in the portal. 

Regards,
Durga G


Marked as answer

DG Durga Gopalakrishnan Syncfusion Team March 2, 2021 01:04 PM UTC

Hi Dario, 
 
We are glad to announce that our v18.4.46 patch release is rolled out; we have added the fix for reported issue. You can use the latest Syncfusion.Blazor NuGet package version. 
 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Durga G 


Loader.
Up arrow icon