From 46ce7a9c9420ed42abf17b32de1b56e565bd7b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Mon, 6 Jul 2020 18:51:53 +0200 Subject: [PATCH] document forceRadial.x() and .y() as setting accessor functions instead of numbers --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bf24aef..ad69b1b 100644 --- a/README.md +++ b/README.md @@ -453,8 +453,25 @@ The *radius* accessor is invoked for each [node](#simulation_nodes) in the simul # radial.x([x]) [<>](https://github.com/d3/d3-force/blob/master/src/radial.js "Source") -If *x* is specified, sets the *x*-coordinate of the circle center to the specified number and returns this force. If *x* is not specified, returns the current *x*-coordinate of the center, which defaults to zero. +If *x* is specified, sets the *x*-coordinate accessor to the specified number or function, re-evaluates the *x*-accessor for each node, and returns this force. If *x* is not specified, returns the current *x*-accessor, which defaults to: + +```js +function x() { + return 0; +} +``` + +The *x*-accessor is invoked for each [node](#simulation_nodes) in the simulation, being passed the *node* and its zero-based *index*. The resulting number is then stored internally, such that the target *x*-coordinate of each node is only recomputed when the force is initialized or when this method is called with a new *x*, and not on every application of the force. # radial.y([y]) [<>](https://github.com/d3/d3-force/blob/master/src/radial.js "Source") -If *y* is specified, sets the *y*-coordinate of the circle center to the specified number and returns this force. If *y* is not specified, returns the current *y*-coordinate of the center, which defaults to zero. +If *y* is specified, sets the *y*-coordinate accessor to the specified number or function, re-evaluates the *y*-accessor for each node, and returns this force. If *y* is not specified, returns the current *y*-accessor, which defaults to: + +```js +function y() { + return 0; +} +``` + +The *y*-accessor is invoked for each [node](#simulation_nodes) in the simulation, being passed the *node* and its zero-based *index*. The resulting number is then stored internally, such that the target *y*-coordinate of each node is only recomputed when the force is initialized or when this method is called with a new *y*, and not on every application of the force. +