Re: Chart is not rendering or showing when page is not referesh

I have tried Accumulation chart but it is not showing when the page is not refresh. I am using Blazor WebAssembly. You can see the project on this link. https://covidtracker-e4711.web.app/ - When the page is first loaded the chart appears but when I navigate to a different page like Canada or Philippine page, the chart is not loading. Is there something I am missing? Code below:

@using Syncfusion.Blazor.Charts
@inject AttributeService AttributeService

<style>
    .e-grid {
        border: none;
    }
        .e-grid tr.e-row {
            height: 30px;
        }
</style>

<div class="row rounded-lg shadow-lg" style="background: white;">
    <div class="col">
        <SfAccumulationChart Title="Status Chart" Width="100%" Height="380px" EnableSmartLabels="true">
            <AccumulationChartSeriesCollection>
                <AccumulationChartSeries DataSource="@Statuses" XName="X" YName="Y" Radius="83%" StartAngle="0" EndAngle="360" InnerRadius="25%" Palettes="@palettes">
                    <AccumulationDataLabelSettings Visible="true" Name="X" Position="AccumulationLabelPosition.Outside">
                        <AccumulationChartConnector Length="10%"></AccumulationChartConnector>
                        <AccumulationChartDataLabelFont Color="Black" Size="14px" FontFamily="Roboto"></AccumulationChartDataLabelFont>
                    </AccumulationDataLabelSettings>
                    <AccumulationChartAnimation Enable="false"></AccumulationChartAnimation>
                </AccumulationChartSeries>
            </AccumulationChartSeriesCollection>
            <AccumulationChartTooltipSettings Enable="true" Format="${point.x} : ${point.y}"></AccumulationChartTooltipSettings>
            <AccumulationChartLegendSettings Visible="false"></AccumulationChartLegendSettings>
        </SfAccumulationChart>
    </div>
    <div class="col mt-5">
        <SfGrid TValue="Status"
                DataSource="@Statuses"
                Width="50%"
                AllowSelection="false"
                GridLines="GridLine.None"
                EnableHover="false">

            <GridTemplates>
                <RowTemplate>
                    @{ var legend = (context as Status);
                        var style = "width: 16px; height: 16px; margin-left: 1px; " +
                                    "border-radius: 16px; background:" + legend.Color;

                        <td><div style="@style"></div></td>
                        <td style="text-align: left;">@legend.X</td>
                        <td style="text-align: right;">@legend.Y.ToString("N0")</td> }
                </RowTemplate>
            </GridTemplates>
            <GridColumns>
                <GridColumn Field="@nameof(Status.Color)" HeaderText="" Width="10" TextAlign="@TextAlign.Center"></GridColumn>
                <GridColumn Field="@nameof(Status.X)" HeaderText="Status" Width="10" TextAlign="@TextAlign.Left"></GridColumn>
                <GridColumn Field="@nameof(Status.Y)" HeaderText="Figure" Width="10" TextAlign="@TextAlign.Right"></GridColumn>
            </GridColumns>
        </SfGrid>
    </div>
</div>

@code { 
    private IEnumerable<Attributes> Countries;
    private List<Attributes> AllAttribute { get; set; }
    private List<Status> Statuses = new List<Status>();
    private string[] palettes = new string[] { "#61EFCD", "#CDDE1F", "#FEC200", "#CA765A" };

    private class Status
    {
        public string X { get; set; }
        public int Y { get; set; }
        public string Color { get; set; }
    }

    protected override async Task OnInitializedAsync()
    {
        AllAttribute = await AttributeService.GetAttributesAsync();
        UpdateValues();
        GetStatuses();
        await InvokeAsync(() => { StateHasChanged(); });
    }

    private void UpdateValues()
    {
        Countries = AllAttribute.Where(a => a.Country_Region == "Canada").ToList();
    }

    private void GetStatuses()
    {
        Statuses.Add(new Status
        {
            X = "Positive",
            Y = Countries.ElementAt(0).Confirmed,
            Color = this.palettes[0]
        });

        Statuses.Add(new Status
        {
            X = "Recovered",
            Y = Countries.ElementAt(0).Recovered,
            Color = this.palettes[1]
        });

        Statuses.Add(new Status
        {
            X = "Active",
            Y = Countries.ElementAt(0).Active,
            Color = this.palettes[2]
        });

        Statuses.Add(new Status
        {
            X = "Deaths",
            Y = Countries.ElementAt(0).Deaths,
            Color = this.palettes[3]
        });
    }


9 Replies 1 reply marked as answer

DG Durga Gopalakrishnan Syncfusion Team August 25, 2020 04:54 PM UTC

Hi Vincent, 

Greetings from Syncfusion. 

We have validated your reported scenario with your attached link and we have noted that at initial rendering the chart is rendered based on the data displayed in grid. While navigating to another page, both the grid and chart is rendering empty, and suspect that the datasource is not getting assigned to both the controls properly. So, now we have prepared a sample with two pages and while navigating from one page to another, charts are rendering fine. please check with attached sample. 

Sample 

Please revert us, if you need any further assistance on this. 

Regards, 
Durga G 



VP Vincent Paul de Jesus August 26, 2020 02:41 AM UTC

Hi Durga G,

Thanks for responding.

I don't think the problem is with the data source not properly assigned. I tried my code also in Blazor Server hosted and it worked just fine. The chart and the grid rendered every time I navigate to the page. I don't know why this is happening in Blazor WebAssembly. But I will figure this out and refactor my code.

Vince  


DG Durga Gopalakrishnan Syncfusion Team August 26, 2020 05:16 PM UTC

Hi Vincent, 

We have ensured both client side(web assembly) and server side blazor sample with provided code snippet. Charts and Grid are rendering fine while navigating from one page to another. Since, we are unable to reproduce the reported issue from our end, we have attached both the samples for your reference. 

Blazor WebAssembly 

Blazor Server 

Since we are unaware of your other customizations you used in your application, please share the following information which will be more helpful for further analysis and provide you the solution sooner. 
  • Try to reproduce the reported scenario in the above sample.
  • Please share your complete sample (or) code snippet with CSS settings that you used to design that part.
  • Share the details if you have done any other customization in your sample.
  • Share your chart and grid data source file, if possible.

Kindly get back to us with our requested details to serve you better. 

Regards, 
Durga G 



VP Vincent Paul de Jesus August 26, 2020 05:25 PM UTC

Durga G,

Download the source code of my project from my GitHub account and see for yourself what I am talking. The solution has both Blazor WASM and Server hosted project with identical code. The Server project runs smoothly without any issues while the Blazor WASM is the one with rendering problems. Follow this link to download - https://github.com/vpdejesus/CovidTracker

I am still refactoring the code and figuring out the problem with WASM project. I made some progress but still problem persist.

Hoping you can help.

Thanks.

Vince




DG Durga Gopalakrishnan Syncfusion Team August 27, 2020 02:53 PM UTC

Hi Vince, 

We are validating your reported scenario with provided sample. We will update the status within two business days(31st August, 2020). We appreciate your patience until then. 

Regards, 
Durga G 



DG Durga Gopalakrishnan Syncfusion Team September 3, 2020 02:53 PM UTC

Hi Vince, 

Sorry for delay in response. We have downloaded the sample from provided Github link. The sample includes both client and server side. We have chosen, Client project as Set as StartUp project and run the sample. We have navigated to Canada tab, both chart and grid is rendering fine, and then navigated to Philiphines tab, in that also both are rendering properly from our end. Please find the screenshots below.  

 

 

Kindly specify, in which scenario you are facing the reported issue and revert us, if you have any concerns. 

Regards, 
Durga G 



VP Vincent Paul de Jesus September 11, 2020 05:14 PM UTC

Hi Durga,

On the Blazor WASM (Client) project, the Global Page is always the problem. Sometimes the chart and the grid is not rendering when the page is not refreshed. This also happens to the Canada and Philippine page sometimes (look at the grid from your attached image from your previous reply on the Philippine Page, it is not rendering. No records displayed when it should have). But the issue is always on the Global Page. At first run, the Global page is okay. But when you navigate to the Canada or Philippine page and navigate back to the Global page, it does not render the chart and the grid always. But if you click the refresh button or reload the page from the browser, it renders the chart and the grid. I don't know the problem with the components. My code is okay already and has been running smoothly on the Blazor (Server) project without problems. Try from this link - https://covidtracker-e4711.web.app/ .  

CovTracker

Vince  


DG Durga Gopalakrishnan Syncfusion Team September 14, 2020 12:40 PM UTC

Hi Vince, 

We have ensured the provided blazor web assembly sample with your reported scenario. We were able to reproduce an issue from our end, but we are validating on this. We will update the status within 2 business days(16th September, 2020). We appreciate your patience until then. 

Regards, 
Durga G 



DG Durga Gopalakrishnan Syncfusion Team September 17, 2020 02:36 PM UTC

Hi Vince, 

Sorry for delay in response. We have validated your reported scenario. While running the blazor web assembly, all required dependencies are downloaded in browser itself and application is executed on browser UI thread. We have noted that, defining the empty list for datasource before obtaining the data from service url, data is not assigned to chart. So while navigation, the reported issue occurs. We suggest you define the list after getting data. Now it works properly as expected. Please find the code snippet and screenshot below. 

protected override async Task OnInitializedAsync() 
    { 
        var attributes = await AttributeService.GetAttributesAsync(); 
        DataSource = new List<PieData>(); 
        for (int i = 0; i < data.Count(); i++) 
        { 
            DataSource.Add(new PieData 
            { 
                X = data.ElementAt(i).Recovered, 
                //… 
            }); 
        } 
    } 


Kindly revert us, if you have any concerns. 

Regards, 
Durga G

Marked as answer
Loader.
Up arrow icon