new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

D3 · all subjects

d3-force/position

17 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

d3.forceX configuration

Force x-positioning configuration methods: x.strength (set force strength), x.x (set target x-coordinate).

d3.forceY configuration

Force y-positioning configuration methods: y.strength (set force strength), y.y (set target y-coordinate).

d3.forceRadial configuration

Force radial positioning configuration methods: radial.strength (set force strength), radial.radius (set target radius), radial.x (set target center x-coordinate), radial.y (set target center y-coordinate).

forceX creates x-axis position force

forceX(x) creates a new position force along the x-axis towards the given position x. If x is not specified, it defaults to 0. The force pushes nodes towards the target position with configurable strength.

forceX example usage

const x = d3.forceX(width / 2);

forceX x method

x.x(x) sets the x-coordinate accessor to a number or function, and re-evaluates it for each node. If not specified, returns the current x-accessor, which defaults to a function returning 0. The x-accessor is invoked for each node with the node and its zero-based index, and the target x-coordinate is only recomputed when the force is initialized or when this method is called.

forceY creates y-axis position force

forceY(y) creates a new position force along the y-axis towards the given position y. If y is not specified, it defaults to 0. The force pushes nodes towards the target position with configurable strength.

forceY example usage

const y = d3.forceY(height / 2);

forceY strength method

y.strength(strength) sets the strength accessor to a number or function. The strength determines how much to increment the node's y-velocity: (y - node.y) × strength. A value of 0.1 means the node moves a tenth of the way from its current y-position to the target y-position per application. Values outside [0,1] are not recommended. If not specified, returns the current strength accessor, which defaults to a function returning 0.1. The strength accessor is invoked for each node with the node and its zero-based index, and recomputed only when the force is initialized or when this method is called.

forceY y method

y.y(y) sets the y-coordinate accessor to a number or function, and re-evaluates it for each node. If not specified, returns the current y-accessor, which defaults to a function returning 0. The y-accessor is invoked for each node with the node and its zero-based index, and the target y-coordinate is only recomputed when the force is initialized or when this method is called.

forceRadial creates radial position force

forceRadial(radius, x, y) creates a new position force towards a circle of the specified radius centered at ⟨x, y⟩. If x and y are not specified, they default to ⟨0, 0⟩. The force pushes nodes towards the closest point on the circle with configurable strength.

forceRadial example usage

const radial = d3.forceRadial(r, width / 2, height / 2);

forceRadial strength method

radial.strength(strength) sets the strength accessor to a number or function. The strength determines how much to increment the node's x- and y-velocity. A value of 0.1 means the node moves a tenth of the way from its current position to the closest point on the circle per application. Values outside [0,1] are not recommended. If not specified, returns the current strength accessor, which defaults to a function returning 0.1. The strength accessor is invoked for each node with the node and its zero-based index, and recomputed only when the force is initialized or when this method is called.

forceRadial radius method

radial.radius(radius) sets the circle radius to a number or function, and re-evaluates it for each node. If not specified, returns the current radius accessor. The radius accessor is invoked for each node with the node and its zero-based index, and the target radius is only recomputed when the force is initialized or when this method is called.

forceRadial x method

radial.x(x) sets the x-coordinate of the circle center to the specified number and returns this force. If not specified, returns the current x-coordinate of the center, which defaults to zero.

forceRadial y method

radial.y(y) sets the y-coordinate of the circle center to the specified number and returns this force. If not specified, returns the current y-coordinate of the center, which defaults to zero.

Position forces push nodes towards desired locations

Position forces (x, y, and radial) push nodes towards a desired position along the given dimension with configurable strength. The strength of the force is proportional to the one-dimensional distance between the node's position and the target position. These forces are intended primarily for global forces that apply to all or most nodes.

Give your agent this brain