Skip to content

feat: add "Size by" dropdown to resize network nodes by a metric (#169) - #361

Draft
bburns632 wants to merge 1 commit into
mainfrom
feature/size-weighted-nodes
Draft

bburns632 wants to merge 1 commit into
mainfrom
feature/size-weighted-nodes

Conversation

@bburns632

@bburns632 bburns632 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a "Size by" dropdown to every network visualization (Function, Dependency, and Inheritance reports), next to the existing "Select by id" dropdown. Choosing a metric resizes nodes by any numeric column in that reporter's nodes table. The default, "none", keeps today's uniform sizing.

Partially addresses #169 (from @alistaire47). you can size the dependency graph by numRecursiveDeps, the issue's "quick 0-dependency" suggestion, and the metric is user-selectable. Package-weight metrics in the style of itdepends (install size, compiled code, LOC, etc.) and a combined score are not part of this PR. Any numeric columns added to DependencyReporter later will show up in the dropdown automatically.

Details

  • Node area is proportional to the value's position in the column's range (radius 10–50; the default size is 25).
  • Missing or non-finite values, and columns with only one value, keep the default size.
  • "none" restores each node's original size. Click-highlighting keeps working with resized nodes.
  • Node colors are unchanged, so size and color can show two different metrics at once.
  • Sizes are precomputed in R (.scaleNodeSizes()) and applied in the browser via htmlwidgets::onRender(). htmlwidgets is added to Imports; visNetwork already depends on it, so users don't install anything new.
  • NAMESPACE was edited by hand to add importFrom(htmlwidgets,onRender), matching the new roxygen tag.

Testing

  • New tests in tests/testthat/test-plotting.R cover the scaling function and the data attached to the widget. The plotting and reporter class tests pass locally (135 passed, 0 failed).
  • R CMD check --as-cran on the built tarball: 0 errors, 0 warnings. 2 NOTEs, neither from this change (the .9999 dev version, and a local .claude/ directory).
  • Checked in headless Chrome on pkgnet's own report: the dropdown lists the numeric metrics, sizing by outDegree gives sizes from 10 to 50, and "none" puts every node back to 25.

🤖 Generated with Claude Code

@bburns632
bburns632 marked this pull request as draft November 16, 2026 03:43
Network visualizations get a dropdown next to "Select by id" that resizes
nodes by any numeric column of the nodes table. Node area is proportional
to the value (radius 10-50). The default, "none", keeps uniform sizing.
Missing/non-finite values and constant columns keep the default size.

Sizes are precomputed in R and applied client-side via
htmlwidgets::onRender, so htmlwidgets is added to Imports (already a
visNetwork dependency).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bburns632
bburns632 force-pushed the feature/size-weighted-nodes branch from 4bffabe to dda0dea Compare November 16, 2026 03:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant