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-scale/point

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

scalePoint constructor signature

scalePoint(*domain*, *range*) constructs a new point scale with the specified domain and range. Default domain is empty. Default range is [0, 1]. Default padding is 0. Default rounding is disabled. Default alignment is 0.5.

Point scale function returns point position

When a point scale is called as a function with a value in the domain, it returns the corresponding point position derived from the output range. If the value is not in the domain, it returns undefined.

scalePoint example with numeric range

Example: const x = d3.scalePoint(["a", "b", "c"], [0, 960]); x("a") returns 0; x("b") returns 480; x("c") returns 960; x("d") returns undefined.

point.domain() method

point.domain(domain) sets the domain to the specified array of values. Domain values are stored internally in an InternMap from primitive value to index. The first element maps to the first point, second to second, etc. If domain is not specified, returns the current domain.

point.range() method

point.range(range) sets the scale's range to a two-element array of numbers. Non-numeric elements are coerced to numbers. If range is not specified, returns the current range which defaults to [0, 1].

point.rangeRound() method

point.rangeRound(range) sets the scale's range to the specified two-element array of numbers while also enabling rounding. Equivalent to point.range(range).round(true).

point.round() method

point.round(round) enables or disables rounding. If rounding is enabled, the position of each point will be integers. If round is not specified, returns whether rounding is enabled.

point.padding() method

point.padding(padding) sets the outer padding to the specified number, typically in the range [0, 1]. The outer padding specifies blank space in terms of multiples of the step to reserve before the first point and after the last point. If padding is not specified, returns the current outer padding which defaults to 0.

point.align() method

point.align(align) sets the alignment to a value in the range [0, 1]. Alignment specifies how leftover unused space in the range is distributed. A value of 0.5 centers points in the range. Values of 0 or 1 shift points to one side, for positioning adjacent to an axis. If align is not specified, returns the current alignment which defaults to 0.5.

point.bandwidth() method

point.bandwidth() returns zero, as point scales have bandwidth fixed to zero.

point.step() method

point.step() returns the distance between adjacent points.

point.copy() method

point.copy() returns an exact copy of the scale. Changes to the original scale do not affect the copy, and vice versa.

Point scales are band scales with zero bandwidth

Point scales are a variant of band scales with the bandwidth fixed to zero. Point scales are typically used for scatterplots with an ordinal or categorical dimension.

Give your agent this brain