Code Monkey home page Code Monkey logo

Comments (7)

zHaytam avatar zHaytam commented on May 25, 2024

Hello and thanks!
The problem here is with GetRelativePoint, which calculates the relative point based on the canvas container. While the canvas didn't render, Container is null, so the calculation isn't possible.
The previous version returned null in that case, but I felt that it doesn't make a lot of sense since you shouldn't be using methods that depend on Container before it's initialized.

Solution: Don't use those methods in OnInitializedAsync. Just set the position to null or something you already know.
Hope this helps!

from blazor.diagrams.

BjornEngelen avatar BjornEngelen commented on May 25, 2024

I have the same result using OnAfterRenderAsync instead of OnInitializedAsync. How can I be alerted when the container is initialized?

from blazor.diagrams.

zHaytam avatar zHaytam commented on May 25, 2024

There is a ContainerChanged event in Diagram. May I know why you need the relative point so soon?

from blazor.diagrams.

BjornEngelen avatar BjornEngelen commented on May 25, 2024

Upon investigation it seemed that we could eleminate the relative point. It was being called from a function that handled adding custom nodes and custom ports both at initialization and when when using drag/drop mouse interaction. It was not needed when seeding the diagram.

However I'm still encoutering a problem without it:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Blazor.Diagrams.Components.DiagramCanvas.get_LayerStyle()
at Blazor.Diagrams.Components.DiagramCanvas.BuildRenderTree(RenderTreeBuilder __builder)

I'll build a minimal example and see if I can isolate the problem

from blazor.diagrams.

BjornEngelen avatar BjornEngelen commented on May 25, 2024

Hello, you can find a minimal example here using blazor webassembly:

https://github.com/BjornEngelen/DiagramIssue

Upon opening the page, an error occurs

from blazor.diagrams.

zHaytam avatar zHaytam commented on May 25, 2024

Hello, not sure if it's normal but you're not setting a value to Diagram.

Anyway, in 2.0.0, there is no need to specify Name in the cascading value. Please use this: <CascadingValue Value="Diagram">.
Tell me if you have any other issues.

from blazor.diagrams.

BjornEngelen avatar BjornEngelen commented on May 25, 2024

My bad on not initializing Diagram. I probably messed up my push. But your suggestion of not using Name did actually solve this issue in my full solution.

With Name="Diagram" I see:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Blazor.Diagrams.Components.DiagramCanvas.OnInitialized() in C:\Users\bjorn\Desktop\Blazor.Diagrams-master\src\Blazor.Diagrams\Components\DiagramCanvas.razor.cs:line 38
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

Without 'Name' the error is gone. Thanks

from blazor.diagrams.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.