Giter VIP home page Giter VIP logo

Comments (5)

vasturiano avatar vasturiano commented on May 13, 2024

@bt2414 you need to get the ref to the element from React, like in this example:
https://github.com/vasturiano/react-force-graph/blob/master/example/dynamic/index.html#L59

from react-force-graph.

bt2414 avatar bt2414 commented on May 13, 2024

@vasturiano Hi, I think I have already used the this.ref, in my code I just used:

this.fg.nodeRelSize(4);

But it gives me the function is not found problem:

app.js:92041 Uncaught TypeError: this.fg.nodeRelSize is not a function
at GraphCom.clickChangeColor (app.js:92041)
at onClick (app.js:92089)
at Button._this.handleClick (app.js:92227)
at HTMLUnknownElement.boundFunc (app.js:56065)
at Object.ReactErrorUtils.invokeGuardedCallback (app.js:56071)
at executeDispatch (app.js:55856)
at Object.executeDispatchesInOrder (app.js:55879)
at executeDispatchesAndRelease (app.js:5018)
at executeDispatchesAndReleaseTopLevel (app.js:5029)
at Array.forEach ()

Could you give me an idea about where goes wrong?

Thanks so much.

from react-force-graph.

vasturiano avatar vasturiano commented on May 13, 2024

@bt2414 nodeRelSize is a prop, not a method. So, you can use it the conventional way in your React component, no need to invoke it on the ref:

<ForceGraph3D
  graphData={data}
  nodeRelSize={4}
/>

from react-force-graph.

bt2414 avatar bt2414 commented on May 13, 2024

@vasturiano I need to use it for future updating the graph.

As I mentioned in:

#21

It can access the function by using:

Graph.nodeRelSize(this.relSize);

Do you have any idea about how to do it?

from react-force-graph.

vasturiano avatar vasturiano commented on May 13, 2024

@bt2414 you can just rely on React's update lifecycle to pass different values to that prop, using the component's state for example. Something like:

render() {
  return <ForceGraph3D
    graphData={data}
    nodeRelSize={this.state.nodeSize}
  />
}

The nodes sizes will update every time the value of state.nodeSize changes.

from react-force-graph.

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.