Skip to content

Feature Request: Support Functional Accessors for nodeRelSize #392

Description

@ProtDos

Problem

nodeRelSize currently only accepts a static number:

graph.nodeRelSize(4);

This makes it impossible to size nodes dynamically based on node data. Other APIs like nodeColor already support function accessors.


Desired Usage

Allow nodeRelSize to accept a function:

graph.nodeRelSize(node => node.importance || 4);

Required Changes

  1. README
    Update documentation to indicate nodeRelSize accepts ([num or fn])
    https://github.com/vasturiano/force-graph/blob/master/README.md#L99

  2. Core logic
    Update nodeRelSize to use an accessor function
    https://github.com/vasturiano/force-graph/blob/master/src/force-graph.js#L306

  3. Canvas renderer
    Apply the same accessor logic here:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions