Updating the diagram sometimes throws System.FormatException

Hi!

I use the <SfDiagramComponent> with a custom node template. Sometimes when I try to update the diagram  component with either DiagramRef.RefreshDataSource() or DiagramRef.AddDiagramElements(diagramObjects) a System.FormatException is thrown with the following message and stack trace:

'The input string '−2' was not in a correct format.'   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)\n   at System.Number.ParseDouble(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info)\n   at System.Double.Parse(String s, IFormatProvider provider)\n   at Syncfusion.Blazor.Diagram.Internal.SVGCommand.<>c.<Parse>b__9_2(String arg)\n   at System.Linq.Enumerable.WhereSelectArrayIterator`2[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7c…ontent.InitLayerObjects()\n   at Syncfusion.Blazor.Diagram.Internal.DiagramLayerContent.InitObjects()\n   at Syncfusion.Blazor.Diagram.Internal.DiagramLayerContent.RefreshDataSource()\n   at Syncfusion.Blazor.Diagram.SfDiagramComponent.RefreshDataSource()

What could cause this exception? 


3 Replies 1 reply marked as answer

SU Sumathi Uthayakumar Syncfusion Team November 28, 2023 06:55 AM UTC

Hi Andreas,


We suspect that the node ID starts with a number, which is why the issue has been raised. At the framework level, there is a restriction that states you should set the ID with starting letters. The ID must begin with a letter ([A-Za-z]) and may be followed by any number of letters or digits ([0-9]). If you set the node's ID to start with a number, please update the proper node ID in your application. We have shared a user guide (UG) and a reference link for your convenience.

If you still persist with the issue, please share the sample to replicate your issue. These details help to provide a better solution for you.


HTML 4: https://www.w3.org/TR/html4/types.html#type-id

HTML 5: https://html.spec.whatwg.org/multipage/dom.html#the-id-attribute 

UG link: https://blazor.syncfusion.com/documentation/diagram/nodes/nodes#how-to-add-node-through-nodes-collection


Regards,

Sumathi U.


Marked as answer

AL Andreas Lymalm November 28, 2023 01:58 PM UTC

Hi Sumathi!

Thank you, that solved the issue. I was using a GUID as ID, and didn't realize it didn't fit the ID string restriction. Now I only generate an ID with letters. 


Sincerely,

Andreas



PR Preethi Rajakandham Syncfusion Team November 29, 2023 05:14 AM UTC

Hi Andreas,

You're welcome. We are glad to know that the reported problem has been resolved. Please let us know if you require any further assistance on this, we will be happy to assist you. 

Regards,

Preethi R


Loader.
Up arrow icon