@plotdb/chart 3.6.0 → 3.7.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/CHANGELOG.md +16 -0
- package/bundle.js +1139 -40
- package/bundle.min.js +1 -1
- package/package.json +1 -1
- package/utils/anim.js +64 -9
- package/utils/anim.min.js +1 -1
- package/utils/brush.js +4 -2
- package/utils/brush.min.js +1 -1
- package/utils/color.js +37 -0
- package/utils/color.min.js +1 -0
- package/utils/scale.js +235 -29
- package/utils/scale.min.js +1 -1
- package/utils/shape.js +799 -0
- package/utils/shape.min.js +1 -0
package/bundle.js
CHANGED
|
@@ -1498,7 +1498,7 @@ var chart = module.exports;
|
|
|
1498
1498
|
}
|
|
1499
1499
|
}).call(this);
|
|
1500
1500
|
(function(){
|
|
1501
|
-
var e10, e5, e2, tickSpec, ticks, linear, band, scale;
|
|
1501
|
+
var e10, e5, e2, tickSpec, ticks, identity, interpNumber, interpValue, normalize, bisectRight, piecewise, continuous, linear, transformPow, transformSqrt, transformSquare, pow, sqrt, symlog, band, point, pointish, scale;
|
|
1502
1502
|
e10 = Math.sqrt(50);
|
|
1503
1503
|
e5 = Math.sqrt(10);
|
|
1504
1504
|
e2 = Math.sqrt(2);
|
|
@@ -1569,58 +1569,246 @@ var chart = module.exports;
|
|
|
1569
1569
|
}
|
|
1570
1570
|
return results$;
|
|
1571
1571
|
};
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1572
|
+
identity = function(x){
|
|
1573
|
+
return x;
|
|
1574
|
+
};
|
|
1575
|
+
interpNumber = function(a, b){
|
|
1576
|
+
var ref$;
|
|
1577
|
+
ref$ = [+a, +b], a = ref$[0], b = ref$[1];
|
|
1578
|
+
return function(t){
|
|
1579
|
+
return a * (1 - t) + b * t;
|
|
1580
|
+
};
|
|
1581
|
+
};
|
|
1582
|
+
interpValue = function(a, b){
|
|
1583
|
+
if (typeof b === 'number') {
|
|
1584
|
+
return interpNumber(a, b);
|
|
1585
|
+
}
|
|
1586
|
+
if (!((typeof chart != 'undefined' && chart !== null) && chart.utils && chart.utils.anim)) {
|
|
1587
|
+
return function(){
|
|
1588
|
+
return b;
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
return chart.utils.anim.interpolate(a, b);
|
|
1592
|
+
};
|
|
1593
|
+
normalize = function(a, b){
|
|
1594
|
+
a = +a;
|
|
1595
|
+
b = b - a;
|
|
1596
|
+
if (b) {
|
|
1597
|
+
return function(x){
|
|
1598
|
+
return (x - a) / b;
|
|
1599
|
+
};
|
|
1600
|
+
} else {
|
|
1601
|
+
if (isNaN(b)) {
|
|
1602
|
+
return function(){
|
|
1603
|
+
return NaN;
|
|
1604
|
+
};
|
|
1605
|
+
} else {
|
|
1606
|
+
return function(){
|
|
1607
|
+
return 0.5;
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
};
|
|
1612
|
+
bisectRight = function(a, x, lo, hi){
|
|
1613
|
+
var mid;
|
|
1614
|
+
while (lo < hi) {
|
|
1615
|
+
mid = lo + hi >>> 1;
|
|
1616
|
+
if (x < a[mid]) {
|
|
1617
|
+
hi = mid;
|
|
1618
|
+
} else {
|
|
1619
|
+
lo = mid + 1;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
return lo;
|
|
1623
|
+
};
|
|
1624
|
+
piecewise = function(dm, rg, ip){
|
|
1625
|
+
var j, ref$, d0, d1, r0, r1, n, i, ns, res$, i$, ips;
|
|
1626
|
+
j = Math.min(dm.length, rg.length) - 1;
|
|
1627
|
+
if (j <= 1) {
|
|
1628
|
+
ref$ = [dm[0], dm[1], rg[0], rg[1]], d0 = ref$[0], d1 = ref$[1], r0 = ref$[2], r1 = ref$[3];
|
|
1629
|
+
ref$ = d1 < d0
|
|
1630
|
+
? [normalize(d1, d0), ip(r1, r0)]
|
|
1631
|
+
: [normalize(d0, d1), ip(r0, r1)], n = ref$[0], i = ref$[1];
|
|
1632
|
+
return function(x){
|
|
1633
|
+
return i(n(x));
|
|
1634
|
+
};
|
|
1635
|
+
}
|
|
1636
|
+
if (dm[j] < dm[0]) {
|
|
1637
|
+
dm = dm.slice().reverse();
|
|
1638
|
+
rg = rg.slice().reverse();
|
|
1639
|
+
}
|
|
1640
|
+
res$ = [];
|
|
1641
|
+
for (i$ = 0; i$ < j; ++i$) {
|
|
1642
|
+
i = i$;
|
|
1643
|
+
res$.push(normalize(dm[i], dm[i + 1]));
|
|
1644
|
+
}
|
|
1645
|
+
ns = res$;
|
|
1646
|
+
res$ = [];
|
|
1647
|
+
for (i$ = 0; i$ < j; ++i$) {
|
|
1648
|
+
i = i$;
|
|
1649
|
+
res$.push(ip(rg[i], rg[i + 1]));
|
|
1650
|
+
}
|
|
1651
|
+
ips = res$;
|
|
1652
|
+
return function(x){
|
|
1653
|
+
var i;
|
|
1654
|
+
i = bisectRight(dm, x, 1, j) - 1;
|
|
1655
|
+
return ips[i](ns[i](x));
|
|
1656
|
+
};
|
|
1657
|
+
};
|
|
1658
|
+
continuous = function(tf, utf){
|
|
1659
|
+
var ref$, dm, rg, clamp, out, inp, clamper, rescale, s;
|
|
1660
|
+
tf == null && (tf = identity);
|
|
1661
|
+
utf == null && (utf = identity);
|
|
1662
|
+
ref$ = [[0, 1], [0, 1], false], dm = ref$[0], rg = ref$[1], clamp = ref$[2];
|
|
1663
|
+
ref$ = [null, null], out = ref$[0], inp = ref$[1];
|
|
1664
|
+
clamper = function(x){
|
|
1665
|
+
var ref$, a, b;
|
|
1666
|
+
if (!clamp) {
|
|
1667
|
+
return x;
|
|
1668
|
+
}
|
|
1669
|
+
ref$ = [dm[0], dm[Math.min(dm.length, rg.length) - 1]], a = ref$[0], b = ref$[1];
|
|
1670
|
+
if (a > b) {
|
|
1671
|
+
ref$ = [b, a], a = ref$[0], b = ref$[1];
|
|
1672
|
+
}
|
|
1673
|
+
return Math.max(a, Math.min(b, x));
|
|
1674
|
+
};
|
|
1675
|
+
rescale = function(){
|
|
1676
|
+
out = null;
|
|
1677
|
+
inp = null;
|
|
1678
|
+
return s;
|
|
1679
|
+
};
|
|
1575
1680
|
s = function(x){
|
|
1576
|
-
var d0, d1, r0, r1, ref$, t, b;
|
|
1577
1681
|
if (!(x != null) || isNaN(x = +x)) {
|
|
1578
1682
|
return undefined;
|
|
1579
1683
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
if (d1 < d0) {
|
|
1583
|
-
ref$ = [d1, d0, r1, r0], d0 = ref$[0], d1 = ref$[1], r0 = ref$[2], r1 = ref$[3];
|
|
1684
|
+
if (!out) {
|
|
1685
|
+
out = piecewise(dm.map(tf), rg, interpValue);
|
|
1584
1686
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1687
|
+
return out(tf(clamper(x)));
|
|
1688
|
+
};
|
|
1689
|
+
s.invert = function(y){
|
|
1690
|
+
if (!inp) {
|
|
1691
|
+
inp = piecewise(rg, dm.map(tf), interpNumber);
|
|
1692
|
+
}
|
|
1693
|
+
return clamper(utf(inp(y)));
|
|
1589
1694
|
};
|
|
1590
1695
|
s.domain = function(it){
|
|
1591
1696
|
if (!arguments.length) {
|
|
1592
|
-
return
|
|
1697
|
+
return dm.slice();
|
|
1593
1698
|
}
|
|
1594
|
-
|
|
1699
|
+
dm = Array.from(it, function(v){
|
|
1595
1700
|
return +v;
|
|
1596
1701
|
});
|
|
1597
|
-
return
|
|
1702
|
+
return rescale();
|
|
1598
1703
|
};
|
|
1599
1704
|
s.range = function(it){
|
|
1600
1705
|
if (!arguments.length) {
|
|
1601
|
-
return
|
|
1706
|
+
return rg.slice();
|
|
1602
1707
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
});
|
|
1606
|
-
return s;
|
|
1708
|
+
rg = Array.from(it);
|
|
1709
|
+
return rescale();
|
|
1607
1710
|
};
|
|
1608
|
-
s.
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
return
|
|
1711
|
+
s.clamp = function(it){
|
|
1712
|
+
if (!arguments.length) {
|
|
1713
|
+
return clamp;
|
|
1714
|
+
}
|
|
1715
|
+
clamp = !!it;
|
|
1716
|
+
return rescale();
|
|
1614
1717
|
};
|
|
1615
1718
|
s.ticks = function(count){
|
|
1616
1719
|
count == null && (count = 10);
|
|
1617
|
-
return ticks(
|
|
1720
|
+
return ticks(dm[0], dm[dm.length - 1], count);
|
|
1721
|
+
};
|
|
1722
|
+
s._transform = function(t, u){
|
|
1723
|
+
tf = t;
|
|
1724
|
+
utf = u;
|
|
1725
|
+
return rescale();
|
|
1726
|
+
};
|
|
1727
|
+
s._copy = function(c){
|
|
1728
|
+
return c.domain(dm).range(rg).clamp(clamp);
|
|
1729
|
+
};
|
|
1730
|
+
s.copy = function(){
|
|
1731
|
+
return s._copy(continuous(tf, utf));
|
|
1732
|
+
};
|
|
1733
|
+
return s;
|
|
1734
|
+
};
|
|
1735
|
+
linear = function(){
|
|
1736
|
+
return continuous();
|
|
1737
|
+
};
|
|
1738
|
+
transformPow = function(e){
|
|
1739
|
+
return function(x){
|
|
1740
|
+
if (x < 0) {
|
|
1741
|
+
return -Math.pow(-x, e);
|
|
1742
|
+
} else {
|
|
1743
|
+
return Math.pow(x, e);
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
};
|
|
1747
|
+
transformSqrt = function(x){
|
|
1748
|
+
if (x < 0) {
|
|
1749
|
+
return -Math.sqrt(-x);
|
|
1750
|
+
} else {
|
|
1751
|
+
return Math.sqrt(x);
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
transformSquare = function(x){
|
|
1755
|
+
if (x < 0) {
|
|
1756
|
+
return -x * x;
|
|
1757
|
+
} else {
|
|
1758
|
+
return x * x;
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
pow = function(){
|
|
1762
|
+
var s, e, update;
|
|
1763
|
+
s = continuous();
|
|
1764
|
+
e = 1;
|
|
1765
|
+
update = function(){
|
|
1766
|
+
if (e === 1) {
|
|
1767
|
+
return s._transform(identity, identity);
|
|
1768
|
+
} else if (e === 0.5) {
|
|
1769
|
+
return s._transform(transformSqrt, transformSquare);
|
|
1770
|
+
} else {
|
|
1771
|
+
return s._transform(transformPow(e), transformPow(1 / e));
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
s.exponent = function(it){
|
|
1775
|
+
if (!arguments.length) {
|
|
1776
|
+
return e;
|
|
1777
|
+
}
|
|
1778
|
+
e = +it;
|
|
1779
|
+
return update();
|
|
1618
1780
|
};
|
|
1619
1781
|
s.copy = function(){
|
|
1620
|
-
return
|
|
1782
|
+
return s._copy(pow().exponent(e));
|
|
1621
1783
|
};
|
|
1622
1784
|
return s;
|
|
1623
1785
|
};
|
|
1786
|
+
sqrt = function(){
|
|
1787
|
+
return pow().exponent(0.5);
|
|
1788
|
+
};
|
|
1789
|
+
symlog = function(){
|
|
1790
|
+
var s, c, update;
|
|
1791
|
+
s = continuous();
|
|
1792
|
+
c = 1;
|
|
1793
|
+
update = function(){
|
|
1794
|
+
return s._transform(function(x){
|
|
1795
|
+
return Math.sign(x) * Math.log1p(Math.abs(x / c));
|
|
1796
|
+
}, function(x){
|
|
1797
|
+
return Math.sign(x) * Math.expm1(Math.abs(x)) * c;
|
|
1798
|
+
});
|
|
1799
|
+
};
|
|
1800
|
+
s.constant = function(it){
|
|
1801
|
+
if (!arguments.length) {
|
|
1802
|
+
return c;
|
|
1803
|
+
}
|
|
1804
|
+
c = +it;
|
|
1805
|
+
return update();
|
|
1806
|
+
};
|
|
1807
|
+
s.copy = function(){
|
|
1808
|
+
return s._copy(symlog().constant(c));
|
|
1809
|
+
};
|
|
1810
|
+
return update();
|
|
1811
|
+
};
|
|
1624
1812
|
band = function(){
|
|
1625
1813
|
var ref$, dm, idx, r, pi, po, al, step, bw, vals, rescale, s;
|
|
1626
1814
|
ref$ = [[], new Map(), [0, 1], 0, 0, 0.5], dm = ref$[0], idx = ref$[1], r = ref$[2], pi = ref$[3], po = ref$[4], al = ref$[5];
|
|
@@ -1716,9 +1904,27 @@ var chart = module.exports;
|
|
|
1716
1904
|
};
|
|
1717
1905
|
return rescale();
|
|
1718
1906
|
};
|
|
1907
|
+
point = function(){
|
|
1908
|
+
return pointish(band().paddingInner(1));
|
|
1909
|
+
};
|
|
1910
|
+
pointish = function(s){
|
|
1911
|
+
var copy;
|
|
1912
|
+
copy = s.copy;
|
|
1913
|
+
s.padding = s.paddingOuter;
|
|
1914
|
+
delete s.paddingInner;
|
|
1915
|
+
delete s.paddingOuter;
|
|
1916
|
+
s.copy = function(){
|
|
1917
|
+
return pointish(copy());
|
|
1918
|
+
};
|
|
1919
|
+
return s;
|
|
1920
|
+
};
|
|
1719
1921
|
scale = {
|
|
1720
1922
|
linear: linear,
|
|
1923
|
+
pow: pow,
|
|
1924
|
+
sqrt: sqrt,
|
|
1925
|
+
symlog: symlog,
|
|
1721
1926
|
band: band,
|
|
1927
|
+
point: point,
|
|
1722
1928
|
ticks: ticks
|
|
1723
1929
|
};
|
|
1724
1930
|
if (typeof chart != 'undefined' && chart !== null) {
|
|
@@ -1726,7 +1932,843 @@ var chart = module.exports;
|
|
|
1726
1932
|
}
|
|
1727
1933
|
}).call(this);
|
|
1728
1934
|
(function(){
|
|
1729
|
-
var
|
|
1935
|
+
var abs, atan2, cos, sin, sqrt, min, max, pi, halfPi, tau, eps, pEps, tauEps, acos, asin, constant, accessor, Path, intersect, cornerTangents, arc, Linear, curveLinear, cardinalPoint, Cardinal, catmullPoint, CatmullRom, catmullRom, custom, curve, asArray, line, area, shape;
|
|
1936
|
+
abs = Math.abs, atan2 = Math.atan2, cos = Math.cos, sin = Math.sin, sqrt = Math.sqrt, min = Math.min, max = Math.max;
|
|
1937
|
+
pi = Math.PI;
|
|
1938
|
+
halfPi = pi / 2;
|
|
1939
|
+
tau = 2 * pi;
|
|
1940
|
+
eps = 1e-12;
|
|
1941
|
+
pEps = 1e-6;
|
|
1942
|
+
tauEps = tau - pEps;
|
|
1943
|
+
acos = function(x){
|
|
1944
|
+
if (x > 1) {
|
|
1945
|
+
return 0;
|
|
1946
|
+
} else if (x < -1) {
|
|
1947
|
+
return pi;
|
|
1948
|
+
} else {
|
|
1949
|
+
return Math.acos(x);
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
asin = function(x){
|
|
1953
|
+
if (x >= 1) {
|
|
1954
|
+
return halfPi;
|
|
1955
|
+
} else if (x <= -1) {
|
|
1956
|
+
return -halfPi;
|
|
1957
|
+
} else {
|
|
1958
|
+
return Math.asin(x);
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
constant = function(x){
|
|
1962
|
+
return function(){
|
|
1963
|
+
return x;
|
|
1964
|
+
};
|
|
1965
|
+
};
|
|
1966
|
+
accessor = function(v){
|
|
1967
|
+
if (typeof v === 'function') {
|
|
1968
|
+
return v;
|
|
1969
|
+
} else {
|
|
1970
|
+
return constant(+v);
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
Path = function(digits){
|
|
1974
|
+
this._x0 = this._y0 = this._x1 = this._y1 = null;
|
|
1975
|
+
this._ = '';
|
|
1976
|
+
this._k = digits != null && Math.floor(digits) <= 15 ? Math.pow(10, Math.floor(digits)) : null;
|
|
1977
|
+
return this;
|
|
1978
|
+
};
|
|
1979
|
+
Path.prototype = {
|
|
1980
|
+
_a: function(cmd){
|
|
1981
|
+
var vs, res$, i$, to$, k;
|
|
1982
|
+
res$ = [];
|
|
1983
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
1984
|
+
res$.push(arguments[i$]);
|
|
1985
|
+
}
|
|
1986
|
+
vs = res$;
|
|
1987
|
+
k = this._k;
|
|
1988
|
+
return this._ += cmd + (k != null ? vs.map(function(it){
|
|
1989
|
+
return Math.round(it * k) / k;
|
|
1990
|
+
}) : vs).join(',');
|
|
1991
|
+
},
|
|
1992
|
+
moveTo: function(x, y){
|
|
1993
|
+
this._x0 = this._x1 = +x;
|
|
1994
|
+
this._y0 = this._y1 = +y;
|
|
1995
|
+
return this._a('M', this._x0, this._y0);
|
|
1996
|
+
},
|
|
1997
|
+
closePath: function(){
|
|
1998
|
+
if (this._x1 !== null) {
|
|
1999
|
+
this._x1 = this._x0;
|
|
2000
|
+
this._y1 = this._y0;
|
|
2001
|
+
return this._ += 'Z';
|
|
2002
|
+
}
|
|
2003
|
+
},
|
|
2004
|
+
lineTo: function(x, y){
|
|
2005
|
+
this._x1 = +x;
|
|
2006
|
+
this._y1 = +y;
|
|
2007
|
+
return this._a('L', this._x1, this._y1);
|
|
2008
|
+
},
|
|
2009
|
+
bezierCurveTo: function(x1, y1, x2, y2, x, y){
|
|
2010
|
+
this._x1 = +x;
|
|
2011
|
+
this._y1 = +y;
|
|
2012
|
+
return this._a('C', +x1, +y1, +x2, +y2, this._x1, this._y1);
|
|
2013
|
+
},
|
|
2014
|
+
arc: function(x, y, r, a0, a1, ccw){
|
|
2015
|
+
var ref$, dx, dy, x0, y0, cw, da;
|
|
2016
|
+
ref$ = [+x, +y, +r, !!ccw], x = ref$[0], y = ref$[1], r = ref$[2], ccw = ref$[3];
|
|
2017
|
+
if (r < 0) {
|
|
2018
|
+
throw new Error("negative radius: " + r);
|
|
2019
|
+
}
|
|
2020
|
+
dx = r * cos(a0);
|
|
2021
|
+
dy = r * sin(a0);
|
|
2022
|
+
x0 = x + dx;
|
|
2023
|
+
y0 = y + dy;
|
|
2024
|
+
cw = ccw ? 0 : 1;
|
|
2025
|
+
da = ccw
|
|
2026
|
+
? a0 - a1
|
|
2027
|
+
: a1 - a0;
|
|
2028
|
+
if (this._x1 === null) {
|
|
2029
|
+
this._a('M', x0, y0);
|
|
2030
|
+
} else if (abs(this._x1 - x0) > pEps || abs(this._y1 - y0) > pEps) {
|
|
2031
|
+
this._a('L', x0, y0);
|
|
2032
|
+
}
|
|
2033
|
+
if (!r) {
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
if (da < 0) {
|
|
2037
|
+
da = da % tau + tau;
|
|
2038
|
+
}
|
|
2039
|
+
if (da > tauEps) {
|
|
2040
|
+
this._a('A', r, r, 0, 1, cw, x - dx, y - dy);
|
|
2041
|
+
this._x1 = x0;
|
|
2042
|
+
this._y1 = y0;
|
|
2043
|
+
return this._a('A', r, r, 0, 1, cw, this._x1, this._y1);
|
|
2044
|
+
} else if (da > pEps) {
|
|
2045
|
+
this._x1 = x + r * cos(a1);
|
|
2046
|
+
this._y1 = y + r * sin(a1);
|
|
2047
|
+
return this._a('A', r, r, 0, da >= pi ? 1 : 0, cw, this._x1, this._y1);
|
|
2048
|
+
}
|
|
2049
|
+
},
|
|
2050
|
+
toString: function(){
|
|
2051
|
+
return this._;
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
intersect = function(x0, y0, x1, y1, x2, y2, x3, y3){
|
|
2055
|
+
var ref$, x10, y10, x32, y32, t;
|
|
2056
|
+
ref$ = [x1 - x0, y1 - y0, x3 - x2, y3 - y2], x10 = ref$[0], y10 = ref$[1], x32 = ref$[2], y32 = ref$[3];
|
|
2057
|
+
t = y32 * x10 - x32 * y10;
|
|
2058
|
+
if (t * t < eps) {
|
|
2059
|
+
return;
|
|
2060
|
+
}
|
|
2061
|
+
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
2062
|
+
return [x0 + t * x10, y0 + t * y10];
|
|
2063
|
+
};
|
|
2064
|
+
cornerTangents = function(x0, y0, x1, y1, r1, rc, cw){
|
|
2065
|
+
var x01, y01, lo, ox, oy, x11, y11, x10, y10, x00, y00, dx, dy, d2, r, D, d, cx0, cy0, cx1, cy1, dx0, dy0, dx1, dy1;
|
|
2066
|
+
x01 = x0 - x1;
|
|
2067
|
+
y01 = y0 - y1;
|
|
2068
|
+
lo = (cw
|
|
2069
|
+
? rc
|
|
2070
|
+
: -rc) / sqrt(x01 * x01 + y01 * y01);
|
|
2071
|
+
ox = lo * y01;
|
|
2072
|
+
oy = -lo * x01;
|
|
2073
|
+
x11 = x0 + ox;
|
|
2074
|
+
y11 = y0 + oy;
|
|
2075
|
+
x10 = x1 + ox;
|
|
2076
|
+
y10 = y1 + oy;
|
|
2077
|
+
x00 = (x11 + x10) / 2;
|
|
2078
|
+
y00 = (y11 + y10) / 2;
|
|
2079
|
+
dx = x10 - x11;
|
|
2080
|
+
dy = y10 - y11;
|
|
2081
|
+
d2 = dx * dx + dy * dy;
|
|
2082
|
+
r = r1 - rc;
|
|
2083
|
+
D = x11 * y10 - x10 * y11;
|
|
2084
|
+
d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D));
|
|
2085
|
+
cx0 = (D * dy - dx * d) / d2;
|
|
2086
|
+
cy0 = (-D * dx - dy * d) / d2;
|
|
2087
|
+
cx1 = (D * dy + dx * d) / d2;
|
|
2088
|
+
cy1 = (-D * dx + dy * d) / d2;
|
|
2089
|
+
dx0 = cx0 - x00;
|
|
2090
|
+
dy0 = cy0 - y00;
|
|
2091
|
+
dx1 = cx1 - x00;
|
|
2092
|
+
dy1 = cy1 - y00;
|
|
2093
|
+
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) {
|
|
2094
|
+
cx0 = cx1;
|
|
2095
|
+
cy0 = cy1;
|
|
2096
|
+
}
|
|
2097
|
+
return {
|
|
2098
|
+
cx: cx0,
|
|
2099
|
+
cy: cy0,
|
|
2100
|
+
x01: -ox,
|
|
2101
|
+
y01: -oy,
|
|
2102
|
+
x11: cx0 * (r1 / r - 1),
|
|
2103
|
+
y11: cy0 * (r1 / r - 1)
|
|
2104
|
+
};
|
|
2105
|
+
};
|
|
2106
|
+
arc = function(){
|
|
2107
|
+
var inner, outer, corner, padRadius, start, end, pad, digits, shape;
|
|
2108
|
+
inner = function(d){
|
|
2109
|
+
return d.innerRadius;
|
|
2110
|
+
};
|
|
2111
|
+
outer = function(d){
|
|
2112
|
+
return d.outerRadius;
|
|
2113
|
+
};
|
|
2114
|
+
corner = constant(0);
|
|
2115
|
+
padRadius = null;
|
|
2116
|
+
start = function(d){
|
|
2117
|
+
return d.startAngle;
|
|
2118
|
+
};
|
|
2119
|
+
end = function(d){
|
|
2120
|
+
return d.endAngle;
|
|
2121
|
+
};
|
|
2122
|
+
pad = function(d){
|
|
2123
|
+
return d && d.padAngle;
|
|
2124
|
+
};
|
|
2125
|
+
digits = 3;
|
|
2126
|
+
shape = function(){
|
|
2127
|
+
var args, ctx, r0, r1, a0, a1, da, cw, ref$, a01, a11, a00, a10, da0, da1, ap, rp, rc, rc0, rc1, p0, p1, x01, y01, x10, y10, x11, y11, x00, y00, oc, ax, ay, bx, by, kc, lc, t0, t1;
|
|
2128
|
+
args = arguments;
|
|
2129
|
+
ctx = new Path(digits);
|
|
2130
|
+
r0 = +inner.apply(this, args);
|
|
2131
|
+
r1 = +outer.apply(this, args);
|
|
2132
|
+
a0 = start.apply(this, args) - halfPi;
|
|
2133
|
+
a1 = end.apply(this, args) - halfPi;
|
|
2134
|
+
da = abs(a1 - a0);
|
|
2135
|
+
cw = a1 > a0;
|
|
2136
|
+
if (r1 < r0) {
|
|
2137
|
+
ref$ = [r1, r0], r0 = ref$[0], r1 = ref$[1];
|
|
2138
|
+
}
|
|
2139
|
+
if (!(r1 > eps)) {
|
|
2140
|
+
ctx.moveTo(0, 0);
|
|
2141
|
+
} else if (da > tau - eps) {
|
|
2142
|
+
ctx.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
2143
|
+
ctx.arc(0, 0, r1, a0, a1, !cw);
|
|
2144
|
+
if (r0 > eps) {
|
|
2145
|
+
ctx.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
2146
|
+
ctx.arc(0, 0, r0, a1, a0, cw);
|
|
2147
|
+
}
|
|
2148
|
+
} else {
|
|
2149
|
+
ref$ = [a0, a1, a0, a1, da, da], a01 = ref$[0], a11 = ref$[1], a00 = ref$[2], a10 = ref$[3], da0 = ref$[4], da1 = ref$[5];
|
|
2150
|
+
ap = pad.apply(this, args) / 2;
|
|
2151
|
+
rp = ap > eps && (padRadius
|
|
2152
|
+
? +padRadius.apply(this, args)
|
|
2153
|
+
: sqrt(r0 * r0 + r1 * r1));
|
|
2154
|
+
rc = min(abs(r1 - r0) / 2, +corner.apply(this, args));
|
|
2155
|
+
rc0 = rc;
|
|
2156
|
+
rc1 = rc;
|
|
2157
|
+
if (rp > eps) {
|
|
2158
|
+
p0 = asin(rp / r0 * sin(ap));
|
|
2159
|
+
p1 = asin(rp / r1 * sin(ap));
|
|
2160
|
+
if ((da0 -= p0 * 2) > eps) {
|
|
2161
|
+
p0 *= cw
|
|
2162
|
+
? 1
|
|
2163
|
+
: -1;
|
|
2164
|
+
a00 += p0;
|
|
2165
|
+
a10 -= p0;
|
|
2166
|
+
} else {
|
|
2167
|
+
da0 = 0;
|
|
2168
|
+
a00 = a10 = (a0 + a1) / 2;
|
|
2169
|
+
}
|
|
2170
|
+
if ((da1 -= p1 * 2) > eps) {
|
|
2171
|
+
p1 *= cw
|
|
2172
|
+
? 1
|
|
2173
|
+
: -1;
|
|
2174
|
+
a01 += p1;
|
|
2175
|
+
a11 -= p1;
|
|
2176
|
+
} else {
|
|
2177
|
+
da1 = 0;
|
|
2178
|
+
a01 = a11 = (a0 + a1) / 2;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
x01 = r1 * cos(a01);
|
|
2182
|
+
y01 = r1 * sin(a01);
|
|
2183
|
+
x10 = r0 * cos(a10);
|
|
2184
|
+
y10 = r0 * sin(a10);
|
|
2185
|
+
if (rc > eps) {
|
|
2186
|
+
x11 = r1 * cos(a11);
|
|
2187
|
+
y11 = r1 * sin(a11);
|
|
2188
|
+
x00 = r0 * cos(a00);
|
|
2189
|
+
y00 = r0 * sin(a00);
|
|
2190
|
+
if (da < pi) {
|
|
2191
|
+
if (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)) {
|
|
2192
|
+
ax = x01 - oc[0];
|
|
2193
|
+
ay = y01 - oc[1];
|
|
2194
|
+
bx = x11 - oc[0];
|
|
2195
|
+
by = y11 - oc[1];
|
|
2196
|
+
kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2);
|
|
2197
|
+
lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
2198
|
+
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
2199
|
+
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
2200
|
+
} else {
|
|
2201
|
+
rc0 = rc1 = 0;
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
if (!(da1 > eps)) {
|
|
2206
|
+
ctx.moveTo(x01, y01);
|
|
2207
|
+
} else if (rc1 > eps) {
|
|
2208
|
+
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
2209
|
+
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
2210
|
+
ctx.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
2211
|
+
if (rc1 < rc) {
|
|
2212
|
+
ctx.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
2213
|
+
} else {
|
|
2214
|
+
ctx.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
2215
|
+
ctx.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
|
|
2216
|
+
ctx.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
2217
|
+
}
|
|
2218
|
+
} else {
|
|
2219
|
+
ctx.moveTo(x01, y01);
|
|
2220
|
+
ctx.arc(0, 0, r1, a01, a11, !cw);
|
|
2221
|
+
}
|
|
2222
|
+
if (!(r0 > eps) || !(da0 > eps)) {
|
|
2223
|
+
ctx.lineTo(x10, y10);
|
|
2224
|
+
} else if (rc0 > eps) {
|
|
2225
|
+
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
2226
|
+
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
2227
|
+
ctx.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
2228
|
+
if (rc0 < rc) {
|
|
2229
|
+
ctx.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
2230
|
+
} else {
|
|
2231
|
+
ctx.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
2232
|
+
ctx.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
|
|
2233
|
+
ctx.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
2234
|
+
}
|
|
2235
|
+
} else {
|
|
2236
|
+
ctx.arc(0, 0, r0, a10, a00, cw);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
ctx.closePath();
|
|
2240
|
+
return ctx.toString() || null;
|
|
2241
|
+
};
|
|
2242
|
+
shape.centroid = function(){
|
|
2243
|
+
var r, a;
|
|
2244
|
+
r = (+inner.apply(this, arguments) + +outer.apply(this, arguments)) / 2;
|
|
2245
|
+
a = (+start.apply(this, arguments) + +end.apply(this, arguments)) / 2 - pi / 2;
|
|
2246
|
+
return [cos(a) * r, sin(a) * r];
|
|
2247
|
+
};
|
|
2248
|
+
shape.innerRadius = function(it){
|
|
2249
|
+
if (!arguments.length) {
|
|
2250
|
+
return inner;
|
|
2251
|
+
}
|
|
2252
|
+
inner = accessor(it);
|
|
2253
|
+
return shape;
|
|
2254
|
+
};
|
|
2255
|
+
shape.outerRadius = function(it){
|
|
2256
|
+
if (!arguments.length) {
|
|
2257
|
+
return outer;
|
|
2258
|
+
}
|
|
2259
|
+
outer = accessor(it);
|
|
2260
|
+
return shape;
|
|
2261
|
+
};
|
|
2262
|
+
shape.cornerRadius = function(it){
|
|
2263
|
+
if (!arguments.length) {
|
|
2264
|
+
return corner;
|
|
2265
|
+
}
|
|
2266
|
+
corner = accessor(it);
|
|
2267
|
+
return shape;
|
|
2268
|
+
};
|
|
2269
|
+
shape.padRadius = function(it){
|
|
2270
|
+
if (!arguments.length) {
|
|
2271
|
+
return padRadius;
|
|
2272
|
+
}
|
|
2273
|
+
padRadius = it != null ? accessor(it) : null;
|
|
2274
|
+
return shape;
|
|
2275
|
+
};
|
|
2276
|
+
shape.startAngle = function(it){
|
|
2277
|
+
if (!arguments.length) {
|
|
2278
|
+
return start;
|
|
2279
|
+
}
|
|
2280
|
+
start = accessor(it);
|
|
2281
|
+
return shape;
|
|
2282
|
+
};
|
|
2283
|
+
shape.endAngle = function(it){
|
|
2284
|
+
if (!arguments.length) {
|
|
2285
|
+
return end;
|
|
2286
|
+
}
|
|
2287
|
+
end = accessor(it);
|
|
2288
|
+
return shape;
|
|
2289
|
+
};
|
|
2290
|
+
shape.padAngle = function(it){
|
|
2291
|
+
if (!arguments.length) {
|
|
2292
|
+
return pad;
|
|
2293
|
+
}
|
|
2294
|
+
pad = accessor(it);
|
|
2295
|
+
return shape;
|
|
2296
|
+
};
|
|
2297
|
+
shape.digits = function(it){
|
|
2298
|
+
if (!arguments.length) {
|
|
2299
|
+
return digits;
|
|
2300
|
+
}
|
|
2301
|
+
digits = it != null ? Math.floor(it) : null;
|
|
2302
|
+
return shape;
|
|
2303
|
+
};
|
|
2304
|
+
return shape;
|
|
2305
|
+
};
|
|
2306
|
+
Linear = function(ctx){
|
|
2307
|
+
this._context = ctx;
|
|
2308
|
+
return this;
|
|
2309
|
+
};
|
|
2310
|
+
Linear.prototype = {
|
|
2311
|
+
areaStart: function(){
|
|
2312
|
+
return this._line = 0;
|
|
2313
|
+
},
|
|
2314
|
+
areaEnd: function(){
|
|
2315
|
+
return this._line = NaN;
|
|
2316
|
+
},
|
|
2317
|
+
lineStart: function(){
|
|
2318
|
+
return this._point = 0;
|
|
2319
|
+
},
|
|
2320
|
+
lineEnd: function(){
|
|
2321
|
+
if (this._line || (this._line !== 0 && this._point === 1)) {
|
|
2322
|
+
this._context.closePath();
|
|
2323
|
+
}
|
|
2324
|
+
return this._line = 1 - this._line;
|
|
2325
|
+
},
|
|
2326
|
+
point: function(x, y){
|
|
2327
|
+
var ref$;
|
|
2328
|
+
ref$ = [+x, +y], x = ref$[0], y = ref$[1];
|
|
2329
|
+
if (this._point === 0) {
|
|
2330
|
+
this._point = 1;
|
|
2331
|
+
if (this._line) {
|
|
2332
|
+
return this._context.lineTo(x, y);
|
|
2333
|
+
} else {
|
|
2334
|
+
return this._context.moveTo(x, y);
|
|
2335
|
+
}
|
|
2336
|
+
} else {
|
|
2337
|
+
this._point = 2;
|
|
2338
|
+
return this._context.lineTo(x, y);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2342
|
+
curveLinear = function(ctx){
|
|
2343
|
+
return new Linear(ctx);
|
|
2344
|
+
};
|
|
2345
|
+
cardinalPoint = function(o, x, y){
|
|
2346
|
+
var k;
|
|
2347
|
+
k = o._k;
|
|
2348
|
+
return o._context.bezierCurveTo(o._x1 + k * (o._x2 - o._x0), o._y1 + k * (o._y2 - o._y0), o._x2 + k * (o._x1 - x), o._y2 + k * (o._y1 - y), o._x2, o._y2);
|
|
2349
|
+
};
|
|
2350
|
+
Cardinal = function(ctx, tension){
|
|
2351
|
+
this._context = ctx;
|
|
2352
|
+
this._k = (1 - tension) / 6;
|
|
2353
|
+
return this;
|
|
2354
|
+
};
|
|
2355
|
+
Cardinal.prototype = {
|
|
2356
|
+
areaStart: function(){
|
|
2357
|
+
return this._line = 0;
|
|
2358
|
+
},
|
|
2359
|
+
areaEnd: function(){
|
|
2360
|
+
return this._line = NaN;
|
|
2361
|
+
},
|
|
2362
|
+
lineStart: function(){
|
|
2363
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
2364
|
+
return this._point = 0;
|
|
2365
|
+
},
|
|
2366
|
+
lineEnd: function(){
|
|
2367
|
+
if (this._point === 2) {
|
|
2368
|
+
this._context.lineTo(this._x2, this._y2);
|
|
2369
|
+
} else if (this._point === 3) {
|
|
2370
|
+
cardinalPoint(this, this._x1, this._y1);
|
|
2371
|
+
}
|
|
2372
|
+
if (this._line || (this._line !== 0 && this._point === 1)) {
|
|
2373
|
+
this._context.closePath();
|
|
2374
|
+
}
|
|
2375
|
+
return this._line = 1 - this._line;
|
|
2376
|
+
},
|
|
2377
|
+
point: function(x, y){
|
|
2378
|
+
var ref$;
|
|
2379
|
+
ref$ = [+x, +y], x = ref$[0], y = ref$[1];
|
|
2380
|
+
if (this._point === 0) {
|
|
2381
|
+
this._point = 1;
|
|
2382
|
+
if (this._line) {
|
|
2383
|
+
this._context.lineTo(x, y);
|
|
2384
|
+
} else {
|
|
2385
|
+
this._context.moveTo(x, y);
|
|
2386
|
+
}
|
|
2387
|
+
} else if (this._point === 1) {
|
|
2388
|
+
this._point = 2;
|
|
2389
|
+
this._x1 = x;
|
|
2390
|
+
this._y1 = y;
|
|
2391
|
+
} else {
|
|
2392
|
+
this._point = 3;
|
|
2393
|
+
cardinalPoint(this, x, y);
|
|
2394
|
+
}
|
|
2395
|
+
ref$ = [this._x1, this._x2, x], this._x0 = ref$[0], this._x1 = ref$[1], this._x2 = ref$[2];
|
|
2396
|
+
return ref$ = [this._y1, this._y2, y], this._y0 = ref$[0], this._y1 = ref$[1], this._y2 = ref$[2], ref$;
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
catmullPoint = function(o, x, y){
|
|
2400
|
+
var ref$, x1, y1, x2, y2, a, n, b, m;
|
|
2401
|
+
ref$ = [o._x1, o._y1, o._x2, o._y2], x1 = ref$[0], y1 = ref$[1], x2 = ref$[2], y2 = ref$[3];
|
|
2402
|
+
if (o._l01_a > eps) {
|
|
2403
|
+
a = 2 * o._l01_2a + 3 * o._l01_a * o._l12_a + o._l12_2a;
|
|
2404
|
+
n = 3 * o._l01_a * (o._l01_a + o._l12_a);
|
|
2405
|
+
x1 = (x1 * a - o._x0 * o._l12_2a + o._x2 * o._l01_2a) / n;
|
|
2406
|
+
y1 = (y1 * a - o._y0 * o._l12_2a + o._y2 * o._l01_2a) / n;
|
|
2407
|
+
}
|
|
2408
|
+
if (o._l23_a > eps) {
|
|
2409
|
+
b = 2 * o._l23_2a + 3 * o._l23_a * o._l12_a + o._l12_2a;
|
|
2410
|
+
m = 3 * o._l23_a * (o._l23_a + o._l12_a);
|
|
2411
|
+
x2 = (x2 * b + o._x1 * o._l23_2a - x * o._l12_2a) / m;
|
|
2412
|
+
y2 = (y2 * b + o._y1 * o._l23_2a - y * o._l12_2a) / m;
|
|
2413
|
+
}
|
|
2414
|
+
return o._context.bezierCurveTo(x1, y1, x2, y2, o._x2, o._y2);
|
|
2415
|
+
};
|
|
2416
|
+
CatmullRom = function(ctx, alpha){
|
|
2417
|
+
this._context = ctx;
|
|
2418
|
+
this._alpha = alpha;
|
|
2419
|
+
return this;
|
|
2420
|
+
};
|
|
2421
|
+
CatmullRom.prototype = {
|
|
2422
|
+
areaStart: function(){
|
|
2423
|
+
return this._line = 0;
|
|
2424
|
+
},
|
|
2425
|
+
areaEnd: function(){
|
|
2426
|
+
return this._line = NaN;
|
|
2427
|
+
},
|
|
2428
|
+
lineStart: function(){
|
|
2429
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
2430
|
+
return this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
|
|
2431
|
+
},
|
|
2432
|
+
lineEnd: function(){
|
|
2433
|
+
if (this._point === 2) {
|
|
2434
|
+
this._context.lineTo(this._x2, this._y2);
|
|
2435
|
+
} else if (this._point === 3) {
|
|
2436
|
+
this.point(this._x2, this._y2);
|
|
2437
|
+
}
|
|
2438
|
+
if (this._line || (this._line !== 0 && this._point === 1)) {
|
|
2439
|
+
this._context.closePath();
|
|
2440
|
+
}
|
|
2441
|
+
return this._line = 1 - this._line;
|
|
2442
|
+
},
|
|
2443
|
+
point: function(x, y){
|
|
2444
|
+
var ref$, x23, y23;
|
|
2445
|
+
ref$ = [+x, +y], x = ref$[0], y = ref$[1];
|
|
2446
|
+
if (this._point) {
|
|
2447
|
+
x23 = this._x2 - x;
|
|
2448
|
+
y23 = this._y2 - y;
|
|
2449
|
+
this._l23_a = sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
|
|
2450
|
+
}
|
|
2451
|
+
if (this._point === 0) {
|
|
2452
|
+
this._point = 1;
|
|
2453
|
+
if (this._line) {
|
|
2454
|
+
this._context.lineTo(x, y);
|
|
2455
|
+
} else {
|
|
2456
|
+
this._context.moveTo(x, y);
|
|
2457
|
+
}
|
|
2458
|
+
} else if (this._point === 1) {
|
|
2459
|
+
this._point = 2;
|
|
2460
|
+
} else {
|
|
2461
|
+
this._point = 3;
|
|
2462
|
+
catmullPoint(this, x, y);
|
|
2463
|
+
}
|
|
2464
|
+
ref$ = [this._l12_a, this._l23_a], this._l01_a = ref$[0], this._l12_a = ref$[1];
|
|
2465
|
+
ref$ = [this._l12_2a, this._l23_2a], this._l01_2a = ref$[0], this._l12_2a = ref$[1];
|
|
2466
|
+
ref$ = [this._x1, this._x2, x], this._x0 = ref$[0], this._x1 = ref$[1], this._x2 = ref$[2];
|
|
2467
|
+
return ref$ = [this._y1, this._y2, y], this._y0 = ref$[0], this._y1 = ref$[1], this._y2 = ref$[2], ref$;
|
|
2468
|
+
}
|
|
2469
|
+
};
|
|
2470
|
+
catmullRom = (custom = function(alpha){
|
|
2471
|
+
var f;
|
|
2472
|
+
f = function(ctx){
|
|
2473
|
+
if (alpha) {
|
|
2474
|
+
return new CatmullRom(ctx, alpha);
|
|
2475
|
+
} else {
|
|
2476
|
+
return new Cardinal(ctx, 0);
|
|
2477
|
+
}
|
|
2478
|
+
};
|
|
2479
|
+
f.alpha = function(a){
|
|
2480
|
+
return custom(+a);
|
|
2481
|
+
};
|
|
2482
|
+
return f;
|
|
2483
|
+
}, custom(0.5));
|
|
2484
|
+
curve = {
|
|
2485
|
+
linear: curveLinear,
|
|
2486
|
+
catmullRom: catmullRom
|
|
2487
|
+
};
|
|
2488
|
+
asArray = function(x){
|
|
2489
|
+
if (typeof x === 'object' && 'length' in x) {
|
|
2490
|
+
return x;
|
|
2491
|
+
} else {
|
|
2492
|
+
return Array.from(x);
|
|
2493
|
+
}
|
|
2494
|
+
};
|
|
2495
|
+
line = function(x, y){
|
|
2496
|
+
var defined, cv, digits, fx, fy, shape;
|
|
2497
|
+
defined = constant(true);
|
|
2498
|
+
cv = curveLinear;
|
|
2499
|
+
digits = 3;
|
|
2500
|
+
fx = typeof x === 'function'
|
|
2501
|
+
? x
|
|
2502
|
+
: x === undefined
|
|
2503
|
+
? function(p){
|
|
2504
|
+
return p[0];
|
|
2505
|
+
}
|
|
2506
|
+
: constant(x);
|
|
2507
|
+
fy = typeof y === 'function'
|
|
2508
|
+
? y
|
|
2509
|
+
: y === undefined
|
|
2510
|
+
? function(p){
|
|
2511
|
+
return p[1];
|
|
2512
|
+
}
|
|
2513
|
+
: constant(y);
|
|
2514
|
+
shape = function(data){
|
|
2515
|
+
var n, defined0, out, buf, i$, i, ok, d;
|
|
2516
|
+
data = asArray(data);
|
|
2517
|
+
n = data.length;
|
|
2518
|
+
defined0 = false;
|
|
2519
|
+
out = cv(buf = new Path(digits));
|
|
2520
|
+
for (i$ = 0; i$ <= n; ++i$) {
|
|
2521
|
+
i = i$;
|
|
2522
|
+
ok = false;
|
|
2523
|
+
if (i < n) {
|
|
2524
|
+
d = data[i];
|
|
2525
|
+
ok = !!defined(d, i, data);
|
|
2526
|
+
}
|
|
2527
|
+
if (!ok === defined0) {
|
|
2528
|
+
defined0 = !defined0;
|
|
2529
|
+
if (defined0) {
|
|
2530
|
+
out.lineStart();
|
|
2531
|
+
} else {
|
|
2532
|
+
out.lineEnd();
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
if (defined0) {
|
|
2536
|
+
out.point(+fx(d, i, data), +fy(d, i, data));
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
return buf.toString() || null;
|
|
2540
|
+
};
|
|
2541
|
+
shape.x = function(it){
|
|
2542
|
+
if (!arguments.length) {
|
|
2543
|
+
return fx;
|
|
2544
|
+
}
|
|
2545
|
+
fx = accessor(it);
|
|
2546
|
+
return shape;
|
|
2547
|
+
};
|
|
2548
|
+
shape.y = function(it){
|
|
2549
|
+
if (!arguments.length) {
|
|
2550
|
+
return fy;
|
|
2551
|
+
}
|
|
2552
|
+
fy = accessor(it);
|
|
2553
|
+
return shape;
|
|
2554
|
+
};
|
|
2555
|
+
shape.defined = function(it){
|
|
2556
|
+
if (!arguments.length) {
|
|
2557
|
+
return defined;
|
|
2558
|
+
}
|
|
2559
|
+
defined = typeof it === 'function'
|
|
2560
|
+
? it
|
|
2561
|
+
: constant(!!it);
|
|
2562
|
+
return shape;
|
|
2563
|
+
};
|
|
2564
|
+
shape.curve = function(it){
|
|
2565
|
+
if (!arguments.length) {
|
|
2566
|
+
return cv;
|
|
2567
|
+
}
|
|
2568
|
+
cv = it;
|
|
2569
|
+
return shape;
|
|
2570
|
+
};
|
|
2571
|
+
shape.digits = function(it){
|
|
2572
|
+
if (!arguments.length) {
|
|
2573
|
+
return digits;
|
|
2574
|
+
}
|
|
2575
|
+
digits = it != null ? Math.floor(it) : null;
|
|
2576
|
+
return shape;
|
|
2577
|
+
};
|
|
2578
|
+
return shape;
|
|
2579
|
+
};
|
|
2580
|
+
area = function(x0, y0, y1){
|
|
2581
|
+
var x1, defined, cv, digits, shape;
|
|
2582
|
+
x1 = null;
|
|
2583
|
+
defined = constant(true);
|
|
2584
|
+
cv = curveLinear;
|
|
2585
|
+
digits = 3;
|
|
2586
|
+
x0 = typeof x0 === 'function'
|
|
2587
|
+
? x0
|
|
2588
|
+
: x0 === undefined
|
|
2589
|
+
? function(p){
|
|
2590
|
+
return p[0];
|
|
2591
|
+
}
|
|
2592
|
+
: constant(+x0);
|
|
2593
|
+
y0 = typeof y0 === 'function'
|
|
2594
|
+
? y0
|
|
2595
|
+
: y0 === undefined
|
|
2596
|
+
? constant(0)
|
|
2597
|
+
: constant(+y0);
|
|
2598
|
+
y1 = typeof y1 === 'function'
|
|
2599
|
+
? y1
|
|
2600
|
+
: y1 === undefined
|
|
2601
|
+
? function(p){
|
|
2602
|
+
return p[1];
|
|
2603
|
+
}
|
|
2604
|
+
: constant(+y1);
|
|
2605
|
+
shape = function(data){
|
|
2606
|
+
var n, defined0, x0z, y0z, j, out, buf, i$, i, ok, d, k;
|
|
2607
|
+
data = asArray(data);
|
|
2608
|
+
n = data.length;
|
|
2609
|
+
defined0 = false;
|
|
2610
|
+
x0z = new Array(n);
|
|
2611
|
+
y0z = new Array(n);
|
|
2612
|
+
j = 0;
|
|
2613
|
+
out = cv(buf = new Path(digits));
|
|
2614
|
+
for (i$ = 0; i$ <= n; ++i$) {
|
|
2615
|
+
i = i$;
|
|
2616
|
+
ok = false;
|
|
2617
|
+
if (i < n) {
|
|
2618
|
+
d = data[i];
|
|
2619
|
+
ok = !!defined(d, i, data);
|
|
2620
|
+
}
|
|
2621
|
+
if (!ok === defined0) {
|
|
2622
|
+
defined0 = !defined0;
|
|
2623
|
+
if (defined0) {
|
|
2624
|
+
j = i;
|
|
2625
|
+
out.areaStart();
|
|
2626
|
+
out.lineStart();
|
|
2627
|
+
} else {
|
|
2628
|
+
out.lineEnd();
|
|
2629
|
+
out.lineStart();
|
|
2630
|
+
k = i - 1;
|
|
2631
|
+
while (k >= j) {
|
|
2632
|
+
out.point(x0z[k], y0z[k]);
|
|
2633
|
+
k--;
|
|
2634
|
+
}
|
|
2635
|
+
out.lineEnd();
|
|
2636
|
+
out.areaEnd();
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
if (defined0) {
|
|
2640
|
+
x0z[i] = +x0(d, i, data);
|
|
2641
|
+
y0z[i] = +y0(d, i, data);
|
|
2642
|
+
out.point(x1
|
|
2643
|
+
? +x1(d, i, data)
|
|
2644
|
+
: x0z[i], y1
|
|
2645
|
+
? +y1(d, i, data)
|
|
2646
|
+
: y0z[i]);
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
return buf.toString() || null;
|
|
2650
|
+
};
|
|
2651
|
+
shape.x = function(it){
|
|
2652
|
+
if (!arguments.length) {
|
|
2653
|
+
return x0;
|
|
2654
|
+
}
|
|
2655
|
+
x0 = accessor(it);
|
|
2656
|
+
x1 = null;
|
|
2657
|
+
return shape;
|
|
2658
|
+
};
|
|
2659
|
+
shape.x0 = function(it){
|
|
2660
|
+
if (!arguments.length) {
|
|
2661
|
+
return x0;
|
|
2662
|
+
}
|
|
2663
|
+
x0 = accessor(it);
|
|
2664
|
+
return shape;
|
|
2665
|
+
};
|
|
2666
|
+
shape.x1 = function(it){
|
|
2667
|
+
if (!arguments.length) {
|
|
2668
|
+
return x1;
|
|
2669
|
+
}
|
|
2670
|
+
x1 = it != null ? accessor(it) : null;
|
|
2671
|
+
return shape;
|
|
2672
|
+
};
|
|
2673
|
+
shape.y = function(it){
|
|
2674
|
+
if (!arguments.length) {
|
|
2675
|
+
return y0;
|
|
2676
|
+
}
|
|
2677
|
+
y0 = accessor(it);
|
|
2678
|
+
y1 = null;
|
|
2679
|
+
return shape;
|
|
2680
|
+
};
|
|
2681
|
+
shape.y0 = function(it){
|
|
2682
|
+
if (!arguments.length) {
|
|
2683
|
+
return y0;
|
|
2684
|
+
}
|
|
2685
|
+
y0 = accessor(it);
|
|
2686
|
+
return shape;
|
|
2687
|
+
};
|
|
2688
|
+
shape.y1 = function(it){
|
|
2689
|
+
if (!arguments.length) {
|
|
2690
|
+
return y1;
|
|
2691
|
+
}
|
|
2692
|
+
y1 = it != null ? accessor(it) : null;
|
|
2693
|
+
return shape;
|
|
2694
|
+
};
|
|
2695
|
+
shape.defined = function(it){
|
|
2696
|
+
if (!arguments.length) {
|
|
2697
|
+
return defined;
|
|
2698
|
+
}
|
|
2699
|
+
defined = typeof it === 'function'
|
|
2700
|
+
? it
|
|
2701
|
+
: constant(!!it);
|
|
2702
|
+
return shape;
|
|
2703
|
+
};
|
|
2704
|
+
shape.curve = function(it){
|
|
2705
|
+
if (!arguments.length) {
|
|
2706
|
+
return cv;
|
|
2707
|
+
}
|
|
2708
|
+
cv = it;
|
|
2709
|
+
return shape;
|
|
2710
|
+
};
|
|
2711
|
+
shape.digits = function(it){
|
|
2712
|
+
if (!arguments.length) {
|
|
2713
|
+
return digits;
|
|
2714
|
+
}
|
|
2715
|
+
digits = it != null ? Math.floor(it) : null;
|
|
2716
|
+
return shape;
|
|
2717
|
+
};
|
|
2718
|
+
return shape;
|
|
2719
|
+
};
|
|
2720
|
+
shape = {
|
|
2721
|
+
arc: arc,
|
|
2722
|
+
line: line,
|
|
2723
|
+
area: area,
|
|
2724
|
+
curve: curve,
|
|
2725
|
+
path: function(digits){
|
|
2726
|
+
return new Path(digits);
|
|
2727
|
+
}
|
|
2728
|
+
};
|
|
2729
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
2730
|
+
(chart.utils || (chart.utils = {})).shape = shape;
|
|
2731
|
+
}
|
|
2732
|
+
}).call(this);
|
|
2733
|
+
(function(){
|
|
2734
|
+
var clamp, turbo, discrete, quantize, color;
|
|
2735
|
+
clamp = function(v){
|
|
2736
|
+
return Math.max(0, Math.min(255, Math.round(v)));
|
|
2737
|
+
};
|
|
2738
|
+
turbo = function(t){
|
|
2739
|
+
var r, g, b;
|
|
2740
|
+
t = Math.max(0, Math.min(1, t));
|
|
2741
|
+
r = clamp(34.61 + t * (1172.33 - t * (10793.56 - t * (33300.12 - t * (38394.49 - t * 14825.05)))));
|
|
2742
|
+
g = clamp(23.31 + t * (557.33 + t * (1225.33 - t * (3574.96 - t * (1073.77 + t * 707.56)))));
|
|
2743
|
+
b = clamp(27.2 + t * (3211.1 - t * (15327.97 - t * (27814 - t * (22569.18 - t * 6838.66)))));
|
|
2744
|
+
return "rgb(" + r + ", " + g + ", " + b + ")";
|
|
2745
|
+
};
|
|
2746
|
+
discrete = function(range){
|
|
2747
|
+
var n;
|
|
2748
|
+
n = range.length;
|
|
2749
|
+
return function(t){
|
|
2750
|
+
return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
|
|
2751
|
+
};
|
|
2752
|
+
};
|
|
2753
|
+
quantize = function(interpolator, n){
|
|
2754
|
+
var i$, i, results$ = [];
|
|
2755
|
+
for (i$ = 0; i$ < n; ++i$) {
|
|
2756
|
+
i = i$;
|
|
2757
|
+
results$.push(interpolator(i / (n - 1)));
|
|
2758
|
+
}
|
|
2759
|
+
return results$;
|
|
2760
|
+
};
|
|
2761
|
+
color = {
|
|
2762
|
+
turbo: turbo,
|
|
2763
|
+
discrete: discrete,
|
|
2764
|
+
quantize: quantize
|
|
2765
|
+
};
|
|
2766
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
2767
|
+
(chart.utils || (chart.utils = {})).color = color;
|
|
2768
|
+
}
|
|
2769
|
+
}).call(this);
|
|
2770
|
+
(function(){
|
|
2771
|
+
var svgns, now, ease, reNum, color, interpColor, interpString, interpolate, getV, setV, rmV, anim, join;
|
|
1730
2772
|
svgns = "http://www.w3.org/2000/svg";
|
|
1731
2773
|
now = function(){
|
|
1732
2774
|
if (typeof performance != 'undefined' && performance !== null) {
|
|
@@ -1803,7 +2845,10 @@ var chart = module.exports;
|
|
|
1803
2845
|
var ref$, ref1$;
|
|
1804
2846
|
return (ref$ = (ref1$ = Math.round(it)) > 0 ? ref1$ : 0) < 255 ? ref$ : 255;
|
|
1805
2847
|
}), r = ref$[0], g = ref$[1], bl = ref$[2];
|
|
1806
|
-
|
|
2848
|
+
al = isNaN(al)
|
|
2849
|
+
? 1
|
|
2850
|
+
: (ref$ = al > 0 ? al : 0) < 1 ? ref$ : 1;
|
|
2851
|
+
if (al === 1) {
|
|
1807
2852
|
return "rgb(" + r + ", " + g + ", " + bl + ")";
|
|
1808
2853
|
} else {
|
|
1809
2854
|
return "rgba(" + r + ", " + g + ", " + bl + ", " + al + ")";
|
|
@@ -1880,6 +2925,27 @@ var chart = module.exports;
|
|
|
1880
2925
|
}
|
|
1881
2926
|
return interpString(a, b);
|
|
1882
2927
|
};
|
|
2928
|
+
getV = function(node, k){
|
|
2929
|
+
if (k.startsWith('style:')) {
|
|
2930
|
+
return node.style.getPropertyValue(k.slice(6));
|
|
2931
|
+
} else {
|
|
2932
|
+
return node.getAttribute(k);
|
|
2933
|
+
}
|
|
2934
|
+
};
|
|
2935
|
+
setV = function(node, k, v){
|
|
2936
|
+
if (k.startsWith('style:')) {
|
|
2937
|
+
return node.style.setProperty(k.slice(6), v);
|
|
2938
|
+
} else {
|
|
2939
|
+
return node.setAttribute(k, v);
|
|
2940
|
+
}
|
|
2941
|
+
};
|
|
2942
|
+
rmV = function(node, k){
|
|
2943
|
+
if (k.startsWith('style:')) {
|
|
2944
|
+
return node.style.removeProperty(k.slice(6));
|
|
2945
|
+
} else {
|
|
2946
|
+
return node.removeAttribute(k);
|
|
2947
|
+
}
|
|
2948
|
+
};
|
|
1883
2949
|
anim = function(opt){
|
|
1884
2950
|
var this$ = this;
|
|
1885
2951
|
opt == null && (opt = {});
|
|
@@ -2018,13 +3084,22 @@ var chart = module.exports;
|
|
|
2018
3084
|
for (k in attrs) {
|
|
2019
3085
|
v = attrs[k];
|
|
2020
3086
|
if (!(v != null)) {
|
|
2021
|
-
node
|
|
3087
|
+
rmV(node, k);
|
|
2022
3088
|
delete item.attr[k];
|
|
2023
3089
|
continue;
|
|
2024
3090
|
}
|
|
2025
3091
|
if (immediate) {
|
|
2026
|
-
node
|
|
3092
|
+
setV(node, k, typeof v === 'function' ? v(1) : v);
|
|
3093
|
+
delete item.attr[k];
|
|
3094
|
+
} else if (k.startsWith('style:') && !node.style.getPropertyValue(k.slice(6)) && window.getComputedStyle(node).getPropertyValue(k.slice(6)) === v + "") {
|
|
2027
3095
|
delete item.attr[k];
|
|
3096
|
+
} else if (typeof v === 'function') {
|
|
3097
|
+
item.attr[k] = {
|
|
3098
|
+
fn: v,
|
|
3099
|
+
start: start,
|
|
3100
|
+
dur: dur > 0 ? dur : 0,
|
|
3101
|
+
ease: ez
|
|
3102
|
+
};
|
|
2028
3103
|
} else {
|
|
2029
3104
|
item.attr[k] = {
|
|
2030
3105
|
to: v,
|
|
@@ -2069,15 +3144,25 @@ var chart = module.exports;
|
|
|
2069
3144
|
if (t < a.start) {
|
|
2070
3145
|
continue;
|
|
2071
3146
|
}
|
|
3147
|
+
if (a.fn) {
|
|
3148
|
+
p = a.dur ? (ref2$ = (t - a.start) / a.dur) < 1 ? ref2$ : 1 : 1;
|
|
3149
|
+
setV(node, k, a.fn(p >= 1
|
|
3150
|
+
? 1
|
|
3151
|
+
: a.ease(p)));
|
|
3152
|
+
if (p >= 1) {
|
|
3153
|
+
delete item.attr[k];
|
|
3154
|
+
}
|
|
3155
|
+
continue;
|
|
3156
|
+
}
|
|
2072
3157
|
if (!a.interp) {
|
|
2073
|
-
a.interp = interpolate(node
|
|
3158
|
+
a.interp = interpolate(getV(node, k), a.to);
|
|
2074
3159
|
}
|
|
2075
3160
|
p = a.dur ? (ref2$ = (t - a.start) / a.dur) < 1 ? ref2$ : 1 : 1;
|
|
2076
3161
|
if (p >= 1) {
|
|
2077
|
-
node
|
|
3162
|
+
setV(node, k, a.to);
|
|
2078
3163
|
delete item.attr[k];
|
|
2079
3164
|
} else {
|
|
2080
|
-
node
|
|
3165
|
+
setV(node, k, a.interp(a.ease(p)));
|
|
2081
3166
|
}
|
|
2082
3167
|
}
|
|
2083
3168
|
if (!(fn$()).length) {
|
|
@@ -2095,7 +3180,7 @@ var chart = module.exports;
|
|
|
2095
3180
|
}
|
|
2096
3181
|
});
|
|
2097
3182
|
join = function(arg$){
|
|
2098
|
-
var root, tag, ref$, cls, data, key, olds, map, enter, update, nodes, exit;
|
|
3183
|
+
var root, tag, ref$, cls, data, key, olds, map, enter, update, nodes, exit, nx, i$, i, n;
|
|
2099
3184
|
root = arg$.root, tag = (ref$ = arg$.tag) != null ? ref$ : 'g', cls = arg$.cls, data = (ref$ = arg$.data) != null
|
|
2100
3185
|
? ref$
|
|
2101
3186
|
: [], key = arg$.key;
|
|
@@ -2127,12 +3212,24 @@ var chart = module.exports;
|
|
|
2127
3212
|
if (cls) {
|
|
2128
3213
|
n.setAttribute('class', cls);
|
|
2129
3214
|
}
|
|
2130
|
-
|
|
3215
|
+
n._entering = true;
|
|
2131
3216
|
enter.push(n);
|
|
2132
3217
|
}
|
|
2133
3218
|
n.__data__ = d;
|
|
2134
3219
|
return nodes.push(n);
|
|
2135
3220
|
});
|
|
3221
|
+
nx = null;
|
|
3222
|
+
for (i$ = nodes.length - 1; i$ >= 0; --i$) {
|
|
3223
|
+
i = i$;
|
|
3224
|
+
n = nodes[i];
|
|
3225
|
+
if (!n._entering) {
|
|
3226
|
+
nx = n;
|
|
3227
|
+
continue;
|
|
3228
|
+
}
|
|
3229
|
+
delete n._entering;
|
|
3230
|
+
root.insertBefore(n, nx);
|
|
3231
|
+
nx = n;
|
|
3232
|
+
}
|
|
2136
3233
|
exit = exit.concat(Array.from(map.values()));
|
|
2137
3234
|
return {
|
|
2138
3235
|
enter: enter,
|
|
@@ -2245,8 +3342,10 @@ var chart = module.exports;
|
|
|
2245
3342
|
this._g = g;
|
|
2246
3343
|
g.setAttribute('fill', 'none');
|
|
2247
3344
|
g.setAttribute('pointer-events', 'all');
|
|
2248
|
-
|
|
2249
|
-
|
|
3345
|
+
if (((typeof navigator != 'undefined' && navigator !== null) && navigator.maxTouchPoints) || 'ontouchstart' in g) {
|
|
3346
|
+
g.style.touchAction = 'none';
|
|
3347
|
+
g.style.setProperty('-webkit-tap-highlight-color', "rgba(0,0,0,0)");
|
|
3348
|
+
}
|
|
2250
3349
|
mk = function(cls, type, attrs){
|
|
2251
3350
|
var n, k, v;
|
|
2252
3351
|
attrs == null && (attrs = {});
|