UNPKG

dc

Version:

A multi-dimensional charting library built to work natively with crossfilter and rendered using d3.js

20 lines (19 loc) 132 kB
/*! * dc 4.0.0-alpha.1 * http://dc-js.github.io/dc.js/ * Copyright 2012-2019 Nick Zhu & the dc.js Developers * https://github.com/dc-js/dc.js/blob/master/AUTHORS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3")):"function"==typeof define&&define.amd?define(["exports","d3"],e):e((t=t||self).dc={},t.d3)}(this,function(t,e){"use strict";const i={CHART_CLASS:"dc-chart",DEBUG_GROUP_CLASS:"debug",STACK_CLASS:"stack",DESELECTED_CLASS:"deselected",SELECTED_CLASS:"selected",NODE_INDEX_NAME:"__index__",GROUP_INDEX_NAME:"__group_index__",DEFAULT_CHART_GROUP:"__default_chart_group__",EVENT_DELAY:40,NEGLIGIBLE_NUMBER:1e-10},s=function(){const t={enableDebugLog:!1,warn:function(e){return console&&(console.warn?console.warn(e):console.log&&console.log(e)),t}},e={};return t.warnOnce=function(i){return e[i]||(e[i]=!0,s.warn(i)),t},t.debug=function(e){return t.enableDebugLog&&console&&(console.debug?console.debug(e):console.log&&console.log(e)),t},t.deprecate=function(e,i){let s=!1;return function(){return s||(t.warn(i),s=!0),e.apply(this,arguments)}},t.annotate=function(t,e){let i=!1;return function(){return i||(console.groupCollapsed(e),console.trace(),console.groupEnd(),i=!0),t.apply(this,arguments)}},t}();class r{constructor(){this._defaultColors=r._schemeCategory20c,this.dateFormat=e.timeFormat("%m/%d/%Y"),this._renderlet=null,this.disableTransitions=!1}defaultColors(t){return arguments.length?(this._defaultColors=t,this):(this._defaultColors===r._schemeCategory20c&&s.warnOnce("You are using d3.schemeCategory20c, which has been removed in D3v5. See the explanation at https://github.com/d3/d3/blob/master/CHANGES.md#changes-in-d3-50. DC is using it for backward compatibility, however it will be changed in DCv3.1. You can change it by calling dc.config.defaultColors(newScheme). See https://github.com/d3/d3-scale-chromatic for some alternatives."),this._defaultColors)}}r._schemeCategory20c=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];const n=new r,h=function(){let t={};function e(e){return e||(e=i.DEFAULT_CHART_GROUP),t[e]||(t[e]=[]),e}return{has:function(e){for(let i in t)if(t[i].indexOf(e)>=0)return!0;return!1},register:function(i,s){s=e(s),t[s].push(i)},deregister:function(i,s){s=e(s);for(let e=0;e<t[s].length;e++)if(t[s][e].anchorName()===i.anchorName()){t[s].splice(e,1);break}},clear:function(e){e?delete t[e]:t={}},list:function(i){return i=e(i),t[i]}}}(),a=function(t,e){h.register(t,e)},l=function(t,e){h.deregister(t,e)},o=function(t){const e=h.list(t);for(let t=0;t<e.length;++t)e[t].render();null!==n._renderlet&&n._renderlet(t)},c=function(t){const e=h.list(t);for(let t=0;t<e.length;++t)e[t].redraw();null!==n._renderlet&&n._renderlet(t)},d=function(t,e,i,s){if(n.disableTransitions||e<=0)return t;let r=t.transition(s);return(e>=0||void 0!==e)&&(r=r.duration(e)),(i>=0||void 0!==i)&&(r=r.delay(i)),r},u=function(t,e,i,s){return t?function(t){return d(t,e,i,s)}:function(t){return t}},_=function(t){return t instanceof Object&&t.__dcFlag__&&!0};class g extends Error{}class p extends Error{}const m=function(t,e){return e?function(i,s){return e.call(i,i[t],s)}:function(e){return e[t]}},x={printSingleValue:function(t){let e=""+t;return t instanceof Date?e=n.dateFormat(t):"string"==typeof t?e=t:x.isFloat(t)?e=x.printSingleValue.fformat(t):x.isInteger(t)&&(e=Math.round(t)),e}};x.printSingleValue.fformat=e.format(".2f"),x.toTimeFunc=function(t){return"time"+t.charAt(0).toUpperCase()+t.slice(1)},x.add=function(t,i,s){if("string"==typeof i&&(i=i.replace("%","")),t instanceof Date)return"string"==typeof i&&(i=+i),"millis"===s?new Date(t.getTime()+i):("function"!=typeof(s=s||e.timeDay)&&(s=e[x.toTimeFunc(s)]),s.offset(t,i));if("string"==typeof i){const e=+i/100;return t>0?t*(1+e):t*(1-e)}return t+i},x.subtract=function(t,i,s){if("string"==typeof i&&(i=i.replace("%","")),t instanceof Date)return"string"==typeof i&&(i=+i),"millis"===s?new Date(t.getTime()-i):("function"!=typeof(s=s||e.timeDay)&&(s=e[x.toTimeFunc(s)]),s.offset(t,-i));if("string"==typeof i){const e=+i/100;return t<0?t*(1+e):t*(1-e)}return t-i},x.isNumber=function(t){return t===+t},x.isFloat=function(t){return t===+t&&t!==(0|t)},x.isInteger=function(t){return t===+t&&t===(0|t)},x.isNegligible=function(t){return!x.isNumber(t)||t<i.NEGLIGIBLE_NUMBER&&t>-i.NEGLIGIBLE_NUMBER},x.clamp=function(t,e,i){return t<e?e:t>i?i:t},x.constant=function(t){return function(){return t}};let y=0;function f(t,e){for(let i=0;i<t.length;i++)if(t[i].key===e)return t[i]}x.uniqueId=function(){return++y},x.nameToId=function(t){return t.toLowerCase().replace(/[\s]/g,"_").replace(/[\.']/g,"")},x.appendOrSelect=function(t,e,i){i=i||e;let s=t.select(e);return s.empty()&&(s=t.append(i)),s},x.safeNumber=function(t){return x.isNumber(+t)?+t:0},x.arraysEqual=function(t,e){return!t&&!e||!(!t||!e)&&(t.length===e.length&&t.every(function(t,i){return t.valueOf()===e[i].valueOf()}))},x.allChildren=function(t){let e=[];if(e.push(t.path),console.log("currentNode",t),t.children)for(let i=0;i<t.children.length;i++)e=e.concat(x.allChildren(t.children[i]));return e},x.toHierarchy=function(t,e){const i={key:"root",children:[]};for(let s=0;s<t.length;s++){const r=t[s],n=r.key,h=e(r);let a=i;for(let t=0;t<n.length;t++){const e=n.slice(0,t+1),i=a.children,s=n[t];let l;t+1<n.length?(void 0===(l=f(i,s))&&(l={key:s,children:[],path:e},i.push(l)),a=l):(l={key:s,value:h,data:r,path:e},i.push(l))}}return i},x.getAncestors=function(t){const e=[];let i=t;for(;i.parent;)e.unshift(i.name),i=i.parent;return e},x.arraysIdentical=function(t,e){let i=t.length;if(i!==e.length)return!1;for(;i--;)if(t[i]!==e[i])return!1;return!0};const b={current:null,trigger:function(t,e){e?(b.current=t,setTimeout(function(){t===b.current&&t()},e)):t()}},A={RangedFilter:function(t,e){const i=new Array(t,e);return i.isFiltered=function(t){return t>=this[0]&&t<this[1]},i.filterType="RangedFilter",i},TwoDimensionalFilter:function(t){if(null===t)return null;const e=t;return e.isFiltered=function(t){return t.length&&t.length===e.length&&t[0]===e[0]&&t[1]===e[1]},e.filterType="TwoDimensionalFilter",e},RangedTwoDimensionalFilter:function(t){if(null===t)return null;const e=t;let i;return i=e[0]instanceof Array?[[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1])],[Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]]:[[t[0],-1/0],[t[1],1/0]],e.isFiltered=function(t){let e,s;return t instanceof Array?(e=t[0],s=t[1]):(e=t,s=i[0][1]),e>=i[0][0]&&e<i[1][0]&&s>=i[0][1]&&s<i[1][1]},e.filterType="RangedTwoDimensionalFilter",e},HierarchyFilter:function(t){if(null===t)return null;const e=t.slice(0);return e.isFiltered=function(t){if(!(e.length&&t&&t.length&&t.length>=e.length))return!1;for(let i=0;i<e.length;i++)if(t[i]!==e[i])return!1;return!0},e}},v={filters:function(t){let e="";for(let i=0;i<t.length;++i)i>0&&(e+=", "),e+=v.filter(t[i]);return e},filter:function(t){let e="";return void 0!==t&&null!==t&&(t instanceof Array?t.length>=2?e="["+t.map(function(t){return x.printSingleValue(t)}).join(" -> ")+"]":t.length>=1&&(e=x.printSingleValue(t[0])):e=x.printSingleValue(t)),e}},C={integers:function(t,e){return Math.abs(e-t)},ordinal:function(){throw new Error("dc.units.ordinal should not be called - it is a placeholder")},fp:{}};C.fp.precision=function(t){const e=function(t,i){const s=Math.abs((i-t)/e.resolution);return x.isNegligible(s-Math.floor(s))?Math.floor(s):Math.ceil(s)};return e.resolution=t,e};const S=function(){let t=1,i=1,s=0;const r=0;let n=null,h=Number,a=L,l=w,o=null,c=!1;const d=3;let u=.3,_=.8,g=!1,p=!0,m=!1;function y(x){x.each(function(x,y){x=x.map(h).sort(e.ascending);const f=e.select(this),b=x.length;let A,v;if(0===b)return;const C=x.quartiles=l(x),S=a&&a.call(this,x,y),L=S&&S.map(function(t){return x[t]}),w=S?e.range(0,S[0]).concat(e.range(S[1]+1,b)):e.range(b);p?(A=x[0],v=x[b-1]):(A=x[S[0]],v=x[S[1]]);const D=e.range(S[0],S[1]+1),R=e.scaleLinear().domain(n&&n.call(this,x,y)||[A,v]).range([i,0]),k=this.__chart__||e.scaleLinear().domain([0,1/0]).range(R.range());this.__chart__=R;const O=f.selectAll("line.center").data(L?[L]:[]);O.enter().insert("line","rect").attr("class","center").attr("x1",t/2).attr("y1",function(t){return k(t[0])}).attr("x2",t/2).attr("y2",function(t){return k(t[1])}).style("opacity",1e-6).transition().duration(s).delay(r).style("opacity",1).attr("y1",function(t){return R(t[0])}).attr("y2",function(t){return R(t[1])}),O.transition().duration(s).delay(r).style("opacity",1).attr("x1",t/2).attr("x2",t/2).attr("y1",function(t){return R(t[0])}).attr("y2",function(t){return R(t[1])}),O.exit().transition().duration(s).delay(r).style("opacity",1e-6).attr("y1",function(t){return R(t[0])}).attr("y2",function(t){return R(t[1])}).remove();const B=f.selectAll("rect.box").data([C]);B.enter().append("rect").attr("class","box").attr("x",0).attr("y",function(t){return k(t[2])}).attr("width",t).attr("height",function(t){return k(t[0])-k(t[2])}).style("fill-opacity",c?.1:1).transition().duration(s).delay(r).attr("y",function(t){return R(t[2])}).attr("height",function(t){return R(t[0])-R(t[2])}),B.transition().duration(s).delay(r).attr("width",t).attr("y",function(t){return R(t[2])}).attr("height",function(t){return R(t[0])-R(t[2])});const F=f.selectAll("line.median").data([C[1]]);F.enter().append("line").attr("class","median").attr("x1",0).attr("y1",k).attr("x2",t).attr("y2",k).transition().duration(s).delay(r).attr("y1",R).attr("y2",R),F.transition().duration(s).delay(r).attr("x1",0).attr("x2",t).attr("y1",R).attr("y2",R);const P=f.selectAll("line.whisker").data(L||[]);if(P.enter().insert("line","circle, text").attr("class","whisker").attr("x1",0).attr("y1",k).attr("x2",t).attr("y2",k).style("opacity",1e-6).transition().duration(s).delay(r).attr("y1",R).attr("y2",R).style("opacity",1),P.transition().duration(s).delay(r).attr("x1",0).attr("x2",t).attr("y1",R).attr("y2",R).style("opacity",1),P.exit().transition().duration(s).delay(r).attr("y1",R).attr("y2",R).style("opacity",1e-6).remove(),p){const e=m?"outlierBold":"outlier",i=m?3:5,n=m?function(){return Math.floor(Math.random()*(t*_)+1+(t-t*_)/2)}:function(){return t/2},h=f.selectAll("circle."+e).data(w,Number);h.enter().insert("circle","text").attr("class",e).attr("r",i).attr("cx",n).attr("cy",function(t){return k(x[t])}).style("opacity",1e-6).transition().duration(s).delay(r).attr("cy",function(t){return R(x[t])}).style("opacity",.6),g&&(h.selectAll("title").remove(),h.append("title").text(function(t){return x[t]})),h.transition().duration(s).delay(r).attr("cx",n).attr("cy",function(t){return R(x[t])}).style("opacity",.6),h.exit().transition().duration(s).delay(r).attr("cy",0).style("opacity",1e-6).remove()}if(c){const e=f.selectAll("circle.data").data(D);e.enter().insert("circle","text").attr("class","data").attr("r",d).attr("cx",function(){return Math.floor(Math.random()*(t*_)+1+(t-t*_)/2)}).attr("cy",function(t){return k(x[t])}).style("opacity",1e-6).transition().duration(s).delay(r).attr("cy",function(t){return R(x[t])}).style("opacity",u),g&&(e.selectAll("title").remove(),e.append("title").text(function(t){return x[t]})),e.transition().duration(s).delay(r).attr("cx",function(){return Math.floor(Math.random()*(t*_)+1+(t-t*_)/2)}).attr("cy",function(t){return R(x[t])}).style("opacity",u),e.exit().transition().duration(s).delay(r).attr("cy",0).style("opacity",1e-6).remove()}const T=o||R.tickFormat(8),E=f.selectAll("text.box").data(C);E.enter().append("text").attr("class","box").attr("dy",".3em").attr("dx",function(t,e){return 1&e?6:-6}).attr("x",function(e,i){return 1&i?t:0}).attr("y",k).attr("text-anchor",function(t,e){return 1&e?"start":"end"}).text(T).transition().duration(s).delay(r).attr("y",R),E.transition().duration(s).delay(r).text(T).attr("x",function(e,i){return 1&i?t:0}).attr("y",R);const H=f.selectAll("text.whisker").data(L||[]);H.enter().append("text").attr("class","whisker").attr("dy",".3em").attr("dx",6).attr("x",t).attr("y",k).text(T).style("opacity",1e-6).transition().duration(s).delay(r).attr("y",R).style("opacity",1),H.transition().duration(s).delay(r).text(T).attr("x",t).attr("y",R).style("opacity",1),H.exit().transition().duration(s).delay(r).attr("y",R).style("opacity",1e-6).remove(),delete x.quartiles}),e.timerFlush()}return y.width=function(e){return arguments.length?(t=e,y):t},y.height=function(t){return arguments.length?(i=t,y):i},y.tickFormat=function(t){return arguments.length?(o=t,y):o},y.showOutliers=function(t){return arguments.length?(p=t,y):p},y.boldOutlier=function(t){return arguments.length?(m=t,y):m},y.renderDataPoints=function(t){return arguments.length?(c=t,y):c},y.renderTitle=function(t){return arguments.length?(g=t,y):g},y.dataOpacity=function(t){return arguments.length?(u=t,y):u},y.dataWidthPortion=function(t){return arguments.length?(_=t,y):_},y.duration=function(t){return arguments.length?(s=t,y):s},y.domain=function(t){return arguments.length?(n=null===t?t:"function"==typeof t?t:x.constant(t),y):n},y.value=function(t){return arguments.length?(h=t,y):h},y.whiskers=function(t){return arguments.length?(a=t,y):a},y.quartiles=function(t){return arguments.length?(l=t,y):l},y};function L(t){return[0,t.length-1]}function w(t){return[e.quantile(t,.25),e.quantile(t,.5),e.quantile(t,.75)]}const D=(t,e)=>(0===e.length?t.filter(null):1!==e.length||e[0].isFiltered?1===e.length&&"RangedFilter"===e[0].filterType?t.filterRange(e[0]):t.filterFunction(t=>{for(let i=0;i<e.length;i++){const s=e[i];if(s.isFiltered&&s.isFiltered(t))return!0;if(s<=t&&s>=t)return!0}return!1}):t.filterExact(e[0]),e),R=(t,e)=>null===e||void 0===e?t.length>0:t.some(t=>e<=t&&e>=t),k=(t,e)=>{for(let i=0;i<t.length;i++)if(t[i]<=e&&t[i]>=e){t.splice(i,1);break}return t},O=(t,e)=>(t.push(e),t),B=t=>[];class F{constructor(){this.__dcFlag__=x.uniqueId(),this._dimension=void 0,this._group=void 0,this._anchor=void 0,this._root=void 0,this._svg=void 0,this._isChild=void 0,this._minWidth=200,this._widthCalc=this._defaultWidthCalc,this._minHeight=200,this._heightCalc=this._defaultHeightCalc,this._width=void 0,this._height=void 0,this._useViewBoxResizing=!1,this._keyAccessor=m("key"),this._valueAccessor=m("value"),this._label=m("key"),this._ordering=m("key"),this._renderLabel=!1,this._title=(t=>this.keyAccessor()(t)+": "+this.valueAccessor()(t)),this._renderTitle=!0,this._controlsUseVisibility=!1,this._transitionDuration=750,this._transitionDelay=0,this._filterPrinter=v.filters,this._mandatoryAttributesList=["dimension","group"],this._chartGroup=i.DEFAULT_CHART_GROUP,this._listeners=e.dispatch("preRender","postRender","preRedraw","postRedraw","filtered","zoomed","renderlet","pretransition"),this._legend=void 0,this._commitHandler=void 0,this._data=this._defaultData,this._filters=[],this._filterHandler=D,this._hasFilterHandler=R,this._removeFilterHandler=k,this._addFilterHandler=O,this._resetFilterHandler=B}height(t){return arguments.length?(this._heightCalc=t?"function"==typeof t?t:x.constant(t):this._defaultHeightCalc,this._height=void 0,this):(x.isNumber(this._height)||(this._height=this._heightCalc(this._root.node())),this._height)}width(t){return arguments.length?(this._widthCalc=t?"function"==typeof t?t:x.constant(t):this._defaultWidthCalc,this._width=void 0,this):(x.isNumber(this._width)||(this._width=this._widthCalc(this._root.node())),this._width)}minWidth(t){return arguments.length?(this._minWidth=t,this):this._minWidth}minHeight(t){return arguments.length?(this._minHeight=t,this):this._minHeight}useViewBoxResizing(t){return arguments.length?(this._useViewBoxResizing=t,this):this._useViewBoxResizing}dimension(t){return arguments.length?(this._dimension=t,this.expireCache(),this):this._dimension}data(t){return arguments.length?(this._data="function"==typeof t?t:x.constant(t),this.expireCache(),this):this._data(this._group)}group(t,e){return arguments.length?(this._group=t,this._groupName=e,this.expireCache(),this):this._group}ordering(t){return arguments.length?(this._ordering=t,this.expireCache(),this):this._ordering}_computeOrderedGroups(t){return Array.from(t).sort((t,e)=>this._ordering(t)-this._ordering(e))}filterAll(){return this.filter(null)}select(t){return this._root.select(t)}selectAll(t){return this._root?this._root.selectAll(t):null}anchor(t,s){if(!arguments.length)return this._anchor;if(_(t))this._anchor=t.anchor(),this._anchor.children&&(this._anchor="#"+t.anchorName()),this._root=t.root(),this._isChild=!0;else{if(!t)throw new g("parent must be defined");t.select&&t.classed?this._anchor=t.node():this._anchor=t,this._root=e.select(this._anchor),this._root.classed(i.CHART_CLASS,!0),a(this,s),this._isChild=!1}return this._chartGroup=s,this}anchorName(){const t=this.anchor();return t&&t.id?t.id:t&&t.replace?t.replace("#",""):"dc-chart"+this.chartID()}root(t){return arguments.length?(this._root=t,this):this._root}svg(t){return arguments.length?(this._svg=t,this):this._svg}resetSvg(){return this.select("svg").remove(),this.generateSvg()}sizeSvg(){this._svg&&(this._useViewBoxResizing?this._svg.attr("viewBox")||this._svg.attr("viewBox","0 0 "+this.width()+" "+this.height()):this._svg.attr("width",this.width()).attr("height",this.height()))}generateSvg(){return this._svg=this.root().append("svg"),this.sizeSvg(),this._svg}filterPrinter(t){return arguments.length?(this._filterPrinter=t,this):this._filterPrinter}controlsUseVisibility(t){return arguments.length?(this._controlsUseVisibility=t,this):this._controlsUseVisibility}turnOnControls(){if(this._root){const t=this.controlsUseVisibility()?"visibility":"display";this.selectAll(".reset").style(t,null),this.selectAll(".filter").text(this._filterPrinter(this.filters())).style(t,null)}return this}turnOffControls(){if(this._root){const t=this.controlsUseVisibility()?"visibility":"display",e=this.controlsUseVisibility()?"hidden":"none";this.selectAll(".reset").style(t,e),this.selectAll(".filter").style(t,e).text(this.filter())}return this}transitionDuration(t){return arguments.length?(this._transitionDuration=t,this):this._transitionDuration}transitionDelay(t){return arguments.length?(this._transitionDelay=t,this):this._transitionDelay}_mandatoryAttributes(t){return arguments.length?(this._mandatoryAttributesList=t,this):this._mandatoryAttributesList}checkForMandatoryAttributes(t){if(!this[t]||!this[t]())throw new p("Mandatory attribute chart."+t+" is missing on chart[#"+this.anchorName()+"]")}render(){this._height=this._width=void 0,this._listeners.call("preRender",this,this),this._mandatoryAttributesList&&this._mandatoryAttributesList.forEach(t=>this.checkForMandatoryAttributes(t));const t=this._doRender();return this._legend&&this._legend.render(),this._activateRenderlets("postRender"),t}_activateRenderlets(t){this._listeners.call("pretransition",this,this),this.transitionDuration()>0&&this._svg?this._svg.transition().duration(this.transitionDuration()).delay(this.transitionDelay()).on("end",()=>{this._listeners.call("renderlet",this,this),t&&this._listeners.call(t,this,this)}):(this._listeners.call("renderlet",this,this),t&&this._listeners.call(t,this,this))}redraw(){this.sizeSvg(),this._listeners.call("preRedraw",this,this);const t=this._doRedraw();return this._legend&&this._legend.render(),this._activateRenderlets("postRedraw"),t}commitHandler(t){return arguments.length?(this._commitHandler=t,this):this._commitHandler}redrawGroup(){return this._commitHandler?this._commitHandler(!1,(t,e)=>{t?console.log(t):c(this.chartGroup())}):c(this.chartGroup()),this}renderGroup(){return this._commitHandler?this._commitHandler(!1,(t,e)=>{t?console.log(t):o(this.chartGroup())}):o(this.chartGroup()),this}_invokeFilteredListener(t){void 0!==t&&this._listeners.call("filtered",this,this,t)}_invokeZoomedListener(){this._listeners.call("zoomed",this,this)}hasFilterHandler(t){return arguments.length?(this._hasFilterHandler=t,this):this._hasFilterHandler}hasFilter(t){return this._hasFilterHandler(this._filters,t)}removeFilterHandler(t){return arguments.length?(this._removeFilterHandler=t,this):this._removeFilterHandler}addFilterHandler(t){return arguments.length?(this._addFilterHandler=t,this):this._addFilterHandler}resetFilterHandler(t){return arguments.length?(this._resetFilterHandler=t,this):this._resetFilterHandler}applyFilters(t){if(this.dimension()&&this.dimension().filter){const e=this._filterHandler(this.dimension(),t);e&&(t=e)}return t}replaceFilter(t){return this._filters=this._resetFilterHandler(this._filters),this.filter(t),this}filter(t){if(!arguments.length)return this._filters.length>0?this._filters[0]:null;let e=this._filters;return t instanceof Array&&t[0]instanceof Array&&!t.isFiltered?t[0].forEach(t=>{e=this._hasFilterHandler(e,t)?this._removeFilterHandler(e,t):this._addFilterHandler(e,t)}):e=null===t?this._resetFilterHandler(e):this._hasFilterHandler(e,t)?this._removeFilterHandler(e,t):this._addFilterHandler(e,t),this._filters=this.applyFilters(e),this._invokeFilteredListener(t),null!==this._root&&this.hasFilter()?this.turnOnControls():this.turnOffControls(),this}filters(){return this._filters}highlightSelected(t){e.select(t).classed(i.SELECTED_CLASS,!0),e.select(t).classed(i.DESELECTED_CLASS,!1)}fadeDeselected(t){e.select(t).classed(i.SELECTED_CLASS,!1),e.select(t).classed(i.DESELECTED_CLASS,!0)}resetHighlight(t){e.select(t).classed(i.SELECTED_CLASS,!1),e.select(t).classed(i.DESELECTED_CLASS,!1)}onClick(t){const e=this.keyAccessor()(t);b.trigger(()=>{this.filter(e),this.redrawGroup()})}filterHandler(t){return arguments.length?(this._filterHandler=t,this):this._filterHandler}_doRender(){return this}_doRedraw(){return this}legendables(){return[]}legendHighlight(){}legendReset(){}legendToggle(){}isLegendableHidden(){return!1}keyAccessor(t){return arguments.length?(this._keyAccessor=t,this):this._keyAccessor}valueAccessor(t){return arguments.length?(this._valueAccessor=t,this):this._valueAccessor}label(t,e){return arguments.length?(this._label=t,(void 0===e||e)&&(this._renderLabel=!0),this):this._label}renderLabel(t){return arguments.length?(this._renderLabel=t,this):this._renderLabel}title(t){return arguments.length?(this._title=t,this):this._title}renderTitle(t){return arguments.length?(this._renderTitle=t,this):this._renderTitle}chartGroup(t){return arguments.length?(this._isChild||l(this,this._chartGroup),this._chartGroup=t,this._isChild||a(this,this._chartGroup),this):this._chartGroup}expireCache(){return this}legend(t){return arguments.length?(this._legend=t,this._legend.parent(this),this):this._legend}chartID(){return this.__dcFlag__}options(t){const e=["anchor","group","xAxisLabel","yAxisLabel","stack","title","point","getColor","overlayGeoJson"];for(let i in t)"function"==typeof this[i]?t[i]instanceof Array&&-1!==e.indexOf(i)?this[i].apply(this,t[i]):this[i].call(this,t[i]):s.debug("Not a valid option setter name: "+i);return this}on(t,e){return this._listeners.on(t,e),this}renderlet(t){return s.warnOnce('chart.renderlet has been deprecated. Please use chart.on("renderlet.<renderletKey>", renderletFunction)'),this.on("renderlet."+x.uniqueId(),t),this}_defaultWidthCalc(t){const e=t&&t.getBoundingClientRect&&t.getBoundingClientRect().width;return e&&e>this._minWidth?e:this._minWidth}_defaultHeightCalc(t){const e=t&&t.getBoundingClientRect&&t.getBoundingClientRect().height;return e&&e>this._minHeight?e:this._minHeight}_defaultData(t){return t.all()}}const P=t=>(class extends t{constructor(){super(),this._colors=e.scaleOrdinal(n.defaultColors()),this._colorAccessor=(t=>this.keyAccessor()(t)),this._colorCalculator=void 0;{const t=this;t.getColor=function(e,i){return t._colorCalculator?t._colorCalculator.call(this,e,i):t._colors(t._colorAccessor.call(this,e,i))}}}calculateColorDomain(){const t=[e.min(this.data(),this.colorAccessor()),e.max(this.data(),this.colorAccessor())];return this._colors.domain(t),this}colors(t){return arguments.length?(t instanceof Array?this._colors=e.scaleQuantize().range(t):this._colors="function"==typeof t?t:x.constant(t),this):this._colors}ordinalColors(t){return this.colors(e.scaleOrdinal().range(t))}linearColors(t){return this.colors(e.scaleLinear().range(t).interpolate(e.interpolateHcl))}colorAccessor(t){return arguments.length?(this._colorAccessor=t,this):this._colorAccessor}colorDomain(t){return arguments.length?(this._colors.domain(t),this):this._colors.domain()}colorCalculator(t){return arguments.length?(this._colorCalculator=t,this):this._colorCalculator||this.getColor}}),T=t=>(class extends(P(t)){constructor(){super(),this._maxBubbleRelativeSize=.3,this._minRadiusWithLabel=10,this._sortBubbleSize=!1,this._elasticRadius=!1,this.BUBBLE_NODE_CLASS="node",this.BUBBLE_CLASS="bubble",this.MIN_RADIUS=10,this.renderLabel(!0),this.data(t=>{const i=t.all();if(this._sortBubbleSize){const t=this.radiusValueAccessor();i.sort((i,s)=>e.descending(t(i),t(s)))}return i}),this._r=e.scaleLinear().domain([0,100])}_rValueAccessor(t){return t.r}r(t){return arguments.length?(this._r=t,this):this._r}elasticRadius(t){return arguments.length?(this._elasticRadius=t,this):this._elasticRadius}calculateRadiusDomain(){this._elasticRadius&&this.r().domain([this.rMin(),this.rMax()])}radiusValueAccessor(t){return arguments.length?(this._rValueAccessor=t,this):this._rValueAccessor}rMin(){return e.min(this.data(),t=>this.radiusValueAccessor()(t))}rMax(){return e.max(this.data(),t=>this.radiusValueAccessor()(t))}bubbleR(t){const e=this.radiusValueAccessor()(t);let i=this.r()(e);return(isNaN(i)||e<=0)&&(i=0),i}_labelFunction(t){return this.label()(t)}_shouldLabel(t){return this.bubbleR(t)>this._minRadiusWithLabel}_labelOpacity(t){return this._shouldLabel(t)?1:0}_labelPointerEvent(t){return this._shouldLabel(t)?"all":"none"}_doRenderLabel(t){if(this.renderLabel()){let e=t.select("text");e.empty()&&(e=t.append("text").attr("text-anchor","middle").attr("dy",".3em").on("click",t=>this.onClick(t))),e.attr("opacity",0).attr("pointer-events",t=>this._labelPointerEvent(t)).text(t=>this._labelFunction(t)),d(e,this.transitionDuration(),this.transitionDelay()).attr("opacity",t=>this._labelOpacity(t))}}doUpdateLabels(t){if(this.renderLabel()){const e=t.select("text").attr("pointer-events",t=>this._labelPointerEvent(t)).text(t=>this._labelFunction(t));d(e,this.transitionDuration(),this.transitionDelay()).attr("opacity",t=>this._labelOpacity(t))}}_titleFunction(t){return this.title()(t)}_doRenderTitles(t){if(this.renderTitle()){t.select("title").empty()&&t.append("title").text(t=>this._titleFunction(t))}}doUpdateTitles(t){this.renderTitle()&&t.select("title").text(t=>this._titleFunction(t))}sortBubbleSize(t){return arguments.length?(this._sortBubbleSize=t,this):this._sortBubbleSize}minRadius(t){return arguments.length?(this.MIN_RADIUS=t,this):this.MIN_RADIUS}minRadiusWithLabel(t){return arguments.length?(this._minRadiusWithLabel=t,this):this._minRadiusWithLabel}maxBubbleRelativeSize(t){return arguments.length?(this._maxBubbleRelativeSize=t,this):this._maxBubbleRelativeSize}fadeDeselectedArea(t){if(this.hasFilter()){const t=this;this.selectAll("g."+t.BUBBLE_NODE_CLASS).each(function(e){t.isSelectedNode(e)?t.highlightSelected(this):t.fadeDeselected(this)})}else{const t=this;this.selectAll("g."+t.BUBBLE_NODE_CLASS).each(function(){t.resetHighlight(this)})}}isSelectedNode(t){return this.hasFilter(t.key)}onClick(t){const e=t.key;b.trigger(()=>{this.filter(e),this.redrawGroup()})}}),E=t=>(class extends t{constructor(){super(),this._margin={top:10,right:50,bottom:30,left:30}}margins(t){return arguments.length?(this._margin=t,this):this._margin}effectiveWidth(){return this.width()-this.margins().left-this.margins().right}effectiveHeight(){return this.height()-this.margins().top-this.margins().bottom}}),H="grid-line",z="horizontal",M="vertical",N="y-axis-label",G="x-axis-label",Y="custom-brush-handle",V=12;class I extends(P(E(F))){constructor(){super(),this.colors(e.scaleOrdinal(e.schemeCategory10)),this._mandatoryAttributes().push("x"),this._parent=void 0,this._g=void 0,this._chartBodyG=void 0,this._x=void 0,this._origX=void 0,this._xOriginalDomain=void 0,this._xAxis=e.axisBottom(),this._xUnits=C.integers,this._xAxisPadding=0,this._xAxisPaddingUnit=e.timeDay,this._xElasticity=!1,this._xAxisLabel=void 0,this._xAxisLabelPadding=0,this._lastXDomain=void 0,this._y=void 0,this._yAxis=null,this._yAxisPadding=0,this._yElasticity=!1,this._yAxisLabel=void 0,this._yAxisLabelPadding=0,this._brush=e.brushX(),this._gBrush=void 0,this._brushOn=!0,this._parentBrushOn=!1,this._round=void 0,this._renderHorizontalGridLine=!1,this._renderVerticalGridLine=!1,this._resizing=!1,this._unitCount=void 0,this._zoomScale=[1,1/0],this._zoomOutRestrict=!0,this._zoom=e.zoom().on("zoom",()=>this._onZoom()),this._nullZoom=e.zoom().on("zoom",null),this._hasBeenMouseZoomable=!1,this._rangeChart=void 0,this._focusChart=void 0,this._mouseZoomable=!1,this._clipPadding=0,this._fOuterRangeBandPadding=.5,this._fRangeBandPadding=0,this._useRightYAxis=!1}rescale(){return this._unitCount=void 0,this._resizing=!0,this}resizing(){return this._resizing}rangeChart(t){return arguments.length?(this._rangeChart=t,this._rangeChart.focusChart(this),this):this._rangeChart}zoomScale(t){return arguments.length?(this._zoomScale=t,this):this._zoomScale}zoomOutRestrict(t){return arguments.length?(this._zoomOutRestrict=t,this):this._zoomOutRestrict}_generateG(t){this._parent=void 0===t?this.svg():t;const e=window.location.href.split("#")[0];return this._g=this._parent.append("g"),this._chartBodyG=this._g.append("g").attr("class","chart-body").attr("transform","translate("+this.margins().left+", "+this.margins().top+")").attr("clip-path","url("+e+"#"+this._getClipPathId()+")"),this._g}g(t){return arguments.length?(this._g=t,this):this._g}mouseZoomable(t){return arguments.length?(this._mouseZoomable=t,this):this._mouseZoomable}chartBodyG(t){return arguments.length?(this._chartBodyG=t,this):this._chartBodyG}x(t){return arguments.length?(this._x=t,this._xOriginalDomain=this._x.domain(),this.rescale(),this):this._x}xOriginalDomain(){return this._xOriginalDomain}xUnits(t){return arguments.length?(this._xUnits=t,this):this._xUnits}xAxis(t){return arguments.length?(this._xAxis=t,this):this._xAxis}elasticX(t){return arguments.length?(this._xElasticity=t,this):this._xElasticity}xAxisPadding(t){return arguments.length?(this._xAxisPadding=t,this):this._xAxisPadding}xAxisPaddingUnit(t){return arguments.length?(this._xAxisPaddingUnit=t,this):this._xAxisPaddingUnit}xUnitCount(){return void 0===this._unitCount&&(this.isOrdinal()?this._unitCount=this.x().domain().length:(this._unitCount=this.xUnits()(this.x().domain()[0],this.x().domain()[1]),this._unitCount instanceof Array&&(this._unitCount=this._unitCount.length))),this._unitCount}useRightYAxis(t){return arguments.length?(this._useRightYAxis!==t&&this._yAxis&&s.warn("Value of useRightYAxis has been altered, after yAxis was created. You might get unexpected yAxis behavior. Make calls to useRightYAxis sooner in your chart creation process."),this._useRightYAxis=t,this):this._useRightYAxis}isOrdinal(){return this.xUnits()===C.ordinal}_useOuterPadding(){return!0}_ordinalXDomain(){return this._computeOrderedGroups(this.data()).map(this.keyAccessor())}_prepareXAxis(t,i){this.isOrdinal()?(this._x.bandwidth||(s.warn("For compatibility with d3v4+, dc.js d3.0 ordinal bar/line/bubble charts need d3.scaleBand() for the x scale, instead of d3.scaleOrdinal(). Replacing .x() with a d3.scaleBand with the same domain - make the same change in your code to avoid this warning!"),this._x=e.scaleBand().domain(this._x.domain())),(this.elasticX()||0===this._x.domain().length)&&this._x.domain(this._ordinalXDomain())):this.elasticX()&&this._x.domain([this.xAxisMin(),this.xAxisMax()]);const r=this._x.domain();!i&&x.arraysEqual(this._lastXDomain,r)||this.rescale(),this._lastXDomain=r,this.isOrdinal()?this._x.range([0,this.xAxisLength()]).paddingInner(this._fRangeBandPadding).paddingOuter(this._useOuterPadding()?this._fOuterRangeBandPadding:0):this._x.range([0,this.xAxisLength()]),this._xAxis=this._xAxis.scale(this.x()),this._renderVerticalGridLines(t)}renderXAxis(t){let e=t.select("g.x");e.empty()&&(e=t.append("g").attr("class","axis x").attr("transform","translate("+this.margins().left+","+this._xAxisY()+")"));let i=t.select("text."+G);i.empty()&&this.xAxisLabel()&&(i=t.append("text").attr("class",G).attr("transform","translate("+(this.margins().left+this.xAxisLength()/2)+","+(this.height()-this._xAxisLabelPadding)+")").attr("text-anchor","middle")),this.xAxisLabel()&&i.text()!==this.xAxisLabel()&&i.text(this.xAxisLabel()),d(e,this.transitionDuration(),this.transitionDelay()).attr("transform","translate("+this.margins().left+","+this._xAxisY()+")").call(this._xAxis),d(i,this.transitionDuration(),this.transitionDelay()).attr("transform","translate("+(this.margins().left+this.xAxisLength()/2)+","+(this.height()-this._xAxisLabelPadding)+")")}_renderVerticalGridLines(t){let e=t.select("g."+M);if(this._renderVerticalGridLine){e.empty()&&(e=t.insert("g",":first-child").attr("class",H+" "+M).attr("transform","translate("+this.margins().left+","+this.margins().top+")"));const i=this._xAxis.tickValues()?this._xAxis.tickValues():"function"==typeof this._x.ticks?this._x.ticks.apply(this._x,this._xAxis.tickArguments()):this._x.domain(),s=e.selectAll("line").data(i),r=s.enter().append("line").attr("x1",t=>this._x(t)).attr("y1",this._xAxisY()-this.margins().top).attr("x2",t=>this._x(t)).attr("y2",0).attr("opacity",0);d(r,this.transitionDuration(),this.transitionDelay()).attr("opacity",.5),d(s,this.transitionDuration(),this.transitionDelay()).attr("x1",t=>this._x(t)).attr("y1",this._xAxisY()-this.margins().top).attr("x2",t=>this._x(t)).attr("y2",0),s.exit().remove()}else e.selectAll("line").remove()}_xAxisY(){return this.height()-this.margins().bottom}xAxisLength(){return this.effectiveWidth()}xAxisLabel(t,e){return arguments.length?(this._xAxisLabel=t,this.margins().bottom-=this._xAxisLabelPadding,this._xAxisLabelPadding=void 0===e?V:e,this.margins().bottom+=this._xAxisLabelPadding,this):this._xAxisLabel}_createYAxis(){return this._useRightYAxis?e.axisRight():e.axisLeft()}_prepareYAxis(t){if(void 0===this._y||this.elasticY()){void 0===this._y&&(this._y=e.scaleLinear());const t=this.yAxisMin()||0,i=this.yAxisMax()||0;this._y.domain([t,i]).rangeRound([this.yAxisHeight(),0])}this._y.range([this.yAxisHeight(),0]),this._yAxis||(this._yAxis=this._createYAxis()),this._yAxis.scale(this._y),this._renderHorizontalGridLinesForAxis(t,this._y,this._yAxis)}renderYAxisLabel(t,e,i,s){s=s||this._yAxisLabelPadding;let r=this.g().select("text."+N+"."+t+"-label");const n=this.margins().top+this.yAxisHeight()/2;r.empty()&&e&&(r=this.g().append("text").attr("transform","translate("+s+","+n+"),rotate("+i+")").attr("class",N+" "+t+"-label").attr("text-anchor","middle").text(e)),e&&r.text()!==e&&r.text(e),d(r,this.transitionDuration(),this.transitionDelay()).attr("transform","translate("+s+","+n+"),rotate("+i+")")}renderYAxisAt(t,e,i){let s=this.g().select("g."+t);s.empty()&&(s=this.g().append("g").attr("class","axis "+t).attr("transform","translate("+i+","+this.margins().top+")")),d(s,this.transitionDuration(),this.transitionDelay()).attr("transform","translate("+i+","+this.margins().top+")").call(e)}renderYAxis(){const t=this._useRightYAxis?this.width()-this.margins().right:this._yAxisX();this.renderYAxisAt("y",this._yAxis,t);const e=this._useRightYAxis?this.width()-this._yAxisLabelPadding:this._yAxisLabelPadding,i=this._useRightYAxis?90:-90;this.renderYAxisLabel("y",this.yAxisLabel(),i,e)}_renderHorizontalGridLinesForAxis(t,e,i){let s=t.select("g."+z);if(this._renderHorizontalGridLine){const r=i.tickValues()?i.tickValues():e.ticks?e.ticks.apply(e,i.tickArguments()):e.domain();s.empty()&&(s=t.insert("g",":first-child").attr("class",H+" "+z).attr("transform","translate("+this.margins().left+","+this.margins().top+")"));const n=s.selectAll("line").data(r),h=n.enter().append("line").attr("x1",1).attr("y1",t=>e(t)).attr("x2",this.xAxisLength()).attr("y2",t=>e(t)).attr("opacity",0);d(h,this.transitionDuration(),this.transitionDelay()).attr("opacity",.5),d(n,this.transitionDuration(),this.transitionDelay()).attr("x1",1).attr("y1",t=>e(t)).attr("x2",this.xAxisLength()).attr("y2",t=>e(t)),n.exit().remove()}else s.selectAll("line").remove()}_yAxisX(){return this.useRightYAxis()?this.width()-this.margins().right:this.margins().left}yAxisLabel(t,e){return arguments.length?(this._yAxisLabel=t,this.margins().left-=this._yAxisLabelPadding,this._yAxisLabelPadding=void 0===e?V:e,this.margins().left+=this._yAxisLabelPadding,this):this._yAxisLabel}y(t){return arguments.length?(this._y=t,this.rescale(),this):this._y}yAxis(t){return arguments.length?(this._yAxis=t,this):(this._yAxis||(this._yAxis=this._createYAxis()),this._yAxis)}elasticY(t){return arguments.length?(this._yElasticity=t,this):this._yElasticity}renderHorizontalGridLines(t){return arguments.length?(this._renderHorizontalGridLine=t,this):this._renderHorizontalGridLine}renderVerticalGridLines(t){return arguments.length?(this._renderVerticalGridLine=t,this):this._renderVerticalGridLine}xAxisMin(){const t=e.min(this.data(),t=>this.keyAccessor()(t));return x.subtract(t,this._xAxisPadding,this._xAxisPaddingUnit)}xAxisMax(){const t=e.max(this.data(),t=>this.keyAccessor()(t));return x.add(t,this._xAxisPadding,this._xAxisPaddingUnit)}yAxisMin(){const t=e.min(this.data(),t=>this.valueAccessor()(t));return x.subtract(t,this._yAxisPadding)}yAxisMax(){const t=e.max(this.data(),t=>this.valueAccessor()(t));return x.add(t,this._yAxisPadding)}yAxisPadding(t){return arguments.length?(this._yAxisPadding=t,this):this._yAxisPadding}yAxisHeight(){return this.effectiveHeight()}round(t){return arguments.length?(this._round=t,this):this._round}_rangeBandPadding(t){return arguments.length?(this._fRangeBandPadding=t,this):this._fRangeBandPadding}_outerRangeBandPadding(t){return arguments.length?(this._fOuterRangeBandPadding=t,this):this._fOuterRangeBandPadding}filter(t){return arguments.length?(super.filter(t),this.redrawBrush(t,!1),this):super.filter()}brush(t){return arguments.length?(this._brush=t,this):this._brush}renderBrush(t,e){this._brushOn&&(this._brush.on("start brush end",()=>this._brushing()),this._gBrush=t.append("g").attr("class","brush").attr("transform","translate("+this.margins().left+","+this.margins().top+")"),this.setBrushExtents(),this.createBrushHandlePaths(this._gBrush,e),this.redrawBrush(this.filter(),e))}createBrushHandlePaths(t){let e=t.selectAll("path."+Y).data([{type:"w"},{type:"e"}]);(e=e.enter().append("path").attr("class",Y).merge(e)).attr("d",t=>this.resizeHandlePath(t))}extendBrush(t){return t&&this.round()&&(t[0]=this.round()(t[0]),t[1]=this.round()(t[1])),t}brushIsEmpty(t){return!t||t[1]<=t[0]}_brushing(){if(!e.event.sourceEvent)return;if(e.event.sourceEvent.type&&-1!==["start","brush","end"].indexOf(e.event.sourceEvent.type))return;let t=e.event.selection;t&&(t=t.map(this.x().invert)),t=this.extendBrush(t),this.redrawBrush(t,!1);const s=this.brushIsEmpty(t)?null:A.RangedFilter(t[0],t[1]);b.trigger(()=>{this.applyBrushSelection(s)},i.EVENT_DELAY)}applyBrushSelection(t){this.replaceFilter(t),this.redrawGroup()}setBrushExtents(t){this._brush.extent([[0,0],[this.effectiveWidth(),this.effectiveHeight()]]),this._gBrush.call(this._brush)}redrawBrush(t,e){if(this._brushOn&&this._gBrush)if(this._resizing&&this.setBrushExtents(e),t){const i=[this._x(t[0]),this._x(t[1])],s=u(e,this.transitionDuration(),this.transitionDelay())(this._gBrush);s.call(this._brush.move,i),s.selectAll("path."+Y).attr("display",null).attr("transform",(e,i)=>"translate("+this._x(t[i])+", 0)").attr("d",t=>this.resizeHandlePath(t))}else this._gBrush.call(this._brush.move,null),this._gBrush.selectAll("path."+Y).attr("display","none");this.fadeDeselectedArea(t)}fadeDeselectedArea(t){}resizeHandlePath(t){const e=+("e"===(t=t.type)),i=e?1:-1,s=this.effectiveHeight()/3;return"M"+.5*i+","+s+"A6,6 0 0 "+e+" "+6.5*i+","+(s+6)+"V"+(2*s-6)+"A6,6 0 0 "+e+" "+.5*i+","+2*s+"ZM"+2.5*i+","+(s+8)+"V"+(2*s-8)+"M"+4.5*i+","+(s+8)+"V"+(2*s-8)}_getClipPathId(){return this.anchorName().replace(/[ .#=\[\]"]/g,"-")+"-clip"}clipPadding(t){return arguments.length?(this._clipPadding=t,this):this._clipPadding}_generateClipPath(){const t=x.appendOrSelect(this._parent,"defs"),e=this._getClipPathId(),i=x.appendOrSelect(t,"#"+e,"clipPath").attr("id",e),s=2*this._clipPadding;x.appendOrSelect(i,"rect").attr("width",this.xAxisLength()+s).attr("height",this.yAxisHeight()+s).attr("transform","translate(-"+this._clipPadding+", -"+this._clipPadding+")")}_preprocessData(){}_doRender(){return this.resetSvg(),this._preprocessData(),this._generateG(),this._generateClipPath(),this._drawChart(!0),this._configureMouseZoom(),this}_doRedraw(){return this._preprocessData(),this._drawChart(!1),this._generateClipPath(),this}_drawChart(t){this.isOrdinal()&&(this._brushOn=!1),this._prepareXAxis(this.g(),t),this._prepareYAxis(this.g()),this.plotData(),(this.elasticX()||this._resizing||t)&&this.renderXAxis(this.g()),(this.elasticY()||this._resizing||t)&&this.renderYAxis(this.g()),t?this.renderBrush(this.g(),!1):this.redrawBrush(this.filter(),this._resizing),this.fadeDeselectedArea(this.filter()),this._resizing=!1}_configureMouseZoom(){this._origX=this._x.copy(),this._mouseZoomable?this._enableMouseZoom():this._hasBeenMouseZoomable&&this._disableMouseZoom()}_enableMouseZoom(){this._hasBeenMouseZoomable=!0;const t=[[0,0],[this.effectiveWidth(),this.effectiveHeight()]];if(this._zoom.scaleExtent(this._zoomScale).extent(t).duration(this.transitionDuration()),this._zoomOutRestrict){const e=Math.max(this._zoomScale[0],1);this._zoom.translateExtent(t).scaleExtent([e,this._zoomScale[1]])}this.root().call(this._zoom),this._updateD3zoomTransform()}_disableMouseZoom(){this.root().call(this._nullZoom)}_zoomHandler(t,e){let s;this._hasRangeSelected(t)?(this.x().domain(t),s=A.RangedFilter(t[0],t[1])):(this.x().domain(this._xOriginalDomain),s=null),this.replaceFilter(s),this.rescale(),this.redraw(),e||(this._rangeChart&&!x.arraysEqual(this.filter(),this._rangeChart.filter())&&b.trigger(()=>{this._rangeChart.replaceFilter(s),this._rangeChart.redraw()}),this._invokeZoomedListener(),b.trigger(()=>{this.redrawGroup()},i.EVENT_DELAY))}_domainToZoomTransform(t,i,s){const r=(i[1]-i[0])/(t[1]-t[0]),n=-1*s(t[0]);return e.zoomIdentity.scale(r).translate(n,0)}_updateD3zoomTransform(){this._zoom&&this._zoom.transform(this.root(),this._domainToZoomTransform(this.x().domain(),this._xOriginalDomain,this._origX))}_onZoom(){if(!e.event.sourceEvent)return;if(e.event.sourceEvent.type&&-1!==["start","zoom","end"].indexOf(e.event.sourceEvent.type))return;const t=e.event.transform.rescaleX(this._origX).domain();this.focus(t,!1)}_checkExtents(t,e){return t&&2===t.length&&e&&2===e.length?((t[0]>e[1]||t[1]<e[0])&&console.warn("Could not intersect extents, will reset"),[t[0]>e[0]?t[0]:e[0],t[1]<e[1]?t[1]:e[1]]):t}focus(t,e){this._zoomOutRestrict&&(t=this._checkExtents(t,this._xOriginalDomain),this._rangeChart&&(t=this._checkExtents(t,this._rangeChart.x().domain()))),this._zoomHandler(t,e),this._updateD3zoomTransform()}refocused(){return!x.arraysEqual(this.x().domain(),this._xOriginalDomain)}focusChart(t){return arguments.length?(this._focusChart=t,this.on("filtered.dcjs-range-chart",t=>{t.filter()?x.arraysEqual(t.filter(),this._focusChart.filter())||b.trigger(()=>{this._focusChart.focus(t.filter(),!0)}):b.trigger(()=>{this._focusChart.x().domain(this._focusChart.xOriginalDomain(),!0)})}),this):this._focusChart}brushOn(t){return arguments.length?(this._brushOn=t,this):this._brushOn}parentBrushOn(t){return arguments.length?(this._parentBrushOn=t,this):this._parentBrushOn}gBrush(){return this._gBrush}_hasRangeSelected(t){return t instanceof Array&&t.length>1}}const U=t=>(class extends t{constructor(){super(),this._cap=1/0,this._takeFront=!0,this._othersLabel="Others",this.ordering(t=>-t.value),this.data(t=>{if(this._cap===1/0)return this._computeOrderedGroups(t.all());{let e,i=t.all();if(i=this._computeOrderedGroups(i),this._cap)if(this._takeFront)e=i.slice(this._cap),i=i.slice(0,this._cap);else{const t=Math.max(0,i.length-this._cap);e=i.slice(0,t),i=i.slice(t)}return this._othersGrouper?this._othersGrouper(i,e):i}})}cappedKeyAccessor(t,e){return t.others?t.key:this.keyAccessor()(t,e)}cappedValueAccessor(t,e){return t.others?t.value:this.valueAccessor()(t,e)}_othersGrouper(t,i){const s=e.sum(i,this.valueAccessor()),r=i.map(this.keyAccessor());return s>0?t.concat([{others:r,key:this.othersLabel(),value:s}]):t}cap(t){return arguments.length?(this._cap=t,this):this._cap}takeFront(t){return arguments.length?(this._takeFront=t,this):this._takeFront}othersLabel(t){return arguments.length?(this._othersLabel=t,this):this._othersLabel}othersGrouper(t){return arguments.length?(this._othersGrouper=t,this):this._othersGrouper}onClick(t){t.others&&this.filter([t.others]),super.onClick(t)}}),W=2;class X{constructor(){this._parent=void 0,this._x=0,this._y=0,this._itemHeight=12,this._gap=5,this._horizontal=!1,this._legendWidth=560,this._itemWidth=70,this._autoItemWidth=!1,this._legendText=m("name"),this._maxItems=void 0,this._g=void 0}parent(t){return arguments.length?(this._parent=t,this):this._parent}x(t){return arguments.length?(this._x=t,this):this._x}y(t){return arguments.length?(this._y=t,this):this._y}gap(t){return arguments.length?(this._gap=t,this):this._gap}itemHeight(t){return arguments.length?(this._itemHeight=t,this):this._itemHeight}horizontal(t){return arguments.length?(this._horizontal=t,this):this._horizontal}legendWidth(t){return arguments.length?(this._legendWidth=t,this):this._legendWidth}itemWidth(t){return arguments.length?(this._itemWidth=t,this):this._itemWidth}autoItemWidth(t){return arguments.length?(this._autoItemWidth=t,this):this._autoItemWidth}legendText(t){return arguments.length?(this._legendText=t,this):this._legendText}maxItems(t){return arguments.length?(this._maxItems=x.isNumber(t)?t:void 0,this):this._maxItems}_legendItemHeight(){return this._gap+this._itemHeight}render(){this._parent.svg().select("g.dc-legend").remove(),this._g=this._parent.svg().append("g").attr("class","dc-legend").attr("transform","translate("+this._x+","+this._y+")");let t=this._parent.legendables();void 0!==this._maxItems&&(t=t.slice(0,this._maxItems));const e=this._g.selectAll("g.dc-legend-item").data(t).enter().append("g").attr("class","dc-legend-item").on("mouseover",t=>{this._parent.legendHighlight(t)}).on("mouseout",t=>{this._parent.legendReset(t)}).on("click",t=>{t.chart.legendToggle(t)});this._g.selectAll("g.dc-legend-item").classed("fadeout",t=>t.chart.isLegendableHidden(t)),t.some(m("dashstyle"))?e.append("line").attr("x1",0).attr("y1",this._itemHeight/2).attr("x2",this._itemHeight).attr("y2",this._itemHeight/2).attr("stroke-width",2).attr("stroke-dasharray",m("dashstyle")).attr("stroke",m("color")):e.append("rect").attr("width",this._itemHeight).attr("height",this._itemHeight).attr("fill",t=>t?t.color:"blue");{const t=this;e.append("text").text(t._legendText).attr("x",t._itemHeight+W).attr("y",function(){return t._itemHeight/2+(this.clientHeight?this.clientHeight:13)/2-2})}let i=0,s=0;{const t=this;e.attr("transform",function(e,r){if(t._horizontal){const e=!0===t._autoItemWidth?this.getBBox().width+t._gap:t._itemWidth;i+e>t._legendWidth&&i>0&&(++s,i=0);const r="translate("+i+","+s*t._legendItemHeight()+")";return i+=e,r}return"translate(0,"+r*t._legendItemHeight()+")"})}}}const q=t=>(class extends t{constructor(){super(),this._stackLayout=e.stack(),this._stack=[],this._titles={},this._hidableStacks=!1,this._evadeDomainFilter=!1,this.data(()=>{const t=this._stack.filter(this._visibility);if(!t.length)return[];t.forEach((t,e)=>this._prepareValues(t,e));const e=t[0].values.map((e,i)=>{const s={x:e.x};return t.forEach(t=>{s[t.name]=t.values[i].y}),s}),i=t.map(t=>t.name);return this.stackLayout().keys(i)(e).forEach((e,i)=>{e.forEach((e,s)=>{t[i].values[s].y0=e[0],t[i].values[s].y1=e[1]})}),t}),this.colorAccessor(function(t){return this.layer||this.name||t.name||t.layer})}_prepareValues(t,e){const i=t.accessor||this.valueAccessor();t.name=String(t.name||e);const s=t.group.all().map((e,s)=>({x:this.keyAccessor()(e,s),y:t.hidden?null:i(e,s),data:e,layer:t.name,hidden:t.hidden}));t.domainValues=s.filter(t=>this._domainFilter()(t)),t.values=this.evadeDomainFilter()?s:t.domainValues}_domainFilter(){if(!this.x())return x.constant(!0);const t=this.x().domain();return this.isOrdinal()?()=>!0:this.elasticX()?()=>!0:e=>e.x>=t[0]&&e.x<=t[t.length-1]}stack(t,e,i){if(!arguments.length)return this._stack;arguments.length<=2&&(i=e);const s={group:t};return"string"==typeof e&&(s.name=e),"function"==typeof i&&(s.accessor=i),this._stack.push(s),this}group(t,e,i){return arguments.length?(this._stack=[],this._titles={},this.stack(t,e),i&&this.valueAccessor(i),super.group(t,e)):super.group()}hidableStacks(t){return arguments.length?(this._hidableStacks=t,this):this._hidableStacks}_findLayerByName(t){const e=this._stack.map(m("name")).indexOf(t);return this._stack[e]}hideStack(t){const e=this._findLayerByName(t);return e&&(e.hidden=!0),this}showStack(t){const e=this._findLayerByName(t);return e&&(e.hidden=!1),this}getValueAccessorByIndex(t){return this._stack[t].accessor||this.valueAccessor()}yAxisMin(){const t=e.