question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Network component needs documentation, and API could allow rendering custom nodes

See original GitHub issue

Network component seem to be poorly documented on how to use with Layers, as well as interactivity. My immediate desire is to be able to show some information about a node on hover (or always), such as a label. I can’t seem to find anything about this anywhere, and it seems to be a very common use case for this type of data visualization. There isn’t much to learn from an unlabeled graph.

Ideally the API would allow for rendering any arbitrary component as a node, which would take the place of supplying nodeColor, nodeBorderWidth, nodeBorderColor and allow for more flexibility. For example:

const CustomNodesNetwork = data => {
  const renderNode = node => (
    <svg width="50" height="50" version="1.1" xmlns="http://www.w3.org/2000/svg">
      <g>
        <rect
          x={10}
          y={10}
          width={30}
          height={30}
          fill={node.color}
         />
        <text
          x={0}
          y={0}
          fill="black"
        >
          {node.label}
        </text>
      </g>
    </svg>
  );

  return (
    <ResponsiveNetwork
      height={700}
      nodes={data.nodes}
      links={data.links}
      renderNode={t => renderNode(t)}
      linkThickness={t => (2 * (2 - t.source.depth))}
    />
  );
}

Alternatively, a default label/hover behavior could easily render some text under certain conditions:

    <ResponsiveNetwork
      ...
      nodeLabel={t => t.label}
      labelVisibility={visible: boolean | string}
    />

Thanks for your hard work on this excellent library, and sorry if this the library already has this capability and I’m just dumb! First time using anything D3.js related.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
plouccommented, Jan 18, 2020

No worries, it does not support this, and that’s definitely an interesting suggestion, I’m currently working on migrating the whole codebase to TypeScript and trying to improve some packages in the process, I’ll see what I can do about this then, do not expect this feature to be available soon though as I currently have a limited amount of time to spend on side projects.

3reactions
iDreadfulcommented, Apr 10, 2020

Voting for these features! My use case is a uses relationship map where the nodes are their userpics. Thank you for the great work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Enable Server-Side Rendering for a React App
In this tutorial, you will initialize a React app using Create React App and then modify the project to enable server-side rendering.
Read more >
vis.js - Network documentation. - GitHub Pages
Network is a visualization to display networks and networks consisting of nodes and edges. The visualization is easy to use and supports custom...
Read more >
SDK vs. API: What's the Difference? - IBM
Because some APIs provide the interface directly, the terms “API” and “interface” are sometimes used interchangeably.
Read more >
Support policies for Azure Kubernetes Service (AKS)
Learn about Azure Kubernetes Service (AKS) support policies, shared responsibility, and features that are in preview (or alpha or beta).
Read more >
Express/Node introduction - Learn web development | MDN
You can use Node.js to create a simple web server using the Node HTTP ... or only show a small part of what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found