Chart Data Label Template throws error

When trying out the code from here:

https://blazor.syncfusion.com/documentation/chart/data-label-template/

which is this (without changes)

@using Syncfusion.Blazor.Charts

<SfChart>
    <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"/>
    <ChartSeriesCollection>
        <ChartSeries DataSource="@WeatherReports" XName="X" YName="Y">
            <ChartMarker>
                <ChartDataLabel Visible="true">
                    <Template>
                        @{ 
                            var data = context as ChartDataPointInfo;
                        }
                        <div style="background-color: aliceblue">@data.PointX</div>
                    </Template>
                </ChartDataLabel>
            </ChartMarker>
        </ChartSeries>
    </ChartSeriesCollection>
</SfChart>

@code{
    public class Data
    {
        public string X { get; set; }
        public double Y { get; set; }
        public string Fill { get; set; }
        public string Text { get; set; }
    }

    public List<Data> WeatherReports = new List<Data> {
           new Data{ X= "Jan", Y= 3,   Fill= "#498fff", Text= "January" },
           new Data{ X= "Feb", Y= 3.5, Fill= "#ffa060", Text= "February" },
           new Data{ X= "Mar", Y= 7,   Fill= "#ff68b6", Text= "March" },
           new Data{ X= "Apr", Y= 13.5,Fill= "#81e2a1", Text= "April" }
        };
};

The following exception is thrown  (SF 19.1.0.63)


System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.Blazor.Charts.SfChart.UpdateDatalabelTemplate()
   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)


4 Replies 1 reply marked as answer

SM Srihari Muthukaruppan Syncfusion Team May 26, 2021 12:56 PM UTC

Hi Joseph, 
 
We are able to reproduce the reported scenario. Based on your request we have logged a bug task on this. You can keep track of it from the below feedback portal link.  
  
 
This fix will be available in our weekly patch release which is scheduled to be rolled out on or before 8 June 2021. We appreciate your patience until then. 
 
Regards, 
Srihari M 



SM Srihari Muthukaruppan Syncfusion Team June 9, 2021 12:37 PM UTC

Hi Joseph,   
   
We are glad to announce that our v19.1.67 patch release is rolled out, we have added the fix for the reported scenario. And you can use the latest (19.1.67) Syncfusion.EJ2.Blazor NuGet package version to get rid of the reported issue.    
     
 
 
Screenshot:  
 
  
We appreciate your patience in waiting for this release. Kindly let us know if you need further assistance.    
    
Regards,    
Srihari    


Marked as answer

JT Joseph Tan June 23, 2021 10:30 PM UTC

that worked. Thanks



SM Srihari Muthukaruppan Syncfusion Team June 24, 2021 05:49 AM UTC

Hi Joseph, 
 
Most welcome. 
 
Kindly get in touch with us, if you requires further assistance. We are always happy in assisting you.   
   
Thanks,   
Srihari 


Loader.
Up arrow icon