@mui/x-charts-vendor 7.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -0
- package/d3-color.d.ts +5 -0
- package/d3-color.js +7 -0
- package/d3-delaunay.d.ts +5 -0
- package/d3-delaunay.js +7 -0
- package/d3-interpolate.d.ts +5 -0
- package/d3-interpolate.js +7 -0
- package/d3-scale.d.ts +5 -0
- package/d3-scale.js +7 -0
- package/d3-shape.d.ts +5 -0
- package/d3-shape.js +7 -0
- package/d3-time.d.ts +5 -0
- package/d3-time.js +7 -0
- package/es/d3-array.js +6 -0
- package/es/d3-color.js +6 -0
- package/es/d3-delaunay.js +6 -0
- package/es/d3-format.js +6 -0
- package/es/d3-interpolate.js +6 -0
- package/es/d3-path.js +6 -0
- package/es/d3-scale.js +6 -0
- package/es/d3-shape.js +6 -0
- package/es/d3-time-format.js +6 -0
- package/es/d3-time.js +6 -0
- package/es/delaunator.js +6 -0
- package/es/internmap.js +6 -0
- package/es/robust-predicates.js +6 -0
- package/lib/d3-array.js +6 -0
- package/lib/d3-color.js +6 -0
- package/lib/d3-delaunay.js +6 -0
- package/lib/d3-format.js +6 -0
- package/lib/d3-interpolate.js +6 -0
- package/lib/d3-path.js +6 -0
- package/lib/d3-scale.js +6 -0
- package/lib/d3-shape.js +6 -0
- package/lib/d3-time-format.js +6 -0
- package/lib/d3-time.js +6 -0
- package/lib/delaunator.js +6 -0
- package/lib/internmap.js +6 -0
- package/lib/robust-predicates.js +6 -0
- package/lib-vendor/d3-array/LICENSE +13 -0
- package/lib-vendor/d3-array/dist/d3-array.js +1349 -0
- package/lib-vendor/d3-array/dist/d3-array.min.js +777 -0
- package/lib-vendor/d3-array/src/array.js +9 -0
- package/lib-vendor/d3-array/src/ascending.js +9 -0
- package/lib-vendor/d3-array/src/bin.js +126 -0
- package/lib-vendor/d3-array/src/bisect.js +15 -0
- package/lib-vendor/d3-array/src/bisector.js +59 -0
- package/lib-vendor/d3-array/src/blur.js +122 -0
- package/lib-vendor/d3-array/src/constant.js +9 -0
- package/lib-vendor/d3-array/src/count.js +24 -0
- package/lib-vendor/d3-array/src/cross.js +35 -0
- package/lib-vendor/d3-array/src/cumsum.js +11 -0
- package/lib-vendor/d3-array/src/descending.js +9 -0
- package/lib-vendor/d3-array/src/deviation.js +12 -0
- package/lib-vendor/d3-array/src/difference.js +16 -0
- package/lib-vendor/d3-array/src/disjoint.js +24 -0
- package/lib-vendor/d3-array/src/every.js +16 -0
- package/lib-vendor/d3-array/src/extent.js +35 -0
- package/lib-vendor/d3-array/src/filter.js +17 -0
- package/lib-vendor/d3-array/src/fsum.js +77 -0
- package/lib-vendor/d3-array/src/greatest.js +31 -0
- package/lib-vendor/d3-array/src/greatestIndex.js +23 -0
- package/lib-vendor/d3-array/src/group.js +67 -0
- package/lib-vendor/d3-array/src/groupSort.js +15 -0
- package/lib-vendor/d3-array/src/identity.js +9 -0
- package/lib-vendor/d3-array/src/index.js +539 -0
- package/lib-vendor/d3-array/src/intersection.js +23 -0
- package/lib-vendor/d3-array/src/least.js +31 -0
- package/lib-vendor/d3-array/src/leastIndex.js +23 -0
- package/lib-vendor/d3-array/src/map.js +11 -0
- package/lib-vendor/d3-array/src/max.js +24 -0
- package/lib-vendor/d3-array/src/maxIndex.js +26 -0
- package/lib-vendor/d3-array/src/mean.js +25 -0
- package/lib-vendor/d3-array/src/median.js +16 -0
- package/lib-vendor/d3-array/src/merge.js +14 -0
- package/lib-vendor/d3-array/src/min.js +24 -0
- package/lib-vendor/d3-array/src/minIndex.js +26 -0
- package/lib-vendor/d3-array/src/mode.js +33 -0
- package/lib-vendor/d3-array/src/nice.js +23 -0
- package/lib-vendor/d3-array/src/number.js +26 -0
- package/lib-vendor/d3-array/src/pairs.js +21 -0
- package/lib-vendor/d3-array/src/permute.js +9 -0
- package/lib-vendor/d3-array/src/quantile.js +55 -0
- package/lib-vendor/d3-array/src/quickselect.js +47 -0
- package/lib-vendor/d3-array/src/range.js +16 -0
- package/lib-vendor/d3-array/src/rank.js +30 -0
- package/lib-vendor/d3-array/src/reduce.js +28 -0
- package/lib-vendor/d3-array/src/reverse.js +10 -0
- package/lib-vendor/d3-array/src/scan.js +12 -0
- package/lib-vendor/d3-array/src/shuffle.js +20 -0
- package/lib-vendor/d3-array/src/some.js +16 -0
- package/lib-vendor/d3-array/src/sort.js +45 -0
- package/lib-vendor/d3-array/src/subset.js +11 -0
- package/lib-vendor/d3-array/src/sum.js +24 -0
- package/lib-vendor/d3-array/src/superset.js +28 -0
- package/lib-vendor/d3-array/src/threshold/freedmanDiaconis.js +14 -0
- package/lib-vendor/d3-array/src/threshold/scott.js +14 -0
- package/lib-vendor/d3-array/src/threshold/sturges.js +11 -0
- package/lib-vendor/d3-array/src/ticks.js +60 -0
- package/lib-vendor/d3-array/src/transpose.js +20 -0
- package/lib-vendor/d3-array/src/union.js +16 -0
- package/lib-vendor/d3-array/src/variance.js +31 -0
- package/lib-vendor/d3-array/src/zip.js +11 -0
- package/lib-vendor/d3-color/LICENSE +13 -0
- package/lib-vendor/d3-color/dist/d3-color.js +532 -0
- package/lib-vendor/d3-color/dist/d3-color.min.js +446 -0
- package/lib-vendor/d3-color/src/color.js +366 -0
- package/lib-vendor/d3-color/src/cubehelix.js +61 -0
- package/lib-vendor/d3-color/src/define.js +16 -0
- package/lib-vendor/d3-color/src/index.js +59 -0
- package/lib-vendor/d3-color/src/lab.js +117 -0
- package/lib-vendor/d3-color/src/math.js +8 -0
- package/lib-vendor/d3-delaunay/LICENSE +14 -0
- package/lib-vendor/d3-delaunay/dist/d3-delaunay.js +1398 -0
- package/lib-vendor/d3-delaunay/dist/d3-delaunay.min.js +853 -0
- package/lib-vendor/d3-delaunay/src/delaunay.js +282 -0
- package/lib-vendor/d3-delaunay/src/index.js +20 -0
- package/lib-vendor/d3-delaunay/src/path.js +43 -0
- package/lib-vendor/d3-delaunay/src/polygon.js +24 -0
- package/lib-vendor/d3-delaunay/src/voronoi.js +390 -0
- package/lib-vendor/d3-format/LICENSE +13 -0
- package/lib-vendor/d3-format/dist/d3-format.js +313 -0
- package/lib-vendor/d3-format/dist/d3-format.min.js +193 -0
- package/lib-vendor/d3-format/src/defaultLocale.js +23 -0
- package/lib-vendor/d3-format/src/exponent.js +10 -0
- package/lib-vendor/d3-format/src/formatDecimal.js +23 -0
- package/lib-vendor/d3-format/src/formatGroup.js +22 -0
- package/lib-vendor/d3-format/src/formatNumerals.js +13 -0
- package/lib-vendor/d3-format/src/formatPrefixAuto.js +18 -0
- package/lib-vendor/d3-format/src/formatRounded.js +14 -0
- package/lib-vendor/d3-format/src/formatSpecifier.js +42 -0
- package/lib-vendor/d3-format/src/formatTrim.js +25 -0
- package/lib-vendor/d3-format/src/formatTypes.js +25 -0
- package/lib-vendor/d3-format/src/identity.js +9 -0
- package/lib-vendor/d3-format/src/index.js +68 -0
- package/lib-vendor/d3-format/src/locale.js +152 -0
- package/lib-vendor/d3-format/src/precisionFixed.js +11 -0
- package/lib-vendor/d3-format/src/precisionPrefix.js +11 -0
- package/lib-vendor/d3-format/src/precisionRound.js +12 -0
- package/lib-vendor/d3-interpolate/LICENSE +13 -0
- package/lib-vendor/d3-interpolate/dist/d3-interpolate.js +543 -0
- package/lib-vendor/d3-interpolate/dist/d3-interpolate.min.js +362 -0
- package/lib-vendor/d3-interpolate/src/array.js +28 -0
- package/lib-vendor/d3-interpolate/src/basis.js +23 -0
- package/lib-vendor/d3-interpolate/src/basisClosed.js +18 -0
- package/lib-vendor/d3-interpolate/src/color.js +33 -0
- package/lib-vendor/d3-interpolate/src/constant.js +8 -0
- package/lib-vendor/d3-interpolate/src/cubehelix.js +32 -0
- package/lib-vendor/d3-interpolate/src/date.js +12 -0
- package/lib-vendor/d3-interpolate/src/discrete.js +12 -0
- package/lib-vendor/d3-interpolate/src/hcl.js +27 -0
- package/lib-vendor/d3-interpolate/src/hsl.js +27 -0
- package/lib-vendor/d3-interpolate/src/hue.js +14 -0
- package/lib-vendor/d3-interpolate/src/index.js +191 -0
- package/lib-vendor/d3-interpolate/src/lab.js +22 -0
- package/lib-vendor/d3-interpolate/src/number.js +11 -0
- package/lib-vendor/d3-interpolate/src/numberArray.js +20 -0
- package/lib-vendor/d3-interpolate/src/object.js +26 -0
- package/lib-vendor/d3-interpolate/src/piecewise.js +20 -0
- package/lib-vendor/d3-interpolate/src/quantize.js +11 -0
- package/lib-vendor/d3-interpolate/src/rgb.js +59 -0
- package/lib-vendor/d3-interpolate/src/round.js +11 -0
- package/lib-vendor/d3-interpolate/src/string.js +75 -0
- package/lib-vendor/d3-interpolate/src/transform/decompose.js +31 -0
- package/lib-vendor/d3-interpolate/src/transform/index.js +83 -0
- package/lib-vendor/d3-interpolate/src/transform/parse.js +25 -0
- package/lib-vendor/d3-interpolate/src/value.js +23 -0
- package/lib-vendor/d3-interpolate/src/zoom.js +66 -0
- package/lib-vendor/d3-path/LICENSE +13 -0
- package/lib-vendor/d3-path/dist/d3-path.js +161 -0
- package/lib-vendor/d3-path/dist/d3-path.min.js +92 -0
- package/lib-vendor/d3-path/src/index.js +24 -0
- package/lib-vendor/d3-path/src/path.js +158 -0
- package/lib-vendor/d3-scale/LICENSE +13 -0
- package/lib-vendor/d3-scale/dist/d3-scale.js +944 -0
- package/lib-vendor/d3-scale/dist/d3-scale.min.js +690 -0
- package/lib-vendor/d3-scale/src/band.js +87 -0
- package/lib-vendor/d3-scale/src/colors.js +11 -0
- package/lib-vendor/d3-scale/src/constant.js +11 -0
- package/lib-vendor/d3-scale/src/continuous.js +116 -0
- package/lib-vendor/d3-scale/src/diverging.js +91 -0
- package/lib-vendor/d3-scale/src/identity.js +27 -0
- package/lib-vendor/d3-scale/src/index.js +193 -0
- package/lib-vendor/d3-scale/src/init.js +38 -0
- package/lib-vendor/d3-scale/src/linear.js +67 -0
- package/lib-vendor/d3-scale/src/log.js +123 -0
- package/lib-vendor/d3-scale/src/nice.js +21 -0
- package/lib-vendor/d3-scale/src/number.js +9 -0
- package/lib-vendor/d3-scale/src/ordinal.js +44 -0
- package/lib-vendor/d3-scale/src/pow.js +44 -0
- package/lib-vendor/d3-scale/src/quantile.js +48 -0
- package/lib-vendor/d3-scale/src/quantize.js +46 -0
- package/lib-vendor/d3-scale/src/radial.js +53 -0
- package/lib-vendor/d3-scale/src/sequential.js +90 -0
- package/lib-vendor/d3-scale/src/sequentialQuantile.js +38 -0
- package/lib-vendor/d3-scale/src/symlog.js +35 -0
- package/lib-vendor/d3-scale/src/threshold.js +34 -0
- package/lib-vendor/d3-scale/src/tickFormat.js +37 -0
- package/lib-vendor/d3-scale/src/time.js +62 -0
- package/lib-vendor/d3-scale/src/utcTime.js +13 -0
- package/lib-vendor/d3-shape/LICENSE +13 -0
- package/lib-vendor/d3-shape/dist/d3-shape.js +2004 -0
- package/lib-vendor/d3-shape/dist/d3-shape.min.js +1389 -0
- package/lib-vendor/d3-shape/src/arc.js +250 -0
- package/lib-vendor/d3-shape/src/area.js +98 -0
- package/lib-vendor/d3-shape/src/areaRadial.js +42 -0
- package/lib-vendor/d3-shape/src/array.js +12 -0
- package/lib-vendor/d3-shape/src/constant.js +11 -0
- package/lib-vendor/d3-shape/src/curve/basis.js +62 -0
- package/lib-vendor/d3-shape/src/curve/basisClosed.js +70 -0
- package/lib-vendor/d3-shape/src/curve/basisOpen.js +54 -0
- package/lib-vendor/d3-shape/src/curve/bump.js +81 -0
- package/lib-vendor/d3-shape/src/curve/bundle.js +50 -0
- package/lib-vendor/d3-shape/src/curve/cardinal.js +69 -0
- package/lib-vendor/d3-shape/src/curve/cardinalClosed.js +76 -0
- package/lib-vendor/d3-shape/src/curve/cardinalOpen.js +60 -0
- package/lib-vendor/d3-shape/src/curve/catmullRom.js +92 -0
- package/lib-vendor/d3-shape/src/curve/catmullRomClosed.js +83 -0
- package/lib-vendor/d3-shape/src/curve/catmullRomOpen.js +67 -0
- package/lib-vendor/d3-shape/src/curve/linear.js +42 -0
- package/lib-vendor/d3-shape/src/curve/linearClosed.js +28 -0
- package/lib-vendor/d3-shape/src/curve/monotone.js +121 -0
- package/lib-vendor/d3-shape/src/curve/natural.js +67 -0
- package/lib-vendor/d3-shape/src/curve/radial.js +37 -0
- package/lib-vendor/d3-shape/src/curve/step.js +63 -0
- package/lib-vendor/d3-shape/src/descending.js +9 -0
- package/lib-vendor/d3-shape/src/identity.js +9 -0
- package/lib-vendor/d3-shape/src/index.js +436 -0
- package/lib-vendor/d3-shape/src/line.js +52 -0
- package/lib-vendor/d3-shape/src/lineRadial.js +24 -0
- package/lib-vendor/d3-shape/src/link.js +70 -0
- package/lib-vendor/d3-shape/src/math.js +26 -0
- package/lib-vendor/d3-shape/src/noop.js +7 -0
- package/lib-vendor/d3-shape/src/offset/diverging.js +20 -0
- package/lib-vendor/d3-shape/src/offset/expand.js +16 -0
- package/lib-vendor/d3-shape/src/offset/none.js +15 -0
- package/lib-vendor/d3-shape/src/offset/silhouette.js +16 -0
- package/lib-vendor/d3-shape/src/offset/wiggle.js +30 -0
- package/lib-vendor/d3-shape/src/order/appearance.js +23 -0
- package/lib-vendor/d3-shape/src/order/ascending.js +23 -0
- package/lib-vendor/d3-shape/src/order/descending.js +11 -0
- package/lib-vendor/d3-shape/src/order/insideOut.js +31 -0
- package/lib-vendor/d3-shape/src/order/none.js +12 -0
- package/lib-vendor/d3-shape/src/order/reverse.js +11 -0
- package/lib-vendor/d3-shape/src/path.js +22 -0
- package/lib-vendor/d3-shape/src/pie.js +79 -0
- package/lib-vendor/d3-shape/src/point.js +13 -0
- package/lib-vendor/d3-shape/src/pointRadial.js +9 -0
- package/lib-vendor/d3-shape/src/stack.js +55 -0
- package/lib-vendor/d3-shape/src/symbol/asterisk.js +21 -0
- package/lib-vendor/d3-shape/src/symbol/circle.js +14 -0
- package/lib-vendor/d3-shape/src/symbol/cross.js +25 -0
- package/lib-vendor/d3-shape/src/symbol/diamond.js +20 -0
- package/lib-vendor/d3-shape/src/symbol/diamond2.js +17 -0
- package/lib-vendor/d3-shape/src/symbol/plus.js +16 -0
- package/lib-vendor/d3-shape/src/symbol/square.js +14 -0
- package/lib-vendor/d3-shape/src/symbol/square2.js +17 -0
- package/lib-vendor/d3-shape/src/symbol/star.js +28 -0
- package/lib-vendor/d3-shape/src/symbol/times.js +16 -0
- package/lib-vendor/d3-shape/src/symbol/triangle.js +17 -0
- package/lib-vendor/d3-shape/src/symbol/triangle2.js +19 -0
- package/lib-vendor/d3-shape/src/symbol/wye.js +32 -0
- package/lib-vendor/d3-shape/src/symbol.js +50 -0
- package/lib-vendor/d3-time/LICENSE +13 -0
- package/lib-vendor/d3-time/dist/d3-time.js +367 -0
- package/lib-vendor/d3-time/dist/d3-time.min.js +190 -0
- package/lib-vendor/d3-time/src/day.js +30 -0
- package/lib-vendor/d3-time/src/duration.js +13 -0
- package/lib-vendor/d3-time/src/hour.js +28 -0
- package/lib-vendor/d3-time/src/index.js +417 -0
- package/lib-vendor/d3-time/src/interval.js +61 -0
- package/lib-vendor/d3-time/src/millisecond.js +29 -0
- package/lib-vendor/d3-time/src/minute.js +28 -0
- package/lib-vendor/d3-time/src/month.js +29 -0
- package/lib-vendor/d3-time/src/second.js +18 -0
- package/lib-vendor/d3-time/src/ticks.js +41 -0
- package/lib-vendor/d3-time/src/week.js +56 -0
- package/lib-vendor/d3-time/src/year.js +51 -0
- package/lib-vendor/d3-time-format/LICENSE +13 -0
- package/lib-vendor/d3-time-format/dist/d3-time-format.js +648 -0
- package/lib-vendor/d3-time-format/dist/d3-time-format.min.js +528 -0
- package/lib-vendor/d3-time-format/src/defaultLocale.js +32 -0
- package/lib-vendor/d3-time-format/src/index.js +60 -0
- package/lib-vendor/d3-time-format/src/isoFormat.js +13 -0
- package/lib-vendor/d3-time-format/src/isoParse.js +14 -0
- package/lib-vendor/d3-time-format/src/locale.js +606 -0
- package/lib-vendor/delaunator/LICENSE +15 -0
- package/lib-vendor/delaunator/delaunator.js +688 -0
- package/lib-vendor/delaunator/delaunator.min.js +316 -0
- package/lib-vendor/delaunator/index.js +440 -0
- package/lib-vendor/internmap/LICENSE +13 -0
- package/lib-vendor/internmap/dist/internmap.js +93 -0
- package/lib-vendor/internmap/dist/internmap.min.js +81 -0
- package/lib-vendor/internmap/src/index.js +87 -0
- package/lib-vendor/robust-predicates/LICENSE +24 -0
- package/lib-vendor/robust-predicates/esm/incircle.js +667 -0
- package/lib-vendor/robust-predicates/esm/insphere.js +693 -0
- package/lib-vendor/robust-predicates/esm/orient2d.js +174 -0
- package/lib-vendor/robust-predicates/esm/orient3d.js +422 -0
- package/lib-vendor/robust-predicates/esm/util.js +147 -0
- package/lib-vendor/robust-predicates/index.js +57 -0
- package/lib-vendor/robust-predicates/umd/incircle.js +798 -0
- package/lib-vendor/robust-predicates/umd/incircle.min.js +170 -0
- package/lib-vendor/robust-predicates/umd/insphere.js +828 -0
- package/lib-vendor/robust-predicates/umd/insphere.min.js +223 -0
- package/lib-vendor/robust-predicates/umd/orient2d.js +260 -0
- package/lib-vendor/robust-predicates/umd/orient2d.min.js +69 -0
- package/lib-vendor/robust-predicates/umd/orient3d.js +550 -0
- package/lib-vendor/robust-predicates/umd/orient3d.min.js +133 -0
- package/lib-vendor/robust-predicates/umd/predicates.js +2073 -0
- package/lib-vendor/robust-predicates/umd/predicates.min.js +468 -0
- package/package.json +63 -0
|
@@ -0,0 +1,2004 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// https://d3js.org/d3-shape/ v3.2.0 Copyright 2010-2022 Mike Bostock
|
|
4
|
+
(function (global, factory) {
|
|
5
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require("../../../lib-vendor/d3-path/src/index.js")) : typeof define === 'function' && define.amd ? define(['exports', 'd3-path'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}, global.d3));
|
|
6
|
+
})(this, function (exports, d3Path) {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
function constant(x) {
|
|
10
|
+
return function constant() {
|
|
11
|
+
return x;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const abs = Math.abs;
|
|
15
|
+
const atan2 = Math.atan2;
|
|
16
|
+
const cos = Math.cos;
|
|
17
|
+
const max = Math.max;
|
|
18
|
+
const min = Math.min;
|
|
19
|
+
const sin = Math.sin;
|
|
20
|
+
const sqrt = Math.sqrt;
|
|
21
|
+
const epsilon = 1e-12;
|
|
22
|
+
const pi = Math.PI;
|
|
23
|
+
const halfPi = pi / 2;
|
|
24
|
+
const tau = 2 * pi;
|
|
25
|
+
function acos(x) {
|
|
26
|
+
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
|
|
27
|
+
}
|
|
28
|
+
function asin(x) {
|
|
29
|
+
return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);
|
|
30
|
+
}
|
|
31
|
+
function withPath(shape) {
|
|
32
|
+
let digits = 3;
|
|
33
|
+
shape.digits = function (_) {
|
|
34
|
+
if (!arguments.length) return digits;
|
|
35
|
+
if (_ == null) {
|
|
36
|
+
digits = null;
|
|
37
|
+
} else {
|
|
38
|
+
const d = Math.floor(_);
|
|
39
|
+
if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`);
|
|
40
|
+
digits = d;
|
|
41
|
+
}
|
|
42
|
+
return shape;
|
|
43
|
+
};
|
|
44
|
+
return () => new d3Path.Path(digits);
|
|
45
|
+
}
|
|
46
|
+
function arcInnerRadius(d) {
|
|
47
|
+
return d.innerRadius;
|
|
48
|
+
}
|
|
49
|
+
function arcOuterRadius(d) {
|
|
50
|
+
return d.outerRadius;
|
|
51
|
+
}
|
|
52
|
+
function arcStartAngle(d) {
|
|
53
|
+
return d.startAngle;
|
|
54
|
+
}
|
|
55
|
+
function arcEndAngle(d) {
|
|
56
|
+
return d.endAngle;
|
|
57
|
+
}
|
|
58
|
+
function arcPadAngle(d) {
|
|
59
|
+
return d && d.padAngle; // Note: optional!
|
|
60
|
+
}
|
|
61
|
+
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
|
|
62
|
+
var x10 = x1 - x0,
|
|
63
|
+
y10 = y1 - y0,
|
|
64
|
+
x32 = x3 - x2,
|
|
65
|
+
y32 = y3 - y2,
|
|
66
|
+
t = y32 * x10 - x32 * y10;
|
|
67
|
+
if (t * t < epsilon) return;
|
|
68
|
+
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
69
|
+
return [x0 + t * x10, y0 + t * y10];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Compute perpendicular offset line of length rc.
|
|
73
|
+
// http://mathworld.wolfram.com/Circle-LineIntersection.html
|
|
74
|
+
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
|
|
75
|
+
var x01 = x0 - x1,
|
|
76
|
+
y01 = y0 - y1,
|
|
77
|
+
lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01),
|
|
78
|
+
ox = lo * y01,
|
|
79
|
+
oy = -lo * x01,
|
|
80
|
+
x11 = x0 + ox,
|
|
81
|
+
y11 = y0 + oy,
|
|
82
|
+
x10 = x1 + ox,
|
|
83
|
+
y10 = y1 + oy,
|
|
84
|
+
x00 = (x11 + x10) / 2,
|
|
85
|
+
y00 = (y11 + y10) / 2,
|
|
86
|
+
dx = x10 - x11,
|
|
87
|
+
dy = y10 - y11,
|
|
88
|
+
d2 = dx * dx + dy * dy,
|
|
89
|
+
r = r1 - rc,
|
|
90
|
+
D = x11 * y10 - x10 * y11,
|
|
91
|
+
d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)),
|
|
92
|
+
cx0 = (D * dy - dx * d) / d2,
|
|
93
|
+
cy0 = (-D * dx - dy * d) / d2,
|
|
94
|
+
cx1 = (D * dy + dx * d) / d2,
|
|
95
|
+
cy1 = (-D * dx + dy * d) / d2,
|
|
96
|
+
dx0 = cx0 - x00,
|
|
97
|
+
dy0 = cy0 - y00,
|
|
98
|
+
dx1 = cx1 - x00,
|
|
99
|
+
dy1 = cy1 - y00;
|
|
100
|
+
|
|
101
|
+
// Pick the closer of the two intersection points.
|
|
102
|
+
// TODO Is there a faster way to determine which intersection to use?
|
|
103
|
+
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
|
|
104
|
+
return {
|
|
105
|
+
cx: cx0,
|
|
106
|
+
cy: cy0,
|
|
107
|
+
x01: -ox,
|
|
108
|
+
y01: -oy,
|
|
109
|
+
x11: cx0 * (r1 / r - 1),
|
|
110
|
+
y11: cy0 * (r1 / r - 1)
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function arc() {
|
|
114
|
+
var innerRadius = arcInnerRadius,
|
|
115
|
+
outerRadius = arcOuterRadius,
|
|
116
|
+
cornerRadius = constant(0),
|
|
117
|
+
padRadius = null,
|
|
118
|
+
startAngle = arcStartAngle,
|
|
119
|
+
endAngle = arcEndAngle,
|
|
120
|
+
padAngle = arcPadAngle,
|
|
121
|
+
context = null,
|
|
122
|
+
path = withPath(arc);
|
|
123
|
+
function arc() {
|
|
124
|
+
var buffer,
|
|
125
|
+
r,
|
|
126
|
+
r0 = +innerRadius.apply(this, arguments),
|
|
127
|
+
r1 = +outerRadius.apply(this, arguments),
|
|
128
|
+
a0 = startAngle.apply(this, arguments) - halfPi,
|
|
129
|
+
a1 = endAngle.apply(this, arguments) - halfPi,
|
|
130
|
+
da = abs(a1 - a0),
|
|
131
|
+
cw = a1 > a0;
|
|
132
|
+
if (!context) context = buffer = path();
|
|
133
|
+
|
|
134
|
+
// Ensure that the outer radius is always larger than the inner radius.
|
|
135
|
+
if (r1 < r0) r = r1, r1 = r0, r0 = r;
|
|
136
|
+
|
|
137
|
+
// Is it a point?
|
|
138
|
+
if (!(r1 > epsilon)) context.moveTo(0, 0);
|
|
139
|
+
|
|
140
|
+
// Or is it a circle or annulus?
|
|
141
|
+
else if (da > tau - epsilon) {
|
|
142
|
+
context.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
143
|
+
context.arc(0, 0, r1, a0, a1, !cw);
|
|
144
|
+
if (r0 > epsilon) {
|
|
145
|
+
context.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
146
|
+
context.arc(0, 0, r0, a1, a0, cw);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Or is it a circular or annular sector?
|
|
151
|
+
else {
|
|
152
|
+
var a01 = a0,
|
|
153
|
+
a11 = a1,
|
|
154
|
+
a00 = a0,
|
|
155
|
+
a10 = a1,
|
|
156
|
+
da0 = da,
|
|
157
|
+
da1 = da,
|
|
158
|
+
ap = padAngle.apply(this, arguments) / 2,
|
|
159
|
+
rp = ap > epsilon && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)),
|
|
160
|
+
rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)),
|
|
161
|
+
rc0 = rc,
|
|
162
|
+
rc1 = rc,
|
|
163
|
+
t0,
|
|
164
|
+
t1;
|
|
165
|
+
|
|
166
|
+
// Apply padding? Note that since r1 ≥ r0, da1 ≥ da0.
|
|
167
|
+
if (rp > epsilon) {
|
|
168
|
+
var p0 = asin(rp / r0 * sin(ap)),
|
|
169
|
+
p1 = asin(rp / r1 * sin(ap));
|
|
170
|
+
if ((da0 -= p0 * 2) > epsilon) p0 *= cw ? 1 : -1, a00 += p0, a10 -= p0;else da0 = 0, a00 = a10 = (a0 + a1) / 2;
|
|
171
|
+
if ((da1 -= p1 * 2) > epsilon) p1 *= cw ? 1 : -1, a01 += p1, a11 -= p1;else da1 = 0, a01 = a11 = (a0 + a1) / 2;
|
|
172
|
+
}
|
|
173
|
+
var x01 = r1 * cos(a01),
|
|
174
|
+
y01 = r1 * sin(a01),
|
|
175
|
+
x10 = r0 * cos(a10),
|
|
176
|
+
y10 = r0 * sin(a10);
|
|
177
|
+
|
|
178
|
+
// Apply rounded corners?
|
|
179
|
+
if (rc > epsilon) {
|
|
180
|
+
var x11 = r1 * cos(a11),
|
|
181
|
+
y11 = r1 * sin(a11),
|
|
182
|
+
x00 = r0 * cos(a00),
|
|
183
|
+
y00 = r0 * sin(a00),
|
|
184
|
+
oc;
|
|
185
|
+
|
|
186
|
+
// Restrict the corner radius according to the sector angle. If this
|
|
187
|
+
// intersection fails, it’s probably because the arc is too small, so
|
|
188
|
+
// disable the corner radius entirely.
|
|
189
|
+
if (da < pi) {
|
|
190
|
+
if (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)) {
|
|
191
|
+
var ax = x01 - oc[0],
|
|
192
|
+
ay = y01 - oc[1],
|
|
193
|
+
bx = x11 - oc[0],
|
|
194
|
+
by = y11 - oc[1],
|
|
195
|
+
kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2),
|
|
196
|
+
lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
197
|
+
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
198
|
+
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
199
|
+
} else {
|
|
200
|
+
rc0 = rc1 = 0;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Is the sector collapsed to a line?
|
|
206
|
+
if (!(da1 > epsilon)) context.moveTo(x01, y01);
|
|
207
|
+
|
|
208
|
+
// Does the sector’s outer ring have rounded corners?
|
|
209
|
+
else if (rc1 > epsilon) {
|
|
210
|
+
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
211
|
+
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
212
|
+
context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
213
|
+
|
|
214
|
+
// Have the corners merged?
|
|
215
|
+
if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
216
|
+
|
|
217
|
+
// Otherwise, draw the two corners and the ring.
|
|
218
|
+
else {
|
|
219
|
+
context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
220
|
+
context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
|
|
221
|
+
context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Or is the outer ring just a circular arc?
|
|
226
|
+
else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
|
|
227
|
+
|
|
228
|
+
// Is there no inner ring, and it’s a circular sector?
|
|
229
|
+
// Or perhaps it’s an annular sector collapsed due to padding?
|
|
230
|
+
if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10);
|
|
231
|
+
|
|
232
|
+
// Does the sector’s inner ring (or point) have rounded corners?
|
|
233
|
+
else if (rc0 > epsilon) {
|
|
234
|
+
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
235
|
+
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
236
|
+
context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
237
|
+
|
|
238
|
+
// Have the corners merged?
|
|
239
|
+
if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
240
|
+
|
|
241
|
+
// Otherwise, draw the two corners and the ring.
|
|
242
|
+
else {
|
|
243
|
+
context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
244
|
+
context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
|
|
245
|
+
context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Or is the inner ring just a circular arc?
|
|
250
|
+
else context.arc(0, 0, r0, a10, a00, cw);
|
|
251
|
+
}
|
|
252
|
+
context.closePath();
|
|
253
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
254
|
+
}
|
|
255
|
+
arc.centroid = function () {
|
|
256
|
+
var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2,
|
|
257
|
+
a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2;
|
|
258
|
+
return [cos(a) * r, sin(a) * r];
|
|
259
|
+
};
|
|
260
|
+
arc.innerRadius = function (_) {
|
|
261
|
+
return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant(+_), arc) : innerRadius;
|
|
262
|
+
};
|
|
263
|
+
arc.outerRadius = function (_) {
|
|
264
|
+
return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant(+_), arc) : outerRadius;
|
|
265
|
+
};
|
|
266
|
+
arc.cornerRadius = function (_) {
|
|
267
|
+
return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant(+_), arc) : cornerRadius;
|
|
268
|
+
};
|
|
269
|
+
arc.padRadius = function (_) {
|
|
270
|
+
return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant(+_), arc) : padRadius;
|
|
271
|
+
};
|
|
272
|
+
arc.startAngle = function (_) {
|
|
273
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), arc) : startAngle;
|
|
274
|
+
};
|
|
275
|
+
arc.endAngle = function (_) {
|
|
276
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), arc) : endAngle;
|
|
277
|
+
};
|
|
278
|
+
arc.padAngle = function (_) {
|
|
279
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), arc) : padAngle;
|
|
280
|
+
};
|
|
281
|
+
arc.context = function (_) {
|
|
282
|
+
return arguments.length ? (context = _ == null ? null : _, arc) : context;
|
|
283
|
+
};
|
|
284
|
+
return arc;
|
|
285
|
+
}
|
|
286
|
+
var slice = Array.prototype.slice;
|
|
287
|
+
function array(x) {
|
|
288
|
+
return typeof x === "object" && "length" in x ? x // Array, TypedArray, NodeList, array-like
|
|
289
|
+
: Array.from(x); // Map, Set, iterable, string, or anything else
|
|
290
|
+
}
|
|
291
|
+
function Linear(context) {
|
|
292
|
+
this._context = context;
|
|
293
|
+
}
|
|
294
|
+
Linear.prototype = {
|
|
295
|
+
areaStart: function () {
|
|
296
|
+
this._line = 0;
|
|
297
|
+
},
|
|
298
|
+
areaEnd: function () {
|
|
299
|
+
this._line = NaN;
|
|
300
|
+
},
|
|
301
|
+
lineStart: function () {
|
|
302
|
+
this._point = 0;
|
|
303
|
+
},
|
|
304
|
+
lineEnd: function () {
|
|
305
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
306
|
+
this._line = 1 - this._line;
|
|
307
|
+
},
|
|
308
|
+
point: function (x, y) {
|
|
309
|
+
x = +x, y = +y;
|
|
310
|
+
switch (this._point) {
|
|
311
|
+
case 0:
|
|
312
|
+
this._point = 1;
|
|
313
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
314
|
+
break;
|
|
315
|
+
case 1:
|
|
316
|
+
this._point = 2;
|
|
317
|
+
// falls through
|
|
318
|
+
default:
|
|
319
|
+
this._context.lineTo(x, y);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
function curveLinear(context) {
|
|
325
|
+
return new Linear(context);
|
|
326
|
+
}
|
|
327
|
+
function x(p) {
|
|
328
|
+
return p[0];
|
|
329
|
+
}
|
|
330
|
+
function y(p) {
|
|
331
|
+
return p[1];
|
|
332
|
+
}
|
|
333
|
+
function line(x$1, y$1) {
|
|
334
|
+
var defined = constant(true),
|
|
335
|
+
context = null,
|
|
336
|
+
curve = curveLinear,
|
|
337
|
+
output = null,
|
|
338
|
+
path = withPath(line);
|
|
339
|
+
x$1 = typeof x$1 === "function" ? x$1 : x$1 === undefined ? x : constant(x$1);
|
|
340
|
+
y$1 = typeof y$1 === "function" ? y$1 : y$1 === undefined ? y : constant(y$1);
|
|
341
|
+
function line(data) {
|
|
342
|
+
var i,
|
|
343
|
+
n = (data = array(data)).length,
|
|
344
|
+
d,
|
|
345
|
+
defined0 = false,
|
|
346
|
+
buffer;
|
|
347
|
+
if (context == null) output = curve(buffer = path());
|
|
348
|
+
for (i = 0; i <= n; ++i) {
|
|
349
|
+
if (!(i < n && defined(d = data[i], i, data)) === defined0) {
|
|
350
|
+
if (defined0 = !defined0) output.lineStart();else output.lineEnd();
|
|
351
|
+
}
|
|
352
|
+
if (defined0) output.point(+x$1(d, i, data), +y$1(d, i, data));
|
|
353
|
+
}
|
|
354
|
+
if (buffer) return output = null, buffer + "" || null;
|
|
355
|
+
}
|
|
356
|
+
line.x = function (_) {
|
|
357
|
+
return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), line) : x$1;
|
|
358
|
+
};
|
|
359
|
+
line.y = function (_) {
|
|
360
|
+
return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), line) : y$1;
|
|
361
|
+
};
|
|
362
|
+
line.defined = function (_) {
|
|
363
|
+
return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), line) : defined;
|
|
364
|
+
};
|
|
365
|
+
line.curve = function (_) {
|
|
366
|
+
return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve;
|
|
367
|
+
};
|
|
368
|
+
line.context = function (_) {
|
|
369
|
+
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context;
|
|
370
|
+
};
|
|
371
|
+
return line;
|
|
372
|
+
}
|
|
373
|
+
function area(x0, y0, y1) {
|
|
374
|
+
var x1 = null,
|
|
375
|
+
defined = constant(true),
|
|
376
|
+
context = null,
|
|
377
|
+
curve = curveLinear,
|
|
378
|
+
output = null,
|
|
379
|
+
path = withPath(area);
|
|
380
|
+
x0 = typeof x0 === "function" ? x0 : x0 === undefined ? x : constant(+x0);
|
|
381
|
+
y0 = typeof y0 === "function" ? y0 : y0 === undefined ? constant(0) : constant(+y0);
|
|
382
|
+
y1 = typeof y1 === "function" ? y1 : y1 === undefined ? y : constant(+y1);
|
|
383
|
+
function area(data) {
|
|
384
|
+
var i,
|
|
385
|
+
j,
|
|
386
|
+
k,
|
|
387
|
+
n = (data = array(data)).length,
|
|
388
|
+
d,
|
|
389
|
+
defined0 = false,
|
|
390
|
+
buffer,
|
|
391
|
+
x0z = new Array(n),
|
|
392
|
+
y0z = new Array(n);
|
|
393
|
+
if (context == null) output = curve(buffer = path());
|
|
394
|
+
for (i = 0; i <= n; ++i) {
|
|
395
|
+
if (!(i < n && defined(d = data[i], i, data)) === defined0) {
|
|
396
|
+
if (defined0 = !defined0) {
|
|
397
|
+
j = i;
|
|
398
|
+
output.areaStart();
|
|
399
|
+
output.lineStart();
|
|
400
|
+
} else {
|
|
401
|
+
output.lineEnd();
|
|
402
|
+
output.lineStart();
|
|
403
|
+
for (k = i - 1; k >= j; --k) {
|
|
404
|
+
output.point(x0z[k], y0z[k]);
|
|
405
|
+
}
|
|
406
|
+
output.lineEnd();
|
|
407
|
+
output.areaEnd();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (defined0) {
|
|
411
|
+
x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data);
|
|
412
|
+
output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (buffer) return output = null, buffer + "" || null;
|
|
416
|
+
}
|
|
417
|
+
function arealine() {
|
|
418
|
+
return line().defined(defined).curve(curve).context(context);
|
|
419
|
+
}
|
|
420
|
+
area.x = function (_) {
|
|
421
|
+
return arguments.length ? (x0 = typeof _ === "function" ? _ : constant(+_), x1 = null, area) : x0;
|
|
422
|
+
};
|
|
423
|
+
area.x0 = function (_) {
|
|
424
|
+
return arguments.length ? (x0 = typeof _ === "function" ? _ : constant(+_), area) : x0;
|
|
425
|
+
};
|
|
426
|
+
area.x1 = function (_) {
|
|
427
|
+
return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant(+_), area) : x1;
|
|
428
|
+
};
|
|
429
|
+
area.y = function (_) {
|
|
430
|
+
return arguments.length ? (y0 = typeof _ === "function" ? _ : constant(+_), y1 = null, area) : y0;
|
|
431
|
+
};
|
|
432
|
+
area.y0 = function (_) {
|
|
433
|
+
return arguments.length ? (y0 = typeof _ === "function" ? _ : constant(+_), area) : y0;
|
|
434
|
+
};
|
|
435
|
+
area.y1 = function (_) {
|
|
436
|
+
return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant(+_), area) : y1;
|
|
437
|
+
};
|
|
438
|
+
area.lineX0 = area.lineY0 = function () {
|
|
439
|
+
return arealine().x(x0).y(y0);
|
|
440
|
+
};
|
|
441
|
+
area.lineY1 = function () {
|
|
442
|
+
return arealine().x(x0).y(y1);
|
|
443
|
+
};
|
|
444
|
+
area.lineX1 = function () {
|
|
445
|
+
return arealine().x(x1).y(y0);
|
|
446
|
+
};
|
|
447
|
+
area.defined = function (_) {
|
|
448
|
+
return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), area) : defined;
|
|
449
|
+
};
|
|
450
|
+
area.curve = function (_) {
|
|
451
|
+
return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve;
|
|
452
|
+
};
|
|
453
|
+
area.context = function (_) {
|
|
454
|
+
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context;
|
|
455
|
+
};
|
|
456
|
+
return area;
|
|
457
|
+
}
|
|
458
|
+
function descending$1(a, b) {
|
|
459
|
+
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
|
460
|
+
}
|
|
461
|
+
function identity(d) {
|
|
462
|
+
return d;
|
|
463
|
+
}
|
|
464
|
+
function pie() {
|
|
465
|
+
var value = identity,
|
|
466
|
+
sortValues = descending$1,
|
|
467
|
+
sort = null,
|
|
468
|
+
startAngle = constant(0),
|
|
469
|
+
endAngle = constant(tau),
|
|
470
|
+
padAngle = constant(0);
|
|
471
|
+
function pie(data) {
|
|
472
|
+
var i,
|
|
473
|
+
n = (data = array(data)).length,
|
|
474
|
+
j,
|
|
475
|
+
k,
|
|
476
|
+
sum = 0,
|
|
477
|
+
index = new Array(n),
|
|
478
|
+
arcs = new Array(n),
|
|
479
|
+
a0 = +startAngle.apply(this, arguments),
|
|
480
|
+
da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)),
|
|
481
|
+
a1,
|
|
482
|
+
p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)),
|
|
483
|
+
pa = p * (da < 0 ? -1 : 1),
|
|
484
|
+
v;
|
|
485
|
+
for (i = 0; i < n; ++i) {
|
|
486
|
+
if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {
|
|
487
|
+
sum += v;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// Optionally sort the arcs by previously-computed values or by data.
|
|
492
|
+
if (sortValues != null) index.sort(function (i, j) {
|
|
493
|
+
return sortValues(arcs[i], arcs[j]);
|
|
494
|
+
});else if (sort != null) index.sort(function (i, j) {
|
|
495
|
+
return sort(data[i], data[j]);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
// Compute the arcs! They are stored in the original data's order.
|
|
499
|
+
for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {
|
|
500
|
+
j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
|
|
501
|
+
data: data[j],
|
|
502
|
+
index: i,
|
|
503
|
+
value: v,
|
|
504
|
+
startAngle: a0,
|
|
505
|
+
endAngle: a1,
|
|
506
|
+
padAngle: p
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
return arcs;
|
|
510
|
+
}
|
|
511
|
+
pie.value = function (_) {
|
|
512
|
+
return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), pie) : value;
|
|
513
|
+
};
|
|
514
|
+
pie.sortValues = function (_) {
|
|
515
|
+
return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
|
|
516
|
+
};
|
|
517
|
+
pie.sort = function (_) {
|
|
518
|
+
return arguments.length ? (sort = _, sortValues = null, pie) : sort;
|
|
519
|
+
};
|
|
520
|
+
pie.startAngle = function (_) {
|
|
521
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), pie) : startAngle;
|
|
522
|
+
};
|
|
523
|
+
pie.endAngle = function (_) {
|
|
524
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie) : endAngle;
|
|
525
|
+
};
|
|
526
|
+
pie.padAngle = function (_) {
|
|
527
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie) : padAngle;
|
|
528
|
+
};
|
|
529
|
+
return pie;
|
|
530
|
+
}
|
|
531
|
+
var curveRadialLinear = curveRadial(curveLinear);
|
|
532
|
+
function Radial(curve) {
|
|
533
|
+
this._curve = curve;
|
|
534
|
+
}
|
|
535
|
+
Radial.prototype = {
|
|
536
|
+
areaStart: function () {
|
|
537
|
+
this._curve.areaStart();
|
|
538
|
+
},
|
|
539
|
+
areaEnd: function () {
|
|
540
|
+
this._curve.areaEnd();
|
|
541
|
+
},
|
|
542
|
+
lineStart: function () {
|
|
543
|
+
this._curve.lineStart();
|
|
544
|
+
},
|
|
545
|
+
lineEnd: function () {
|
|
546
|
+
this._curve.lineEnd();
|
|
547
|
+
},
|
|
548
|
+
point: function (a, r) {
|
|
549
|
+
this._curve.point(r * Math.sin(a), r * -Math.cos(a));
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
function curveRadial(curve) {
|
|
553
|
+
function radial(context) {
|
|
554
|
+
return new Radial(curve(context));
|
|
555
|
+
}
|
|
556
|
+
radial._curve = curve;
|
|
557
|
+
return radial;
|
|
558
|
+
}
|
|
559
|
+
function lineRadial(l) {
|
|
560
|
+
var c = l.curve;
|
|
561
|
+
l.angle = l.x, delete l.x;
|
|
562
|
+
l.radius = l.y, delete l.y;
|
|
563
|
+
l.curve = function (_) {
|
|
564
|
+
return arguments.length ? c(curveRadial(_)) : c()._curve;
|
|
565
|
+
};
|
|
566
|
+
return l;
|
|
567
|
+
}
|
|
568
|
+
function lineRadial$1() {
|
|
569
|
+
return lineRadial(line().curve(curveRadialLinear));
|
|
570
|
+
}
|
|
571
|
+
function areaRadial() {
|
|
572
|
+
var a = area().curve(curveRadialLinear),
|
|
573
|
+
c = a.curve,
|
|
574
|
+
x0 = a.lineX0,
|
|
575
|
+
x1 = a.lineX1,
|
|
576
|
+
y0 = a.lineY0,
|
|
577
|
+
y1 = a.lineY1;
|
|
578
|
+
a.angle = a.x, delete a.x;
|
|
579
|
+
a.startAngle = a.x0, delete a.x0;
|
|
580
|
+
a.endAngle = a.x1, delete a.x1;
|
|
581
|
+
a.radius = a.y, delete a.y;
|
|
582
|
+
a.innerRadius = a.y0, delete a.y0;
|
|
583
|
+
a.outerRadius = a.y1, delete a.y1;
|
|
584
|
+
a.lineStartAngle = function () {
|
|
585
|
+
return lineRadial(x0());
|
|
586
|
+
}, delete a.lineX0;
|
|
587
|
+
a.lineEndAngle = function () {
|
|
588
|
+
return lineRadial(x1());
|
|
589
|
+
}, delete a.lineX1;
|
|
590
|
+
a.lineInnerRadius = function () {
|
|
591
|
+
return lineRadial(y0());
|
|
592
|
+
}, delete a.lineY0;
|
|
593
|
+
a.lineOuterRadius = function () {
|
|
594
|
+
return lineRadial(y1());
|
|
595
|
+
}, delete a.lineY1;
|
|
596
|
+
a.curve = function (_) {
|
|
597
|
+
return arguments.length ? c(curveRadial(_)) : c()._curve;
|
|
598
|
+
};
|
|
599
|
+
return a;
|
|
600
|
+
}
|
|
601
|
+
function pointRadial(x, y) {
|
|
602
|
+
return [(y = +y) * Math.cos(x -= Math.PI / 2), y * Math.sin(x)];
|
|
603
|
+
}
|
|
604
|
+
class Bump {
|
|
605
|
+
constructor(context, x) {
|
|
606
|
+
this._context = context;
|
|
607
|
+
this._x = x;
|
|
608
|
+
}
|
|
609
|
+
areaStart() {
|
|
610
|
+
this._line = 0;
|
|
611
|
+
}
|
|
612
|
+
areaEnd() {
|
|
613
|
+
this._line = NaN;
|
|
614
|
+
}
|
|
615
|
+
lineStart() {
|
|
616
|
+
this._point = 0;
|
|
617
|
+
}
|
|
618
|
+
lineEnd() {
|
|
619
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
620
|
+
this._line = 1 - this._line;
|
|
621
|
+
}
|
|
622
|
+
point(x, y) {
|
|
623
|
+
x = +x, y = +y;
|
|
624
|
+
switch (this._point) {
|
|
625
|
+
case 0:
|
|
626
|
+
{
|
|
627
|
+
this._point = 1;
|
|
628
|
+
if (this._line) this._context.lineTo(x, y);else this._context.moveTo(x, y);
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
case 1:
|
|
632
|
+
this._point = 2;
|
|
633
|
+
// falls through
|
|
634
|
+
default:
|
|
635
|
+
{
|
|
636
|
+
if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x) / 2, this._y0, this._x0, y, x, y);else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y) / 2, x, this._y0, x, y);
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
this._x0 = x, this._y0 = y;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
class BumpRadial {
|
|
644
|
+
constructor(context) {
|
|
645
|
+
this._context = context;
|
|
646
|
+
}
|
|
647
|
+
lineStart() {
|
|
648
|
+
this._point = 0;
|
|
649
|
+
}
|
|
650
|
+
lineEnd() {}
|
|
651
|
+
point(x, y) {
|
|
652
|
+
x = +x, y = +y;
|
|
653
|
+
if (this._point === 0) {
|
|
654
|
+
this._point = 1;
|
|
655
|
+
} else {
|
|
656
|
+
const p0 = pointRadial(this._x0, this._y0);
|
|
657
|
+
const p1 = pointRadial(this._x0, this._y0 = (this._y0 + y) / 2);
|
|
658
|
+
const p2 = pointRadial(x, this._y0);
|
|
659
|
+
const p3 = pointRadial(x, y);
|
|
660
|
+
this._context.moveTo(...p0);
|
|
661
|
+
this._context.bezierCurveTo(...p1, ...p2, ...p3);
|
|
662
|
+
}
|
|
663
|
+
this._x0 = x, this._y0 = y;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function bumpX(context) {
|
|
667
|
+
return new Bump(context, true);
|
|
668
|
+
}
|
|
669
|
+
function bumpY(context) {
|
|
670
|
+
return new Bump(context, false);
|
|
671
|
+
}
|
|
672
|
+
function bumpRadial(context) {
|
|
673
|
+
return new BumpRadial(context);
|
|
674
|
+
}
|
|
675
|
+
function linkSource(d) {
|
|
676
|
+
return d.source;
|
|
677
|
+
}
|
|
678
|
+
function linkTarget(d) {
|
|
679
|
+
return d.target;
|
|
680
|
+
}
|
|
681
|
+
function link(curve) {
|
|
682
|
+
let source = linkSource,
|
|
683
|
+
target = linkTarget,
|
|
684
|
+
x$1 = x,
|
|
685
|
+
y$1 = y,
|
|
686
|
+
context = null,
|
|
687
|
+
output = null,
|
|
688
|
+
path = withPath(link);
|
|
689
|
+
function link() {
|
|
690
|
+
let buffer;
|
|
691
|
+
const argv = slice.call(arguments);
|
|
692
|
+
const s = source.apply(this, argv);
|
|
693
|
+
const t = target.apply(this, argv);
|
|
694
|
+
if (context == null) output = curve(buffer = path());
|
|
695
|
+
output.lineStart();
|
|
696
|
+
argv[0] = s, output.point(+x$1.apply(this, argv), +y$1.apply(this, argv));
|
|
697
|
+
argv[0] = t, output.point(+x$1.apply(this, argv), +y$1.apply(this, argv));
|
|
698
|
+
output.lineEnd();
|
|
699
|
+
if (buffer) return output = null, buffer + "" || null;
|
|
700
|
+
}
|
|
701
|
+
link.source = function (_) {
|
|
702
|
+
return arguments.length ? (source = _, link) : source;
|
|
703
|
+
};
|
|
704
|
+
link.target = function (_) {
|
|
705
|
+
return arguments.length ? (target = _, link) : target;
|
|
706
|
+
};
|
|
707
|
+
link.x = function (_) {
|
|
708
|
+
return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link) : x$1;
|
|
709
|
+
};
|
|
710
|
+
link.y = function (_) {
|
|
711
|
+
return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link) : y$1;
|
|
712
|
+
};
|
|
713
|
+
link.context = function (_) {
|
|
714
|
+
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), link) : context;
|
|
715
|
+
};
|
|
716
|
+
return link;
|
|
717
|
+
}
|
|
718
|
+
function linkHorizontal() {
|
|
719
|
+
return link(bumpX);
|
|
720
|
+
}
|
|
721
|
+
function linkVertical() {
|
|
722
|
+
return link(bumpY);
|
|
723
|
+
}
|
|
724
|
+
function linkRadial() {
|
|
725
|
+
const l = link(bumpRadial);
|
|
726
|
+
l.angle = l.x, delete l.x;
|
|
727
|
+
l.radius = l.y, delete l.y;
|
|
728
|
+
return l;
|
|
729
|
+
}
|
|
730
|
+
const sqrt3$2 = sqrt(3);
|
|
731
|
+
var asterisk = {
|
|
732
|
+
draw(context, size) {
|
|
733
|
+
const r = sqrt(size + min(size / 28, 0.75)) * 0.59436;
|
|
734
|
+
const t = r / 2;
|
|
735
|
+
const u = t * sqrt3$2;
|
|
736
|
+
context.moveTo(0, r);
|
|
737
|
+
context.lineTo(0, -r);
|
|
738
|
+
context.moveTo(-u, -t);
|
|
739
|
+
context.lineTo(u, t);
|
|
740
|
+
context.moveTo(-u, t);
|
|
741
|
+
context.lineTo(u, -t);
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
var circle = {
|
|
745
|
+
draw(context, size) {
|
|
746
|
+
const r = sqrt(size / pi);
|
|
747
|
+
context.moveTo(r, 0);
|
|
748
|
+
context.arc(0, 0, r, 0, tau);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
var cross = {
|
|
752
|
+
draw(context, size) {
|
|
753
|
+
const r = sqrt(size / 5) / 2;
|
|
754
|
+
context.moveTo(-3 * r, -r);
|
|
755
|
+
context.lineTo(-r, -r);
|
|
756
|
+
context.lineTo(-r, -3 * r);
|
|
757
|
+
context.lineTo(r, -3 * r);
|
|
758
|
+
context.lineTo(r, -r);
|
|
759
|
+
context.lineTo(3 * r, -r);
|
|
760
|
+
context.lineTo(3 * r, r);
|
|
761
|
+
context.lineTo(r, r);
|
|
762
|
+
context.lineTo(r, 3 * r);
|
|
763
|
+
context.lineTo(-r, 3 * r);
|
|
764
|
+
context.lineTo(-r, r);
|
|
765
|
+
context.lineTo(-3 * r, r);
|
|
766
|
+
context.closePath();
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
const tan30 = sqrt(1 / 3);
|
|
770
|
+
const tan30_2 = tan30 * 2;
|
|
771
|
+
var diamond = {
|
|
772
|
+
draw(context, size) {
|
|
773
|
+
const y = sqrt(size / tan30_2);
|
|
774
|
+
const x = y * tan30;
|
|
775
|
+
context.moveTo(0, -y);
|
|
776
|
+
context.lineTo(x, 0);
|
|
777
|
+
context.lineTo(0, y);
|
|
778
|
+
context.lineTo(-x, 0);
|
|
779
|
+
context.closePath();
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
var diamond2 = {
|
|
783
|
+
draw(context, size) {
|
|
784
|
+
const r = sqrt(size) * 0.62625;
|
|
785
|
+
context.moveTo(0, -r);
|
|
786
|
+
context.lineTo(r, 0);
|
|
787
|
+
context.lineTo(0, r);
|
|
788
|
+
context.lineTo(-r, 0);
|
|
789
|
+
context.closePath();
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
var plus = {
|
|
793
|
+
draw(context, size) {
|
|
794
|
+
const r = sqrt(size - min(size / 7, 2)) * 0.87559;
|
|
795
|
+
context.moveTo(-r, 0);
|
|
796
|
+
context.lineTo(r, 0);
|
|
797
|
+
context.moveTo(0, r);
|
|
798
|
+
context.lineTo(0, -r);
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
var square = {
|
|
802
|
+
draw(context, size) {
|
|
803
|
+
const w = sqrt(size);
|
|
804
|
+
const x = -w / 2;
|
|
805
|
+
context.rect(x, x, w, w);
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
var square2 = {
|
|
809
|
+
draw(context, size) {
|
|
810
|
+
const r = sqrt(size) * 0.4431;
|
|
811
|
+
context.moveTo(r, r);
|
|
812
|
+
context.lineTo(r, -r);
|
|
813
|
+
context.lineTo(-r, -r);
|
|
814
|
+
context.lineTo(-r, r);
|
|
815
|
+
context.closePath();
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
const ka = 0.89081309152928522810;
|
|
819
|
+
const kr = sin(pi / 10) / sin(7 * pi / 10);
|
|
820
|
+
const kx = sin(tau / 10) * kr;
|
|
821
|
+
const ky = -cos(tau / 10) * kr;
|
|
822
|
+
var star = {
|
|
823
|
+
draw(context, size) {
|
|
824
|
+
const r = sqrt(size * ka);
|
|
825
|
+
const x = kx * r;
|
|
826
|
+
const y = ky * r;
|
|
827
|
+
context.moveTo(0, -r);
|
|
828
|
+
context.lineTo(x, y);
|
|
829
|
+
for (let i = 1; i < 5; ++i) {
|
|
830
|
+
const a = tau * i / 5;
|
|
831
|
+
const c = cos(a);
|
|
832
|
+
const s = sin(a);
|
|
833
|
+
context.lineTo(s * r, -c * r);
|
|
834
|
+
context.lineTo(c * x - s * y, s * x + c * y);
|
|
835
|
+
}
|
|
836
|
+
context.closePath();
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
const sqrt3$1 = sqrt(3);
|
|
840
|
+
var triangle = {
|
|
841
|
+
draw(context, size) {
|
|
842
|
+
const y = -sqrt(size / (sqrt3$1 * 3));
|
|
843
|
+
context.moveTo(0, y * 2);
|
|
844
|
+
context.lineTo(-sqrt3$1 * y, -y);
|
|
845
|
+
context.lineTo(sqrt3$1 * y, -y);
|
|
846
|
+
context.closePath();
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
const sqrt3 = sqrt(3);
|
|
850
|
+
var triangle2 = {
|
|
851
|
+
draw(context, size) {
|
|
852
|
+
const s = sqrt(size) * 0.6824;
|
|
853
|
+
const t = s / 2;
|
|
854
|
+
const u = s * sqrt3 / 2; // cos(Math.PI / 6)
|
|
855
|
+
context.moveTo(0, -s);
|
|
856
|
+
context.lineTo(u, t);
|
|
857
|
+
context.lineTo(-u, t);
|
|
858
|
+
context.closePath();
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
const c = -0.5;
|
|
862
|
+
const s = sqrt(3) / 2;
|
|
863
|
+
const k = 1 / sqrt(12);
|
|
864
|
+
const a = (k / 2 + 1) * 3;
|
|
865
|
+
var wye = {
|
|
866
|
+
draw(context, size) {
|
|
867
|
+
const r = sqrt(size / a);
|
|
868
|
+
const x0 = r / 2,
|
|
869
|
+
y0 = r * k;
|
|
870
|
+
const x1 = x0,
|
|
871
|
+
y1 = r * k + r;
|
|
872
|
+
const x2 = -x1,
|
|
873
|
+
y2 = y1;
|
|
874
|
+
context.moveTo(x0, y0);
|
|
875
|
+
context.lineTo(x1, y1);
|
|
876
|
+
context.lineTo(x2, y2);
|
|
877
|
+
context.lineTo(c * x0 - s * y0, s * x0 + c * y0);
|
|
878
|
+
context.lineTo(c * x1 - s * y1, s * x1 + c * y1);
|
|
879
|
+
context.lineTo(c * x2 - s * y2, s * x2 + c * y2);
|
|
880
|
+
context.lineTo(c * x0 + s * y0, c * y0 - s * x0);
|
|
881
|
+
context.lineTo(c * x1 + s * y1, c * y1 - s * x1);
|
|
882
|
+
context.lineTo(c * x2 + s * y2, c * y2 - s * x2);
|
|
883
|
+
context.closePath();
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
var times = {
|
|
887
|
+
draw(context, size) {
|
|
888
|
+
const r = sqrt(size - min(size / 6, 1.7)) * 0.6189;
|
|
889
|
+
context.moveTo(-r, -r);
|
|
890
|
+
context.lineTo(r, r);
|
|
891
|
+
context.moveTo(-r, r);
|
|
892
|
+
context.lineTo(r, -r);
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
// These symbols are designed to be filled.
|
|
897
|
+
const symbolsFill = [circle, cross, diamond, square, star, triangle, wye];
|
|
898
|
+
|
|
899
|
+
// These symbols are designed to be stroked (with a width of 1.5px and round caps).
|
|
900
|
+
const symbolsStroke = [circle, plus, times, triangle2, asterisk, square2, diamond2];
|
|
901
|
+
function Symbol(type, size) {
|
|
902
|
+
let context = null,
|
|
903
|
+
path = withPath(symbol);
|
|
904
|
+
type = typeof type === "function" ? type : constant(type || circle);
|
|
905
|
+
size = typeof size === "function" ? size : constant(size === undefined ? 64 : +size);
|
|
906
|
+
function symbol() {
|
|
907
|
+
let buffer;
|
|
908
|
+
if (!context) context = buffer = path();
|
|
909
|
+
type.apply(this, arguments).draw(context, +size.apply(this, arguments));
|
|
910
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
911
|
+
}
|
|
912
|
+
symbol.type = function (_) {
|
|
913
|
+
return arguments.length ? (type = typeof _ === "function" ? _ : constant(_), symbol) : type;
|
|
914
|
+
};
|
|
915
|
+
symbol.size = function (_) {
|
|
916
|
+
return arguments.length ? (size = typeof _ === "function" ? _ : constant(+_), symbol) : size;
|
|
917
|
+
};
|
|
918
|
+
symbol.context = function (_) {
|
|
919
|
+
return arguments.length ? (context = _ == null ? null : _, symbol) : context;
|
|
920
|
+
};
|
|
921
|
+
return symbol;
|
|
922
|
+
}
|
|
923
|
+
function noop() {}
|
|
924
|
+
function point$3(that, x, y) {
|
|
925
|
+
that._context.bezierCurveTo((2 * that._x0 + that._x1) / 3, (2 * that._y0 + that._y1) / 3, (that._x0 + 2 * that._x1) / 3, (that._y0 + 2 * that._y1) / 3, (that._x0 + 4 * that._x1 + x) / 6, (that._y0 + 4 * that._y1 + y) / 6);
|
|
926
|
+
}
|
|
927
|
+
function Basis(context) {
|
|
928
|
+
this._context = context;
|
|
929
|
+
}
|
|
930
|
+
Basis.prototype = {
|
|
931
|
+
areaStart: function () {
|
|
932
|
+
this._line = 0;
|
|
933
|
+
},
|
|
934
|
+
areaEnd: function () {
|
|
935
|
+
this._line = NaN;
|
|
936
|
+
},
|
|
937
|
+
lineStart: function () {
|
|
938
|
+
this._x0 = this._x1 = this._y0 = this._y1 = NaN;
|
|
939
|
+
this._point = 0;
|
|
940
|
+
},
|
|
941
|
+
lineEnd: function () {
|
|
942
|
+
switch (this._point) {
|
|
943
|
+
case 3:
|
|
944
|
+
point$3(this, this._x1, this._y1);
|
|
945
|
+
// falls through
|
|
946
|
+
case 2:
|
|
947
|
+
this._context.lineTo(this._x1, this._y1);
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
951
|
+
this._line = 1 - this._line;
|
|
952
|
+
},
|
|
953
|
+
point: function (x, y) {
|
|
954
|
+
x = +x, y = +y;
|
|
955
|
+
switch (this._point) {
|
|
956
|
+
case 0:
|
|
957
|
+
this._point = 1;
|
|
958
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
959
|
+
break;
|
|
960
|
+
case 1:
|
|
961
|
+
this._point = 2;
|
|
962
|
+
break;
|
|
963
|
+
case 2:
|
|
964
|
+
this._point = 3;
|
|
965
|
+
this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
|
|
966
|
+
// falls through
|
|
967
|
+
default:
|
|
968
|
+
point$3(this, x, y);
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
971
|
+
this._x0 = this._x1, this._x1 = x;
|
|
972
|
+
this._y0 = this._y1, this._y1 = y;
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
function basis(context) {
|
|
976
|
+
return new Basis(context);
|
|
977
|
+
}
|
|
978
|
+
function BasisClosed(context) {
|
|
979
|
+
this._context = context;
|
|
980
|
+
}
|
|
981
|
+
BasisClosed.prototype = {
|
|
982
|
+
areaStart: noop,
|
|
983
|
+
areaEnd: noop,
|
|
984
|
+
lineStart: function () {
|
|
985
|
+
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN;
|
|
986
|
+
this._point = 0;
|
|
987
|
+
},
|
|
988
|
+
lineEnd: function () {
|
|
989
|
+
switch (this._point) {
|
|
990
|
+
case 1:
|
|
991
|
+
{
|
|
992
|
+
this._context.moveTo(this._x2, this._y2);
|
|
993
|
+
this._context.closePath();
|
|
994
|
+
break;
|
|
995
|
+
}
|
|
996
|
+
case 2:
|
|
997
|
+
{
|
|
998
|
+
this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3);
|
|
999
|
+
this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3);
|
|
1000
|
+
this._context.closePath();
|
|
1001
|
+
break;
|
|
1002
|
+
}
|
|
1003
|
+
case 3:
|
|
1004
|
+
{
|
|
1005
|
+
this.point(this._x2, this._y2);
|
|
1006
|
+
this.point(this._x3, this._y3);
|
|
1007
|
+
this.point(this._x4, this._y4);
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
point: function (x, y) {
|
|
1013
|
+
x = +x, y = +y;
|
|
1014
|
+
switch (this._point) {
|
|
1015
|
+
case 0:
|
|
1016
|
+
this._point = 1;
|
|
1017
|
+
this._x2 = x, this._y2 = y;
|
|
1018
|
+
break;
|
|
1019
|
+
case 1:
|
|
1020
|
+
this._point = 2;
|
|
1021
|
+
this._x3 = x, this._y3 = y;
|
|
1022
|
+
break;
|
|
1023
|
+
case 2:
|
|
1024
|
+
this._point = 3;
|
|
1025
|
+
this._x4 = x, this._y4 = y;
|
|
1026
|
+
this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6);
|
|
1027
|
+
break;
|
|
1028
|
+
default:
|
|
1029
|
+
point$3(this, x, y);
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
this._x0 = this._x1, this._x1 = x;
|
|
1033
|
+
this._y0 = this._y1, this._y1 = y;
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
function basisClosed(context) {
|
|
1037
|
+
return new BasisClosed(context);
|
|
1038
|
+
}
|
|
1039
|
+
function BasisOpen(context) {
|
|
1040
|
+
this._context = context;
|
|
1041
|
+
}
|
|
1042
|
+
BasisOpen.prototype = {
|
|
1043
|
+
areaStart: function () {
|
|
1044
|
+
this._line = 0;
|
|
1045
|
+
},
|
|
1046
|
+
areaEnd: function () {
|
|
1047
|
+
this._line = NaN;
|
|
1048
|
+
},
|
|
1049
|
+
lineStart: function () {
|
|
1050
|
+
this._x0 = this._x1 = this._y0 = this._y1 = NaN;
|
|
1051
|
+
this._point = 0;
|
|
1052
|
+
},
|
|
1053
|
+
lineEnd: function () {
|
|
1054
|
+
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
|
|
1055
|
+
this._line = 1 - this._line;
|
|
1056
|
+
},
|
|
1057
|
+
point: function (x, y) {
|
|
1058
|
+
x = +x, y = +y;
|
|
1059
|
+
switch (this._point) {
|
|
1060
|
+
case 0:
|
|
1061
|
+
this._point = 1;
|
|
1062
|
+
break;
|
|
1063
|
+
case 1:
|
|
1064
|
+
this._point = 2;
|
|
1065
|
+
break;
|
|
1066
|
+
case 2:
|
|
1067
|
+
this._point = 3;
|
|
1068
|
+
var x0 = (this._x0 + 4 * this._x1 + x) / 6,
|
|
1069
|
+
y0 = (this._y0 + 4 * this._y1 + y) / 6;
|
|
1070
|
+
this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0);
|
|
1071
|
+
break;
|
|
1072
|
+
case 3:
|
|
1073
|
+
this._point = 4;
|
|
1074
|
+
// falls through
|
|
1075
|
+
default:
|
|
1076
|
+
point$3(this, x, y);
|
|
1077
|
+
break;
|
|
1078
|
+
}
|
|
1079
|
+
this._x0 = this._x1, this._x1 = x;
|
|
1080
|
+
this._y0 = this._y1, this._y1 = y;
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
function basisOpen(context) {
|
|
1084
|
+
return new BasisOpen(context);
|
|
1085
|
+
}
|
|
1086
|
+
function Bundle(context, beta) {
|
|
1087
|
+
this._basis = new Basis(context);
|
|
1088
|
+
this._beta = beta;
|
|
1089
|
+
}
|
|
1090
|
+
Bundle.prototype = {
|
|
1091
|
+
lineStart: function () {
|
|
1092
|
+
this._x = [];
|
|
1093
|
+
this._y = [];
|
|
1094
|
+
this._basis.lineStart();
|
|
1095
|
+
},
|
|
1096
|
+
lineEnd: function () {
|
|
1097
|
+
var x = this._x,
|
|
1098
|
+
y = this._y,
|
|
1099
|
+
j = x.length - 1;
|
|
1100
|
+
if (j > 0) {
|
|
1101
|
+
var x0 = x[0],
|
|
1102
|
+
y0 = y[0],
|
|
1103
|
+
dx = x[j] - x0,
|
|
1104
|
+
dy = y[j] - y0,
|
|
1105
|
+
i = -1,
|
|
1106
|
+
t;
|
|
1107
|
+
while (++i <= j) {
|
|
1108
|
+
t = i / j;
|
|
1109
|
+
this._basis.point(this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), this._beta * y[i] + (1 - this._beta) * (y0 + t * dy));
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
this._x = this._y = null;
|
|
1113
|
+
this._basis.lineEnd();
|
|
1114
|
+
},
|
|
1115
|
+
point: function (x, y) {
|
|
1116
|
+
this._x.push(+x);
|
|
1117
|
+
this._y.push(+y);
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
var bundle = function custom(beta) {
|
|
1121
|
+
function bundle(context) {
|
|
1122
|
+
return beta === 1 ? new Basis(context) : new Bundle(context, beta);
|
|
1123
|
+
}
|
|
1124
|
+
bundle.beta = function (beta) {
|
|
1125
|
+
return custom(+beta);
|
|
1126
|
+
};
|
|
1127
|
+
return bundle;
|
|
1128
|
+
}(0.85);
|
|
1129
|
+
function point$2(that, x, y) {
|
|
1130
|
+
that._context.bezierCurveTo(that._x1 + that._k * (that._x2 - that._x0), that._y1 + that._k * (that._y2 - that._y0), that._x2 + that._k * (that._x1 - x), that._y2 + that._k * (that._y1 - y), that._x2, that._y2);
|
|
1131
|
+
}
|
|
1132
|
+
function Cardinal(context, tension) {
|
|
1133
|
+
this._context = context;
|
|
1134
|
+
this._k = (1 - tension) / 6;
|
|
1135
|
+
}
|
|
1136
|
+
Cardinal.prototype = {
|
|
1137
|
+
areaStart: function () {
|
|
1138
|
+
this._line = 0;
|
|
1139
|
+
},
|
|
1140
|
+
areaEnd: function () {
|
|
1141
|
+
this._line = NaN;
|
|
1142
|
+
},
|
|
1143
|
+
lineStart: function () {
|
|
1144
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
1145
|
+
this._point = 0;
|
|
1146
|
+
},
|
|
1147
|
+
lineEnd: function () {
|
|
1148
|
+
switch (this._point) {
|
|
1149
|
+
case 2:
|
|
1150
|
+
this._context.lineTo(this._x2, this._y2);
|
|
1151
|
+
break;
|
|
1152
|
+
case 3:
|
|
1153
|
+
point$2(this, this._x1, this._y1);
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1157
|
+
this._line = 1 - this._line;
|
|
1158
|
+
},
|
|
1159
|
+
point: function (x, y) {
|
|
1160
|
+
x = +x, y = +y;
|
|
1161
|
+
switch (this._point) {
|
|
1162
|
+
case 0:
|
|
1163
|
+
this._point = 1;
|
|
1164
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
1165
|
+
break;
|
|
1166
|
+
case 1:
|
|
1167
|
+
this._point = 2;
|
|
1168
|
+
this._x1 = x, this._y1 = y;
|
|
1169
|
+
break;
|
|
1170
|
+
case 2:
|
|
1171
|
+
this._point = 3;
|
|
1172
|
+
// falls through
|
|
1173
|
+
default:
|
|
1174
|
+
point$2(this, x, y);
|
|
1175
|
+
break;
|
|
1176
|
+
}
|
|
1177
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1178
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
var cardinal = function custom(tension) {
|
|
1182
|
+
function cardinal(context) {
|
|
1183
|
+
return new Cardinal(context, tension);
|
|
1184
|
+
}
|
|
1185
|
+
cardinal.tension = function (tension) {
|
|
1186
|
+
return custom(+tension);
|
|
1187
|
+
};
|
|
1188
|
+
return cardinal;
|
|
1189
|
+
}(0);
|
|
1190
|
+
function CardinalClosed(context, tension) {
|
|
1191
|
+
this._context = context;
|
|
1192
|
+
this._k = (1 - tension) / 6;
|
|
1193
|
+
}
|
|
1194
|
+
CardinalClosed.prototype = {
|
|
1195
|
+
areaStart: noop,
|
|
1196
|
+
areaEnd: noop,
|
|
1197
|
+
lineStart: function () {
|
|
1198
|
+
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
|
|
1199
|
+
this._point = 0;
|
|
1200
|
+
},
|
|
1201
|
+
lineEnd: function () {
|
|
1202
|
+
switch (this._point) {
|
|
1203
|
+
case 1:
|
|
1204
|
+
{
|
|
1205
|
+
this._context.moveTo(this._x3, this._y3);
|
|
1206
|
+
this._context.closePath();
|
|
1207
|
+
break;
|
|
1208
|
+
}
|
|
1209
|
+
case 2:
|
|
1210
|
+
{
|
|
1211
|
+
this._context.lineTo(this._x3, this._y3);
|
|
1212
|
+
this._context.closePath();
|
|
1213
|
+
break;
|
|
1214
|
+
}
|
|
1215
|
+
case 3:
|
|
1216
|
+
{
|
|
1217
|
+
this.point(this._x3, this._y3);
|
|
1218
|
+
this.point(this._x4, this._y4);
|
|
1219
|
+
this.point(this._x5, this._y5);
|
|
1220
|
+
break;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
},
|
|
1224
|
+
point: function (x, y) {
|
|
1225
|
+
x = +x, y = +y;
|
|
1226
|
+
switch (this._point) {
|
|
1227
|
+
case 0:
|
|
1228
|
+
this._point = 1;
|
|
1229
|
+
this._x3 = x, this._y3 = y;
|
|
1230
|
+
break;
|
|
1231
|
+
case 1:
|
|
1232
|
+
this._point = 2;
|
|
1233
|
+
this._context.moveTo(this._x4 = x, this._y4 = y);
|
|
1234
|
+
break;
|
|
1235
|
+
case 2:
|
|
1236
|
+
this._point = 3;
|
|
1237
|
+
this._x5 = x, this._y5 = y;
|
|
1238
|
+
break;
|
|
1239
|
+
default:
|
|
1240
|
+
point$2(this, x, y);
|
|
1241
|
+
break;
|
|
1242
|
+
}
|
|
1243
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1244
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
var cardinalClosed = function custom(tension) {
|
|
1248
|
+
function cardinal(context) {
|
|
1249
|
+
return new CardinalClosed(context, tension);
|
|
1250
|
+
}
|
|
1251
|
+
cardinal.tension = function (tension) {
|
|
1252
|
+
return custom(+tension);
|
|
1253
|
+
};
|
|
1254
|
+
return cardinal;
|
|
1255
|
+
}(0);
|
|
1256
|
+
function CardinalOpen(context, tension) {
|
|
1257
|
+
this._context = context;
|
|
1258
|
+
this._k = (1 - tension) / 6;
|
|
1259
|
+
}
|
|
1260
|
+
CardinalOpen.prototype = {
|
|
1261
|
+
areaStart: function () {
|
|
1262
|
+
this._line = 0;
|
|
1263
|
+
},
|
|
1264
|
+
areaEnd: function () {
|
|
1265
|
+
this._line = NaN;
|
|
1266
|
+
},
|
|
1267
|
+
lineStart: function () {
|
|
1268
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
1269
|
+
this._point = 0;
|
|
1270
|
+
},
|
|
1271
|
+
lineEnd: function () {
|
|
1272
|
+
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
|
|
1273
|
+
this._line = 1 - this._line;
|
|
1274
|
+
},
|
|
1275
|
+
point: function (x, y) {
|
|
1276
|
+
x = +x, y = +y;
|
|
1277
|
+
switch (this._point) {
|
|
1278
|
+
case 0:
|
|
1279
|
+
this._point = 1;
|
|
1280
|
+
break;
|
|
1281
|
+
case 1:
|
|
1282
|
+
this._point = 2;
|
|
1283
|
+
break;
|
|
1284
|
+
case 2:
|
|
1285
|
+
this._point = 3;
|
|
1286
|
+
this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
|
|
1287
|
+
break;
|
|
1288
|
+
case 3:
|
|
1289
|
+
this._point = 4;
|
|
1290
|
+
// falls through
|
|
1291
|
+
default:
|
|
1292
|
+
point$2(this, x, y);
|
|
1293
|
+
break;
|
|
1294
|
+
}
|
|
1295
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1296
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
var cardinalOpen = function custom(tension) {
|
|
1300
|
+
function cardinal(context) {
|
|
1301
|
+
return new CardinalOpen(context, tension);
|
|
1302
|
+
}
|
|
1303
|
+
cardinal.tension = function (tension) {
|
|
1304
|
+
return custom(+tension);
|
|
1305
|
+
};
|
|
1306
|
+
return cardinal;
|
|
1307
|
+
}(0);
|
|
1308
|
+
function point$1(that, x, y) {
|
|
1309
|
+
var x1 = that._x1,
|
|
1310
|
+
y1 = that._y1,
|
|
1311
|
+
x2 = that._x2,
|
|
1312
|
+
y2 = that._y2;
|
|
1313
|
+
if (that._l01_a > epsilon) {
|
|
1314
|
+
var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a,
|
|
1315
|
+
n = 3 * that._l01_a * (that._l01_a + that._l12_a);
|
|
1316
|
+
x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n;
|
|
1317
|
+
y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n;
|
|
1318
|
+
}
|
|
1319
|
+
if (that._l23_a > epsilon) {
|
|
1320
|
+
var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a,
|
|
1321
|
+
m = 3 * that._l23_a * (that._l23_a + that._l12_a);
|
|
1322
|
+
x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m;
|
|
1323
|
+
y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m;
|
|
1324
|
+
}
|
|
1325
|
+
that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2);
|
|
1326
|
+
}
|
|
1327
|
+
function CatmullRom(context, alpha) {
|
|
1328
|
+
this._context = context;
|
|
1329
|
+
this._alpha = alpha;
|
|
1330
|
+
}
|
|
1331
|
+
CatmullRom.prototype = {
|
|
1332
|
+
areaStart: function () {
|
|
1333
|
+
this._line = 0;
|
|
1334
|
+
},
|
|
1335
|
+
areaEnd: function () {
|
|
1336
|
+
this._line = NaN;
|
|
1337
|
+
},
|
|
1338
|
+
lineStart: function () {
|
|
1339
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
1340
|
+
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
|
|
1341
|
+
},
|
|
1342
|
+
lineEnd: function () {
|
|
1343
|
+
switch (this._point) {
|
|
1344
|
+
case 2:
|
|
1345
|
+
this._context.lineTo(this._x2, this._y2);
|
|
1346
|
+
break;
|
|
1347
|
+
case 3:
|
|
1348
|
+
this.point(this._x2, this._y2);
|
|
1349
|
+
break;
|
|
1350
|
+
}
|
|
1351
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1352
|
+
this._line = 1 - this._line;
|
|
1353
|
+
},
|
|
1354
|
+
point: function (x, y) {
|
|
1355
|
+
x = +x, y = +y;
|
|
1356
|
+
if (this._point) {
|
|
1357
|
+
var x23 = this._x2 - x,
|
|
1358
|
+
y23 = this._y2 - y;
|
|
1359
|
+
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
|
|
1360
|
+
}
|
|
1361
|
+
switch (this._point) {
|
|
1362
|
+
case 0:
|
|
1363
|
+
this._point = 1;
|
|
1364
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
1365
|
+
break;
|
|
1366
|
+
case 1:
|
|
1367
|
+
this._point = 2;
|
|
1368
|
+
break;
|
|
1369
|
+
case 2:
|
|
1370
|
+
this._point = 3;
|
|
1371
|
+
// falls through
|
|
1372
|
+
default:
|
|
1373
|
+
point$1(this, x, y);
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
|
|
1377
|
+
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
|
|
1378
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1379
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
var catmullRom = function custom(alpha) {
|
|
1383
|
+
function catmullRom(context) {
|
|
1384
|
+
return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0);
|
|
1385
|
+
}
|
|
1386
|
+
catmullRom.alpha = function (alpha) {
|
|
1387
|
+
return custom(+alpha);
|
|
1388
|
+
};
|
|
1389
|
+
return catmullRom;
|
|
1390
|
+
}(0.5);
|
|
1391
|
+
function CatmullRomClosed(context, alpha) {
|
|
1392
|
+
this._context = context;
|
|
1393
|
+
this._alpha = alpha;
|
|
1394
|
+
}
|
|
1395
|
+
CatmullRomClosed.prototype = {
|
|
1396
|
+
areaStart: noop,
|
|
1397
|
+
areaEnd: noop,
|
|
1398
|
+
lineStart: function () {
|
|
1399
|
+
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
|
|
1400
|
+
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
|
|
1401
|
+
},
|
|
1402
|
+
lineEnd: function () {
|
|
1403
|
+
switch (this._point) {
|
|
1404
|
+
case 1:
|
|
1405
|
+
{
|
|
1406
|
+
this._context.moveTo(this._x3, this._y3);
|
|
1407
|
+
this._context.closePath();
|
|
1408
|
+
break;
|
|
1409
|
+
}
|
|
1410
|
+
case 2:
|
|
1411
|
+
{
|
|
1412
|
+
this._context.lineTo(this._x3, this._y3);
|
|
1413
|
+
this._context.closePath();
|
|
1414
|
+
break;
|
|
1415
|
+
}
|
|
1416
|
+
case 3:
|
|
1417
|
+
{
|
|
1418
|
+
this.point(this._x3, this._y3);
|
|
1419
|
+
this.point(this._x4, this._y4);
|
|
1420
|
+
this.point(this._x5, this._y5);
|
|
1421
|
+
break;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
},
|
|
1425
|
+
point: function (x, y) {
|
|
1426
|
+
x = +x, y = +y;
|
|
1427
|
+
if (this._point) {
|
|
1428
|
+
var x23 = this._x2 - x,
|
|
1429
|
+
y23 = this._y2 - y;
|
|
1430
|
+
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
|
|
1431
|
+
}
|
|
1432
|
+
switch (this._point) {
|
|
1433
|
+
case 0:
|
|
1434
|
+
this._point = 1;
|
|
1435
|
+
this._x3 = x, this._y3 = y;
|
|
1436
|
+
break;
|
|
1437
|
+
case 1:
|
|
1438
|
+
this._point = 2;
|
|
1439
|
+
this._context.moveTo(this._x4 = x, this._y4 = y);
|
|
1440
|
+
break;
|
|
1441
|
+
case 2:
|
|
1442
|
+
this._point = 3;
|
|
1443
|
+
this._x5 = x, this._y5 = y;
|
|
1444
|
+
break;
|
|
1445
|
+
default:
|
|
1446
|
+
point$1(this, x, y);
|
|
1447
|
+
break;
|
|
1448
|
+
}
|
|
1449
|
+
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
|
|
1450
|
+
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
|
|
1451
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1452
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
var catmullRomClosed = function custom(alpha) {
|
|
1456
|
+
function catmullRom(context) {
|
|
1457
|
+
return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0);
|
|
1458
|
+
}
|
|
1459
|
+
catmullRom.alpha = function (alpha) {
|
|
1460
|
+
return custom(+alpha);
|
|
1461
|
+
};
|
|
1462
|
+
return catmullRom;
|
|
1463
|
+
}(0.5);
|
|
1464
|
+
function CatmullRomOpen(context, alpha) {
|
|
1465
|
+
this._context = context;
|
|
1466
|
+
this._alpha = alpha;
|
|
1467
|
+
}
|
|
1468
|
+
CatmullRomOpen.prototype = {
|
|
1469
|
+
areaStart: function () {
|
|
1470
|
+
this._line = 0;
|
|
1471
|
+
},
|
|
1472
|
+
areaEnd: function () {
|
|
1473
|
+
this._line = NaN;
|
|
1474
|
+
},
|
|
1475
|
+
lineStart: function () {
|
|
1476
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
1477
|
+
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
|
|
1478
|
+
},
|
|
1479
|
+
lineEnd: function () {
|
|
1480
|
+
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
|
|
1481
|
+
this._line = 1 - this._line;
|
|
1482
|
+
},
|
|
1483
|
+
point: function (x, y) {
|
|
1484
|
+
x = +x, y = +y;
|
|
1485
|
+
if (this._point) {
|
|
1486
|
+
var x23 = this._x2 - x,
|
|
1487
|
+
y23 = this._y2 - y;
|
|
1488
|
+
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
|
|
1489
|
+
}
|
|
1490
|
+
switch (this._point) {
|
|
1491
|
+
case 0:
|
|
1492
|
+
this._point = 1;
|
|
1493
|
+
break;
|
|
1494
|
+
case 1:
|
|
1495
|
+
this._point = 2;
|
|
1496
|
+
break;
|
|
1497
|
+
case 2:
|
|
1498
|
+
this._point = 3;
|
|
1499
|
+
this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
|
|
1500
|
+
break;
|
|
1501
|
+
case 3:
|
|
1502
|
+
this._point = 4;
|
|
1503
|
+
// falls through
|
|
1504
|
+
default:
|
|
1505
|
+
point$1(this, x, y);
|
|
1506
|
+
break;
|
|
1507
|
+
}
|
|
1508
|
+
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
|
|
1509
|
+
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
|
|
1510
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1511
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
var catmullRomOpen = function custom(alpha) {
|
|
1515
|
+
function catmullRom(context) {
|
|
1516
|
+
return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0);
|
|
1517
|
+
}
|
|
1518
|
+
catmullRom.alpha = function (alpha) {
|
|
1519
|
+
return custom(+alpha);
|
|
1520
|
+
};
|
|
1521
|
+
return catmullRom;
|
|
1522
|
+
}(0.5);
|
|
1523
|
+
function LinearClosed(context) {
|
|
1524
|
+
this._context = context;
|
|
1525
|
+
}
|
|
1526
|
+
LinearClosed.prototype = {
|
|
1527
|
+
areaStart: noop,
|
|
1528
|
+
areaEnd: noop,
|
|
1529
|
+
lineStart: function () {
|
|
1530
|
+
this._point = 0;
|
|
1531
|
+
},
|
|
1532
|
+
lineEnd: function () {
|
|
1533
|
+
if (this._point) this._context.closePath();
|
|
1534
|
+
},
|
|
1535
|
+
point: function (x, y) {
|
|
1536
|
+
x = +x, y = +y;
|
|
1537
|
+
if (this._point) this._context.lineTo(x, y);else this._point = 1, this._context.moveTo(x, y);
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
function linearClosed(context) {
|
|
1541
|
+
return new LinearClosed(context);
|
|
1542
|
+
}
|
|
1543
|
+
function sign(x) {
|
|
1544
|
+
return x < 0 ? -1 : 1;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
// Calculate the slopes of the tangents (Hermite-type interpolation) based on
|
|
1548
|
+
// the following paper: Steffen, M. 1990. A Simple Method for Monotonic
|
|
1549
|
+
// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO.
|
|
1550
|
+
// NOV(II), P. 443, 1990.
|
|
1551
|
+
function slope3(that, x2, y2) {
|
|
1552
|
+
var h0 = that._x1 - that._x0,
|
|
1553
|
+
h1 = x2 - that._x1,
|
|
1554
|
+
s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0),
|
|
1555
|
+
s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0),
|
|
1556
|
+
p = (s0 * h1 + s1 * h0) / (h0 + h1);
|
|
1557
|
+
return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
// Calculate a one-sided slope.
|
|
1561
|
+
function slope2(that, t) {
|
|
1562
|
+
var h = that._x1 - that._x0;
|
|
1563
|
+
return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations
|
|
1567
|
+
// "you can express cubic Hermite interpolation in terms of cubic Bézier curves
|
|
1568
|
+
// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1".
|
|
1569
|
+
function point(that, t0, t1) {
|
|
1570
|
+
var x0 = that._x0,
|
|
1571
|
+
y0 = that._y0,
|
|
1572
|
+
x1 = that._x1,
|
|
1573
|
+
y1 = that._y1,
|
|
1574
|
+
dx = (x1 - x0) / 3;
|
|
1575
|
+
that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1);
|
|
1576
|
+
}
|
|
1577
|
+
function MonotoneX(context) {
|
|
1578
|
+
this._context = context;
|
|
1579
|
+
}
|
|
1580
|
+
MonotoneX.prototype = {
|
|
1581
|
+
areaStart: function () {
|
|
1582
|
+
this._line = 0;
|
|
1583
|
+
},
|
|
1584
|
+
areaEnd: function () {
|
|
1585
|
+
this._line = NaN;
|
|
1586
|
+
},
|
|
1587
|
+
lineStart: function () {
|
|
1588
|
+
this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;
|
|
1589
|
+
this._point = 0;
|
|
1590
|
+
},
|
|
1591
|
+
lineEnd: function () {
|
|
1592
|
+
switch (this._point) {
|
|
1593
|
+
case 2:
|
|
1594
|
+
this._context.lineTo(this._x1, this._y1);
|
|
1595
|
+
break;
|
|
1596
|
+
case 3:
|
|
1597
|
+
point(this, this._t0, slope2(this, this._t0));
|
|
1598
|
+
break;
|
|
1599
|
+
}
|
|
1600
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1601
|
+
this._line = 1 - this._line;
|
|
1602
|
+
},
|
|
1603
|
+
point: function (x, y) {
|
|
1604
|
+
var t1 = NaN;
|
|
1605
|
+
x = +x, y = +y;
|
|
1606
|
+
if (x === this._x1 && y === this._y1) return; // Ignore coincident points.
|
|
1607
|
+
switch (this._point) {
|
|
1608
|
+
case 0:
|
|
1609
|
+
this._point = 1;
|
|
1610
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
1611
|
+
break;
|
|
1612
|
+
case 1:
|
|
1613
|
+
this._point = 2;
|
|
1614
|
+
break;
|
|
1615
|
+
case 2:
|
|
1616
|
+
this._point = 3;
|
|
1617
|
+
point(this, slope2(this, t1 = slope3(this, x, y)), t1);
|
|
1618
|
+
break;
|
|
1619
|
+
default:
|
|
1620
|
+
point(this, this._t0, t1 = slope3(this, x, y));
|
|
1621
|
+
break;
|
|
1622
|
+
}
|
|
1623
|
+
this._x0 = this._x1, this._x1 = x;
|
|
1624
|
+
this._y0 = this._y1, this._y1 = y;
|
|
1625
|
+
this._t0 = t1;
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
function MonotoneY(context) {
|
|
1629
|
+
this._context = new ReflectContext(context);
|
|
1630
|
+
}
|
|
1631
|
+
(MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function (x, y) {
|
|
1632
|
+
MonotoneX.prototype.point.call(this, y, x);
|
|
1633
|
+
};
|
|
1634
|
+
function ReflectContext(context) {
|
|
1635
|
+
this._context = context;
|
|
1636
|
+
}
|
|
1637
|
+
ReflectContext.prototype = {
|
|
1638
|
+
moveTo: function (x, y) {
|
|
1639
|
+
this._context.moveTo(y, x);
|
|
1640
|
+
},
|
|
1641
|
+
closePath: function () {
|
|
1642
|
+
this._context.closePath();
|
|
1643
|
+
},
|
|
1644
|
+
lineTo: function (x, y) {
|
|
1645
|
+
this._context.lineTo(y, x);
|
|
1646
|
+
},
|
|
1647
|
+
bezierCurveTo: function (x1, y1, x2, y2, x, y) {
|
|
1648
|
+
this._context.bezierCurveTo(y1, x1, y2, x2, y, x);
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
function monotoneX(context) {
|
|
1652
|
+
return new MonotoneX(context);
|
|
1653
|
+
}
|
|
1654
|
+
function monotoneY(context) {
|
|
1655
|
+
return new MonotoneY(context);
|
|
1656
|
+
}
|
|
1657
|
+
function Natural(context) {
|
|
1658
|
+
this._context = context;
|
|
1659
|
+
}
|
|
1660
|
+
Natural.prototype = {
|
|
1661
|
+
areaStart: function () {
|
|
1662
|
+
this._line = 0;
|
|
1663
|
+
},
|
|
1664
|
+
areaEnd: function () {
|
|
1665
|
+
this._line = NaN;
|
|
1666
|
+
},
|
|
1667
|
+
lineStart: function () {
|
|
1668
|
+
this._x = [];
|
|
1669
|
+
this._y = [];
|
|
1670
|
+
},
|
|
1671
|
+
lineEnd: function () {
|
|
1672
|
+
var x = this._x,
|
|
1673
|
+
y = this._y,
|
|
1674
|
+
n = x.length;
|
|
1675
|
+
if (n) {
|
|
1676
|
+
this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]);
|
|
1677
|
+
if (n === 2) {
|
|
1678
|
+
this._context.lineTo(x[1], y[1]);
|
|
1679
|
+
} else {
|
|
1680
|
+
var px = controlPoints(x),
|
|
1681
|
+
py = controlPoints(y);
|
|
1682
|
+
for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) {
|
|
1683
|
+
this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
if (this._line || this._line !== 0 && n === 1) this._context.closePath();
|
|
1688
|
+
this._line = 1 - this._line;
|
|
1689
|
+
this._x = this._y = null;
|
|
1690
|
+
},
|
|
1691
|
+
point: function (x, y) {
|
|
1692
|
+
this._x.push(+x);
|
|
1693
|
+
this._y.push(+y);
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
|
|
1697
|
+
// See https://www.particleincell.com/2012/bezier-splines/ for derivation.
|
|
1698
|
+
function controlPoints(x) {
|
|
1699
|
+
var i,
|
|
1700
|
+
n = x.length - 1,
|
|
1701
|
+
m,
|
|
1702
|
+
a = new Array(n),
|
|
1703
|
+
b = new Array(n),
|
|
1704
|
+
r = new Array(n);
|
|
1705
|
+
a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1];
|
|
1706
|
+
for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1];
|
|
1707
|
+
a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n];
|
|
1708
|
+
for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1];
|
|
1709
|
+
a[n - 1] = r[n - 1] / b[n - 1];
|
|
1710
|
+
for (i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i];
|
|
1711
|
+
b[n - 1] = (x[n] + a[n - 1]) / 2;
|
|
1712
|
+
for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1];
|
|
1713
|
+
return [a, b];
|
|
1714
|
+
}
|
|
1715
|
+
function natural(context) {
|
|
1716
|
+
return new Natural(context);
|
|
1717
|
+
}
|
|
1718
|
+
function Step(context, t) {
|
|
1719
|
+
this._context = context;
|
|
1720
|
+
this._t = t;
|
|
1721
|
+
}
|
|
1722
|
+
Step.prototype = {
|
|
1723
|
+
areaStart: function () {
|
|
1724
|
+
this._line = 0;
|
|
1725
|
+
},
|
|
1726
|
+
areaEnd: function () {
|
|
1727
|
+
this._line = NaN;
|
|
1728
|
+
},
|
|
1729
|
+
lineStart: function () {
|
|
1730
|
+
this._x = this._y = NaN;
|
|
1731
|
+
this._point = 0;
|
|
1732
|
+
},
|
|
1733
|
+
lineEnd: function () {
|
|
1734
|
+
if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y);
|
|
1735
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1736
|
+
if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line;
|
|
1737
|
+
},
|
|
1738
|
+
point: function (x, y) {
|
|
1739
|
+
x = +x, y = +y;
|
|
1740
|
+
switch (this._point) {
|
|
1741
|
+
case 0:
|
|
1742
|
+
this._point = 1;
|
|
1743
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
1744
|
+
break;
|
|
1745
|
+
case 1:
|
|
1746
|
+
this._point = 2;
|
|
1747
|
+
// falls through
|
|
1748
|
+
default:
|
|
1749
|
+
{
|
|
1750
|
+
if (this._t <= 0) {
|
|
1751
|
+
this._context.lineTo(this._x, y);
|
|
1752
|
+
this._context.lineTo(x, y);
|
|
1753
|
+
} else {
|
|
1754
|
+
var x1 = this._x * (1 - this._t) + x * this._t;
|
|
1755
|
+
this._context.lineTo(x1, this._y);
|
|
1756
|
+
this._context.lineTo(x1, y);
|
|
1757
|
+
}
|
|
1758
|
+
break;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
this._x = x, this._y = y;
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
function step(context) {
|
|
1765
|
+
return new Step(context, 0.5);
|
|
1766
|
+
}
|
|
1767
|
+
function stepBefore(context) {
|
|
1768
|
+
return new Step(context, 0);
|
|
1769
|
+
}
|
|
1770
|
+
function stepAfter(context) {
|
|
1771
|
+
return new Step(context, 1);
|
|
1772
|
+
}
|
|
1773
|
+
function none$1(series, order) {
|
|
1774
|
+
if (!((n = series.length) > 1)) return;
|
|
1775
|
+
for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
|
|
1776
|
+
s0 = s1, s1 = series[order[i]];
|
|
1777
|
+
for (j = 0; j < m; ++j) {
|
|
1778
|
+
s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
function none(series) {
|
|
1783
|
+
var n = series.length,
|
|
1784
|
+
o = new Array(n);
|
|
1785
|
+
while (--n >= 0) o[n] = n;
|
|
1786
|
+
return o;
|
|
1787
|
+
}
|
|
1788
|
+
function stackValue(d, key) {
|
|
1789
|
+
return d[key];
|
|
1790
|
+
}
|
|
1791
|
+
function stackSeries(key) {
|
|
1792
|
+
const series = [];
|
|
1793
|
+
series.key = key;
|
|
1794
|
+
return series;
|
|
1795
|
+
}
|
|
1796
|
+
function stack() {
|
|
1797
|
+
var keys = constant([]),
|
|
1798
|
+
order = none,
|
|
1799
|
+
offset = none$1,
|
|
1800
|
+
value = stackValue;
|
|
1801
|
+
function stack(data) {
|
|
1802
|
+
var sz = Array.from(keys.apply(this, arguments), stackSeries),
|
|
1803
|
+
i,
|
|
1804
|
+
n = sz.length,
|
|
1805
|
+
j = -1,
|
|
1806
|
+
oz;
|
|
1807
|
+
for (const d of data) {
|
|
1808
|
+
for (i = 0, ++j; i < n; ++i) {
|
|
1809
|
+
(sz[i][j] = [0, +value(d, sz[i].key, j, data)]).data = d;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
for (i = 0, oz = array(order(sz)); i < n; ++i) {
|
|
1813
|
+
sz[oz[i]].index = i;
|
|
1814
|
+
}
|
|
1815
|
+
offset(sz, oz);
|
|
1816
|
+
return sz;
|
|
1817
|
+
}
|
|
1818
|
+
stack.keys = function (_) {
|
|
1819
|
+
return arguments.length ? (keys = typeof _ === "function" ? _ : constant(Array.from(_)), stack) : keys;
|
|
1820
|
+
};
|
|
1821
|
+
stack.value = function (_) {
|
|
1822
|
+
return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), stack) : value;
|
|
1823
|
+
};
|
|
1824
|
+
stack.order = function (_) {
|
|
1825
|
+
return arguments.length ? (order = _ == null ? none : typeof _ === "function" ? _ : constant(Array.from(_)), stack) : order;
|
|
1826
|
+
};
|
|
1827
|
+
stack.offset = function (_) {
|
|
1828
|
+
return arguments.length ? (offset = _ == null ? none$1 : _, stack) : offset;
|
|
1829
|
+
};
|
|
1830
|
+
return stack;
|
|
1831
|
+
}
|
|
1832
|
+
function expand(series, order) {
|
|
1833
|
+
if (!((n = series.length) > 0)) return;
|
|
1834
|
+
for (var i, n, j = 0, m = series[0].length, y; j < m; ++j) {
|
|
1835
|
+
for (y = i = 0; i < n; ++i) y += series[i][j][1] || 0;
|
|
1836
|
+
if (y) for (i = 0; i < n; ++i) series[i][j][1] /= y;
|
|
1837
|
+
}
|
|
1838
|
+
none$1(series, order);
|
|
1839
|
+
}
|
|
1840
|
+
function diverging(series, order) {
|
|
1841
|
+
if (!((n = series.length) > 0)) return;
|
|
1842
|
+
for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) {
|
|
1843
|
+
for (yp = yn = 0, i = 0; i < n; ++i) {
|
|
1844
|
+
if ((dy = (d = series[order[i]][j])[1] - d[0]) > 0) {
|
|
1845
|
+
d[0] = yp, d[1] = yp += dy;
|
|
1846
|
+
} else if (dy < 0) {
|
|
1847
|
+
d[1] = yn, d[0] = yn += dy;
|
|
1848
|
+
} else {
|
|
1849
|
+
d[0] = 0, d[1] = dy;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
function silhouette(series, order) {
|
|
1855
|
+
if (!((n = series.length) > 0)) return;
|
|
1856
|
+
for (var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j) {
|
|
1857
|
+
for (var i = 0, y = 0; i < n; ++i) y += series[i][j][1] || 0;
|
|
1858
|
+
s0[j][1] += s0[j][0] = -y / 2;
|
|
1859
|
+
}
|
|
1860
|
+
none$1(series, order);
|
|
1861
|
+
}
|
|
1862
|
+
function wiggle(series, order) {
|
|
1863
|
+
if (!((n = series.length) > 0) || !((m = (s0 = series[order[0]]).length) > 0)) return;
|
|
1864
|
+
for (var y = 0, j = 1, s0, m, n; j < m; ++j) {
|
|
1865
|
+
for (var i = 0, s1 = 0, s2 = 0; i < n; ++i) {
|
|
1866
|
+
var si = series[order[i]],
|
|
1867
|
+
sij0 = si[j][1] || 0,
|
|
1868
|
+
sij1 = si[j - 1][1] || 0,
|
|
1869
|
+
s3 = (sij0 - sij1) / 2;
|
|
1870
|
+
for (var k = 0; k < i; ++k) {
|
|
1871
|
+
var sk = series[order[k]],
|
|
1872
|
+
skj0 = sk[j][1] || 0,
|
|
1873
|
+
skj1 = sk[j - 1][1] || 0;
|
|
1874
|
+
s3 += skj0 - skj1;
|
|
1875
|
+
}
|
|
1876
|
+
s1 += sij0, s2 += s3 * sij0;
|
|
1877
|
+
}
|
|
1878
|
+
s0[j - 1][1] += s0[j - 1][0] = y;
|
|
1879
|
+
if (s1) y -= s2 / s1;
|
|
1880
|
+
}
|
|
1881
|
+
s0[j - 1][1] += s0[j - 1][0] = y;
|
|
1882
|
+
none$1(series, order);
|
|
1883
|
+
}
|
|
1884
|
+
function appearance(series) {
|
|
1885
|
+
var peaks = series.map(peak);
|
|
1886
|
+
return none(series).sort(function (a, b) {
|
|
1887
|
+
return peaks[a] - peaks[b];
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
function peak(series) {
|
|
1891
|
+
var i = -1,
|
|
1892
|
+
j = 0,
|
|
1893
|
+
n = series.length,
|
|
1894
|
+
vi,
|
|
1895
|
+
vj = -Infinity;
|
|
1896
|
+
while (++i < n) if ((vi = +series[i][1]) > vj) vj = vi, j = i;
|
|
1897
|
+
return j;
|
|
1898
|
+
}
|
|
1899
|
+
function ascending(series) {
|
|
1900
|
+
var sums = series.map(sum);
|
|
1901
|
+
return none(series).sort(function (a, b) {
|
|
1902
|
+
return sums[a] - sums[b];
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
function sum(series) {
|
|
1906
|
+
var s = 0,
|
|
1907
|
+
i = -1,
|
|
1908
|
+
n = series.length,
|
|
1909
|
+
v;
|
|
1910
|
+
while (++i < n) if (v = +series[i][1]) s += v;
|
|
1911
|
+
return s;
|
|
1912
|
+
}
|
|
1913
|
+
function descending(series) {
|
|
1914
|
+
return ascending(series).reverse();
|
|
1915
|
+
}
|
|
1916
|
+
function insideOut(series) {
|
|
1917
|
+
var n = series.length,
|
|
1918
|
+
i,
|
|
1919
|
+
j,
|
|
1920
|
+
sums = series.map(sum),
|
|
1921
|
+
order = appearance(series),
|
|
1922
|
+
top = 0,
|
|
1923
|
+
bottom = 0,
|
|
1924
|
+
tops = [],
|
|
1925
|
+
bottoms = [];
|
|
1926
|
+
for (i = 0; i < n; ++i) {
|
|
1927
|
+
j = order[i];
|
|
1928
|
+
if (top < bottom) {
|
|
1929
|
+
top += sums[j];
|
|
1930
|
+
tops.push(j);
|
|
1931
|
+
} else {
|
|
1932
|
+
bottom += sums[j];
|
|
1933
|
+
bottoms.push(j);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
return bottoms.reverse().concat(tops);
|
|
1937
|
+
}
|
|
1938
|
+
function reverse(series) {
|
|
1939
|
+
return none(series).reverse();
|
|
1940
|
+
}
|
|
1941
|
+
exports.arc = arc;
|
|
1942
|
+
exports.area = area;
|
|
1943
|
+
exports.areaRadial = areaRadial;
|
|
1944
|
+
exports.curveBasis = basis;
|
|
1945
|
+
exports.curveBasisClosed = basisClosed;
|
|
1946
|
+
exports.curveBasisOpen = basisOpen;
|
|
1947
|
+
exports.curveBumpX = bumpX;
|
|
1948
|
+
exports.curveBumpY = bumpY;
|
|
1949
|
+
exports.curveBundle = bundle;
|
|
1950
|
+
exports.curveCardinal = cardinal;
|
|
1951
|
+
exports.curveCardinalClosed = cardinalClosed;
|
|
1952
|
+
exports.curveCardinalOpen = cardinalOpen;
|
|
1953
|
+
exports.curveCatmullRom = catmullRom;
|
|
1954
|
+
exports.curveCatmullRomClosed = catmullRomClosed;
|
|
1955
|
+
exports.curveCatmullRomOpen = catmullRomOpen;
|
|
1956
|
+
exports.curveLinear = curveLinear;
|
|
1957
|
+
exports.curveLinearClosed = linearClosed;
|
|
1958
|
+
exports.curveMonotoneX = monotoneX;
|
|
1959
|
+
exports.curveMonotoneY = monotoneY;
|
|
1960
|
+
exports.curveNatural = natural;
|
|
1961
|
+
exports.curveStep = step;
|
|
1962
|
+
exports.curveStepAfter = stepAfter;
|
|
1963
|
+
exports.curveStepBefore = stepBefore;
|
|
1964
|
+
exports.line = line;
|
|
1965
|
+
exports.lineRadial = lineRadial$1;
|
|
1966
|
+
exports.link = link;
|
|
1967
|
+
exports.linkHorizontal = linkHorizontal;
|
|
1968
|
+
exports.linkRadial = linkRadial;
|
|
1969
|
+
exports.linkVertical = linkVertical;
|
|
1970
|
+
exports.pie = pie;
|
|
1971
|
+
exports.pointRadial = pointRadial;
|
|
1972
|
+
exports.radialArea = areaRadial;
|
|
1973
|
+
exports.radialLine = lineRadial$1;
|
|
1974
|
+
exports.stack = stack;
|
|
1975
|
+
exports.stackOffsetDiverging = diverging;
|
|
1976
|
+
exports.stackOffsetExpand = expand;
|
|
1977
|
+
exports.stackOffsetNone = none$1;
|
|
1978
|
+
exports.stackOffsetSilhouette = silhouette;
|
|
1979
|
+
exports.stackOffsetWiggle = wiggle;
|
|
1980
|
+
exports.stackOrderAppearance = appearance;
|
|
1981
|
+
exports.stackOrderAscending = ascending;
|
|
1982
|
+
exports.stackOrderDescending = descending;
|
|
1983
|
+
exports.stackOrderInsideOut = insideOut;
|
|
1984
|
+
exports.stackOrderNone = none;
|
|
1985
|
+
exports.stackOrderReverse = reverse;
|
|
1986
|
+
exports.symbol = Symbol;
|
|
1987
|
+
exports.symbolAsterisk = asterisk;
|
|
1988
|
+
exports.symbolCircle = circle;
|
|
1989
|
+
exports.symbolCross = cross;
|
|
1990
|
+
exports.symbolDiamond = diamond;
|
|
1991
|
+
exports.symbolDiamond2 = diamond2;
|
|
1992
|
+
exports.symbolPlus = plus;
|
|
1993
|
+
exports.symbolSquare = square;
|
|
1994
|
+
exports.symbolSquare2 = square2;
|
|
1995
|
+
exports.symbolStar = star;
|
|
1996
|
+
exports.symbolTimes = times;
|
|
1997
|
+
exports.symbolTriangle = triangle;
|
|
1998
|
+
exports.symbolTriangle2 = triangle2;
|
|
1999
|
+
exports.symbolWye = wye;
|
|
2000
|
+
exports.symbolX = times;
|
|
2001
|
+
exports.symbols = symbolsFill;
|
|
2002
|
+
exports.symbolsFill = symbolsFill;
|
|
2003
|
+
exports.symbolsStroke = symbolsStroke;
|
|
2004
|
+
});
|