From d335adea31f1bb1b195686b2a7f16a38c18a14de Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 2 Jun 2020 00:01:33 -0600 Subject: [PATCH] fix: use d3-delaunay --- .eslintrc | 10 +- .gitignore | 1 + {src/d3 => d3}/entry.js | 12 +- d3/rollup.config.js | 22 + package.json | 83 +- size-plugin.json | 2 +- src/.eslintrc | 5 - src/components/Voronoi.js | 21 +- src/d3/index.js | 1 - src/d3/rollup.config.js | 18 - src/hooks/usePropsMemo.js | 21 - src/primitives/Circle.js | 18 +- src/primitives/Group.js | 6 +- src/primitives/Line.js | 24 +- src/primitives/Path.js | 16 +- src/primitives/Text.js | 16 +- src/seriesTypes/Area.js | 148 +- src/seriesTypes/Bar.js | 153 +- src/seriesTypes/Bubble.js | 109 +- src/seriesTypes/Line.js | 167 +- src/utils/Curves.js | 4 +- src/utils/buildAxis.linear.js | 2 +- stats.html | 2 +- yarn.lock | 5713 +++++++++++++++++++-------------- 24 files changed, 3807 insertions(+), 2767 deletions(-) rename {src/d3 => d3}/entry.js (72%) create mode 100644 d3/rollup.config.js delete mode 100644 src/.eslintrc delete mode 100644 src/d3/index.js delete mode 100644 src/d3/rollup.config.js delete mode 100644 src/hooks/usePropsMemo.js diff --git a/.eslintrc b/.eslintrc index 05544ddd..177e296a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,4 @@ { - "parser": "babel-eslint", - "extends": ["react-app", "prettier"], - "env": { - "es6": true - }, - "parserOptions": { - "sourceType": "module" - } + "extends": ["react-app", "prettier"] + // "parser": "babel-eslint" } diff --git a/.gitignore b/.gitignore index b98237d1..79c2a87f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ build dist artifacts .rpt2_cache +d3/index.js # misc .DS_Store diff --git a/src/d3/entry.js b/d3/entry.js similarity index 72% rename from src/d3/entry.js rename to d3/entry.js index 5664d52b..5e9b0021 100644 --- a/src/d3/entry.js +++ b/d3/entry.js @@ -1,12 +1,6 @@ -export {voronoi} from 'd3-voronoi' +export { Delaunay } from 'd3-delaunay' -export { - scaleLinear, - scaleLog, - scaleTime, - scaleUtc, - scaleBand -} from "d3-scale" +export { scaleLinear, scaleLog, scaleTime, scaleUtc, scaleBand } from 'd3-scale' export { arc, @@ -31,4 +25,4 @@ export { curveStep, curveStepAfter, curveStepBefore, -} from 'd3-shape' \ No newline at end of file +} from 'd3-shape' diff --git a/d3/rollup.config.js b/d3/rollup.config.js new file mode 100644 index 00000000..fb4700e4 --- /dev/null +++ b/d3/rollup.config.js @@ -0,0 +1,22 @@ +import path from 'path' +import node from 'rollup-plugin-node-resolve' +// import { terser } from 'rollup-plugin-terser' + +export default [ + { + input: path.join(__dirname, 'entry.js'), + output: { + format: 'es', + file: path.join(__dirname, 'index.js'), + }, + plugins: [node()], + onwarn, + }, +] + +function onwarn(message) { + if (message.code === 'CIRCULAR_DEPENDENCY') { + return + } + console.error(message) +} diff --git a/package.json b/package.json index c5552b38..d17d8bae 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,11 @@ "test:dev": "jest --watch", "test:ci": "jest", "test:coverage": "yarn test:ci; open coverage/lcov-report/index.html", - "build-d3": "rollup -c src/d3/rollup.config.js", + "build-d3": "rollup -c d3/rollup.config.js", "build": "yarn build-d3 && NODE_ENV=production rollup -c", "now-build": "yarn && cd www && yarn && yarn build", "start": "yarn build-d3 && rollup -c -w", - "prepare": "yarn build", - "prepublishOnly": "yarn test:ci", + "prepublishOnly": "yarn build && yarn test:ci", "release": "yarn publish", "releaseNext": "yarn publish --tag next", "format": "prettier {src,src/**,example/src,example/src/**}/*.{md,js,jsx,tsx} --write", @@ -35,48 +34,58 @@ "files": [ "dist" ], - "peerDependencies": { - "react": "^16.6.3" - }, "dependencies": { "@reach/observe-rect": "^1.1.0", - "d3-delaunay": "^5.2.1", + "@scarf/scarf": "^1.0.0", + "d3-delaunay": "^5.3.0", "d3-scale": "^3.2.1", - "d3-shape": "^1.3.7", - "d3-voronoi": "^1.1.2" + "d3-shape": "^1.3.7" + }, + "peerDependencies": { + "react": "^16.6.3" }, "devDependencies": { - "@babel/preset-env": "^7.9.0", - "@babel/preset-react": "^7.9.4", - "@rollup/plugin-node-resolve": "^7.1.1", - "@rollup/plugin-replace": "^2.3.2", - "@svgr/rollup": "^5.3.0", + "@babel/core": "^7.8.6", + "@babel/preset-env": "^7.8.6", + "@babel/preset-react": "^7.8.3", + "@rollup/plugin-replace": "^2.3.1", + "@svgr/rollup": "^4.3.0", + "@testing-library/react": "^9.4.1", "babel-core": "7.0.0-bridge.0", - "babel-eslint": "10.1.0", - "cross-env": "^7.0.2", - "eslint": "6.8.0", - "eslint-config-prettier": "^6.10.1", - "eslint-config-react-app": "^5.2.1", - "eslint-config-standard": "^14.1.1", - "eslint-config-standard-react": "^9.2.0", - "eslint-plugin-flowtype": "4.7.0", - "eslint-plugin-import": "2.20.1", - "eslint-plugin-jsx-a11y": "6.2.3", - "eslint-plugin-node": "^11.0.0", - "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-react": "7.19.0", - "eslint-plugin-react-hooks": "2.5.1", - "eslint-plugin-standard": "^4.0.1", - "jest": "^26.0.1", - "react": "^16.13.1", - "react-dom": "^16.13.1", - "rollup": "^2.2.0", - "rollup-plugin-babel": "^4.4.0", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-node-resolve": "^5.2.0", + "babel-eslint": "9.x", + "babel-jest": "^24.9.0", + "babel-plugin-transform-async-to-promises": "^0.8.15", + "cross-env": "^5.1.4", + "dtslint": "^3.4.1", + "eslint": "5.x", + "eslint-config-prettier": "^4.3.0", + "eslint-config-react-app": "^4.0.1", + "eslint-config-standard": "^12.0.0", + "eslint-config-standard-react": "^7.0.2", + "eslint-plugin-flowtype": "2.x", + "eslint-plugin-import": "2.x", + "eslint-plugin-jsx-a11y": "6.x", + "eslint-plugin-node": "^9.1.0", + "eslint-plugin-prettier": "^3.1.2", + "eslint-plugin-promise": "^4.1.1", + "eslint-plugin-react": "7.18.3", + "eslint-plugin-react-hooks": "1.5.0", + "eslint-plugin-standard": "^4.0.0", + "is-ci-cli": "^2.0.0", + "jest": "^24.9.0", + "prettier": "^1.19.1", + "react": "^16.13.0", + "react-dom": "^16.13.0", + "react-error-boundary": "^2.2.1", + "rollup": "^1.32.0", + "rollup-plugin-babel": "^4.3.2", + "rollup-plugin-commonjs": "^10.0.0", + "rollup-plugin-jscc": "^1.0.0", + "rollup-plugin-node-resolve": "^5.0.0", "rollup-plugin-peer-deps-external": "^2.2.2", + "rollup-plugin-prettier": "^0.6.0", "rollup-plugin-size": "^0.2.2", - "rollup-plugin-terser": "^5.3.0", + "rollup-plugin-terser": "^5.2.0", "rollup-plugin-visualizer": "^4.0.4" } } diff --git a/size-plugin.json b/size-plugin.json index 29b55347..729cab7b 100644 --- a/size-plugin.json +++ b/size-plugin.json @@ -1 +1 @@ -[{"timestamp":1590788251975,"files":[{"filename":"react-charts.production.min.js","size":36178,"delta":19703}]},{"timestamp":1585154943498,"files":[{"filename":"react-charts.production.min.js","size":16475,"delta":16475}]}] +[{"timestamp":1591076297995,"files":[{"filename":"react-charts.production.min.js","size":38874,"delta":2933}]},{"timestamp":1590960432591,"files":[{"filename":"react-charts.production.min.js","size":35941,"delta":-237}]},{"timestamp":1590788251975,"files":[{"filename":"react-charts.production.min.js","size":36178,"delta":19703}]},{"timestamp":1585154943498,"files":[{"filename":"react-charts.production.min.js","size":16475,"delta":16475}]}] diff --git a/src/.eslintrc b/src/.eslintrc deleted file mode 100644 index 55f121d1..00000000 --- a/src/.eslintrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "env": { - "jest": true - } -} diff --git a/src/components/Voronoi.js b/src/components/Voronoi.js index c9cc8e44..469708bd 100644 --- a/src/components/Voronoi.js +++ b/src/components/Voronoi.js @@ -1,9 +1,8 @@ import React from 'react' -import { voronoi, line } from '../d3' +import { Delaunay, line } from '../../d3' // import ChartContext from '../utils/ChartContext' import Path from '../primitives/Path' -// import Utils from '../utils/Utils' const lineFn = line() @@ -143,23 +142,28 @@ export default function Voronoi() { }) }) - vor = voronoi() - .x(d => d.x) - .y(d => d.y) - .extent(extent)(voronoiData) + const delaunay = Delaunay.from( + voronoiData, + d => d.x, + d => d.y + ) + + const voronoi = delaunay.voronoi(extent.flat()) - polygons = vor.polygons() + polygons = [...voronoi.cellPolygons()] return ( {polygons.map((points, i) => { + const index = points.index + const datum = voronoiData[index].datum const path = lineFn(points) return ( onHover(points.data.datum)} + onMouseEnter={e => onHover(datum)} onMouseLeave={e => onHover(null)} style={{ fill: 'rgba(0,0,0,.2)', @@ -175,6 +179,7 @@ export default function Voronoi() { gridHeight, gridWidth, height, + needsVoronoi, onHover, primaryAxes.length, secondaryAxes.length, diff --git a/src/d3/index.js b/src/d3/index.js deleted file mode 100644 index d45f368e..00000000 --- a/src/d3/index.js +++ /dev/null @@ -1 +0,0 @@ -function t(t){return function(){return t}}function n(t){return t[0]}function e(t){return t[1]}function i(){this._=null}function r(t){t.U=t.C=t.L=t.R=t.P=t.N=null}function o(t,n){var e=n,i=n.R,r=e.U;r?r.L===e?r.L=i:r.R=i:t._=i,i.U=r,e.U=i,e.R=i.L,e.R&&(e.R.U=e),i.L=e}function s(t,n){var e=n,i=n.L,r=e.U;r?r.L===e?r.L=i:r.R=i:t._=i,i.U=r,e.U=i,e.L=i.R,e.L&&(e.L.U=e),i.R=e}function u(t){for(;t.L;)t=t.L;return t}function a(t,n,e,i){var r=[null,null],o=A.push(r)-1;return r.left=t,r.right=n,e&&c(r,t,n,e),i&&c(r,n,t,i),D[t.index].halfedges.push(o),D[n.index].halfedges.push(o),r}function h(t,n,e){var i=[n,e];return i.left=t,i}function c(t,n,e,i){t[0]||t[1]?t.left===e?t[1]=i:t[0]=i:(t[0]=i,t.left=n,t.right=e)}function l(t,n,e,i,r){var o,s=t[0],u=t[1],a=s[0],h=s[1],c=0,l=1,f=u[0]-a,_=u[1]-h;if(o=n-a,f||!(o>0)){if(o/=f,f<0){if(o0){if(o>l)return;o>c&&(c=o)}if(o=i-a,f||!(o<0)){if(o/=f,f<0){if(o>l)return;o>c&&(c=o)}else if(f>0){if(o0)){if(o/=_,_<0){if(o0){if(o>l)return;o>c&&(c=o)}if(o=r-h,_||!(o<0)){if(o/=_,_<0){if(o>l)return;o>c&&(c=o)}else if(_>0){if(o0||l<1)||(c>0&&(t[0]=[a+c*f,h+c*_]),l<1&&(t[1]=[a+l*f,h+l*_]),!0)}}}}}function f(t,n,e,i,r){var o=t[1];if(o)return!0;var s,u,a=t[0],h=t.left,c=t.right,l=h[0],f=h[1],_=c[0],y=c[1],g=(l+_)/2,p=(f+y)/2;if(y===f){if(g=i)return;if(l>_){if(a){if(a[1]>=r)return}else a=[g,e];o=[g,r]}else{if(a){if(a[1]1)if(l>_){if(a){if(a[1]>=r)return}else a=[(e-u)/s,e];o=[(r-u)/s,r]}else{if(a){if(a[1]=i)return}else a=[n,s*n+u];o=[i,s*i+u]}else{if(a){if(a[0]=-E)){var _=a*a+h*h,y=c*c+l*l,g=(l*_-h*y)/f,v=(a*y-c*_)/f,m=x.pop()||new d;m.arc=t,m.site=r,m.x=g+s,m.y=(m.cy=v+u)+Math.sqrt(g*g+v*v),t.circle=m;for(var M=null,w=L._;w;)if(m.yR)u=u.L;else{if(!((r=o-U(u,s))>R)){i>-R?(n=u.P,e=u):r>-R?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}!function(t){D[t.index]={site:t,halfedges:[]}}(t);var h=b(t);if(S.insert(n,h),n||e){if(n===e)return m(n),e=b(n.site),S.insert(h,e),h.edge=e.edge=a(n.site,h.site),v(n),void v(e);if(e){m(n),m(e);var l=n.site,f=l[0],_=l[1],y=t[0]-f,g=t[1]-_,p=e.site,x=p[0]-f,d=p[1]-_,M=2*(y*d-g*x),w=y*y+g*g,T=x*x+d*d,C=[(d*w-g*T)/M+f,(y*T-x*w)/M+_];c(e.edge,l,p,C),h.edge=a(l,t,null,C),e.edge=a(t,p,null,C),v(n),v(e)}else h.edge=a(n.site,h.site)}}function k(t,n){var e=t.site,i=e[0],r=e[1],o=r-n;if(!o)return i;var s=t.P;if(!s)return-1/0;var u=(e=s.site)[0],a=e[1],h=a-n;if(!h)return u;var c=u-i,l=1/o-1/h,f=c/h;return l?(-f+Math.sqrt(f*f-2*l*(c*c/(-2*h)-a+h/2+r-o/2)))/l+i:(i+u)/2}function U(t,n){var e=t.N;if(e)return k(e,n);var i=t.site;return i[1]===n?i[0]:1/0}var S,D,L,A,R=1e-6,E=1e-12;function P(t,n){return n[1]-t[1]||n[0]-t[0]}function F(t,n){var e,r,o,s=t.sort(P).pop();for(A=[],D=new Array(t.length),S=new i,L=new i;;)if(o=p,s&&(!o||s[1]R||Math.abs(r[0][1]-r[1][1])>R)||delete A[o]}(u,a,c,x),function(t,n,e,i){var r,o,s,u,a,c,l,f,_,p,x,d,v=D.length,m=!0;for(r=0;rR||Math.abs(d-_)>R)&&(a.splice(u,0,A.push(h(s,p,Math.abs(x-t)R?[t,Math.abs(f-t)R?[Math.abs(_-i)R?[e,Math.abs(f-e)R?[Math.abs(_-n)n?1:t>=n?0:NaN}function q(t){var n;return 1===t.length&&(n=t,t=function(t,e){return H(n(t),e)}),{left:function(n,e,i,r){for(null==i&&(i=0),null==r&&(r=n.length);i>>1;t(n[o],e)<0?i=o+1:r=o}return i},right:function(n,e,i,r){for(null==i&&(i=0),null==r&&(r=n.length);i>>1;t(n[o],e)>0?r=o:i=o+1}return i}}}F.prototype={constructor:F,polygons:function(){var t=this.edges;return this.cells.map((function(n){var e=n.halfedges.map((function(e){return y(n,t[e])}));return e.data=n.site.data,e}))},triangles:function(){var t=[],n=this.edges;return this.cells.forEach((function(e,i){if(o=(r=e.halfedges).length)for(var r,o,s,u,a,h,c=e.site,l=-1,f=n[r[o-1]],_=f.left===c?f.right:f.left;++l=u)return null;var a=t-r.site[0],h=n-r.site[1],c=a*a+h*h;do{r=o.cells[i=s],s=null,r.halfedges.forEach((function(e){var i=o.edges[e],u=i.left;if(u!==r.site&&u||(u=i.right)){var a=t-u[0],h=n-u[1],l=a*a+h*h;l0)return[t];if((i=n0)for(t=Math.ceil(t/s),n=Math.floor(n/s),o=new Array(r=Math.ceil(n-t+1));++u=0?(o>=O?10:o>=Z?5:o>=I?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=O?10:o>=Z?5:o>=I?2:1)}function B(t,n,e){var i=Math.abs(n-t)/Math.max(0,e),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=i/r;return o>=O?r*=10:o>=Z?r*=5:o>=I&&(r*=2),n>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?new vt(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?new vt(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=ot.exec(t))?new vt(n[1],n[2],n[3],1):(n=st.exec(t))?new vt(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=ut.exec(t))?pt(n[1],n[2],n[3],n[4]):(n=at.exec(t))?pt(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=ht.exec(t))?bt(n[1],n[2]/100,n[3]/100,1):(n=ct.exec(t))?bt(n[1],n[2]/100,n[3]/100,n[4]):lt.hasOwnProperty(t)?gt(lt[t]):"transparent"===t?new vt(NaN,NaN,NaN,0):null}function gt(t){return new vt(t>>16&255,t>>8&255,255&t,1)}function pt(t,n,e,i){return i<=0&&(t=n=e=NaN),new vt(t,n,e,i)}function xt(t){return t instanceof tt||(t=yt(t)),t?new vt((t=t.rgb()).r,t.g,t.b,t.opacity):new vt}function dt(t,n,e,i){return 1===arguments.length?xt(t):new vt(t,n,e,null==i?1:i)}function vt(t,n,e,i){this.r=+t,this.g=+n,this.b=+e,this.opacity=+i}function mt(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)}function Mt(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function wt(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function bt(t,n,e,i){return i<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new Ct(t,n,e,i)}function Tt(t){if(t instanceof Ct)return new Ct(t.h,t.s,t.l,t.opacity);if(t instanceof tt||(t=yt(t)),!t)return new Ct;if(t instanceof Ct)return t;var n=(t=t.rgb()).r/255,e=t.g/255,i=t.b/255,r=Math.min(n,e,i),o=Math.max(n,e,i),s=NaN,u=o-r,a=(o+r)/2;return u?(s=n===o?(e-i)/u+6*(e0&&a<1?0:s,new Ct(s,u,a,t.opacity)}function Ct(t,n,e,i){this.h=+t,this.s=+n,this.l=+e,this.opacity=+i}function Nt(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}function kt(t){return function(){return t}}function Ut(t){return 1==(t=+t)?St:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(i){return Math.pow(t+i*n,e)}}(n,e,t):kt(isNaN(n)?e:n)}}function St(t,n){var e=n-t;return e?function(t,n){return function(e){return t+e*n}}(t,e):kt(isNaN(t)?n:t)}G(tt,yt,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:ft,formatHex:ft,formatHsl:function(){return Tt(this).formatHsl()},formatRgb:_t,toString:_t}),G(vt,dt,K(tt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new vt(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new vt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:mt,formatHex:mt,formatRgb:Mt,toString:Mt})),G(Ct,(function(t,n,e,i){return 1===arguments.length?Tt(t):new Ct(t,n,e,null==i?1:i)}),K(tt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new Ct(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Ct(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,i=e+(e<.5?e:1-e)*n,r=2*e-i;return new vt(Nt(t>=240?t-240:t+120,r,i),Nt(t,r,i),Nt(t<120?t+240:t-120,r,i),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var Dt=function t(n){var e=Ut(n);function i(t,n){var i=e((t=dt(t)).r,(n=dt(n)).r),r=e(t.g,n.g),o=e(t.b,n.b),s=St(t.opacity,n.opacity);return function(n){return t.r=i(n),t.g=r(n),t.b=o(n),t.opacity=s(n),t+""}}return i.gamma=t,i}(1);function Lt(t,n){n||(n=[]);var e,i=t?Math.min(n.length,t.length):0,r=n.slice();return function(o){for(e=0;eo&&(r=n.slice(o,r),u[s]?u[s]+=r:u[++s]=r),(e=e[0])===(i=i[0])?u[s]?u[s]+=i:u[++s]=i:(u[++s]=null,a.push({i:s,x:Et(e,i)})),o=Yt.lastIndex;return on&&(e=t,t=n,n=e),h=function(e){return Math.max(t,Math.min(n,e))}),i=a>2?Vt:$t,r=o=null,l}function l(n){return isNaN(n=+n)?e:(r||(r=i(s.map(t),u,a)))(t(h(n)))}return l.invert=function(e){return h(n((o||(o=i(u,s.map(t),Et)))(e)))},l.domain=function(t){return arguments.length?(s=Array.from(t,jt),c()):s.slice()},l.range=function(t){return arguments.length?(u=Array.from(t),c()):u.slice()},l.rangeRound=function(t){return u=Array.from(t),a=zt,c()},l.clamp=function(t){return arguments.length?(h=!!t||Zt,c()):h!==Zt},l.interpolate=function(t){return arguments.length?(a=t,c()):a},l.unknown=function(t){return arguments.length?(e=t,l):e},function(e,i){return t=e,n=i,c()}}function Wt(){return Xt()(Zt,Zt)}function Qt(t,n){if((e=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var e,i=t.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+t.slice(e+1)]}function Jt(t){return(t=Qt(Math.abs(t)))?t[1]:NaN}var Gt,Kt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function tn(t){if(!(n=Kt.exec(t)))throw new Error("invalid format: "+t);var n;return new nn({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function nn(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function en(t,n){var e=Qt(t,n);if(!e)return t+"";var i=e[0],r=e[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}tn.prototype=nn.prototype,nn.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var rn={"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return en(100*t,n)},r:en,s:function(t,n){var e=Qt(t,n);if(!e)return t+"";var i=e[0],r=e[1],o=r-(Gt=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,s=i.length;return o===s?i:o>s?i+new Array(o-s+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+Qt(t,Math.max(0,n+o-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}};function on(t){return t}var sn,un,an,hn=Array.prototype.map,cn=["y","z","a","f","p","n","ยต","m","","k","M","G","T","P","E","Z","Y"];function ln(t){var n,e,i=void 0===t.grouping||void 0===t.thousands?on:(n=hn.call(t.grouping,Number),e=t.thousands+"",function(t,i){for(var r=t.length,o=[],s=0,u=n[0],a=0;r>0&&u>0&&(a+u+1>i&&(u=Math.max(1,i-a)),o.push(t.substring(r-=u,r+u)),!((a+=u+1)>i));)u=n[s=(s+1)%n.length];return o.reverse().join(e)}),r=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",s=void 0===t.decimal?".":t.decimal+"",u=void 0===t.numerals?on:function(t){return function(n){return n.replace(/[0-9]/g,(function(n){return t[+n]}))}}(hn.call(t.numerals,String)),a=void 0===t.percent?"%":t.percent+"",h=void 0===t.minus?"-":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function l(t){var n=(t=tn(t)).fill,e=t.align,l=t.sign,f=t.symbol,_=t.zero,y=t.width,g=t.comma,p=t.precision,x=t.trim,d=t.type;"n"===d?(g=!0,d="g"):rn[d]||(void 0===p&&(p=12),x=!0,d="g"),(_||"0"===n&&"="===e)&&(_=!0,n="0",e="=");var v="$"===f?r:"#"===f&&/[boxX]/.test(d)?"0"+d.toLowerCase():"",m="$"===f?o:/[%p]/.test(d)?a:"",M=rn[d],w=/[defgprs%]/.test(d);function b(t){var r,o,a,f=v,b=m;if("c"===d)b=M(t)+b,t="";else{var T=(t=+t)<0;if(t=isNaN(t)?c:M(Math.abs(t),p),x&&(t=function(t){t:for(var n,e=t.length,i=1,r=-1;i0){if(!+t[i])break t;r=0}}return r>0?t.slice(0,r)+t.slice(n+1):t}(t)),T&&0==+t&&(T=!1),f=(T?"("===l?l:h:"-"===l||"("===l?"":l)+f,b=("s"===d?cn[8+Gt/3]:"")+b+(T&&"("===l?")":""),w)for(r=-1,o=t.length;++r(a=t.charCodeAt(r))||a>57){b=(46===a?s+t.slice(r+1):t.slice(r))+b,t=t.slice(0,r);break}}g&&!_&&(t=i(t,1/0));var C=f.length+t.length+b.length,N=C>1)+f+t+b+N.slice(C);break;default:t=N+f+t+b}return u(t)}return p=void 0===p?6:/[gprs]/.test(d)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p)),b.toString=function(){return t+""},b}return{format:l,formatPrefix:function(t,n){var e=l(((t=tn(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor(Jt(n)/3))),r=Math.pow(10,-i),o=cn[8+i/3];return function(t){return e(r*t)+o}}}}function fn(t,n,e,i){var r,o=B(t,n,e);switch((i=tn(null==i?",f":i)).type){case"s":var s=Math.max(Math.abs(t),Math.abs(n));return null!=i.precision||isNaN(r=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Jt(n)/3)))-Jt(Math.abs(t)))}(o,s))||(i.precision=r),an(i,s);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(r=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Jt(n)-Jt(t))+1}(o,Math.max(Math.abs(t),Math.abs(n))))||(i.precision=r-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(r=function(t){return Math.max(0,-Jt(Math.abs(t)))}(o))||(i.precision=r-2*("%"===i.type))}return un(i)}function _n(t){var n=t.domain;return t.ticks=function(t){var e=n();return $(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){var i=n();return fn(i[0],i[i.length-1],null==t?10:t,e)},t.nice=function(e){null==e&&(e=10);var i,r=n(),o=0,s=r.length-1,u=r[o],a=r[s];return a0?i=V(u=Math.floor(u/i)*i,a=Math.ceil(a/i)*i,e):i<0&&(i=V(u=Math.ceil(u*i)/i,a=Math.floor(a*i)/i,e)),i>0?(r[o]=Math.floor(u/i)*i,r[s]=Math.ceil(a/i)*i,n(r)):i<0&&(r[o]=Math.ceil(u*i)/i,r[s]=Math.floor(a*i)/i,n(r)),t},t}function yn(){var t=Wt();return t.copy=function(){return Bt(t,yn())},X.apply(t,arguments),_n(t)}function gn(t,n){var e,i=0,r=(t=t.slice()).length-1,o=t[i],s=t[r];return s0){for(;f<=_;++f)for(c=1,h=e(f);ca)break;g.push(l)}}else for(;f<=_;++f)for(c=o-1,h=e(f);c>=1;--c)if(!((l=h*c)a)break;g.push(l)}2*g.length0))return u;do{u.push(s=new Date(+e)),n(e,o),t(e)}while(s=n)for(;t(n),!e(n);)n.setTime(n-1)}),(function(t,i){if(t>=t)if(i<0)for(;++i<=0;)for(;n(t,-1),!e(t););else for(;--i>=0;)for(;n(t,1),!e(t););}))},e&&(r.count=function(n,i){return Tn.setTime(+n),Cn.setTime(+i),t(Tn),t(Cn),Math.floor(e(Tn,Cn))},r.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?r.filter(i?function(n){return i(n)%t==0}:function(n){return r.count(0,n)%t==0}):r:null}),r}var kn=Nn((function(){}),(function(t,n){t.setTime(+t+n)}),(function(t,n){return n-t}));kn.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?Nn((function(n){n.setTime(Math.floor(n/t)*t)}),(function(n,e){n.setTime(+n+e*t)}),(function(n,e){return(e-n)/t})):kn:null};var Un=Nn((function(t){t.setTime(t-t.getMilliseconds())}),(function(t,n){t.setTime(+t+1e3*n)}),(function(t,n){return(n-t)/1e3}),(function(t){return t.getUTCSeconds()})),Sn=Nn((function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds())}),(function(t,n){t.setTime(+t+6e4*n)}),(function(t,n){return(n-t)/6e4}),(function(t){return t.getMinutes()})),Dn=Nn((function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-6e4*t.getMinutes())}),(function(t,n){t.setTime(+t+36e5*n)}),(function(t,n){return(n-t)/36e5}),(function(t){return t.getHours()})),Ln=Nn((function(t){t.setHours(0,0,0,0)}),(function(t,n){t.setDate(t.getDate()+n)}),(function(t,n){return(n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5}),(function(t){return t.getDate()-1}));function An(t){return Nn((function(n){n.setDate(n.getDate()-(n.getDay()+7-t)%7),n.setHours(0,0,0,0)}),(function(t,n){t.setDate(t.getDate()+7*n)}),(function(t,n){return(n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/6048e5}))}var Rn=An(0),En=An(1),Pn=(An(2),An(3),An(4)),Fn=(An(5),An(6),Nn((function(t){t.setDate(1),t.setHours(0,0,0,0)}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t,n){return n.getMonth()-t.getMonth()+12*(n.getFullYear()-t.getFullYear())}),(function(t){return t.getMonth()}))),Yn=Nn((function(t){t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t,n){return n.getFullYear()-t.getFullYear()}),(function(t){return t.getFullYear()}));Yn.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Nn((function(n){n.setFullYear(Math.floor(n.getFullYear()/t)*t),n.setMonth(0,1),n.setHours(0,0,0,0)}),(function(n,e){n.setFullYear(n.getFullYear()+e*t)})):null};var Hn=Nn((function(t){t.setUTCSeconds(0,0)}),(function(t,n){t.setTime(+t+6e4*n)}),(function(t,n){return(n-t)/6e4}),(function(t){return t.getUTCMinutes()})),qn=Nn((function(t){t.setUTCMinutes(0,0,0)}),(function(t,n){t.setTime(+t+36e5*n)}),(function(t,n){return(n-t)/36e5}),(function(t){return t.getUTCHours()})),zn=Nn((function(t){t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCDate(t.getUTCDate()+n)}),(function(t,n){return(n-t)/864e5}),(function(t){return t.getUTCDate()-1}));function jn(t){return Nn((function(n){n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+7-t)%7),n.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCDate(t.getUTCDate()+7*n)}),(function(t,n){return(n-t)/6048e5}))}var On=jn(0),Zn=jn(1),In=(jn(2),jn(3),jn(4)),$n=(jn(5),jn(6),Nn((function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCMonth(t.getUTCMonth()+n)}),(function(t,n){return n.getUTCMonth()-t.getUTCMonth()+12*(n.getUTCFullYear()-t.getUTCFullYear())}),(function(t){return t.getUTCMonth()}))),Vn=Nn((function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n)}),(function(t,n){return n.getUTCFullYear()-t.getUTCFullYear()}),(function(t){return t.getUTCFullYear()}));function Bn(t){if(0<=t.y&&t.y<100){var n=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return n.setFullYear(t.y),n}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Xn(t){if(0<=t.y&&t.y<100){var n=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return n.setUTCFullYear(t.y),n}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Wn(t,n,e){return{y:t,m:n,d:e,H:0,M:0,S:0,L:0}}Vn.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Nn((function(n){n.setUTCFullYear(Math.floor(n.getUTCFullYear()/t)*t),n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)}),(function(n,e){n.setUTCFullYear(n.getUTCFullYear()+e*t)})):null};var Qn,Jn,Gn,Kn={"-":"",_:" ",0:"0"},te=/^\s*\d+/,ne=/^%/,ee=/[\\^$*+?|[\]().{}]/g;function ie(t,n,e){var i=t<0?"-":"",r=(i?-t:t)+"",o=r.length;return i+(o68?1900:2e3),e+i[0].length):-1}function ye(t,n,e){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(e,e+6));return i?(t.Z=i[1]?0:-(i[2]+(i[3]||"00")),e+i[0].length):-1}function ge(t,n,e){var i=te.exec(n.slice(e,e+1));return i?(t.q=3*i[0]-3,e+i[0].length):-1}function pe(t,n,e){var i=te.exec(n.slice(e,e+2));return i?(t.m=i[0]-1,e+i[0].length):-1}function xe(t,n,e){var i=te.exec(n.slice(e,e+2));return i?(t.d=+i[0],e+i[0].length):-1}function de(t,n,e){var i=te.exec(n.slice(e,e+3));return i?(t.m=0,t.d=+i[0],e+i[0].length):-1}function ve(t,n,e){var i=te.exec(n.slice(e,e+2));return i?(t.H=+i[0],e+i[0].length):-1}function me(t,n,e){var i=te.exec(n.slice(e,e+2));return i?(t.M=+i[0],e+i[0].length):-1}function Me(t,n,e){var i=te.exec(n.slice(e,e+2));return i?(t.S=+i[0],e+i[0].length):-1}function we(t,n,e){var i=te.exec(n.slice(e,e+3));return i?(t.L=+i[0],e+i[0].length):-1}function be(t,n,e){var i=te.exec(n.slice(e,e+6));return i?(t.L=Math.floor(i[0]/1e3),e+i[0].length):-1}function Te(t,n,e){var i=ne.exec(n.slice(e,e+1));return i?e+i[0].length:-1}function Ce(t,n,e){var i=te.exec(n.slice(e));return i?(t.Q=+i[0],e+i[0].length):-1}function Ne(t,n,e){var i=te.exec(n.slice(e));return i?(t.s=+i[0],e+i[0].length):-1}function ke(t,n){return ie(t.getDate(),n,2)}function Ue(t,n){return ie(t.getHours(),n,2)}function Se(t,n){return ie(t.getHours()%12||12,n,2)}function De(t,n){return ie(1+Ln.count(Yn(t),t),n,3)}function Le(t,n){return ie(t.getMilliseconds(),n,3)}function Ae(t,n){return Le(t,n)+"000"}function Re(t,n){return ie(t.getMonth()+1,n,2)}function Ee(t,n){return ie(t.getMinutes(),n,2)}function Pe(t,n){return ie(t.getSeconds(),n,2)}function Fe(t){var n=t.getDay();return 0===n?7:n}function Ye(t,n){return ie(Rn.count(Yn(t)-1,t),n,2)}function He(t,n){var e=t.getDay();return t=e>=4||0===e?Pn(t):Pn.ceil(t),ie(Pn.count(Yn(t),t)+(4===Yn(t).getDay()),n,2)}function qe(t){return t.getDay()}function ze(t,n){return ie(En.count(Yn(t)-1,t),n,2)}function je(t,n){return ie(t.getFullYear()%100,n,2)}function Oe(t,n){return ie(t.getFullYear()%1e4,n,4)}function Ze(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+ie(n/60|0,"0",2)+ie(n%60,"0",2)}function Ie(t,n){return ie(t.getUTCDate(),n,2)}function $e(t,n){return ie(t.getUTCHours(),n,2)}function Ve(t,n){return ie(t.getUTCHours()%12||12,n,2)}function Be(t,n){return ie(1+zn.count(Vn(t),t),n,3)}function Xe(t,n){return ie(t.getUTCMilliseconds(),n,3)}function We(t,n){return Xe(t,n)+"000"}function Qe(t,n){return ie(t.getUTCMonth()+1,n,2)}function Je(t,n){return ie(t.getUTCMinutes(),n,2)}function Ge(t,n){return ie(t.getUTCSeconds(),n,2)}function Ke(t){var n=t.getUTCDay();return 0===n?7:n}function ti(t,n){return ie(On.count(Vn(t)-1,t),n,2)}function ni(t,n){var e=t.getUTCDay();return t=e>=4||0===e?In(t):In.ceil(t),ie(In.count(Vn(t),t)+(4===Vn(t).getUTCDay()),n,2)}function ei(t){return t.getUTCDay()}function ii(t,n){return ie(Zn.count(Vn(t)-1,t),n,2)}function ri(t,n){return ie(t.getUTCFullYear()%100,n,2)}function oi(t,n){return ie(t.getUTCFullYear()%1e4,n,4)}function si(){return"+0000"}function ui(){return"%"}function ai(t){return+t}function hi(t){return Math.floor(+t/1e3)}!function(t){Qn=function(t){var n=t.dateTime,e=t.date,i=t.time,r=t.periods,o=t.days,s=t.shortDays,u=t.months,a=t.shortMonths,h=oe(r),c=se(r),l=oe(o),f=se(o),_=oe(s),y=se(s),g=oe(u),p=se(u),x=oe(a),d=se(a),v={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return a[t.getMonth()]},B:function(t){return u[t.getMonth()]},c:null,d:ke,e:ke,f:Ae,H:Ue,I:Se,j:De,L:Le,m:Re,M:Ee,p:function(t){return r[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:ai,s:hi,S:Pe,u:Fe,U:Ye,V:He,w:qe,W:ze,x:null,X:null,y:je,Y:Oe,Z:Ze,"%":ui},m={a:function(t){return s[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return a[t.getUTCMonth()]},B:function(t){return u[t.getUTCMonth()]},c:null,d:Ie,e:Ie,f:We,H:$e,I:Ve,j:Be,L:Xe,m:Qe,M:Je,p:function(t){return r[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:ai,s:hi,S:Ge,u:Ke,U:ti,V:ni,w:ei,W:ii,x:null,X:null,y:ri,Y:oi,Z:si,"%":ui},M={a:function(t,n,e){var i=_.exec(n.slice(e));return i?(t.w=y[i[0].toLowerCase()],e+i[0].length):-1},A:function(t,n,e){var i=l.exec(n.slice(e));return i?(t.w=f[i[0].toLowerCase()],e+i[0].length):-1},b:function(t,n,e){var i=x.exec(n.slice(e));return i?(t.m=d[i[0].toLowerCase()],e+i[0].length):-1},B:function(t,n,e){var i=g.exec(n.slice(e));return i?(t.m=p[i[0].toLowerCase()],e+i[0].length):-1},c:function(t,e,i){return T(t,n,e,i)},d:xe,e:xe,f:be,H:ve,I:ve,j:de,L:we,m:pe,M:me,p:function(t,n,e){var i=h.exec(n.slice(e));return i?(t.p=c[i[0].toLowerCase()],e+i[0].length):-1},q:ge,Q:Ce,s:Ne,S:Me,u:ae,U:he,V:ce,w:ue,W:le,x:function(t,n,i){return T(t,e,n,i)},X:function(t,n,e){return T(t,i,n,e)},y:_e,Y:fe,Z:ye,"%":Te};function w(t,n){return function(e){var i,r,o,s=[],u=-1,a=0,h=t.length;for(e instanceof Date||(e=new Date(+e));++u53)return null;"w"in o||(o.w=1),"Z"in o?(r=(i=Xn(Wn(o.y,0,1))).getUTCDay(),i=r>4||0===r?Zn.ceil(i):Zn(i),i=zn.offset(i,7*(o.V-1)),o.y=i.getUTCFullYear(),o.m=i.getUTCMonth(),o.d=i.getUTCDate()+(o.w+6)%7):(r=(i=Bn(Wn(o.y,0,1))).getDay(),i=r>4||0===r?En.ceil(i):En(i),i=Ln.offset(i,7*(o.V-1)),o.y=i.getFullYear(),o.m=i.getMonth(),o.d=i.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),r="Z"in o?Xn(Wn(o.y,0,1)).getUTCDay():Bn(Wn(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(r+5)%7:o.w+7*o.U-(r+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,Xn(o)):Bn(o)}}function T(t,n,e,i){for(var r,o,s=0,u=n.length,a=e.length;s=a)return-1;if(37===(r=n.charCodeAt(s++))){if(r=n.charAt(s++),!(o=M[r in Kn?n.charAt(s++):r])||(i=o(t,e,i))<0)return-1}else if(r!=e.charCodeAt(i++))return-1}return i}return v.x=w(e,v),v.X=w(i,v),v.c=w(n,v),m.x=w(e,m),m.X=w(i,m),m.c=w(n,m),{format:function(t){var n=w(t+="",v);return n.toString=function(){return t},n},parse:function(t){var n=b(t+="",!1);return n.toString=function(){return t},n},utcFormat:function(t){var n=w(t+="",m);return n.toString=function(){return t},n},utcParse:function(t){var n=b(t+="",!0);return n.toString=function(){return t},n}}}(t),Jn=Qn.format,Qn.parse,Gn=Qn.utcFormat,Qn.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function ci(t){return new Date(t)}function li(t){return t instanceof Date?+t:+new Date(+t)}function fi(t,n,e,i,r,o,s,u,a){var h=Wt(),c=h.invert,l=h.domain,f=a(".%L"),_=a(":%S"),y=a("%I:%M"),g=a("%I %p"),p=a("%a %d"),x=a("%b %d"),d=a("%B"),v=a("%Y"),m=[[s,1,1e3],[s,5,5e3],[s,15,15e3],[s,30,3e4],[o,1,6e4],[o,5,3e5],[o,15,9e5],[o,30,18e5],[r,1,36e5],[r,3,108e5],[r,6,216e5],[r,12,432e5],[i,1,864e5],[i,2,1728e5],[e,1,6048e5],[n,1,2592e6],[n,3,7776e6],[t,1,31536e6]];function M(u){return(s(u)1e-6)if(Math.abs(c*u-a*h)>1e-6&&r){var f=e-o,_=i-s,y=u*u+a*a,g=f*f+_*_,p=Math.sqrt(y),x=Math.sqrt(l),d=r*Math.tan((gi-Math.acos((y+l-g)/(2*p*x)))/2),v=d/x,m=d/p;Math.abs(v-1)>1e-6&&(this._+="L"+(t+v*h)+","+(n+v*c)),this._+="A"+r+","+r+",0,0,"+ +(c*f>h*_)+","+(this._x1=t+m*u)+","+(this._y1=n+m*a)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,i,r,o){t=+t,n=+n,o=!!o;var s=(e=+e)*Math.cos(i),u=e*Math.sin(i),a=t+s,h=n+u,c=1^o,l=o?i-r:r-i;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+a+","+h:(Math.abs(this._x1-a)>1e-6||Math.abs(this._y1-h)>1e-6)&&(this._+="L"+a+","+h),e&&(l<0&&(l=l%pi+pi),l>xi?this._+="A"+e+","+e+",0,1,"+c+","+(t-s)+","+(n-u)+"A"+e+","+e+",0,1,"+c+","+(this._x1=a)+","+(this._y1=h):l>1e-6&&(this._+="A"+e+","+e+",0,"+ +(l>=gi)+","+c+","+(this._x1=t+e*Math.cos(r))+","+(this._y1=n+e*Math.sin(r))))},rect:function(t,n,e,i){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +i+"h"+-e+"Z"},toString:function(){return this._}};var Mi=Math.abs,wi=Math.atan2,bi=Math.cos,Ti=Math.max,Ci=Math.min,Ni=Math.sin,ki=Math.sqrt,Ui=Math.PI,Si=Ui/2,Di=2*Ui;function Li(t){return t>1?0:t<-1?Ui:Math.acos(t)}function Ai(t){return t>=1?Si:t<=-1?-Si:Math.asin(t)}function Ri(t){return t.innerRadius}function Ei(t){return t.outerRadius}function Pi(t){return t.startAngle}function Fi(t){return t.endAngle}function Yi(t){return t&&t.padAngle}function Hi(t,n,e,i,r,o,s,u){var a=e-t,h=i-n,c=s-r,l=u-o,f=l*a-c*h;if(!(f*f<1e-12))return[t+(f=(c*(n-o)-l*(t-r))/f)*a,n+f*h]}function qi(t,n,e,i,r,o,s){var u=t-e,a=n-i,h=(s?o:-o)/ki(u*u+a*a),c=h*a,l=-h*u,f=t+c,_=n+l,y=e+c,g=i+l,p=(f+y)/2,x=(_+g)/2,d=y-f,v=g-_,m=d*d+v*v,M=r-o,w=f*g-y*_,b=(v<0?-1:1)*ki(Ti(0,M*M*m-w*w)),T=(w*v-d*b)/m,C=(-w*d-v*b)/m,N=(w*v+d*b)/m,k=(-w*d+v*b)/m,U=T-p,S=C-x,D=N-p,L=k-x;return U*U+S*S>D*D+L*L&&(T=N,C=k),{cx:T,cy:C,x01:-c,y01:-l,x11:T*(r/M-1),y11:C*(r/M-1)}}function zi(){var t=Ri,n=Ei,e=mi(0),i=null,r=Pi,o=Fi,s=Yi,u=null;function a(){var a,h,c=+t.apply(this,arguments),l=+n.apply(this,arguments),f=r.apply(this,arguments)-Si,_=o.apply(this,arguments)-Si,y=Mi(_-f),g=_>f;if(u||(u=a=vi()),l1e-12)if(y>Di-1e-12)u.moveTo(l*bi(f),l*Ni(f)),u.arc(0,0,l,f,_,!g),c>1e-12&&(u.moveTo(c*bi(_),c*Ni(_)),u.arc(0,0,c,_,f,g));else{var p,x,d=f,v=_,m=f,M=_,w=y,b=y,T=s.apply(this,arguments)/2,C=T>1e-12&&(i?+i.apply(this,arguments):ki(c*c+l*l)),N=Ci(Mi(l-c)/2,+e.apply(this,arguments)),k=N,U=N;if(C>1e-12){var S=Ai(C/c*Ni(T)),D=Ai(C/l*Ni(T));(w-=2*S)>1e-12?(m+=S*=g?1:-1,M-=S):(w=0,m=M=(f+_)/2),(b-=2*D)>1e-12?(d+=D*=g?1:-1,v-=D):(b=0,d=v=(f+_)/2)}var L=l*bi(d),A=l*Ni(d),R=c*bi(M),E=c*Ni(M);if(N>1e-12){var P,F=l*bi(v),Y=l*Ni(v),H=c*bi(m),q=c*Ni(m);if(y1e-12?U>1e-12?(p=qi(H,q,L,A,l,U,g),x=qi(F,Y,R,E,l,U,g),u.moveTo(p.cx+p.x01,p.cy+p.y01),U1e-12&&w>1e-12?k>1e-12?(p=qi(R,E,F,Y,c,-k,g),x=qi(L,A,H,q,c,-k,g),u.lineTo(p.cx+p.x01,p.cy+p.y01),k=c;--l)u.point(p[l],x[l]);u.lineEnd(),u.areaEnd()}g&&(p[h]=+t(f,h,a),x[h]=+e(f,h,a),u.point(n?+n(f,h,a):p[h],i?+i(f,h,a):x[h]))}if(_)return u=null,_+""||null}function h(){return $i().defined(r).curve(s).context(o)}return a.x=function(e){return arguments.length?(t="function"==typeof e?e:mi(+e),n=null,a):t},a.x0=function(n){return arguments.length?(t="function"==typeof n?n:mi(+n),a):t},a.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:mi(+t),a):n},a.y=function(t){return arguments.length?(e="function"==typeof t?t:mi(+t),i=null,a):e},a.y0=function(t){return arguments.length?(e="function"==typeof t?t:mi(+t),a):e},a.y1=function(t){return arguments.length?(i=null==t?null:"function"==typeof t?t:mi(+t),a):i},a.lineX0=a.lineY0=function(){return h().x(t).y(e)},a.lineY1=function(){return h().x(t).y(i)},a.lineX1=function(){return h().x(n).y(e)},a.defined=function(t){return arguments.length?(r="function"==typeof t?t:mi(!!t),a):r},a.curve=function(t){return arguments.length?(s=t,null!=o&&(u=s(o)),a):s},a.context=function(t){return arguments.length?(null==t?o=u=null:u=s(o=t),a):o},a}function Bi(t,n){return nt?1:n>=t?0:NaN}function Xi(t){return t}function Wi(){var t=Xi,n=Bi,e=null,i=mi(0),r=mi(Di),o=mi(0);function s(s){var u,a,h,c,l,f=s.length,_=0,y=new Array(f),g=new Array(f),p=+i.apply(this,arguments),x=Math.min(Di,Math.max(-Di,r.apply(this,arguments)-p)),d=Math.min(Math.abs(x)/f,o.apply(this,arguments)),v=d*(x<0?-1:1);for(u=0;u0&&(_+=l);for(null!=n?y.sort((function(t,e){return n(g[t],g[e])})):null!=e&&y.sort((function(t,n){return e(s[t],s[n])})),u=0,h=_?(x-f*v)/_:0;u0?l*h:0)+v,g[a]={data:s[a],index:u,value:l,startAngle:p,endAngle:c,padAngle:d};return g}return s.value=function(n){return arguments.length?(t="function"==typeof n?n:mi(+n),s):t},s.sortValues=function(t){return arguments.length?(n=t,e=null,s):n},s.sort=function(t){return arguments.length?(e=t,n=null,s):e},s.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:mi(+t),s):i},s.endAngle=function(t){return arguments.length?(r="function"==typeof t?t:mi(+t),s):r},s.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:mi(+t),s):o},s}function Qi(){}function Ji(t,n,e){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+n)/6,(t._y0+4*t._y1+e)/6)}function Gi(t){this._context=t}function Ki(t){return new Gi(t)}function tr(t){this._context=t}function nr(t){return new tr(t)}function er(t){this._context=t}function ir(t){return new er(t)}function rr(t,n){this._basis=new Gi(t),this._beta=n}ji.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._context.lineTo(t,n)}}},Gi.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Ji(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Ji(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},tr.prototype={areaStart:Qi,areaEnd:Qi,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x2=t,this._y2=n;break;case 1:this._point=2,this._x3=t,this._y3=n;break;case 2:this._point=3,this._x4=t,this._y4=n,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+n)/6);break;default:Ji(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},er.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var e=(this._x0+4*this._x1+t)/6,i=(this._y0+4*this._y1+n)/6;this._line?this._context.lineTo(e,i):this._context.moveTo(e,i);break;case 3:this._point=4;default:Ji(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},rr.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,n=this._y,e=t.length-1;if(e>0)for(var i,r=t[0],o=n[0],s=t[e]-r,u=n[e]-o,a=-1;++a<=e;)i=a/e,this._basis.point(this._beta*t[a]+(1-this._beta)*(r+i*s),this._beta*n[a]+(1-this._beta)*(o+i*u));this._x=this._y=null,this._basis.lineEnd()},point:function(t,n){this._x.push(+t),this._y.push(+n)}};var or=function t(n){function e(t){return 1===n?new Gi(t):new rr(t,n)}return e.beta=function(n){return t(+n)},e}(.85);function sr(t,n,e){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-n),t._y2+t._k*(t._y1-e),t._x2,t._y2)}function ur(t,n){this._context=t,this._k=(1-n)/6}ur.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:sr(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2,this._x1=t,this._y1=n;break;case 2:this._point=3;default:sr(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var ar=function t(n){function e(t){return new ur(t,n)}return e.tension=function(n){return t(+n)},e}(0);function hr(t,n){this._context=t,this._k=(1-n)/6}hr.prototype={areaStart:Qi,areaEnd:Qi,lineStart:function(){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,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:sr(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var cr=function t(n){function e(t){return new hr(t,n)}return e.tension=function(n){return t(+n)},e}(0);function lr(t,n){this._context=t,this._k=(1-n)/6}lr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:sr(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var fr=function t(n){function e(t){return new lr(t,n)}return e.tension=function(n){return t(+n)},e}(0);function _r(t,n,e){var i=t._x1,r=t._y1,o=t._x2,s=t._y2;if(t._l01_a>1e-12){var u=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,a=3*t._l01_a*(t._l01_a+t._l12_a);i=(i*u-t._x0*t._l12_2a+t._x2*t._l01_2a)/a,r=(r*u-t._y0*t._l12_2a+t._y2*t._l01_2a)/a}if(t._l23_a>1e-12){var h=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,c=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*h+t._x1*t._l23_2a-n*t._l12_2a)/c,s=(s*h+t._y1*t._l23_2a-e*t._l12_2a)/c}t._context.bezierCurveTo(i,r,o,s,t._x2,t._y2)}function yr(t,n){this._context=t,this._alpha=n}yr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,i=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3;default:_r(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var gr=function t(n){function e(t){return n?new yr(t,n):new ur(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function pr(t,n){this._context=t,this._alpha=n}pr.prototype={areaStart:Qi,areaEnd:Qi,lineStart:function(){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,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,i=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:_r(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var xr=function t(n){function e(t){return n?new pr(t,n):new hr(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function dr(t,n){this._context=t,this._alpha=n}dr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,i=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+i*i,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:_r(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var vr=function t(n){function e(t){return n?new dr(t,n):new lr(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function mr(t){this._context=t}function Mr(t){return new mr(t)}function wr(t){return t<0?-1:1}function br(t,n,e){var i=t._x1-t._x0,r=n-t._x1,o=(t._y1-t._y0)/(i||r<0&&-0),s=(e-t._y1)/(r||i<0&&-0),u=(o*r+s*i)/(i+r);return(wr(o)+wr(s))*Math.min(Math.abs(o),Math.abs(s),.5*Math.abs(u))||0}function Tr(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function Cr(t,n,e){var i=t._x0,r=t._y0,o=t._x1,s=t._y1,u=(o-i)/3;t._context.bezierCurveTo(i+u,r+u*n,o-u,s-u*e,o,s)}function Nr(t){this._context=t}function kr(t){this._context=new Ur(t)}function Ur(t){this._context=t}function Sr(t){return new Nr(t)}function Dr(t){return new kr(t)}function Lr(t){this._context=t}function Ar(t){var n,e,i=t.length-1,r=new Array(i),o=new Array(i),s=new Array(i);for(r[0]=0,o[0]=2,s[0]=t[0]+2*t[1],n=1;n=0;--n)r[n]=(s[n]-r[n+1])/o[n];for(o[i-1]=(t[i]+r[i-1])/2,n=0;n=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,n),this._context.lineTo(t,n);else{var e=this._x*(1-this._t)+t*this._t;this._context.lineTo(e,this._y),this._context.lineTo(e,n)}}this._x=t,this._y=n}};export{zi as arc,Vi as area,Ki as curveBasis,nr as curveBasisClosed,ir as curveBasisOpen,or as curveBundle,ar as curveCardinal,cr as curveCardinalClosed,fr as curveCardinalOpen,gr as curveCatmullRom,xr as curveCatmullRomClosed,vr as curveCatmullRomOpen,Oi as curveLinear,Mr as curveLinearClosed,Sr as curveMonotoneX,Dr as curveMonotoneY,Rr as curveNatural,Pr as curveStep,Yr as curveStepAfter,Fr as curveStepBefore,$i as line,Wi as pie,J as scaleBand,yn as scaleLinear,bn as scaleLog,_i as scaleTime,yi as scaleUtc,Y as voronoi}; diff --git a/src/d3/rollup.config.js b/src/d3/rollup.config.js deleted file mode 100644 index 1abf7ef0..00000000 --- a/src/d3/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import path from 'path' -import node from "rollup-plugin-node-resolve"; -import { terser } from 'rollup-plugin-terser' - -export default { - input: path.join(__dirname, 'entry.js'), - output: { - format: 'es', - file: path.join(__dirname, 'index.js'), - }, - plugins: [node(), terser()], - onwarn: function ( message ) { - if (message.code === 'CIRCULAR_DEPENDENCY') { - return; - } - console.error( message ); - } -}; \ No newline at end of file diff --git a/src/hooks/usePropsMemo.js b/src/hooks/usePropsMemo.js deleted file mode 100644 index e4d70ee7..00000000 --- a/src/hooks/usePropsMemo.js +++ /dev/null @@ -1,21 +0,0 @@ -import React from "react"; -// -import Utils from "../utils/Utils"; - -export default function usePropsMemo(fn, obj = {}) { - const watchRef = React.useRef({ - style: {}, - props: {} - }); - const valueRef = React.useRef(); - - const { style = {}, ...props } = obj; - if ( - Utils.shallowDiff(watchRef.current.style, style) || - Utils.shallowDiff(watchRef.current.props, props) - ) { - watchRef.current = obj; - valueRef.current = fn(); - } - return valueRef.current; -} diff --git a/src/primitives/Circle.js b/src/primitives/Circle.js index 60e3491d..bb9b1ef4 100644 --- a/src/primitives/Circle.js +++ b/src/primitives/Circle.js @@ -1,21 +1,21 @@ -import React from "react"; +import React from 'react' // const defaultStyle = { r: 2, - strokeWidth: "1", - stroke: "#000000", - fill: "#000000", - opacity: 1 -}; + strokeWidth: '1', + stroke: '#000000', + fill: '#000000', + opacity: 1, +} export default function Circle({ x, y, r, style, ...rest }) { const resolvedStyle = { ...defaultStyle, - ...style - }; + ...style, + } return ( - ); + ) } diff --git a/src/primitives/Group.js b/src/primitives/Group.js index 1e7b50b8..042aa11d 100644 --- a/src/primitives/Group.js +++ b/src/primitives/Group.js @@ -1,5 +1,5 @@ -import React from "react"; +import React from 'react' export default React.forwardRef(function Group(props, ref) { - return ; -}); + return +}) diff --git a/src/primitives/Line.js b/src/primitives/Line.js index b58d000e..6cac1668 100644 --- a/src/primitives/Line.js +++ b/src/primitives/Line.js @@ -1,21 +1,17 @@ -import React from "react"; +import React from 'react' // const defaultStyle = { strokeWidth: 1, - fill: "transparent", - opacity: 1 -}; - -export default class Line extends React.Component { - render() { - const { style, ...rest } = this.props; - - const resolvedStyle = { - ...defaultStyle, - ...style - }; + fill: 'transparent', + opacity: 1, +} - return ; +export default function Line({ style, ...rest }) { + const resolvedStyle = { + ...defaultStyle, + ...style, } + + return } diff --git a/src/primitives/Path.js b/src/primitives/Path.js index 5c0dbd70..fe1294fd 100644 --- a/src/primitives/Path.js +++ b/src/primitives/Path.js @@ -1,18 +1,18 @@ -import React from "react"; +import React from 'react' // const defaultStyle = { strokeWidth: 2, - stroke: "#6b6b6b", - fill: "transparent", - opacity: 1 -}; + stroke: '#6b6b6b', + fill: 'transparent', + opacity: 1, +} export default function Path({ style, ...rest }) { const resolvedStyle = { ...defaultStyle, - ...style - }; + ...style, + } - return ; + return } diff --git a/src/primitives/Text.js b/src/primitives/Text.js index fef630e6..3be1569b 100644 --- a/src/primitives/Text.js +++ b/src/primitives/Text.js @@ -1,17 +1,17 @@ -import React from "react"; +import React from 'react' // const defaultStyle = { - fontFamily: "Helvetica", + fontFamily: 'Helvetica', fontSize: 10, - opacity: 1 -}; + opacity: 1, +} -export default function Text ({ style, opacity = 1, ...rest }) { +export default function Text({ style, opacity = 1, ...rest }) { const resolvedStyle = { ...defaultStyle, - ...style - }; + ...style, + } - return ; + return } diff --git a/src/seriesTypes/Area.js b/src/seriesTypes/Area.js index 6e514775..96e134cd 100644 --- a/src/seriesTypes/Area.js +++ b/src/seriesTypes/Area.js @@ -1,24 +1,23 @@ -import React from "react"; -import { area, line } from "../d3"; +import React from 'react' +import { area, line } from '../../d3' // -import Utils from "../utils/Utils"; -import { curveLinear } from "../utils/Curves"; +import Utils from '../utils/Utils' +import { curveLinear } from '../utils/Curves' -import usePropsMemo from "../hooks/usePropsMemo"; -import useSeriesStyle from "../hooks/useSeriesStyle"; -import useDatumStyle from "../hooks/useDatumStyle"; +import useSeriesStyle from '../hooks/useSeriesStyle' +import useDatumStyle from '../hooks/useDatumStyle' -import Path from "../primitives/Path"; -import Line from "../primitives/Line"; +import Path from '../primitives/Path' +import Line from '../primitives/Line' const defaultAreaStyle = { - strokeWidth: 0 -}; + strokeWidth: 0, +} const lineDefaultStyle = { - strokeWidth: 3 -}; + strokeWidth: 3, +} export default function Area({ series, showOrphans, curve }) { const areaFn = React.useMemo( @@ -30,7 +29,7 @@ export default function Area({ series, showOrphans, curve }) { .defined(d => d.defined) .curve(curve), [curve] - ); + ) const lineFn = React.useMemo( () => @@ -40,17 +39,17 @@ export default function Area({ series, showOrphans, curve }) { .defined(d => d.defined) .curve(curve), [curve] - ); + ) const areaPath = React.useMemo(() => areaFn(series.datums), [ areaFn, - series.datums - ]); + series.datums, + ]) const linePath = React.useMemo(() => lineFn(series.datums), [ lineFn, - series.datums - ]); + series.datums, + ]) - const style = useSeriesStyle(series); + const style = useSeriesStyle(series) const areaPathProps = { d: areaPath, @@ -58,13 +57,9 @@ export default function Area({ series, showOrphans, curve }) { ...defaultAreaStyle, ...style, ...style.line, - ...style.area - } - }; - const renderedAreaPath = usePropsMemo( - () => , - areaPathProps - ); + ...style.area, + }, + } const linePathProps = { d: linePath, @@ -72,18 +67,14 @@ export default function Area({ series, showOrphans, curve }) { ...defaultAreaStyle, ...style, ...style.line, - fill: "none" - } - }; - const renderedLinePath = usePropsMemo( - () => , - linePathProps - ); + fill: 'none', + }, + } return ( - {renderedAreaPath} - {renderedLinePath} + + {showOrphans && series.datums.map((datum, index, all) => { return ( @@ -93,83 +84,83 @@ export default function Area({ series, showOrphans, curve }) { datum, style, all, - index + index, }} /> - ); + ) })} - ); + ) } Area.defaultProps = { showOrphans: true, - curve: curveLinear -}; + curve: curveLinear, +} Area.plotDatum = (datum, { primaryAxis, secondaryAxis, xAxis, yAxis }) => { // Turn clamping on for secondaryAxis - secondaryAxis.scale.clamp(true); + secondaryAxis.scale.clamp(true) - datum.primaryCoord = primaryAxis.scale(datum.primary); - datum.secondaryCoord = secondaryAxis.scale(datum.secondary); - datum.x = xAxis.scale(datum.xValue); - datum.y = yAxis.scale(datum.yValue); + datum.primaryCoord = primaryAxis.scale(datum.primary) + datum.secondaryCoord = secondaryAxis.scale(datum.secondary) + datum.x = xAxis.scale(datum.xValue) + datum.y = yAxis.scale(datum.yValue) datum.defined = - Utils.isValidPoint(datum.xValue) && Utils.isValidPoint(datum.yValue); + Utils.isValidPoint(datum.xValue) && Utils.isValidPoint(datum.yValue) datum.base = primaryAxis.vertical ? xAxis.scale(datum.baseValue) - : yAxis.scale(datum.baseValue); + : yAxis.scale(datum.baseValue) // Turn clamping back off for secondaryAxis - secondaryAxis.scale.clamp(false); + secondaryAxis.scale.clamp(false) // Adjust non-bar elements for ordinal scales - if (xAxis.type === "ordinal") { - datum.x += xAxis.tickOffset; + if (xAxis.type === 'ordinal') { + datum.x += xAxis.tickOffset } - if (yAxis.type === "ordinal") { - datum.y += yAxis.tickOffset; + if (yAxis.type === 'ordinal') { + datum.y += yAxis.tickOffset } // Set the default anchor point datum.anchor = { x: datum.x, - y: datum.y - }; + y: datum.y, + } // Set the pointer points (used in voronoi) datum.boundingPoints = [ datum.anchor, { x: primaryAxis.vertical - ? primaryAxis.position === "left" + ? primaryAxis.position === 'left' ? datum.base - 1 : datum.base : datum.anchor.x, y: !primaryAxis.vertical - ? primaryAxis.position === "bottom" + ? primaryAxis.position === 'bottom' ? datum.base - 1 : datum.base - : datum.anchor.y - } - ]; -}; + : datum.anchor.y, + }, + ] +} Area.buildStyles = (series, { defaultColors }) => { const defaults = { // Pass some sane defaults - color: defaultColors[series.index % (defaultColors.length - 1)] - }; + color: defaultColors[series.index % (defaultColors.length - 1)], + } - Utils.buildStyleGetters(series, defaults); -}; + Utils.buildStyleGetters(series, defaults) +} const OrphanLine = function OrphanLine({ datum, style, all, index }) { - const prev = all[index - 1] || { defined: false }; - const next = all[index + 1] || { defined: false }; + const prev = all[index - 1] || { defined: false } + const next = all[index + 1] || { defined: false } - const dataStyle = useDatumStyle(datum); + const dataStyle = useDatumStyle(datum) const lineProps = { x1: !datum || Number.isNaN(datum.x) ? null : datum.x, @@ -181,14 +172,13 @@ const OrphanLine = function OrphanLine({ datum, style, all, index }) { ...style, ...style.line, ...dataStyle, - ...dataStyle.line - } - }; - - return usePropsMemo(() => { - if (!datum.defined || prev.defined || next.defined) { - return null; - } - return ; - }, lineProps); -}; + ...dataStyle.line, + }, + } + + if (!datum.defined || prev.defined || next.defined) { + return null + } + + return +} diff --git a/src/seriesTypes/Bar.js b/src/seriesTypes/Bar.js index e6cdce5a..594278c1 100644 --- a/src/seriesTypes/Bar.js +++ b/src/seriesTypes/Bar.js @@ -1,22 +1,21 @@ -import React from "react"; +import React from 'react' // -import ChartContext from "../utils/ChartContext"; -import Utils from "../utils/Utils"; +import ChartContext from '../utils/ChartContext' +import Utils from '../utils/Utils' -import usePropsMemo from "../hooks/usePropsMemo"; -import useSeriesStyle from "../hooks/useSeriesStyle"; -import useDatumStyle from "../hooks/useDatumStyle"; +import useSeriesStyle from '../hooks/useSeriesStyle' +import useDatumStyle from '../hooks/useDatumStyle' -import Rectangle from "../primitives/Rectangle"; +import Rectangle from '../primitives/Rectangle' export default function Bar({ series }) { - const [{ primaryAxes }] = React.useContext(ChartContext); + const [{ primaryAxes }] = React.useContext(ChartContext) - const style = useSeriesStyle(series); + const style = useSeriesStyle(series) const { barOffset } = series.primaryAxisID ? primaryAxes.find(d => d.id === series.primaryAxisID) - : primaryAxes[0]; + : primaryAxes[0] return ( @@ -27,93 +26,99 @@ export default function Bar({ series }) { {...{ datum, barOffset, - style + style, }} /> - ); + ) })} - ); + ) } function BarPiece({ datum, barOffset, style }) { - const [{ primaryAxes }, setChartState] = React.useContext(ChartContext); - - const x = datum ? datum.x : 0; - const y = datum ? datum.y : 0; - const base = datum ? datum.base : 0; - const size = datum ? datum.size : 0; - let x1; - let y1; - let x2; - let y2; + const [{ primaryAxes }, setChartState] = React.useContext(ChartContext) + + const x = datum ? datum.x : 0 + const y = datum ? datum.y : 0 + const base = datum ? datum.base : 0 + const size = datum ? datum.size : 0 + let x1 + let y1 + let x2 + let y2 if (primaryAxes.find(d => d.vertical)) { - x1 = base; - x2 = x; - y1 = y + barOffset; - y2 = y1 + size; + x1 = base + x2 = x + y1 = y + barOffset + y2 = y1 + size } else { - x1 = x + barOffset; - x2 = x1 + size; - y1 = y; - y2 = base; + x1 = x + barOffset + x2 = x1 + size + y1 = y + y2 = base } - const dataStyle = useDatumStyle(datum); + const dataStyle = useDatumStyle(datum) const rectangleProps = { style: { - pointerEvents: "all", + pointerEvents: 'all', ...style, ...style.rectangle, ...dataStyle, - ...dataStyle.rectangle + ...dataStyle.rectangle, }, x1: Number.isNaN(x1) ? null : x1, y1: Number.isNaN(y1) ? null : y1, x2: Number.isNaN(x2) ? null : x2, y2: Number.isNaN(y2) ? null : y2, - onMouseEnter: e => - setChartState(state => ({ - ...state, - element: datum - })), - onMouseLeave: e => - setChartState(state => ({ - ...state, - element: null - })) - }; - - return usePropsMemo(() => , rectangleProps); + onMouseEnter: React.useCallback( + e => + setChartState(state => ({ + ...state, + element: datum, + })), + [datum, setChartState] + ), + onMouseLeave: React.useCallback( + e => + setChartState(state => ({ + ...state, + element: null, + })), + [setChartState] + ), + } + + return } Bar.plotDatum = (datum, { xAxis, yAxis, primaryAxis, secondaryAxis }) => { // Turn clamping on for secondaryAxis - secondaryAxis.scale.clamp(true); + secondaryAxis.scale.clamp(true) - datum.primaryCoord = primaryAxis.scale(datum.primary); - datum.secondaryCoord = secondaryAxis.scale(datum.secondary); - datum.x = xAxis.scale(datum.xValue); - datum.y = yAxis.scale(datum.yValue); + datum.primaryCoord = primaryAxis.scale(datum.primary) + datum.secondaryCoord = secondaryAxis.scale(datum.secondary) + datum.x = xAxis.scale(datum.xValue) + datum.y = yAxis.scale(datum.yValue) datum.defined = - Utils.isValidPoint(datum.xValue) && Utils.isValidPoint(datum.yValue); - datum.base = secondaryAxis.scale(datum.baseValue); - datum.size = primaryAxis.barSize; + Utils.isValidPoint(datum.xValue) && Utils.isValidPoint(datum.yValue) + datum.base = secondaryAxis.scale(datum.baseValue) + datum.size = primaryAxis.barSize // Turn clamping back off for secondaryAxis - secondaryAxis.scale.clamp(false); + secondaryAxis.scale.clamp(false) if (!secondaryAxis.stacked) { - datum.size = primaryAxis.seriesBarSize; + datum.size = primaryAxis.seriesBarSize // Use the seriesTypeIndex here in case we have mixed types. const seriesBandScaleOffset = primaryAxis.seriesBandScale( datum.seriesTypeIndex - ); + ) if (secondaryAxis.vertical) { - datum.x += seriesBandScaleOffset; + datum.x += seriesBandScaleOffset } else { - datum.y += seriesBandScaleOffset; + datum.y += seriesBandScaleOffset } } @@ -122,14 +127,14 @@ Bar.plotDatum = (datum, { xAxis, yAxis, primaryAxis, secondaryAxis }) => { x: datum.x, y: datum.y, horizontalPadding: secondaryAxis.vertical ? datum.size / 2 : 0, - verticalPadding: secondaryAxis.vertical ? 0 : datum.size / 2 - }; + verticalPadding: secondaryAxis.vertical ? 0 : datum.size / 2, + } // Adjust the anchor point for bars if (!primaryAxis.vertical) { - datum.anchor.x += primaryAxis.type !== "ordinal" ? 0 : datum.size / 2; + datum.anchor.x += primaryAxis.type !== 'ordinal' ? 0 : datum.size / 2 } else { - datum.anchor.y += primaryAxis.type !== "ordinal" ? 0 : datum.size / 2; + datum.anchor.y += primaryAxis.type !== 'ordinal' ? 0 : datum.size / 2 } // Set the pointer points (used in voronoi) @@ -139,24 +144,24 @@ Bar.plotDatum = (datum, { xAxis, yAxis, primaryAxis, secondaryAxis }) => { // Start of bar { x: primaryAxis.vertical - ? primaryAxis.position === "left" + ? primaryAxis.position === 'left' ? datum.base + 1 : datum.base : datum.anchor.x, y: !primaryAxis.vertical - ? primaryAxis.position === "bottom" + ? primaryAxis.position === 'bottom' ? datum.base - 1 : datum.base - : datum.anchor.y - } - ]; -}; + : datum.anchor.y, + }, + ] +} Bar.buildStyles = (series, { defaultColors }) => { const defaults = { // Pass some sane defaults - color: defaultColors[series.index % (defaultColors.length - 1)] - }; + color: defaultColors[series.index % (defaultColors.length - 1)], + } - Utils.buildStyleGetters(series, defaults); -}; + Utils.buildStyleGetters(series, defaults) +} diff --git a/src/seriesTypes/Bubble.js b/src/seriesTypes/Bubble.js index d8948518..084c09df 100644 --- a/src/seriesTypes/Bubble.js +++ b/src/seriesTypes/Bubble.js @@ -1,21 +1,20 @@ -import React from "react"; +import React from 'react' // -import ChartContext from "../utils/ChartContext"; -import Utils from "../utils/Utils"; +import ChartContext from '../utils/ChartContext' +import Utils from '../utils/Utils' -import usePropsMemo from "../hooks/usePropsMemo"; -import useSeriesStyle from "../hooks/useSeriesStyle"; -import useDatumStyle from "../hooks/useDatumStyle"; +import useSeriesStyle from '../hooks/useSeriesStyle' +import useDatumStyle from '../hooks/useDatumStyle' -import Circle from "../primitives/Circle"; +import Circle from '../primitives/Circle' const circleDefaultStyle = { - r: 2 -}; + r: 2, +} export default function Bubble({ series }) { - const style = useSeriesStyle(series); + const style = useSeriesStyle(series) return ( @@ -25,31 +24,31 @@ export default function Bubble({ series }) { {...{ key: i, datum, - style + style, }} /> - ); + ) })} - ); + ) } Bubble.plotDatum = (datum, { primaryAxis, secondaryAxis, xAxis, yAxis }) => { - datum.primaryCoord = primaryAxis.scale(datum.primary); - datum.secondaryCoord = secondaryAxis.scale(datum.secondary); - datum.x = xAxis.scale(datum.xValue); - datum.y = yAxis.scale(datum.yValue); + datum.primaryCoord = primaryAxis.scale(datum.primary) + datum.secondaryCoord = secondaryAxis.scale(datum.secondary) + datum.x = xAxis.scale(datum.xValue) + datum.y = yAxis.scale(datum.yValue) datum.defined = - Utils.isValidPoint(datum.xValue) && Utils.isValidPoint(datum.yValue); + Utils.isValidPoint(datum.xValue) && Utils.isValidPoint(datum.yValue) datum.base = primaryAxis.vertical ? xAxis.scale(datum.baseValue) - : yAxis.scale(datum.baseValue); + : yAxis.scale(datum.baseValue) // Adjust non-bar elements for ordinal scales - if (xAxis.type === "ordinal") { - datum.x += xAxis.tickOffset; + if (xAxis.type === 'ordinal') { + datum.x += xAxis.tickOffset } - if (yAxis.type === "ordinal") { - datum.y += yAxis.tickOffset; + if (yAxis.type === 'ordinal') { + datum.y += yAxis.tickOffset } // Set the default anchor point @@ -57,57 +56,61 @@ Bubble.plotDatum = (datum, { primaryAxis, secondaryAxis, xAxis, yAxis }) => { x: datum.x, y: datum.y, verticalPadding: datum.r, - horizontalPadding: datum.r - }; + horizontalPadding: datum.r, + } // Set the pointer points (used in voronoi) - datum.boundingPoints = [datum.anchor]; -}; + datum.boundingPoints = [datum.anchor] +} Bubble.buildStyles = (series, { defaultColors }) => { const defaults = { // Pass some sane defaults - color: defaultColors[series.index % (defaultColors.length - 1)] - }; + color: defaultColors[series.index % (defaultColors.length - 1)], + } - Utils.buildStyleGetters(series, defaults); -}; + Utils.buildStyleGetters(series, defaults) +} function Point({ datum, style }) { - const dataStyle = useDatumStyle(datum); - const [, setChartState] = React.useContext(ChartContext); + const dataStyle = useDatumStyle(datum) + const [, setChartState] = React.useContext(ChartContext) const circleProps = { x: datum ? datum.x : undefined, y: datum ? datum.y : undefined, style: { ...circleDefaultStyle, - ...(typeof datum.r !== "undefined" + ...(typeof datum.r !== 'undefined' ? { - r: datum.r + r: datum.r, } : {}), ...style, ...style.circle, ...dataStyle, - ...dataStyle.circle + ...dataStyle.circle, }, - onMouseEnter: e => - setChartState(state => ({ - ...state, - element: datum - })), - onMouseLeave: e => - setChartState(state => ({ - ...state, - element: null - })) - }; + onMouseEnter: React.useCallback( + e => + setChartState(state => ({ + ...state, + element: datum, + })), + [datum, setChartState] + ), + onMouseLeave: React.useCallback( + e => + setChartState(state => ({ + ...state, + element: null, + })), + [setChartState] + ), + } - return usePropsMemo(() => { - if (!datum.defined) { - return null; - } - return ; - }, circleProps); + if (!datum.defined) { + return null + } + return } diff --git a/src/seriesTypes/Line.js b/src/seriesTypes/Line.js index 7ae52f3a..d7393f83 100644 --- a/src/seriesTypes/Line.js +++ b/src/seriesTypes/Line.js @@ -1,25 +1,24 @@ -import React from "react"; -import { line } from "../d3"; +import React from 'react' +import { line } from '../../d3' // -import ChartContext from "../utils/ChartContext"; -import Utils from "../utils/Utils"; -import { curveMonotoneX } from "../utils/Curves"; +import ChartContext from '../utils/ChartContext' +import Utils from '../utils/Utils' +import { curveMonotoneX } from '../utils/Curves' -import usePropsMemo from "../hooks/usePropsMemo"; -import useSeriesStyle from "../hooks/useSeriesStyle"; -import useDatumStyle from "../hooks/useDatumStyle"; +import useSeriesStyle from '../hooks/useSeriesStyle' +import useDatumStyle from '../hooks/useDatumStyle' -import Path from "../primitives/Path"; -import Circle from "../primitives/Circle"; +import Path from '../primitives/Path' +import Circle from '../primitives/Circle' const pathDefaultStyle = { - strokeWidth: 2 -}; + strokeWidth: 2, +} const circleDefaultStyle = { - r: 2 -}; + r: 2, +} export default function Line({ series, showPoints, curve }) { const lineFn = React.useMemo( @@ -30,13 +29,13 @@ export default function Line({ series, showPoints, curve }) { .defined(d => d.defined) .curve(curve), [curve] - ); + ) const path = React.useMemo(() => lineFn(series.datums), [ lineFn, - series.datums - ]); + series.datums, + ]) - const style = useSeriesStyle(series); + const style = useSeriesStyle(series) const pathProps = { d: path, @@ -44,79 +43,75 @@ export default function Line({ series, showPoints, curve }) { ...pathDefaultStyle, ...style, ...style.line, - fill: "none" - } - }; - const renderedPath = usePropsMemo(() => , pathProps); - - return React.useMemo( - () => ( - - {renderedPath} - {showPoints && - series.datums.map((datum, i) => { - return ( - - ); - })} - - ), - [renderedPath, series.datums, showPoints, style] - ); + fill: 'none', + }, + } + + return ( + + + {showPoints && + series.datums.map((datum, i) => { + return ( + + ) + })} + + ) } Line.defaultProps = { - curve: curveMonotoneX -}; + curve: curveMonotoneX, +} Line.plotDatum = (datum, { primaryAxis, secondaryAxis, xAxis, yAxis }) => { - datum.primaryCoord = primaryAxis.scale(datum.primary); - datum.secondaryCoord = secondaryAxis.scale(datum.secondary); - datum.x = xAxis.scale(datum.xValue); - datum.y = yAxis.scale(datum.yValue); + datum.primaryCoord = primaryAxis.scale(datum.primary) + datum.secondaryCoord = secondaryAxis.scale(datum.secondary) + datum.x = xAxis.scale(datum.xValue) + datum.y = yAxis.scale(datum.yValue) datum.defined = - Utils.isValidPoint(datum.xValue) && Utils.isValidPoint(datum.yValue); + Utils.isValidPoint(datum.xValue) && Utils.isValidPoint(datum.yValue) datum.base = primaryAxis.vertical ? xAxis.scale(datum.baseValue) - : yAxis.scale(datum.baseValue); + : yAxis.scale(datum.baseValue) // Adjust non-bar elements for ordinal scales - if (xAxis.type === "ordinal") { - datum.x += xAxis.tickOffset; + if (xAxis.type === 'ordinal') { + datum.x += xAxis.tickOffset } - if (yAxis.type === "ordinal") { - datum.y += yAxis.tickOffset; + if (yAxis.type === 'ordinal') { + datum.y += yAxis.tickOffset } // Set the default anchor point datum.anchor = { x: datum.x, - y: datum.y - }; + y: datum.y, + } // Set the pointer points (used in voronoi) - datum.boundingPoints = [datum.anchor]; -}; + datum.boundingPoints = [datum.anchor] +} Line.buildStyles = (series, { defaultColors }) => { const defaults = { // Pass some sane defaults - color: defaultColors[series.index % (defaultColors.length - 1)] - }; + color: defaultColors[series.index % (defaultColors.length - 1)], + } - Utils.buildStyleGetters(series, defaults); -}; + Utils.buildStyleGetters(series, defaults) +} function Point({ datum, style }) { - const [, setChartState] = React.useContext(ChartContext); + const [, setChartState] = React.useContext(ChartContext) - const dataStyle = useDatumStyle(datum); + const dataStyle = useDatumStyle(datum) const circleProps = { x: datum ? datum.x : undefined, @@ -126,23 +121,29 @@ function Point({ datum, style }) { ...style, ...style.circle, ...dataStyle, - ...dataStyle.circle + ...dataStyle.circle, }, - onMouseEnter: e => - setChartState(state => ({ - ...state, - element: datum - })), - onMouseLeave: e => - setChartState(state => ({ - ...state, - element: null - })) - }; - return usePropsMemo(() => { - if (!datum.defined) { - return null; - } - return ; - }, circleProps); + onMouseEnter: React.useCallback( + e => + setChartState(state => ({ + ...state, + element: datum, + })), + [datum, setChartState] + ), + onMouseLeave: React.useCallback( + e => + setChartState(state => ({ + ...state, + element: null, + })), + [setChartState] + ), + } + + if (!datum.defined) { + return null + } + + return } diff --git a/src/utils/Curves.js b/src/utils/Curves.js index bddf7eee..aabb0b00 100644 --- a/src/utils/Curves.js +++ b/src/utils/Curves.js @@ -16,5 +16,5 @@ export { curveNatural, curveStep, curveStepAfter, - curveStepBefore -} from "../d3"; + curveStepBefore, +} from '../../d3' diff --git a/src/utils/buildAxis.linear.js b/src/utils/buildAxis.linear.js index e057c659..3cdb6306 100644 --- a/src/utils/buildAxis.linear.js +++ b/src/utils/buildAxis.linear.js @@ -1,4 +1,4 @@ -import { scaleLinear, scaleLog, scaleTime, scaleUtc, scaleBand } from '../d3' +import { scaleLinear, scaleLog, scaleTime, scaleUtc, scaleBand } from '../../d3' // import { positionTop, diff --git a/stats.html b/stats.html index aaba5be2..66ee62ff 100644 --- a/stats.html +++ b/stats.html @@ -2638,7 +2638,7 @@