datetimecategory System.InvalidOperationException Sequence contains no elements

Hi, I'm newbie to using stock chart,


I made three different charts.

first and second chart loads data when initialize the page and those

"StockChartPrimaryXAxis" is mentioned as 

<StockChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTimeCategory">

.

It works perfect but not the third one.

third one calls the data with null at initialization.

When I choose the selection with dropdownbox,

StockChartSeries DataSource="@stockhistorylist" ​stockhistorylist will be called and call refresh() method.


I tried,

1) call valuetype at the first,

<StockChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTimeCategory">

then, I got this error, 

warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]

      Unhandled exception rendering component: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

      System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

         at System.Collections.Generic.List`1.get_Item(Int32 index)

         at Syncfusion.Blazor.Charts.SfStockChart.CalculateAutoPeriods()

         at Syncfusion.Blazor.Charts.SfStockChart.CalculateStartEndValue()

         at Syncfusion.Blazor.Charts.SfStockChart.CalculateSeriesXMinMax()

         at Syncfusion.Blazor.Charts.SfStockChart.RenderStockChart(Boolean isRender)

         at Syncfusion.Blazor.Charts.SfStockChart.OnAfterScriptRendered()

         at Syncfusion.Blazor.SfBaseComponent.OnAfterRenderAsync(Boolean firstRender)

         at Syncfusion.Blazor.SfDataBoundComponent.OnAfterRenderAsync(Boolean firstRender)

         at Syncfusion.Blazor.Charts.SfStockChart.OnAfterRenderAsync(Boolean firstRender)


2) I tried using base type for StockChartPrimaryXAxis by

<StockChartPrimaryXAxis @ref=@mainx ValueType="@mainchartXAxis">

StockChartPrimaryXAxis mainx = new();

Syncfusion.Blazor.Charts.ValueType mainchartXAxis = new();

and when stockhistorylist.count() == 0, I changed mainchartXAxis to  Syncfusion.Blazor.Charts.ValueType.DateTime

and when stockhistorylist.count() > 0 , I changed mainchartXAxis to  Syncfusion.Blazor.Charts.ValueType.DateTimeCategory

then, I've got this error,

warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]

      Unhandled exception rendering component: Sequence contains no elements

      System.InvalidOperationException: Sequence contains no elements

         at System.Linq.ThrowHelper.ThrowNoElementsException()

         at System.Linq.Enumerable.Max(IEnumerable`1 source)

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRenderer.InitializeDoubleRange()

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRenderer.CalculateRangeAndInterval()

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRenderer.ComputeSize(Size availableSize)

         at Syncfusion.Blazor.Charts.Internal.CartesianAxisLayout.MeasureColumnDefinition(ChartColumnRenderer renderer, Size size)

         at Syncfusion.Blazor.Charts.Internal.CartesianAxisLayout.MeasureColumnAxis()

         at Syncfusion.Blazor.Charts.Internal.CartesianAxisLayout.ComputePlotAreaBounds(Rect rect)

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRendererContainer.ComputePlotAreaBounds(Rect newRect)

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRendererContainer.HandleChartSizeChange(Rect rect)

         at Syncfusion.Blazor.Charts.SfChart.UpdateRenderers(Boolean skip)

         at Syncfusion.Blazor.Charts.ChartSeries.OnParametersSetAsync()

         at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]

      Unhandled exception in circuit 'jLQvN3uymvh6f1oK4I6LHyLXwdEgV1SbpSfQslShe6s'.

      System.InvalidOperationException: Sequence contains no elements

         at System.Linq.ThrowHelper.ThrowNoElementsException()

         at System.Linq.Enumerable.Max(IEnumerable`1 source)

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRenderer.InitializeDoubleRange()

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRenderer.CalculateRangeAndInterval()

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRenderer.ComputeSize(Size availableSize)

         at Syncfusion.Blazor.Charts.Internal.CartesianAxisLayout.MeasureColumnDefinition(ChartColumnRenderer renderer, Size size)

         at Syncfusion.Blazor.Charts.Internal.CartesianAxisLayout.MeasureColumnAxis()

         at Syncfusion.Blazor.Charts.Internal.CartesianAxisLayout.ComputePlotAreaBounds(Rect rect)

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRendererContainer.ComputePlotAreaBounds(Rect newRect)

         at Syncfusion.Blazor.Charts.Internal.ChartAxisRendererContainer.HandleChartSizeChange(Rect rect)

         at Syncfusion.Blazor.Charts.SfChart.UpdateRenderers(Boolean skip)

         at Syncfusion.Blazor.Charts.ChartSeries.OnParametersSetAsync()

         at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)


I posted a zip file with test.txt

and you can see

//PLEASE LOOK THIS CODE


Can I get a help for this?


Attachment: test_76de7fd5.zip

2 Replies

DG Durga Gopalakrishnan Syncfusion Team October 24, 2024 12:25 PM UTC

Hi Steve,


Greetings from Syncfusion.


We have considered your reported scenario as bug and logged a defect report for the issue ”Stockchart throws console error for datetimecategory axis”. This fix will be available in our weekly patch release which is scheduled to be rolled out on 12th November 2024. We appreciate your patience until then. You can keep track of the bug from the below feedback link.


Feedback : https://www.syncfusion.com/feedback/62520/stockchart-throws-console-error-for-datetimecategory-axis


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.


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”


Regards,

Durga Gopalakrishnan.



DG Durga Gopalakrishnan Syncfusion Team November 25, 2024 02:21 PM UTC

Steve,


We are glad to announce that our v27.2.3 patch release is rolled out; we have added the fix for reported issue. You can use the latest Syncfusion.Blazor.Charts NuGet package.


Root Cause:

Changing the ValueType and DataSource of the axis dynamically at the same time leads to an exception occurring.


Fix:

Provided the correct method to refresh the stock chart along with the data source and related properties.

              

NuGet Package : https://www.nuget.org/packages/Syncfusion.Blazor.Charts/


Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/StkChartDatetimeCtg1324145617.zip


Feedback : https://www.syncfusion.com/feedback/62520/stockchart-throws-console-error-for-datetimecategory-axis


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.


Loader.
Up arrow icon