Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept iterables. #153

Merged
merged 18 commits into from
Aug 19, 2020
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ Equivalent to [*link*.y](#link_y), except the accessor returns the radius: the d

Symbols provide a categorical shape encoding as is commonly used in scatterplots. Symbols are always centered at ⟨0,0⟩; use a transform (see: [SVG](http://www.w3.org/TR/SVG/coords.html#TransformAttribute), [Canvas](http://www.w3.org/TR/2dcontext/#transformations)) to move the symbol to a different position.

<a name="symbol" href="#symbol">#</a> d3.<b>symbol</b>() · [Source](https://github.com/d3/d3-shape/blob/master/src/symbol.js)
<a name="symbol" href="#symbol">#</a> d3.<b>symbol</b>([<i>type</i>][, <i>size</i>]) · [Source](https://github.com/d3/d3-shape/blob/master/src/symbol.js)

Constructs a new symbol generator with the default settings.
Constructs a new symbol generator of the specified [type](#symbol_type) and [size](#symbol_size). If not specified, *type* defaults to a circle, and *size* defaults to 64.

<a name="_symbol" href="#_symbol">#</a> <i>symbol</i>(<i>arguments</i>…) · [Source](https://github.com/d3/d3-shape/blob/master/src/symbol.js)

Expand Down
8 changes: 4 additions & 4 deletions src/symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export var symbols = [
wye
];

export default function() {
var type = constant(circle),
size = constant(64),
context = null;
export default function(type, size) {
var context = null;
type = typeof type === "function" ? type : constant(type || circle);
size = typeof size === "function" ? size : constant(size === undefined ? 64 : +size);

function symbol() {
var buffer;
Expand Down
8 changes: 8 additions & 0 deletions test/symbol-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,11 @@ tape("symbol.type(symbolWye) generates the expected path", function(test) {
test.pathEqual(s(10), "M0.853360,0.492688L0.853360,2.199408L-0.853360,2.199408L-0.853360,0.492688L-2.331423,-0.360672L-1.478063,-1.838735L0,-0.985375L1.478063,-1.838735L2.331423,-0.360672Z");
test.end();
});

tape("symbol(type, size) is equivalent to symbol().type(type).size(size)", function(test) {
var s0 = shape.symbol().type(shape.symbolCross).size(16),
s1 = shape.symbol(shape.symbolCross, 16);
test.equal(s0(), s1());
test.end();
});