fix: add valueField support to circle-packing layout#283
Conversation
The circle-packing layout was hardcoded to read values from 'value' field. Now it supports custom valueField configuration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds support for reading node values from a custom field when computing circle-packing layout values, instead of always using datum.value.
Changes:
- Add
valueField?: stringtoCirclePackingOptions(defaulting to'value'). - Thread
valueFieldfromCirclePackingLayoutintocalculateNodeValue.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/vlayouts/src/circle-packing/layout.ts | Stores valueField from options and passes it into calculateNodeValue during layout. |
| packages/vlayouts/src/circle-packing/interface.ts | Extends the public options interface with the new valueField option and inline docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const res = calculateNodeValue<HierarchicalDatum, CirclePackingNodeElement>( | ||
| data, | ||
| nodes, | ||
| 0, | ||
| -1, | ||
| null, | ||
| this._getNodeKey | ||
| this._getNodeKey, | ||
| this._valueField | ||
| ); |
There was a problem hiding this comment.
New valueField option is now used to read values via calculateNodeValue, but existing circle-packing tests only cover the default 'value' field. Add/extend a Jest test to pass new CirclePackingLayout({ valueField: 'sales' }) with input data using sales and assert the resulting node value/radius match expectations, to prevent regressions.
Summary
valueFieldoption toCirclePackingOptionsinterface to support custom value fieldvalueFieldfromCirclePackingLayouttocalculateNodeValuefunctionTest plan
🤖 Generated with Claude Code