Skip to content

Commit

Permalink
feat(vega-force): Enable expr support for nbody 'strength' param (#3676)
Browse files Browse the repository at this point in the history
* feat(vega-force): Enable expr support for nbody params 'strength' and 'theta'
* Roll back theta (sim global unsuitable per node) update strength param in transform interface ForceNBody
---------
Co-authored-by: Wilson Stockman <wstockman@soasta.com>
  • Loading branch information
handsfelloff committed Mar 8, 2023
1 parent fb1092f commit 3771cd6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/docs/transforms/force.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ An n-body force that causes nodes to either attract or repel each other.
| Property | Type | Description |
| :------------------ | :----------------------------: | :------------ |
| force | {% include type t="String" %} | The value `"nbody"`.|
| strength | {% include type t="Number" %} | The relative strength of this force (default `-30`). Negative values cause nodes to repel, positive values to attract.|
| strength | {% include type t="Number|Expr" %} | The relative strength of this force (default `-30`). Negative values cause nodes to repel, positive values to attract.|
| theta | {% include type t="Number" %} | Approximation parameter for aggregating more distance forces (default `0.9`).|
| distanceMin | {% include type t="Number" %} | The minimum distance over which this force acts. If two nodes are close than _distanceMin_, the exerted forces will be as if they are _distanceMin_ apart (default `1`).|
| distanceMax | {% include type t="Number" %} | The maximum distance over which this force acts. If two nodes exceed _distanceMax_, they will not exert forces on each other.|
Expand Down
2 changes: 1 addition & 1 deletion packages/vega-force/src/Force.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Force.Definition = {
{
'key': {'force': 'nbody'},
'params': [
{ 'name': 'strength', 'type': 'number', 'default': -30 },
{ 'name': 'strength', 'type': 'number', 'default': -30, 'expr': true },
{ 'name': 'theta', 'type': 'number', 'default': 0.9 },
{ 'name': 'distanceMin', 'type': 'number', 'default': 1 },
{ 'name': 'distanceMax', 'type': 'number' }
Expand Down
2 changes: 1 addition & 1 deletion packages/vega-typings/types/spec/transform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export interface ForceLink {
}
export interface ForceNBody {
force: 'nbody';
strength?: number | SignalRef;
strength?: number | SignalRef | ExprRef;
theta?: number | SignalRef;
distanceMin?: number | SignalRef;
distanceMax?: number | SignalRef;
Expand Down

0 comments on commit 3771cd6

Please sign in to comment.