Skip to content

Add label rendering support to NetworkModule#58

Open
Tejasv-Singh wants to merge 1 commit intomesa:mainfrom
Tejasv-Singh:fix/network-node-labels
Open

Add label rendering support to NetworkModule#58
Tejasv-Singh wants to merge 1 commit intomesa:mainfrom
Tejasv-Singh:fix/network-node-labels

Conversation

@Tejasv-Singh
Copy link

Summary

The label key in node portrayals was accepted but never rendered. This adds text elements positioned at node centers.

Changes

  • Added labels SVG group for text elements
  • Text labels are centered using text-anchor: middle and dominant-baseline: middle
  • Dynamic font sizing based on node size (size * 1.5 px)
  • Optional label_color property (defaults to black)

Usage

portrayal['nodes'].append({
    'size': 12,
    'color': '#CC0000',
    'label': str(agent.value),        # NEW: renders text on node
    'label_color': '#FFFFFF',         # NEW: optional, defaults to black
})

The label key in node portrayals was accepted but never rendered.
This adds text elements positioned at node centers with:
- Proper centering using text-anchor and dominant-baseline
- Dynamic font sizing based on node size
- Optional label_color property (defaults to black)
@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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