Git Product home page Git Product logo

Comments (4)

tomwanzek avatar tomwanzek commented on July 19, 2024 1

@mvala A couple of things: Your local simulation variable is not properly defined/assigned. It should be defined as let simulation: Simulation<YourNodeType, YourLinkType>; and assigned as

      simulation = d3.forceSimulation<YourNodeType, YourLinkType>(this.nodes)
        .force("charge", d3.forceManyBody<YourNodeType>())
        .force("center", d3.forceCenter<YourNodeType>(this.width / 2, this.height / 2))
        .on("tick", ticked);

Note, that I avoided your usage of Node and Link simply because Node is a TypeScript "reserved" name, you are overloading.

With these changes, the error on line 81 will disappear. However, you are not defining and setting the Link force before trying to retrieve it.

Should you experience any further issues building out your force simulation, please use StackOverflow for further clarifications. Unfortunately, I have to keep the scope of the issues in this repo managed to bugs and feature requests. Thanks for understanding.

from d3-ng2-service.

tomwanzek avatar tomwanzek commented on July 19, 2024

@mvala It seems you are referencing the SO post with the solution to your problem. However, the source code your referenced does not actually apply the key fixes I suggested in my SO post.

Specifically, if you re-read my SO solution, you will see that d3.forceSimulation<YourNodeType, YourLinkType>() and simulation.force<ForceLink<YourNodeType, YourLinkType>>('link') are invoked with generic parameters set to correspond to the node data type and link data type applicable to your data structure. I.e. the interfaces YourNodeType and YourLinkType have to be provided by you, as appropriate to your problem domain.

If you follow the instructions in the post, and possibly re-read the extensive JSDoc comments in the typescript definitions file for d3-force it should all fall into place.

I am closing the issue here, as it does not seem to reflect a problem with the service or the definitions. Should following the provided instructions not address your problem, please feel free to post an issue on SO (or comment on the existing one). You can then simply ping me here under this issue here, and I will respond on SO.

Cheers. 😄

from d3-ng2-service.

mvala avatar mvala commented on July 19, 2024

@tomwanzek , thanks for your help. I added type Node and Link
https://gitlab.openbrain.sk/mvala/bpt-webapp/tree/master/src/app/shared/d3/models
and after applying

https://gitlab.openbrain.sk/mvala/bpt-webapp/blob/master/src/app/shared/d3/bpt/bpt.component.ts#L81
i get error

src/app/shared/d3/bpt/bpt.component.ts (81,19): Untyped function calls may not accept type arguments.

from d3-ng2-service.

mvala avatar mvala commented on July 19, 2024

Thanks for help. I will do my next interaction on StackOverflow

from d3-ng2-service.

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.