From 988a8b29a9fc45e272b74e70f982659454b64317 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Thu, 7 Jan 2016 15:26:45 -0800 Subject: [PATCH] =?UTF-8?q?Prefix=20symbols=20with=20=E2=80=9Csymbol?= =?UTF-8?q?=E2=80=9D.=20Prefix=20curves=20with=20=E2=80=9Ccurve=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 146 ++++++++++++++-------------- index.js | 62 ++++++------ package.json | 4 +- test/area-test.js | 12 +-- test/curve/basis-test.js | 8 +- test/curve/basisClosed-test.js | 4 +- test/curve/basisOpen-test.js | 8 +- test/curve/bundle-test.js | 10 +- test/curve/cardinal-test.js | 28 +++--- test/curve/cardinalClosed-test.js | 14 +-- test/curve/cardinalOpen-test.js | 28 +++--- test/curve/catmullRom-test.js | 32 +++--- test/curve/catmullRomClosed-test.js | 22 ++--- test/curve/catmullRomOpen-test.js | 32 +++--- test/curve/linear-test.js | 8 +- test/curve/linearClosed-test.js | 4 +- test/curve/monotone-test.js | 20 ++-- test/curve/natural-test.js | 8 +- test/curve/step-test.js | 8 +- test/curve/stepAfter-test.js | 8 +- test/curve/stepBefore-test.js | 8 +- test/line-test.js | 12 +-- test/offset/expand-test.js | 12 +-- test/offset/none-test.js | 12 +-- test/offset/silhouette-test.js | 12 +-- test/offset/wiggle-test.js | 12 +-- test/order/ascending-test.js | 8 +- test/order/descending-test.js | 8 +- test/order/insideOut-test.js | 8 +- test/order/none-test.js | 4 +- test/order/reverse-test.js | 4 +- test/stack-test.js | 12 +-- test/symbol-test.js | 56 +++++------ test/symbols-test.js | 14 +-- 34 files changed, 324 insertions(+), 324 deletions(-) diff --git a/README.md b/README.md index 399199a..f93aeb1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Visualizations typically consist of discrete graphical marks, such as [symbols]( As with other aspects of D3, these shapes are driven by data: each shape generator exposes accessors that control how the input data are mapped to a visual representation. For example, you might define a line generator for a time series by [scaling](https://github.com/d3/d3-scale) fields of your data to fit the chart: ```js -var line = d3_shape.line() +var line = d3.line() .x(function(d) { return x(d.date); }) .y(function(d) { return y(d.value); }); ``` @@ -30,7 +30,7 @@ If you use NPM, `npm install d3-shape`. Otherwise, download the [latest release] ```html - + ``` In a vanilla environment, a `d3_shape` global is exported. [Try d3-shape in your browser.](https://tonicdev.com/npm/d3-shape) @@ -55,7 +55,7 @@ The arc generator produces a [circular](https://en.wikipedia.org/wiki/Circular_s See also the [pie generator](#pies), which computes the necessary angles to represent an array of data as a pie or donut chart; these angles can then be passed to an arc generator. -# d3_shape.arc() +# d3.arc() Constructs a new arc generator with the default settings. @@ -64,7 +64,7 @@ Constructs a new arc generator with the default settings. Generates an arc for the given *arguments*. The *arguments* are arbitrary; they are simply propagated to the arc generator’s accessor functions along with the `this` object. For example, with the default settings, an object with radii and angles is expected: ```js -var arc = d3_shape.arc(); +var arc = d3.arc(); arc({ innerRadius: 0, @@ -77,7 +77,7 @@ arc({ If the radii and angles are instead defined as constants, you can generate an arc without any arguments: ```js -var arc = d3_shape.arc() +var arc = d3.arc() .innerRadius(0) .outerRadius(100) .startAngle(0) @@ -192,7 +192,7 @@ If *context* is specified, sets the context and returns this arc generator. If * The pie generator does not produce a shape directly, but instead computes the necessary angles to represent a tabular dataset as a pie or donut chart; these angles can then be passed to an [arc generator](#arcs). -# d3_shape.pie() +# d3.pie() Constructs a new pie generator with the default settings. @@ -213,7 +213,7 @@ Given a small dataset of numbers, here is how to compute the arc angles to rende ```js var data = [1, 1, 2, 3, 5, 8, 13, 21]; -var arcs = d3_shape.pie()(data); +var arcs = d3.pie()(data); ``` The first pair of parens, `pie()`, [constructs](#pie) a default pie generator. The second, `pie()(data)`, [invokes](#_pie) this generator on the dataset, returning an array of objects: @@ -255,7 +255,7 @@ var data = [ {"number": 42, "name": Kwon} ]; -var arcs = d3_shape.pie() +var arcs = d3.pie() .value(function(d) { return d.number; }) (data); ``` @@ -263,7 +263,7 @@ var arcs = d3_shape.pie() This is similar to [mapping](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) your data to values before invoking the pie generator: ```js -var arcs = d3_shape.pie()(data.map(function(d) { return d.number; })); +var arcs = d3.pie()(data.map(function(d) { return d.number; })); ``` The benefit of an accessor is that the input data remains associated with the returned objects, thereby making it easier to access other fields of the data, for example to set the color or to add text labels. @@ -344,7 +344,7 @@ The pad angle here means the angular separation between each adjacent arc. The t The line generator produces a [spline](https://en.wikipedia.org/wiki/Spline_\(mathematics\)) or [polyline](https://en.wikipedia.org/wiki/Polygonal_chain), as in a line chart. Lines also appear in many other visualization types, such as the links in [hierarchical edge bundling](http://bl.ocks.org/mbostock/7607999). -# d3_shape.line() +# d3.line() Constructs a new line generator with the default settings. @@ -375,7 +375,7 @@ var data = [ … ]; -var line = d3_shape.line() +var line = d3.line() .x(function(d) { return x(d.date); }) .y(function(d) { return y(d.value); }); ``` @@ -406,17 +406,17 @@ The default accessor thus assumes that the input data is always defined. When a [Line with Missing Data](http://bl.ocks.org/mbostock/0533f44f2cfabecc5e3a) -Note that if a line segment consists of only a single point, it may appear invisible unless rendered with rounded or square [line caps](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap). In addition, some curves such as [cardinalOpen](#cardinalOpen) only render a visible segment if it contains multiple points. +Note that if a line segment consists of only a single point, it may appear invisible unless rendered with rounded or square [line caps](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap). In addition, some curves such as [curveCardinalOpen](#curveCardinalOpen) only render a visible segment if it contains multiple points. # line.curve([curve[, parameters…]]) -If *curve* is specified, sets the [curve factory](#curves) and returns this line generator. Any optional *parameters*, if specified, will be bound to the specified *curve*. If *curve* is not specified, returns the current curve factory, which defaults to [linear](#linear). +If *curve* is specified, sets the [curve factory](#curves) and returns this line generator. Any optional *parameters*, if specified, will be bound to the specified *curve*. If *curve* is not specified, returns the current curve factory, which defaults to [curveLinear](#curveLinear). # line.context([context]) If *context* is specified, sets the context and returns this line generator. If *context* is not specified, returns the current context, which defaults to null. If the context is not null, then the [generated line](#_line) is rendered to this context as a sequence of [path method](http://www.w3.org/TR/2dcontext/#canvaspathmethods) calls. Otherwise, a [path data](http://www.w3.org/TR/SVG/paths.html#PathData) string representing the generated line is returned. -# d3_shape.radialLine() +# d3.radialLine() Radial Line @@ -440,7 +440,7 @@ Equivalent to [*line*.defined](#line_defined). # radialLine.curve([curve[, parameters…]]) -Equivalent to [*line*.curve](#line_curve). Note that the [monotone](#monotone) curve is not recommended for radial lines because it assumes that the data is monotonic in *x*, which is typically untrue of radial lines. +Equivalent to [*line*.curve](#line_curve). Note that [curveMonotone](#curveMonotone) is not recommended for radial lines because it assumes that the data is monotonic in *x*, which is typically untrue of radial lines. # radialLine.context([context]) @@ -450,9 +450,9 @@ Equivalent to [*line*.context](#line_context). [Area Chart](http://bl.ocks.org/mbostock/3883195)[Stacked Area Chart](http://bl.ocks.org/mbostock/3885211)[Difference Chart](http://bl.ocks.org/mbostock/3894205) -The area generator produces an area, as in an area chart. An area is defined by two bounding [lines](#lines), either splines or polylines. Typically, the two lines share the same [*x*-values](#area_x) ([x0](#area_x0) = [x1](#area_x1)), differing only in *y*-value ([y0](#area_y0) and [y1](#area_y1)); most commonly, y0 is defined as a constant representing [zero](http://www.vox.com/2015/11/19/9758062/y-axis-zero-chart). The first line (the topline) is defined by x1 and y1 and is rendered first; the second line (the baseline) is defined by x0 and y0 and is rendered second, with the points in reverse order. With a [linear](#linear) [curve](#area_curve), this produces a clockwise polygon. +The area generator produces an area, as in an area chart. An area is defined by two bounding [lines](#lines), either splines or polylines. Typically, the two lines share the same [*x*-values](#area_x) ([x0](#area_x0) = [x1](#area_x1)), differing only in *y*-value ([y0](#area_y0) and [y1](#area_y1)); most commonly, y0 is defined as a constant representing [zero](http://www.vox.com/2015/11/19/9758062/y-axis-zero-chart). The first line (the topline) is defined by x1 and y1 and is rendered first; the second line (the baseline) is defined by x0 and y0 and is rendered second, with the points in reverse order. With a [curveLinear](#curveLinear) [curve](#area_curve), this produces a clockwise polygon. -# d3_shape.area() +# d3.area() Constructs a new area generator with the default settings. @@ -487,7 +487,7 @@ var data = [ … ]; -var area = d3_shape.area() +var area = d3.area() .x(function(d) { return x(d.date); }) .y1(function(d) { return y(d.value); }) .y0(y(0)); @@ -541,17 +541,17 @@ The default accessor thus assumes that the input data is always defined. When an [Area with Missing Data](http://bl.ocks.org/mbostock/3035090) -Note that if an area segment consists of only a single point, it may appear invisible unless rendered with rounded or square [line caps](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap). In addition, some curves such as [cardinalOpen](#cardinalOpen) only render a visible segment if it contains multiple points. +Note that if an area segment consists of only a single point, it may appear invisible unless rendered with rounded or square [line caps](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap). In addition, some curves such as [curveCardinalOpen](#curveCardinalOpen) only render a visible segment if it contains multiple points. # area.curve([curve[, parameters…]]) -If *curve* is specified, sets the [curve factory](#curves) and returns this area generator. Any optional *parameters*, if specified, will be bound to the specified *curve*. If *curve* is not specified, returns the current curve factory, which defaults to [linear](#linear). +If *curve* is specified, sets the [curve factory](#curves) and returns this area generator. Any optional *parameters*, if specified, will be bound to the specified *curve*. If *curve* is not specified, returns the current curve factory, which defaults to [curveLinear](#curveLinear). # area.context([context]) If *context* is specified, sets the context and returns this area generator. If *context* is not specified, returns the current context, which defaults to null. If the context is not null, then the [generated area](#_area) is rendered to this context as a sequence of [path method](http://www.w3.org/TR/2dcontext/#canvaspathmethods) calls. Otherwise, a [path data](http://www.w3.org/TR/SVG/paths.html#PathData) string representing the generated area is returned. -# d3_shape.radialArea() +# d3.radialArea() Radial Area @@ -591,7 +591,7 @@ Equivalent to [*area*.defined](#area_defined). # radialArea.curve([curve[, parameters…]]) -Equivalent to [*area*.curve](#area_curve). Note that the [monotone](#monotone) curve is not recommended for radial areas because it assumes that the data is monotonic in *x*, which is typically untrue of radial areas. +Equivalent to [*area*.curve](#area_curve). Note that [curveMonotone](#curveMonotone) is not recommended for radial areas because it assumes that the data is monotonic in *x*, which is typically untrue of radial areas. # radialArea.context([context]) @@ -604,109 +604,109 @@ While [lines](#lines) are defined as a sequence of two-dimensional [*x*, *y*] po Curves are typically not constructed or used directly, instead being passed to [*line*.curve](#line_curve) and [*area*.curve](#area_curve). For example: ```js -var line = d3_shape.line() +var line = d3.line() .x(function(d) { return x(d.date); }) .y(function(d) { return y(d.value); }) - .curve(d3_shape.catmullRom, 0.5); + .curve(d3.curveCatmullRom, 0.5); ``` -# d3_shape.basis(context) +# d3.curveBasis(context) basis Produces a cubic [basis spline](https://en.wikipedia.org/wiki/B-spline) using the specified control points. The first and last points are triplicated such that the spline starts at the first point and ends at the last point, and is tangent to the line between the first and second points, and to the line between the penultimate and last points. -# d3_shape.basisClosed(context) +# d3.curveBasisClosed(context) basisClosed Produces a closed cubic [basis spline](https://en.wikipedia.org/wiki/B-spline) using the specified control points. When a line segment ends, the first three control points are repeated, producing a closed loop with C2 continuity. -# d3_shape.basisOpen(context) +# d3.curveBasisOpen(context) basisOpen Produces a cubic [basis spline](https://en.wikipedia.org/wiki/B-spline) using the specified control points. Unlike [basis](#basis), the first and last points are not repeated, and thus the curve typically does not intersect these points. -# d3_shape.bundle(context[, beta]) +# d3.curveBundle(context[, beta]) bundle Produces a straightened cubic [basis spline](https://en.wikipedia.org/wiki/B-spline) using the specified control points, with the spline straightened according to the specified parameter *beta* in the range [0, 1]. If *beta* equals zero, a straight line between the first and last point is produced; if *beta* equals one, a standard [basis](#basis) spline is produced. If *beta* is not specified, it defaults to 0.85. This curve is typically used in [hierarchical edge bundling](http://bl.ocks.org/mbostock/7607999) to disambiguate connections, as proposed by [Danny Holten](https://www.win.tue.nl/vis1/home/dholten/) in [Hierarchical Edge Bundles: Visualization of Adjacency Relations in Hierarchical Data](https://www.win.tue.nl/vis1/home/dholten/papers/bundles_infovis.pdf); *beta* represents the bundle strength. -# d3_shape.cardinal(context[, tension]) +# d3.curveCardinal(context[, tension]) cardinal -Produces a cubic [cardinal spline](https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline) using the specified control points, with one-sided differences used for the first and last piece. The *tension* parameter in the range [0, 1] determines the length of the tangents: a *tension* of one yields all zero tangents, equivalent to [linear](#linear); a *tension* of zero produces a uniform [Catmull–Rom](#catmullRom) spline. If *tension* is not specified, it defaults to zero. +Produces a cubic [cardinal spline](https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline) using the specified control points, with one-sided differences used for the first and last piece. The *tension* parameter in the range [0, 1] determines the length of the tangents: a *tension* of one yields all zero tangents, equivalent to [curveLinear](#curveLinear); a *tension* of zero produces a uniform [Catmull–Rom](#curveCatmullRom) spline. If *tension* is not specified, it defaults to zero. -# d3_shape.cardinalClosed(context[, tension]) +# d3.curveCardinalClosed(context[, tension]) cardinalClosed -Produces a closed cubic [cardinal spline](https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline) using the specified control points. When a line segment ends, the first three control points are repeated, producing a closed loop. The *tension* parameter in the range [0, 1] determines the length of the tangents: a *tension* of one yields all zero tangents, equivalent to [linearClosed](#linearClosed); a *tension* of zero produces a closed uniform [Catmull–Rom](#catmullRomClosed) spline. +Produces a closed cubic [cardinal spline](https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline) using the specified control points. When a line segment ends, the first three control points are repeated, producing a closed loop. The *tension* parameter in the range [0, 1] determines the length of the tangents: a *tension* of one yields all zero tangents, equivalent to [curveLinearClosed](#curveLinearClosed); a *tension* of zero produces a closed uniform [Catmull–Rom](#curveCatmullRomClosed) spline. -# d3_shape.cardinalOpen(context[, tension]) +# d3.curveCardinalOpen(context[, tension]) cardinalOpen -Produces a cubic [cardinal spline](https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline) using the specified control points. Unlike [cardinal](#cardinal), one-sided differences are not used for the first and last piece, and thus the curve starts at the second point and ends at the penultimate point. +Produces a cubic [cardinal spline](https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline) using the specified control points. Unlike [curveCardinal](#curveCardinal), one-sided differences are not used for the first and last piece, and thus the curve starts at the second point and ends at the penultimate point. -# d3_shape.catmullRom(context[, alpha]) +# d3.curveCatmullRom(context[, alpha]) catmullRom -Produces a cubic Catmull–Rom spline using the specified control points and the parameter *alpha*, as proposed by Yuksel et al. in [On the Parameterization of Catmull–Rom Curves](http://www.cemyuksel.com/research/catmullrom_param/), with one-sided differences used for the first and last piece. If *alpha* is zero, produces a uniform spline, equivalent to [cardinal](#cardinal) with a tension of zero; if *alpha* is one, produces a chordal spline; if *alpha* is 0.5, produces a [centripetal spline](https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline). If *alpha* is not specified, it defaults to 0.5. Centripetal splines are recommended to avoid self-intersections and overshoot. +Produces a cubic Catmull–Rom spline using the specified control points and the parameter *alpha*, as proposed by Yuksel et al. in [On the Parameterization of Catmull–Rom Curves](http://www.cemyuksel.com/research/catmullrom_param/), with one-sided differences used for the first and last piece. If *alpha* is zero, produces a uniform spline, equivalent to [curveCardinal](#curveCardinal) with a tension of zero; if *alpha* is one, produces a chordal spline; if *alpha* is 0.5, produces a [centripetal spline](https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline). If *alpha* is not specified, it defaults to 0.5. Centripetal splines are recommended to avoid self-intersections and overshoot. -# d3_shape.catmullRomClosed(context[, alpha]) +# d3.curveCatmullRomClosed(context[, alpha]) catmullRomClosed -Produces a closed cubic Catmull–Rom spline using the specified control points and the parameter *alpha*, as proposed by Yuksel et al. When a line segment ends, the first three control points are repeated, producing a closed loop. If *alpha* is zero, produces a uniform spline, equivalent to [cardinalClosed](#cardinalClosed) with a tension of zero; if *alpha* is one, produces a chordal spline; if *alpha* is 0.5, produces a [centripetal spline](https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline). If *alpha* is not specified, it defaults to 0.5. Centripetal splines are recommended to avoid self-intersections and overshoot. +Produces a closed cubic Catmull–Rom spline using the specified control points and the parameter *alpha*, as proposed by Yuksel et al. When a line segment ends, the first three control points are repeated, producing a closed loop. If *alpha* is zero, produces a uniform spline, equivalent to [curveCardinalClosed](#curveCardinalClosed) with a tension of zero; if *alpha* is one, produces a chordal spline; if *alpha* is 0.5, produces a [centripetal spline](https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline). If *alpha* is not specified, it defaults to 0.5. Centripetal splines are recommended to avoid self-intersections and overshoot. -# d3_shape.catmullRomOpen(context[, alpha]) +# d3.curveCatmullRomOpen(context[, alpha]) catmullRomOpen -Produces a cubic Catmull–Rom spline using the specified control points and the parameter *alpha*, as proposed by Yuksel et al. Unlike [catmullRom](#catmullRom), one-sided differences are not used for the first and last piece, and thus the curve starts at the second point and ends at the penultimate point. If *alpha* is zero, produces a uniform spline, equivalent to [cardinalOpen](#cardinalOpen) with a tension of zero; if *alpha* is one, produces a chordal spline; if *alpha* is 0.5, produces a [centripetal spline](https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline). If *alpha* is not specified, it defaults to 0.5. Centripetal splines are recommended to avoid self-intersections and overshoot. +Produces a cubic Catmull–Rom spline using the specified control points and the parameter *alpha*, as proposed by Yuksel et al. Unlike [curveCatmullRom](#curveCatmullRom), one-sided differences are not used for the first and last piece, and thus the curve starts at the second point and ends at the penultimate point. If *alpha* is zero, produces a uniform spline, equivalent to [curveCardinalOpen](#curveCardinalOpen) with a tension of zero; if *alpha* is one, produces a chordal spline; if *alpha* is 0.5, produces a [centripetal spline](https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline). If *alpha* is not specified, it defaults to 0.5. Centripetal splines are recommended to avoid self-intersections and overshoot. -# d3_shape.linear(context) +# d3.curveLinear(context) linear Produces a polyline through the specified points. -# d3_shape.linearClosed(context) +# d3.curveLinearClosed(context) linearClosed Produces a closed polyline through the specified points by repeating the first point when the line segment ends. -# d3_shape.monotone(context) +# d3.curveMonotone(context) monotone Produces a cubic spline that [preserves monotonicity](https://en.wikipedia.org/wiki/Monotone_cubic_interpolation) in *y*, as proposed by Steffen in [A simple method for monotonic interpolation in one dimension](http://adsabs.harvard.edu/full/1990A%26A...239..443S): “a smooth curve with continuous first-order derivatives that passes through any given set of data points without spurious oscillations. Local extrema can occur only at grid points where they are given by the data, but not in between two adjacent grid points.” Assumes that the input data is monotonic in *x*. -# d3_shape.natural(context) +# d3.curveNatural(context) natural Produces a [natural](https://en.wikipedia.org/wiki/Spline_interpolation) [cubic spline](http://mathworld.wolfram.com/CubicSpline.html) with the second derivative of the spline set to zero at the endpoints. -# d3_shape.step(context) +# d3.curveStep(context) step Produces a piecewise constant function (a [step function](https://en.wikipedia.org/wiki/Step_function)) consisting of alternating horizontal and vertical lines. The *y*-value changes at the midpoint of each pair of adjacent *x*-values. -# d3_shape.stepAfter(context) +# d3.curveStepAfter(context) stepAfter Produces a piecewise constant function (a [step function](https://en.wikipedia.org/wiki/Step_function)) consisting of alternating horizontal and vertical lines. The *y*-value changes after the *x*-value. -# d3_shape.stepBefore(context) +# d3.curveStepBefore(context) stepBefore @@ -738,11 +738,11 @@ Indicates a new point in the current line segment with the given *x*- and *y*-va ### Symbols - + 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 arc to a different position. -# d3_shape.symbol() +# d3.symbol() Constructs a new symbol generator with the default settings. @@ -770,35 +770,35 @@ Specifying the size as a function is useful for constructing a scatterplot with If *context* is specified, sets the context and returns this symbol generator. If *context* is not specified, returns the current context, which defaults to null. If the context is not null, then the [generated symbol](#_symbol) is rendered to this context as a sequence of [path method](http://www.w3.org/TR/2dcontext/#canvaspathmethods) calls. Otherwise, a [path data](http://www.w3.org/TR/SVG/paths.html#PathData) string representing the generated symbol is returned. -# d3_shape.symbols +# d3.symbols An array containing the set of all built-in symbol types: [circle](#circle), [cross](#cross), [diamond](#diamond), [square](#square), [star](#star), [triangle](#triangle), and [wye](#wye). Useful for constructing the range of an [ordinal scale](https://github.com/d3/d3-scale#ordinal-scales) should you wish to use a shape encoding for categorical data. -# d3_shape.circle +# d3.sybmolCircle A circle. -# d3_shape.cross +# d3.sybmolCross A Greek cross with arms of equal length. -# d3_shape.diamond +# d3.sybmolDiamond A rhombus. -# d3_shape.square +# d3.sybmolSquare A square. -# d3_shape.star +# d3.sybmolStar A pentagonal star (pentagram). -# d3_shape.triangle +# d3.sybmolTriangle An up-pointing triangle. -# d3_shape.wye +# d3.sybmolWye A Y-shape. @@ -816,11 +816,11 @@ Renders this symbol type to the specified *context* with the specified *size* in Some shape types can be stacked, placing one shape adjacent to another. For example, a bar chart of monthly sales might be broken down into a multi-series bar chart by product category, stacking bars vertically. This is equivalent to subdividing a bar chart by an ordinal dimension (such as product category) and applying a color encoding. -Stacked charts can show overall value and per-category value simultaneously; however, it is typically harder to compare across categories, as only the bottom layer of the stack is aligned. So, chose the [stack order](#stack_order) carefully, and consider a [streamgraph](#orderWiggle). (See also [grouped charts](http://bl.ocks.org/mbostock/3887051).) +Stacked charts can show overall value and per-category value simultaneously; however, it is typically harder to compare across categories, as only the bottom layer of the stack is aligned. So, chose the [stack order](#stack_order) carefully, and consider a [streamgraph](#stackOrderWiggle). (See also [grouped charts](http://bl.ocks.org/mbostock/3887051).) Like the [pie generator](#pies), the stack generator does not produce a shape directly. Instead it computes positions which you can then pass to an [area generator](#areas) or use directly, say to position bars. -# stack() +# d3.stack() Constructs a new stack generator with the default settings. @@ -853,7 +853,7 @@ var data = [ To produce a stack for this data: ```js -var stack = d3_shape.stack() +var stack = d3.stack() .keys(["apples", "bananas", "cherries", "dates"]) .order(d3_shape.orderNone) .offset(d3_shape.offsetNone); @@ -892,7 +892,7 @@ Thus, by default the stack generator assumes that the input data is an array of # stack.order([order]) -If *order* is specified, sets the order accessor to the specified function or array and returns this stack generator. If *order* is not specified, returns the current order acccesor, which defaults to [orderNone](#orderNone); this uses the order given by the [key accessor](#stack_key). See [stack orders](#stack-orders) for the built-in orders. +If *order* is specified, sets the order accessor to the specified function or array and returns this stack generator. If *order* is not specified, returns the current order acccesor, which defaults to [stackOrderNone](#stackOrderNone); this uses the order given by the [key accessor](#stack_key). See [stack orders](#stack-orders) for the built-in orders. If *order* is a function, it is passed the generated series array and must return an array of numeric indexes representing the stack order. For example, the default order is defined as: @@ -908,7 +908,7 @@ The stack order is computed prior to the [offset](#stack_offset); thus, the lowe # stack.offset([offset]) -If *offset* is specified, sets the offset accessor to the specified function or array and returns this stack generator. If *offset* is not specified, returns the current offset acccesor, which defaults to [offsetNone](#offsetNone); this uses a zero baseline. See [stack offsets](#stack-offsets) for the built-in offsets. +If *offset* is specified, sets the offset accessor to the specified function or array and returns this stack generator. If *offset* is not specified, returns the current offset acccesor, which defaults to [stackOffsetNone](#stackOffsetNone); this uses a zero baseline. See [stack offsets](#stack-offsets) for the built-in offsets. If *offset* is a function, it is passed the generated series array and the order index array. The offset function is then responsible for updating the lower and upper values in the series array to layout the stack. For example, the default offset is defined as: @@ -928,23 +928,23 @@ function offsetNone(series, order) { Stack orders are typically not used directly, but are instead passed to [*stack*.order](#stack_order). -# orderAscending(series) +# d3.stackOrderAscending(series) Returns a series order such that the smallest series (according to the sum of values) is at the bottom. -# orderDescending(series) +# d3.stackOrderDescending(series) Returns a series order such that the largest series (according to the sum of values) is at the bottom. -# orderInsideOut(series) +# d3.stackOrderInsideOut(series) -Returns a series order such that the larger series (according to the sum of values) are on the inside and the smaller series are on the outside. This order is recommended for streamgraphs in conjunction with the [wiggle offset](#offsetWiggle). See [Stacked Graphs—Geometry & Aesthetics](http://leebyron.com/streamgraph/) by Bryon & Wattenberg for more information. +Returns a series order such that the larger series (according to the sum of values) are on the inside and the smaller series are on the outside. This order is recommended for streamgraphs in conjunction with the [wiggle offset](#stackOffsetWiggle). See [Stacked Graphs—Geometry & Aesthetics](http://leebyron.com/streamgraph/) by Bryon & Wattenberg for more information. -# orderNone(series) +# d3.stackOrderNone(series) Returns the given series order [0, 1, … *n* - 1] where *n* is the number of elements in *series*. Thus, the stack order is given by the [key accessor](#stack_keys). -# orderReverse(series) +# d3.stackOrderReverse(series) Returns the reverse of the given series order [*n* - 1, *n* - 2, … 0] where *n* is the number of elements in *series*. Thus, the stack order is given by the reverse of the [key accessor](#stack_keys). @@ -952,18 +952,18 @@ Returns the reverse of the given series order [*n* - 1, *n* - 2, … 0] where *n Stack offsets are typically not used directly, but are instead passed to [*stack*.offset](#stack_offset). -# offsetExpand(series, order) +# d3.stackOffsetExpand(series, order) Applies a zero baseline and normalizes the values for each point such that the topline is always one. -# offsetNone(series, order) +# d3.stackOffsetNone(series, order) Applies a zero baseline. -# offsetSilhouette(series, order) +# d3.stackOffsetSilhouette(series, order) Shifts the baseline down such that the center of the streamgraph is always at zero. -# offsetWiggle(series, order) +# d3.stackOffsetWiggle(series, order) -Shifts the baseline so as to minimize the weighted wiggle of layers. This offset is recommended for streamgraphs in conjunction with the [inside-out order](#orderInsideOut). See [Stacked Graphs—Geometry & Aesthetics](http://leebyron.com/streamgraph/) by Bryon & Wattenberg for more information. +Shifts the baseline so as to minimize the weighted wiggle of layers. This offset is recommended for streamgraphs in conjunction with the [inside-out order](#stackOrderInsideOut). See [Stacked Graphs—Geometry & Aesthetics](http://leebyron.com/streamgraph/) by Bryon & Wattenberg for more information. diff --git a/index.js b/index.js index 1392b93..b149d8d 100644 --- a/index.js +++ b/index.js @@ -6,37 +6,37 @@ export {default as radialArea} from "./src/radialArea"; export {default as radialLine} from "./src/radialLine"; export {default as symbol, symbols} from "./src/symbol"; -export {default as circle} from "./src/symbol/circle"; -export {default as cross} from "./src/symbol/cross"; -export {default as diamond} from "./src/symbol/diamond"; -export {default as square} from "./src/symbol/square"; -export {default as star} from "./src/symbol/star"; -export {default as triangle} from "./src/symbol/triangle"; -export {default as wye} from "./src/symbol/wye"; +export {default as symbolCircle} from "./src/symbol/circle"; +export {default as symbolCross} from "./src/symbol/cross"; +export {default as symbolDiamond} from "./src/symbol/diamond"; +export {default as symbolSquare} from "./src/symbol/square"; +export {default as symbolStar} from "./src/symbol/star"; +export {default as symbolTriangle} from "./src/symbol/triangle"; +export {default as symbolWye} from "./src/symbol/wye"; -export {default as basisClosed} from "./src/curve/basisClosed"; -export {default as basisOpen} from "./src/curve/basisOpen"; -export {default as basis} from "./src/curve/basis"; -export {default as bundle} from "./src/curve/bundle"; -export {default as cardinalClosed} from "./src/curve/cardinalClosed"; -export {default as cardinalOpen} from "./src/curve/cardinalOpen"; -export {default as cardinal} from "./src/curve/cardinal"; -export {default as catmullRomClosed} from "./src/curve/catmullRomClosed"; -export {default as catmullRomOpen} from "./src/curve/catmullRomOpen"; -export {default as catmullRom} from "./src/curve/catmullRom"; -export {default as linearClosed} from "./src/curve/linearClosed"; -export {default as linear} from "./src/curve/linear"; -export {default as monotone} from "./src/curve/monotone"; -export {default as natural} from "./src/curve/natural"; -export {default as step, stepAfter, stepBefore} from "./src/curve/step"; +export {default as curveBasisClosed} from "./src/curve/basisClosed"; +export {default as curveBasisOpen} from "./src/curve/basisOpen"; +export {default as curveBasis} from "./src/curve/basis"; +export {default as curveBundle} from "./src/curve/bundle"; +export {default as curveCardinalClosed} from "./src/curve/cardinalClosed"; +export {default as curveCardinalOpen} from "./src/curve/cardinalOpen"; +export {default as curveCardinal} from "./src/curve/cardinal"; +export {default as curveCatmullRomClosed} from "./src/curve/catmullRomClosed"; +export {default as curveCatmullRomOpen} from "./src/curve/catmullRomOpen"; +export {default as curveCatmullRom} from "./src/curve/catmullRom"; +export {default as curveLinearClosed} from "./src/curve/linearClosed"; +export {default as curveLinear} from "./src/curve/linear"; +export {default as curveMonotone} from "./src/curve/monotone"; +export {default as curveNatural} from "./src/curve/natural"; +export {default as curveStep, stepAfter as curveStepAfter, stepBefore as curveStepBefore} from "./src/curve/step"; export {default as stack} from "./src/stack"; -export {default as offsetExpand} from "./src/offset/expand"; -export {default as offsetNone} from "./src/offset/none"; -export {default as offsetSilhouette} from "./src/offset/silhouette"; -export {default as offsetWiggle} from "./src/offset/wiggle"; -export {default as orderAscending} from "./src/order/ascending"; -export {default as orderDescending} from "./src/order/descending"; -export {default as orderInsideOut} from "./src/order/insideOut"; -export {default as orderNone} from "./src/order/none"; -export {default as orderReverse} from "./src/order/reverse"; +export {default as stackOffsetExpand} from "./src/offset/expand"; +export {default as stackOffsetNone} from "./src/offset/none"; +export {default as stackOffsetSilhouette} from "./src/offset/silhouette"; +export {default as stackOffsetWiggle} from "./src/offset/wiggle"; +export {default as stackOrderAscending} from "./src/order/ascending"; +export {default as stackOrderDescending} from "./src/order/descending"; +export {default as stackOrderInsideOut} from "./src/order/insideOut"; +export {default as stackOrderNone} from "./src/order/none"; +export {default as stackOrderReverse} from "./src/order/reverse"; diff --git a/package.json b/package.json index 3b65fd9..9c94c97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "d3-shape", - "version": "0.3.0", + "version": "0.4.0", "description": "Graphical primitives for visualization, such as lines and areas.", "keywords": [ "d3", @@ -30,7 +30,7 @@ "d3-path": "~0.1.3" }, "devDependencies": { - "d3-polygon": "~0.0.3", + "d3-polygon": "~0.1.0", "faucet": "0.0", "rollup": "0.20.5", "tape": "4", diff --git a/test/area-test.js b/test/area-test.js index 5eae47d..43a3743 100644 --- a/test/area-test.js +++ b/test/area-test.js @@ -10,7 +10,7 @@ tape("area() returns a default area shape", function(test) { test.equal(a.y0()([42, 34]), 0); test.equal(a.y1()([42, 34]), 34); test.equal(a.defined()([42, 34]), true); - test.equal(a.curve(), shape.linear); + test.equal(a.curve(), shape.curveLinear); test.equal(a.context(), null); test.pathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5L4,0L2,0L0,0Z"); test.end(); @@ -105,13 +105,13 @@ tape("area.y(y)(data) observes the specified constant", function(test) { }); tape("area.curve(curve) sets the curve method", function(test) { - var a = shape.area().curve(shape.cardinal); + var a = shape.area().curve(shape.curveCardinal); test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3L3,0C3,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); test.end(); }); -tape("area.curve(cardinal, tension) sets the cardinal spline tension", function(test) { - var a = shape.area().curve(shape.cardinal, 0.1); +tape("area.curve(curveCardinal, tension) sets the cardinal spline tension", function(test) { + var a = shape.area().curve(shape.curveCardinal, 0.1); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); @@ -120,8 +120,8 @@ tape("area.curve(cardinal, tension) sets the cardinal spline tension", function( test.end(); }); -tape("area.curve(cardinal, tension) coerces the specified tension to a number", function(test) { - var a = shape.area().curve(shape.cardinal, "0.1"); +tape("area.curve(curveCardinal, tension) coerces the specified tension to a number", function(test) { + var a = shape.area().curve(shape.curveCardinal, "0.1"); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); diff --git a/test/curve/basis-test.js b/test/curve/basis-test.js index fb0decd..563a4f5 100644 --- a/test/curve/basis-test.js +++ b/test/curve/basis-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(basis)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.basis); +tape("line.curve(curveBasis)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveBasis); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); @@ -12,8 +12,8 @@ tape("line.curve(basis)(data) generates the expected path", function(test) { test.end(); }); -tape("area.curve(basis)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.basis); +tape("area.curve(curveBasis)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveBasis); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); diff --git a/test/curve/basisClosed-test.js b/test/curve/basisClosed-test.js index ae4e988..c8693e5 100644 --- a/test/curve/basisClosed-test.js +++ b/test/curve/basisClosed-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(basisClosed)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.basisClosed); +tape("line.curve(curveBasisClosed)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveBasisClosed); test.equal(l([]), null); test.pathEqual(l([[0, 0]]), "M0,0Z"); test.pathEqual(l([[0, 0], [0, 10]]), "M0,6.666667L0,3.333333Z"); diff --git a/test/curve/basisOpen-test.js b/test/curve/basisOpen-test.js index 2e678f3..8c0c7e6 100644 --- a/test/curve/basisOpen-test.js +++ b/test/curve/basisOpen-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(basisOpen)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.basisOpen); +tape("line.curve(curveBasisOpen)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveBasisOpen); test.equal(l([]), null); test.equal(l([[0, 0]]), null); test.equal(l([[0, 0], [0, 10]]), null); @@ -14,8 +14,8 @@ tape("line.curve(basisOpen)(data) generates the expected path", function(test) { test.end(); }); -tape("area.curve(basisOpen)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.basisOpen); +tape("area.curve(curveBasisOpen)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveBasisOpen); test.equal(a([]), null); test.equal(a([[0, 1]]), null); test.equal(a([[0, 1], [1, 3]]), null); diff --git a/test/curve/bundle-test.js b/test/curve/bundle-test.js index 8ea44b3..6e23b8a 100644 --- a/test/curve/bundle-test.js +++ b/test/curve/bundle-test.js @@ -3,10 +3,10 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(bundle) uses a default beta of 0.85", function(test) { - var l = shape.line().curve(shape.bundle, 0.85); - test.equal(shape.line().curve(shape.bundle)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.bundle, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.bundle, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("line.curve(curveBundle) uses a default beta of 0.85", function(test) { + var l = shape.line().curve(shape.curveBundle, 0.85); + test.equal(shape.line().curve(shape.curveBundle)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveBundle, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveBundle, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); diff --git a/test/curve/cardinal-test.js b/test/curve/cardinal-test.js index 627adff..8b991ec 100644 --- a/test/curve/cardinal-test.js +++ b/test/curve/cardinal-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(cardinal)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.cardinal); +tape("line.curve(curveCardinal)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCardinal); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); @@ -13,16 +13,16 @@ tape("line.curve(cardinal)(data) generates the expected path", function(test) { test.end(); }); -tape("line.curve(cardinal) uses a default tension of zero", function(test) { - var l = shape.line().curve(shape.cardinal, 0); - test.equal(shape.line().curve(shape.cardinal)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.cardinal, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.cardinal, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("line.curve(curveCardinal) uses a default tension of zero", function(test) { + var l = shape.line().curve(shape.curveCardinal, 0); + test.equal(shape.line().curve(shape.curveCardinal)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCardinal, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCardinal, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); -tape("area.curve(cardinal)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.cardinal); +tape("area.curve(curveCardinal)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveCardinal); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); @@ -31,10 +31,10 @@ tape("area.curve(cardinal)(data) generates the expected path", function(test) { test.end(); }); -tape("area.curve(cardinal) uses a default tension of zero", function(test) { - var a = shape.area().curve(shape.cardinal, 0); - test.equal(shape.area().curve(shape.cardinal)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.area().curve(shape.cardinal, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.area().curve(shape.cardinal, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("area.curve(curveCardinal) uses a default tension of zero", function(test) { + var a = shape.area().curve(shape.curveCardinal, 0); + test.equal(shape.area().curve(shape.curveCardinal)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.area().curve(shape.curveCardinal, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.area().curve(shape.curveCardinal, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); diff --git a/test/curve/cardinalClosed-test.js b/test/curve/cardinalClosed-test.js index 6a1b039..448dcbe 100644 --- a/test/curve/cardinalClosed-test.js +++ b/test/curve/cardinalClosed-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(cardinalClosed)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.cardinalClosed); +tape("line.curve(curveCardinalClosed)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCardinalClosed); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); @@ -13,10 +13,10 @@ tape("line.curve(cardinalClosed)(data) generates the expected path", function(te test.end(); }); -tape("line.curve(cardinalClosed) uses a default tension of zero", function(test) { - var l = shape.line().curve(shape.cardinalClosed, 0); - test.equal(shape.line().curve(shape.cardinalClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.cardinalClosed, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.cardinalClosed, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("line.curve(curveCardinalClosed) uses a default tension of zero", function(test) { + var l = shape.line().curve(shape.curveCardinalClosed, 0); + test.equal(shape.line().curve(shape.curveCardinalClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCardinalClosed, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCardinalClosed, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); diff --git a/test/curve/cardinalOpen-test.js b/test/curve/cardinalOpen-test.js index 2cfde6c..d1d8366 100644 --- a/test/curve/cardinalOpen-test.js +++ b/test/curve/cardinalOpen-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(cardinalOpen)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.cardinalOpen); +tape("line.curve(curveCardinalOpen)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCardinalOpen); test.equal(l([]), null); test.equal(l([[0, 1]]), null); test.equal(l([[0, 1], [1, 3]]), null); @@ -13,16 +13,16 @@ tape("line.curve(cardinalOpen)(data) generates the expected path", function(test test.end(); }); -tape("line.curve(cardinalOpen) uses a default tension of zero", function(test) { - var l = shape.line().curve(shape.cardinalOpen, 0); - test.equal(shape.line().curve(shape.cardinalOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.cardinalOpen, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.cardinalOpen, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("line.curve(curveCardinalOpen) uses a default tension of zero", function(test) { + var l = shape.line().curve(shape.curveCardinalOpen, 0); + test.equal(shape.line().curve(shape.curveCardinalOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCardinalOpen, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCardinalOpen, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); -tape("area.curve(cardinalOpen)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.cardinalOpen); +tape("area.curve(curveCardinalOpen)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveCardinalOpen); test.equal(a([]), null); test.equal(a([[0, 1]]), null); test.equal(a([[0, 1], [1, 3]]), null); @@ -31,10 +31,10 @@ tape("area.curve(cardinalOpen)(data) generates the expected path", function(test test.end(); }); -tape("area.curve(cardinalOpen) uses a default tension of zero", function(test) { - var a = shape.area().curve(shape.cardinalOpen, 0); - test.equal(shape.area().curve(shape.cardinalOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.area().curve(shape.cardinalOpen, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.area().curve(shape.cardinalOpen, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("area.curve(curveCardinalOpen) uses a default tension of zero", function(test) { + var a = shape.area().curve(shape.curveCardinalOpen, 0); + test.equal(shape.area().curve(shape.curveCardinalOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.area().curve(shape.curveCardinalOpen, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.area().curve(shape.curveCardinalOpen, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); diff --git a/test/curve/catmullRom-test.js b/test/curve/catmullRom-test.js index 3e184b5..e5053bd 100644 --- a/test/curve/catmullRom-test.js +++ b/test/curve/catmullRom-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(catmullRom)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.catmullRom); +tape("line.curve(curveCatmullRom)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCatmullRom); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); @@ -13,8 +13,8 @@ tape("line.curve(catmullRom)(data) generates the expected path", function(test) test.end(); }); -tape("line.curve(catmullRom, 1)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.catmullRom, 1); +tape("line.curve(curveCatmullRom, 1)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCatmullRom, 1); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); @@ -23,16 +23,16 @@ tape("line.curve(catmullRom, 1)(data) generates the expected path", function(tes test.end(); }); -tape("line.curve(catmullRom) uses a default alpha of 0.5 (centripetal)", function(test) { - var l = shape.line().curve(shape.catmullRom, 0.5); - test.equal(shape.line().curve(shape.catmullRom)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.catmullRom, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.catmullRom, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("line.curve(curveCatmullRom) uses a default alpha of 0.5 (centripetal)", function(test) { + var l = shape.line().curve(shape.curveCatmullRom, 0.5); + test.equal(shape.line().curve(shape.curveCatmullRom)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCatmullRom, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCatmullRom, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); -tape("area.curve(catmullRom, 0)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.catmullRom, 0); +tape("area.curve(curveCatmullRom, 0)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveCatmullRom, 0); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); @@ -41,10 +41,10 @@ tape("area.curve(catmullRom, 0)(data) generates the expected path", function(tes test.end(); }); -tape("area.curve(catmullRom) uses a default alpha of 0.5 (centripetal)", function(test) { - var a = shape.area().curve(shape.catmullRom, 0.5); - test.equal(shape.area().curve(shape.catmullRom)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.area().curve(shape.catmullRom, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.area().curve(shape.catmullRom, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("area.curve(curveCatmullRom) uses a default alpha of 0.5 (centripetal)", function(test) { + var a = shape.area().curve(shape.curveCatmullRom, 0.5); + test.equal(shape.area().curve(shape.curveCatmullRom)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.area().curve(shape.curveCatmullRom, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.area().curve(shape.curveCatmullRom, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); diff --git a/test/curve/catmullRomClosed-test.js b/test/curve/catmullRomClosed-test.js index f7d36e6..12460ec 100644 --- a/test/curve/catmullRomClosed-test.js +++ b/test/curve/catmullRomClosed-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(catmullRomClosed)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.catmullRomClosed); +tape("line.curve(curveCatmullRomClosed)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCatmullRomClosed); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); @@ -13,8 +13,8 @@ tape("line.curve(catmullRomClosed)(data) generates the expected path", function( test.end(); }); -tape("line.curve(catmullRomClosed, 0)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.catmullRomClosed, 0); +tape("line.curve(curveCatmullRomClosed, 0)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCatmullRomClosed, 0); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); @@ -23,8 +23,8 @@ tape("line.curve(catmullRomClosed, 0)(data) generates the expected path", functi test.end(); }); -tape("line.curve(catmullRomClosed, 1)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.catmullRomClosed, 1); +tape("line.curve(curveCatmullRomClosed, 1)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCatmullRomClosed, 1); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); @@ -33,10 +33,10 @@ tape("line.curve(catmullRomClosed, 1)(data) generates the expected path", functi test.end(); }); -tape("line.curve(catmullRomClosed) uses a default alpha of 0.5 (centripetal)", function(test) { - var l = shape.line().curve(shape.catmullRomClosed, 0.5); - test.equal(shape.line().curve(shape.catmullRomClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.catmullRomClosed, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.catmullRomClosed, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("line.curve(curveCatmullRomClosed) uses a default alpha of 0.5 (centripetal)", function(test) { + var l = shape.line().curve(shape.curveCatmullRomClosed, 0.5); + test.equal(shape.line().curve(shape.curveCatmullRomClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCatmullRomClosed, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCatmullRomClosed, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); diff --git a/test/curve/catmullRomOpen-test.js b/test/curve/catmullRomOpen-test.js index d004423..4de51e5 100644 --- a/test/curve/catmullRomOpen-test.js +++ b/test/curve/catmullRomOpen-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(catmullRomOpen)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.catmullRomOpen); +tape("line.curve(curveCatmullRomOpen)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCatmullRomOpen); test.equal(l([]), null); test.equal(l([[0, 1]]), null); test.equal(l([[0, 1], [1, 3]]), null); @@ -13,8 +13,8 @@ tape("line.curve(catmullRomOpen)(data) generates the expected path", function(te test.end(); }); -tape("line.curve(catmullRomOpen, 1)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.catmullRomOpen, 1); +tape("line.curve(curveCatmullRomOpen, 1)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveCatmullRomOpen, 1); test.equal(l([]), null); test.equal(l([[0, 1]]), null); test.equal(l([[0, 1], [1, 3]]), null); @@ -23,16 +23,16 @@ tape("line.curve(catmullRomOpen, 1)(data) generates the expected path", function test.end(); }); -tape("line.curve(catmullRomOpen) uses a default alpha of 0.5 (centripetal)", function(test) { - var l = shape.line().curve(shape.catmullRomOpen, 0.5); - test.equal(shape.line().curve(shape.catmullRomOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.catmullRomOpen, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.line().curve(shape.catmullRomOpen, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("line.curve(curveCatmullRomOpen) uses a default alpha of 0.5 (centripetal)", function(test) { + var l = shape.line().curve(shape.curveCatmullRomOpen, 0.5); + test.equal(shape.line().curve(shape.curveCatmullRomOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCatmullRomOpen, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.line().curve(shape.curveCatmullRomOpen, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); -tape("area.curve(catmullRomOpen, 0.5)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.catmullRomOpen, 0.5); +tape("area.curve(curveCatmullRomOpen, 0.5)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveCatmullRomOpen, 0.5); test.equal(a([]), null); test.equal(a([[0, 1]]), null); test.equal(a([[0, 1], [1, 3]]), null); @@ -41,10 +41,10 @@ tape("area.curve(catmullRomOpen, 0.5)(data) generates the expected path", functi test.end(); }); -tape("area.curve(catmullRomOpen) uses a default alpha of 0.5 (centripetal)", function(test) { - var a = shape.area().curve(shape.catmullRomOpen, 0.5); - test.equal(shape.area().curve(shape.catmullRomOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.area().curve(shape.catmullRomOpen, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.equal(shape.area().curve(shape.catmullRomOpen, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); +tape("area.curve(curveCatmullRomOpen) uses a default alpha of 0.5 (centripetal)", function(test) { + var a = shape.area().curve(shape.curveCatmullRomOpen, 0.5); + test.equal(shape.area().curve(shape.curveCatmullRomOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.area().curve(shape.curveCatmullRomOpen, null)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); + test.equal(shape.area().curve(shape.curveCatmullRomOpen, undefined)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); test.end(); }); diff --git a/test/curve/linear-test.js b/test/curve/linear-test.js index 5aea89e..3480dd8 100644 --- a/test/curve/linear-test.js +++ b/test/curve/linear-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(linear)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.linear); +tape("line.curve(curveLinear)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveLinear); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3"); @@ -12,8 +12,8 @@ tape("line.curve(linear)(data) generates the expected path", function(test) { test.end(); }); -tape("area.curve(linear)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.linear); +tape("area.curve(curveLinear)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveLinear); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [2, 3]]), "M0,1L2,3L2,0L0,0Z"); diff --git a/test/curve/linearClosed-test.js b/test/curve/linearClosed-test.js index baac306..9312f6b 100644 --- a/test/curve/linearClosed-test.js +++ b/test/curve/linearClosed-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(linearClosed)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.linearClosed); +tape("line.curve(curveLinearClosed)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveLinearClosed); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3Z"); diff --git a/test/curve/monotone-test.js b/test/curve/monotone-test.js index 289d98e..82feca8 100644 --- a/test/curve/monotone-test.js +++ b/test/curve/monotone-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(monotone)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.monotone); +tape("line.curve(curveMonotone)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveMonotone); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); @@ -13,22 +13,22 @@ tape("line.curve(monotone)(data) generates the expected path", function(test) { test.end(); }); -tape("line.curve(monotone)(data) preserves monotonicity in y", function(test) { - var l = shape.line().curve(shape.monotone); +tape("line.curve(curveMonotone)(data) preserves monotonicity in y", function(test) { + var l = shape.line().curve(shape.curveMonotone); test.pathEqual(l([[0, 200], [100, 100], [200, 100], [300, 300], [400, 300]]), "M0,200C33.333333,150,66.666667,100,100,100C133.333333,100,166.666667,100,200,100C233.333333,100,266.666667,300,300,300C333.333333,300,366.666667,300,400,300"); test.end(); }); -tape("line.curve(monotone)(data) handles duplicate x-values", function(test) { - var l = shape.line().curve(shape.monotone); +tape("line.curve(curveMonotone)(data) handles duplicate x-values", function(test) { + var l = shape.line().curve(shape.curveMonotone); test.pathEqual(l([[0, 200], [0, 100], [100, 100], [200, 0]]), "M0,200C0,200,0,100,0,100C33.333333,100,66.666667,100,100,100C133.333333,100,166.666667,50,200,0"); test.pathEqual(l([[0, 200], [100, 100], [100, 0], [200, 0]]), "M0,200C33.333333,183.333333,66.666667,166.666667,100,100C100,100,100,0,100,0C133.333333,0,166.666667,0,200,0"); test.pathEqual(l([[0, 200], [100, 100], [200, 100], [200, 0]]), "M0,200C33.333333,150,66.666667,100,100,100C133.333333,100,166.666667,100,200,100C200,100,200,0,200,0"); test.end(); }); -tape("line.curve(monotone)(data) ignores coincident points", function(test) { - var l = shape.line().curve(shape.monotone), +tape("line.curve(curveMonotone)(data) ignores coincident points", function(test) { + var l = shape.line().curve(shape.curveMonotone), p = l([[0, 200], [50, 200], [100, 100], [150, 0], [200, 0]]); test.equal(l([[0, 200], [0, 200], [50, 200], [100, 100], [150, 0], [200, 0]]), p); test.equal(l([[0, 200], [50, 200], [50, 200], [100, 100], [150, 0], [200, 0]]), p); @@ -38,8 +38,8 @@ tape("line.curve(monotone)(data) ignores coincident points", function(test) { test.end(); }); -tape("area.curve(monotone)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.monotone); +tape("area.curve(curveMonotone)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveMonotone); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); diff --git a/test/curve/natural-test.js b/test/curve/natural-test.js index 5743169..5664b2b 100644 --- a/test/curve/natural-test.js +++ b/test/curve/natural-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(natural)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.natural); +tape("line.curve(curveNatural)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveNatural); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); @@ -13,8 +13,8 @@ tape("line.curve(natural)(data) generates the expected path", function(test) { test.end(); }); -tape("area.curve(natural)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.natural); +tape("area.curve(curveNatural)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveNatural); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); diff --git a/test/curve/step-test.js b/test/curve/step-test.js index 6a9c606..e37e681 100644 --- a/test/curve/step-test.js +++ b/test/curve/step-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(step)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.step); +tape("line.curve(curveStep)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveStep); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L1,1L1,3L2,3"); @@ -12,8 +12,8 @@ tape("line.curve(step)(data) generates the expected path", function(test) { test.end(); }); -tape("area.curve(step)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.step); +tape("area.curve(curveStep)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveStep); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [2, 3]]), "M0,1L1,1L1,3L2,3L2,0L1,0L1,0L0,0Z"); diff --git a/test/curve/stepAfter-test.js b/test/curve/stepAfter-test.js index c4b000f..8466258 100644 --- a/test/curve/stepAfter-test.js +++ b/test/curve/stepAfter-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(stepAfter)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.stepAfter); +tape("line.curve(curveStepAfter)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveStepAfter); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L2,1L2,3"); @@ -12,8 +12,8 @@ tape("line.curve(stepAfter)(data) generates the expected path", function(test) { test.end(); }); -tape("area.curve(stepAfter)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.stepAfter); +tape("area.curve(curveStepAfter)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveStepAfter); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [2, 3]]), "M0,1L2,1L2,3L2,0L2,0L0,0Z"); diff --git a/test/curve/stepBefore-test.js b/test/curve/stepBefore-test.js index f7b7332..7a8470c 100644 --- a/test/curve/stepBefore-test.js +++ b/test/curve/stepBefore-test.js @@ -3,8 +3,8 @@ var tape = require("tape"), require("../pathEqual"); -tape("line.curve(stepBefore)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.stepBefore); +tape("line.curve(curveStepBefore)(data) generates the expected path", function(test) { + var l = shape.line().curve(shape.curveStepBefore); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L0,3L2,3"); @@ -12,8 +12,8 @@ tape("line.curve(stepBefore)(data) generates the expected path", function(test) test.end(); }); -tape("area.curve(stepBefore)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.stepBefore); +tape("area.curve(curveStepBefore)(data) generates the expected path", function(test) { + var a = shape.area().curve(shape.curveStepBefore); test.equal(a([]), null); test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); test.pathEqual(a([[0, 1], [2, 3]]), "M0,1L0,3L2,3L2,0L0,0L0,0Z"); diff --git a/test/line-test.js b/test/line-test.js index da98db4..80071eb 100644 --- a/test/line-test.js +++ b/test/line-test.js @@ -8,7 +8,7 @@ tape("line() returns a default line shape", function(test) { test.equal(l.x()([42, 34]), 42); test.equal(l.y()([42, 34]), 34); test.equal(l.defined()([42, 34]), true); - test.equal(l.curve(), shape.linear); + test.equal(l.curve(), shape.curveLinear); test.equal(l.context(), null); test.pathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5"); test.end(); @@ -60,14 +60,14 @@ tape("line.y(y)(data) observes the specified constant", function(test) { }); tape("line.curve(curve) sets the curve method", function(test) { - var l = shape.line().curve(shape.linearClosed); + var l = shape.line().curve(shape.curveLinearClosed); test.equal(l([]), null); test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3Z"); test.end(); }); -tape("line.curve(cardinal, tension) sets the cardinal spline tension", function(test) { - var l = shape.line().curve(shape.cardinal, 0.1); +tape("line.curve(curveCardinal, tension) sets the cardinal spline tension", function(test) { + var l = shape.line().curve(shape.curveCardinal, 0.1); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); @@ -76,8 +76,8 @@ tape("line.curve(cardinal, tension) sets the cardinal spline tension", function( test.end(); }); -tape("line.curve(cardinal, tension) coerces the specified tension to a number", function(test) { - var l = shape.line().curve(shape.cardinal, "0.1"); +tape("line.curve(curveCardinal, tension) coerces the specified tension to a number", function(test) { + var l = shape.line().curve(shape.curveCardinal, "0.1"); test.equal(l([]), null); test.pathEqual(l([[0, 1]]), "M0,1Z"); test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); diff --git a/test/offset/expand-test.js b/test/offset/expand-test.js index f67a530..497c0c1 100644 --- a/test/offset/expand-test.js +++ b/test/offset/expand-test.js @@ -1,13 +1,13 @@ var tape = require("tape"), shape = require("../../"); -tape("offsetExpand(series, order) expands to fill [0, 1]", function(test) { +tape("stackOffsetExpand(series, order) expands to fill [0, 1]", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetExpand(series, shape.orderNone(series)); + shape.stackOffsetExpand(series, shape.stackOrderNone(series)); test.deepEqual(series, [ [[0 / 9, 1 / 9], [0 / 8, 2 / 8], [0 / 7, 1 / 7]], [[1 / 9, 4 / 9], [2 / 8, 6 / 8], [1 / 7, 3 / 7]], @@ -16,13 +16,13 @@ tape("offsetExpand(series, order) expands to fill [0, 1]", function(test) { test.end(); }); -tape("offsetExpand(series, order) treats NaN as zero", function(test) { +tape("stackOffsetExpand(series, order) treats NaN as zero", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, NaN], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetExpand(series, shape.orderNone(series)); + shape.stackOffsetExpand(series, shape.stackOrderNone(series)); test.ok(isNaN(series[1][1][1])); series[1][1][1] = "NaN"; // can’t test.equal NaN test.deepEqual(series, [ @@ -33,13 +33,13 @@ tape("offsetExpand(series, order) treats NaN as zero", function(test) { test.end(); }); -tape("offsetExpand(series, order) observes the specified order", function(test) { +tape("stackOffsetExpand(series, order) observes the specified order", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetExpand(series, shape.orderReverse(series)); + shape.stackOffsetExpand(series, shape.stackOrderReverse(series)); test.deepEqual(series, [ [[8 / 9, 9 / 9], [6 / 8, 8 / 8], [6 / 7, 7 / 7]], [[5 / 9, 8 / 9], [2 / 8, 6 / 8], [4 / 7, 6 / 7]], diff --git a/test/offset/none-test.js b/test/offset/none-test.js index d9c987d..4d7c73c 100644 --- a/test/offset/none-test.js +++ b/test/offset/none-test.js @@ -1,13 +1,13 @@ var tape = require("tape"), shape = require("../../"); -tape("offsetNone(series, order) uses the existing baseline", function(test) { +tape("stackOffsetNone(series, order) uses the existing baseline", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetNone(series, shape.orderNone(series)); + shape.stackOffsetNone(series, shape.stackOrderNone(series)); test.deepEqual(series, [ [[0, 1], [0, 2], [0, 1]], [[1, 4], [2, 6], [1, 3]], @@ -16,13 +16,13 @@ tape("offsetNone(series, order) uses the existing baseline", function(test) { test.end(); }); -tape("offsetNone(series, order) treats NaN as zero", function(test) { +tape("stackOffsetNone(series, order) treats NaN as zero", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, NaN], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetNone(series, shape.orderNone(series)); + shape.stackOffsetNone(series, shape.stackOrderNone(series)); test.ok(isNaN(series[1][1][1])); series[1][1][1] = "NaN"; // can’t test.equal NaN test.deepEqual(series, [ @@ -33,13 +33,13 @@ tape("offsetNone(series, order) treats NaN as zero", function(test) { test.end(); }); -tape("offsetNone(series, order) observes the specified order", function(test) { +tape("stackOffsetNone(series, order) observes the specified order", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetNone(series, shape.orderReverse(series)); + shape.stackOffsetNone(series, shape.stackOrderReverse(series)); test.deepEqual(series, [ [[8, 9], [6, 8], [6, 7]], [[5, 8], [2, 6], [4, 6]], diff --git a/test/offset/silhouette-test.js b/test/offset/silhouette-test.js index 09365ef..5ab18bf 100644 --- a/test/offset/silhouette-test.js +++ b/test/offset/silhouette-test.js @@ -1,13 +1,13 @@ var tape = require("tape"), shape = require("../../"); -tape("offsetSilhouette(series, order) centers the stack around zero", function(test) { +tape("stackOffsetSilhouette(series, order) centers the stack around zero", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetSilhouette(series, shape.orderNone(series)); + shape.stackOffsetSilhouette(series, shape.stackOrderNone(series)); test.deepEqual(series, [ [[0 - 9 / 2, 1 - 9 / 2], [0 - 8 / 2, 2 - 8 / 2], [0 - 7 / 2, 1 - 7 / 2]], [[1 - 9 / 2, 4 - 9 / 2], [2 - 8 / 2, 6 - 8 / 2], [1 - 7 / 2, 3 - 7 / 2]], @@ -16,13 +16,13 @@ tape("offsetSilhouette(series, order) centers the stack around zero", function(t test.end(); }); -tape("offsetSilhouette(series, order) treats NaN as zero", function(test) { +tape("stackOffsetSilhouette(series, order) treats NaN as zero", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, NaN], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetSilhouette(series, shape.orderNone(series)); + shape.stackOffsetSilhouette(series, shape.stackOrderNone(series)); test.ok(isNaN(series[1][1][1])); series[1][1][1] = "NaN"; // can’t test.equal NaN test.deepEqual(series, [ @@ -33,13 +33,13 @@ tape("offsetSilhouette(series, order) treats NaN as zero", function(test) { test.end(); }); -tape("offsetSilhouette(series, order) observes the specified order", function(test) { +tape("stackOffsetSilhouette(series, order) observes the specified order", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetSilhouette(series, shape.orderReverse(series)); + shape.stackOffsetSilhouette(series, shape.stackOrderReverse(series)); test.deepEqual(series, [ [[8 - 9 / 2, 9 - 9 / 2], [6 - 8 / 2, 8 - 8 / 2], [6 - 7 / 2, 7 - 7 / 2]], [[5 - 9 / 2, 8 - 9 / 2], [2 - 8 / 2, 6 - 8 / 2], [4 - 7 / 2, 6 - 7 / 2]], diff --git a/test/offset/wiggle-test.js b/test/offset/wiggle-test.js index 8f630c0..95d4a45 100644 --- a/test/offset/wiggle-test.js +++ b/test/offset/wiggle-test.js @@ -1,13 +1,13 @@ var tape = require("tape"), shape = require("../../"); -tape("offsetWiggle(series, order) minimizes weighted wiggle", function(test) { +tape("stackOffsetWiggle(series, order) minimizes weighted wiggle", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetWiggle(series, shape.orderNone(series)); + shape.stackOffsetWiggle(series, shape.stackOrderNone(series)); test.deepEqual(series.map(roundSeries), [ [[0, 1], [-1, 1], [0.7857143, 1.7857143]], [[1, 4], [ 1, 5], [1.7857143, 3.7857143]], @@ -16,14 +16,14 @@ tape("offsetWiggle(series, order) minimizes weighted wiggle", function(test) { test.end(); }); -tape("offsetWiggle(series, order) treats NaN as zero", function(test) { +tape("stackOffsetWiggle(series, order) treats NaN as zero", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, NaN], [0, NaN], [0, NaN]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetWiggle(series, shape.orderNone(series)); + shape.stackOffsetWiggle(series, shape.stackOrderNone(series)); test.ok(isNaN(series[1][0][1])); test.ok(isNaN(series[1][0][2])); test.ok(isNaN(series[1][0][3])); @@ -37,13 +37,13 @@ tape("offsetWiggle(series, order) treats NaN as zero", function(test) { test.end(); }); -tape("offsetWiggle(series, order) observes the specified order", function(test) { +tape("stackOffsetWiggle(series, order) observes the specified order", function(test) { var series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.offsetWiggle(series, shape.orderReverse(series)); + shape.stackOffsetWiggle(series, shape.stackOrderReverse(series)); test.deepEqual(series.map(roundSeries), [ [[8, 9], [8, 10], [7.21428571, 8.21428571]], [[5, 8], [4, 8], [5.21428571, 7.21428571]], diff --git a/test/order/ascending-test.js b/test/order/ascending-test.js index 10f19f1..a85d9eb 100644 --- a/test/order/ascending-test.js +++ b/test/order/ascending-test.js @@ -1,8 +1,8 @@ var tape = require("tape"), shape = require("../../"); -tape("orderAscending(series) returns an order by sum", function(test) { - test.deepEqual(shape.orderAscending([ +tape("stackOrderAscending(series) returns an order by sum", function(test) { + test.deepEqual(shape.stackOrderAscending([ [[0, 1], [0, 2], [0, 3]], [[0, 2], [0, 3], [0, 4]], [[0, 0], [0, 1], [0, 2]] @@ -10,8 +10,8 @@ tape("orderAscending(series) returns an order by sum", function(test) { test.end(); }); -tape("orderAscending(series) treats NaN values as zero", function(test) { - test.deepEqual(shape.orderAscending([ +tape("stackOrderAscending(series) treats NaN values as zero", function(test) { + test.deepEqual(shape.stackOrderAscending([ [[0, 1], [0, 2], [0, NaN], [0, 3]], [[0, 2], [0, 3], [0, NaN], [0, 4]], [[0, 0], [0, 1], [0, NaN], [0, 2]] diff --git a/test/order/descending-test.js b/test/order/descending-test.js index 26e5b23..a5f5499 100644 --- a/test/order/descending-test.js +++ b/test/order/descending-test.js @@ -1,8 +1,8 @@ var tape = require("tape"), shape = require("../../"); -tape("orderDescending(series) returns an order by sum", function(test) { - test.deepEqual(shape.orderDescending([ +tape("stackOrderDescending(series) returns an order by sum", function(test) { + test.deepEqual(shape.stackOrderDescending([ [[0, 1], [0, 2], [0, 3]], [[0, 2], [0, 3], [0, 4]], [[0, 0], [0, 1], [0, 2]] @@ -10,8 +10,8 @@ tape("orderDescending(series) returns an order by sum", function(test) { test.end(); }); -tape("orderDescending(series) treats NaN values as zero", function(test) { - test.deepEqual(shape.orderDescending([ +tape("stackOrderDescending(series) treats NaN values as zero", function(test) { + test.deepEqual(shape.stackOrderDescending([ [[0, 1], [0, 2], [0, 3], [0, NaN]], [[0, 2], [0, 3], [0, 4], [0, NaN]], [[0, 0], [0, 1], [0, 2], [0, NaN]] diff --git a/test/order/insideOut-test.js b/test/order/insideOut-test.js index 12f96cd..cbd4010 100644 --- a/test/order/insideOut-test.js +++ b/test/order/insideOut-test.js @@ -1,8 +1,8 @@ var tape = require("tape"), shape = require("../../"); -tape("orderInsideOut(series) returns an order by sum", function(test) { - test.deepEqual(shape.orderInsideOut([ +tape("stackOrderInsideOut(series) returns an order by sum", function(test) { + test.deepEqual(shape.stackOrderInsideOut([ [[0, 0]], [[0, 1]], [[0, 2]], @@ -14,8 +14,8 @@ tape("orderInsideOut(series) returns an order by sum", function(test) { test.end(); }); -tape("orderInsideOut(series) treats NaN values as zero", function(test) { - test.deepEqual(shape.orderInsideOut([ +tape("stackOrderInsideOut(series) treats NaN values as zero", function(test) { + test.deepEqual(shape.stackOrderInsideOut([ [[0, 0], [0, NaN]], [[0, 1], [0, NaN]], [[0, 2], [0, NaN]], diff --git a/test/order/none-test.js b/test/order/none-test.js index 2d8ed12..2f8f9b8 100644 --- a/test/order/none-test.js +++ b/test/order/none-test.js @@ -1,7 +1,7 @@ var tape = require("tape"), shape = require("../../"); -tape("orderNone(series) returns [0, 1, … series.length - 1]", function(test) { - test.deepEqual(shape.orderNone(new Array(4)), [0, 1, 2, 3]); +tape("stackOrderNone(series) returns [0, 1, … series.length - 1]", function(test) { + test.deepEqual(shape.stackOrderNone(new Array(4)), [0, 1, 2, 3]); test.end(); }); diff --git a/test/order/reverse-test.js b/test/order/reverse-test.js index 71d4034..396df3a 100644 --- a/test/order/reverse-test.js +++ b/test/order/reverse-test.js @@ -1,7 +1,7 @@ var tape = require("tape"), shape = require("../../"); -tape("orderReverse(series) returns [series.length - 1, series.length - 2, … 0]", function(test) { - test.deepEqual(shape.orderReverse(new Array(4)), [3, 2, 1, 0]); +tape("stackOrderReverse(series) returns [series.length - 1, series.length - 2, … 0]", function(test) { + test.deepEqual(shape.stackOrderReverse(new Array(4)), [3, 2, 1, 0]); test.end(); }); diff --git a/test/stack-test.js b/test/stack-test.js index 8551d98..76e5719 100644 --- a/test/stack-test.js +++ b/test/stack-test.js @@ -5,8 +5,8 @@ tape("stack() has the expected defaults", function(test) { var s = shape.stack(); test.deepEqual(s.keys()(), []); test.equal(s.value()({foo: 42}, "foo"), 42); - test.equal(s.order(), shape.orderNone); - test.equal(s.offset(), shape.offsetNone); + test.equal(s.order(), shape.stackOrderNone); + test.equal(s.offset(), shape.stackOffsetNone); test.end(); }); @@ -84,9 +84,9 @@ tape("stack(data) coerces the return value of the value accessor to a number", f }); tape("stack.order(function) sets the order function", function(test) { - var s = shape.stack().keys([0, 1, 2, 3]).order(shape.orderReverse), + var s = shape.stack().keys([0, 1, 2, 3]).order(shape.stackOrderReverse), data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; - test.equal(s.order(), shape.orderReverse); + test.equal(s.order(), shape.stackOrderReverse); test.deepEqual(s(data), [ series([[9, 10], [9, 11], [8, 9]], data, 0, 3), series([[6, 9], [5, 9], [6, 8]], data, 1, 2), @@ -97,9 +97,9 @@ tape("stack.order(function) sets the order function", function(test) { }); tape("stack.offset(function) sets the offset function", function(test) { - var s = shape.stack().keys([0, 1, 2, 3]).offset(shape.offsetExpand), + var s = shape.stack().keys([0, 1, 2, 3]).offset(shape.stackOffsetExpand), data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; - test.equal(s.offset(), shape.offsetExpand); + test.equal(s.offset(), shape.stackOffsetExpand); test.deepEqual(s(data).map(roundSeries), [ [[0 / 10, 1 / 10], [0 / 11, 2 / 11], [0 / 9, 1 / 9]], [[1 / 10, 4 / 10], [2 / 11, 6 / 11], [1 / 9, 3 / 9]], diff --git a/test/symbol-test.js b/test/symbol-test.js index 8c8bd8d..38dd91f 100644 --- a/test/symbol-test.js +++ b/test/symbol-test.js @@ -7,7 +7,7 @@ require("./pathEqual"); tape("symbol() returns a default symbol shape", function(test) { var s = shape.symbol(); - test.equal(s.type()(), shape.circle); + test.equal(s.type()(), shape.symbolCircle); test.equal(s.size()(), 64); test.equal(s.context(), null); test.pathEqual(s(), "M4.513517,0A4.513517,4.513517,0,1,1,-4.513517,0A4.513517,4.513517,0,1,1,4.513517,0"); @@ -23,7 +23,7 @@ tape("symbol().size(f)(…) propagates the context and arguments to the specifie tape("symbol().type(f)(…) propagates the context and arguments to the specified function", function(test) { var expected = {that: {}, args: [42]}, actual; - shape.symbol().type(function() { actual = {that: this, args: [].slice.call(arguments)}; return shape.circle; }).apply(expected.that, expected.args); + shape.symbol().type(function() { actual = {that: this, args: [].slice.call(arguments)}; return shape.symbolCircle; }).apply(expected.that, expected.args); test.deepEqual(actual, expected); test.end(); }); @@ -49,93 +49,93 @@ tape("symbol.size(size) observes the specified size constant", function(test) { test.end(); }); -tape("symbol.type(circle) generates the expected path", function(test) { - var s = shape.symbol().type(shape.circle).size(function(d) { return d; }); +tape("symbol.type(symbolCircle) generates the expected path", function(test) { + var s = shape.symbol().type(shape.symbolCircle).size(function(d) { return d; }); test.pathEqual(s(0), "M0,0"); test.pathEqual(s(20), "M2.523133,0A2.523133,2.523133,0,1,1,-2.523133,0A2.523133,2.523133,0,1,1,2.523133,0"); test.end(); }); -tape("symbol.type(cross) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.cross).context(p); +tape("symbol.type(symbolCross) generates a polygon with the specified size", function(test) { + var p = polygonContext(), s = shape.symbol().type(shape.symbolCross).context(p); s.size(1)(); test.inDelta(p.area(), 1); s.size(240)(); test.inDelta(p.area(), 240); test.end(); }); -tape("symbol.type(cross) generates the expected path", function(test) { - var s = shape.symbol().type(shape.cross).size(function(d) { return d; }); +tape("symbol.type(symbolCross) generates the expected path", function(test) { + var s = shape.symbol().type(shape.symbolCross).size(function(d) { return d; }); test.pathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); test.pathEqual(s(20), "M-3,-1L-1,-1L-1,-3L1,-3L1,-1L3,-1L3,1L1,1L1,3L-1,3L-1,1L-3,1Z"); test.end(); }); -tape("symbol.type(diamond) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.diamond).context(p); +tape("symbol.type(symbolDiamond) generates a polygon with the specified size", function(test) { + var p = polygonContext(), s = shape.symbol().type(shape.symbolDiamond).context(p); s.size(1)(); test.inDelta(p.area(), 1); s.size(240)(); test.inDelta(p.area(), 240); test.end(); }); -tape("symbol.type(diamond) generates the expected path", function(test) { - var s = shape.symbol().type(shape.diamond).size(function(d) { return d; }); +tape("symbol.type(symbolDiamond) generates the expected path", function(test) { + var s = shape.symbol().type(shape.symbolDiamond).size(function(d) { return d; }); test.pathEqual(s(0), "M0,0L0,0L0,0L0,0Z"); test.pathEqual(s(10), "M0,-2.942831L1.699044,0L0,2.942831L-1.699044,0Z"); test.end(); }); -tape("symbol.type(star) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.star).context(p); +tape("symbol.type(symbolStar) generates a polygon with the specified size", function(test) { + var p = polygonContext(), s = shape.symbol().type(shape.symbolStar).context(p); s.size(1)(); test.inDelta(p.area(), 1); s.size(240)(); test.inDelta(p.area(), 240); test.end(); }); -tape("symbol.type(star) generates the expected path", function(test) { - var s = shape.symbol().type(shape.star).size(function(d) { return d; }); +tape("symbol.type(symbolStar) generates the expected path", function(test) { + var s = shape.symbol().type(shape.symbolStar).size(function(d) { return d; }); test.pathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); test.pathEqual(s(10), "M0,-2.984649L0.670095,-0.922307L2.838570,-0.922307L1.084237,0.352290L1.754333,2.414632L0,1.140035L-1.754333,2.414632L-1.084237,0.352290L-2.838570,-0.922307L-0.670095,-0.922307Z"); test.end(); }); -tape("symbol.type(square) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.square).context(p); +tape("symbol.type(symbolSquare) generates a polygon with the specified size", function(test) { + var p = polygonContext(), s = shape.symbol().type(shape.symbolSquare).context(p); s.size(1)(); test.inDelta(p.area(), 1); s.size(240)(); test.inDelta(p.area(), 240); test.end(); }); -tape("symbol.type(square) generates the expected path", function(test) { - var s = shape.symbol().type(shape.square).size(function(d) { return d; }); +tape("symbol.type(symbolSquare) generates the expected path", function(test) { + var s = shape.symbol().type(shape.symbolSquare).size(function(d) { return d; }); test.pathEqual(s(0), "M0,0h0v0h0Z"); test.pathEqual(s(4), "M-1,-1h2v2h-2Z"); test.pathEqual(s(16), "M-2,-2h4v4h-4Z"); test.end(); }); -tape("symbol.type(triangle) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.triangle).context(p); +tape("symbol.type(symbolTriangle) generates a polygon with the specified size", function(test) { + var p = polygonContext(), s = shape.symbol().type(shape.symbolTriangle).context(p); s.size(1)(); test.inDelta(p.area(), 1); s.size(240)(); test.inDelta(p.area(), 240); test.end(); }); -tape("symbol.type(triangle) generates the expected path", function(test) { - var s = shape.symbol().type(shape.triangle).size(function(d) { return d; }); +tape("symbol.type(symbolTriangle) generates the expected path", function(test) { + var s = shape.symbol().type(shape.symbolTriangle).size(function(d) { return d; }); test.pathEqual(s(0), "M0,0L0,0L0,0Z"); test.pathEqual(s(10), "M0,-2.774528L2.402811,1.387264L-2.402811,1.387264Z"); test.end(); }); -tape("symbol.type(wye) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.wye).context(p); +tape("symbol.type(symbolWye) generates a polygon with the specified size", function(test) { + var p = polygonContext(), s = shape.symbol().type(shape.symbolWye).context(p); s.size(1)(); test.inDelta(p.area(), 1); s.size(240)(); test.inDelta(p.area(), 240); test.end(); }); -tape("symbol.type(wye) generates the expected path", function(test) { - var s = shape.symbol().type(shape.wye).size(function(d) { return d; }); +tape("symbol.type(symbolWye) generates the expected path", function(test) { + var s = shape.symbol().type(shape.symbolWye).size(function(d) { return d; }); test.pathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); 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(); diff --git a/test/symbols-test.js b/test/symbols-test.js index 017dd29..16a7790 100644 --- a/test/symbols-test.js +++ b/test/symbols-test.js @@ -3,13 +3,13 @@ var tape = require("tape"), tape("symbols is the array of symbol types", function(test) { test.deepEqual(shape.symbols, [ - shape.circle, - shape.cross, - shape.diamond, - shape.square, - shape.star, - shape.triangle, - shape.wye + shape.symbolCircle, + shape.symbolCross, + shape.symbolDiamond, + shape.symbolSquare, + shape.symbolStar, + shape.symbolTriangle, + shape.symbolWye ]); test.end(); });