').replace(/(\r?\n|\t)/g,"").split(/{{(.*)}}/)},setTooltipPosition:function(t,e){var n=this;const s=this,a=s.config,r=s.scale,o=s.state,c=s.$el,l=c.eventRect,d=c.tooltip,u=a.tooltip_contents.bindto,h=a.axis_rotated,g=null==d?void 0:d.datum();if(!u&&g){var f,p;const c=null!=t?t:JSON.parse(g.current),u=G(o.event,null!=e?e:null==l?void 0:l.node()),x={x:u[0],y:u[1]};if(o.hasAxis&&r.x&&g&&"x"in g){const t=function(t,e,a){var c;void 0===t&&(t=0),void 0===a&&(a="y"),i(this,n);const l=r[e?null==(c=s.axis)?void 0:c.getId(e):a];return l?l(t)+(h?o.margin.left:o.margin.top):0}.bind(this);x.xAxis=r.x(g.x)+(a.tooltip_position?h?o.margin.top:o.margin.left:0),1===c.length?x.yAxis=t(c[0].value,c[0].id):x.yAxis=t}const b=g.width,m=void 0===b?0:b,_=g.height,v=void 0===_?0:_,y=null!=(f=null==(p=a.tooltip_position)?void 0:p.bind(s.api)(c,m,v,null==l?void 0:l.node(),x))?f:s.getTooltipPosition.bind(s)(m,v,x);["top","left"].forEach(function(t){i(this,n);const e=y[t];d.style(t,e+"px"),"left"!==t||g.xPosInPercent||(g.xPosInPercent=e/o.current.width*100)}.bind(this))}},getTooltipPosition:function(t,e,n){var s=this;const a=this,r=a.config,o=a.scale,c=a.state,l=c,d=l.width,u=l.height,h=l.current,g=l.isLegendRight,f=l.inputType,p=a.hasType("gauge")&&!r.gauge_fullCircle,x=c.hasTreemap,b=r.axis_rotated,m=a.hasArcType(),_=a.getSvgLeft(!0);let v=_+h.width-a.getCurrentPaddingByDirection("right");let y=n.x,T=n.y;if(m){"touch"===f||a.hasType("radar")||(y+=(d-(g?a.getLegendWidth():0))/2,T+=p?u:u/2)}else if(!x){const t={top:a.getCurrentPaddingByDirection("top",!0),left:a.getCurrentPaddingByDirection("left",!0)};b?(y+=_+t.left+20,T=t.top+n.xAxis+20,v-=_):(y=_+t.left+20+(o.zoom?y:n.xAxis),T+=t.top-5)}if(y+t+15>v&&(y-=t+(x||m?0:b?40:38)),T+e>h.height){T-=p?3*e:e+(x?0:30)}const w={top:T,left:y};return Object.keys(w).forEach(function(t){i(this,s),w[t]<0&&(w[t]=0)}.bind(this)),w},showTooltip:function(t,e){var n=this;const s=this,a=s.config,r=s.$el.tooltip,o=t.filter(function(t){return i(this,n),t&&T(s.getBaseValue(t))}.bind(this));if(!r||0===o.length||!a.tooltip_show)return;let c=r.datum();const l=JSON.stringify(t);if(!c||c.current!==l){const e=t.concat().sort()[0],i=e.index,n=e.x;$(a.tooltip_onshow,s.api,t),r.html(s.getTooltipHTML(t,s.axis?s.axis.getXAxisTickFormat():s.categoryName.bind(s),s.getDefaultValueFormat(),s.color)).style("display",null).style("visibility",null).datum(c={index:i,x:n,current:l,width:r.property("offsetWidth"),height:r.property("offsetHeight")}),$(a.tooltip_onshown,s.api,t),s._handleLinkedCharts(!0,i)}s.setTooltipPosition(o,e)},bindTooltipResizePos:function(){var t=this;const e=this,n=e.resizeFunction,s=e.state,a=e.$el.tooltip;n.add(function(){if(i(this,t),"block"===a.style("display")){const t=s.current,e=a.datum(),i=e.width,n=e.xPosInPercent;let r=t.width/100*n;const o=t.width-(r+i);o<0&&(r+=o),a.style("left",r+"px")}}.bind(this))},hideTooltip:function(t){const e=this,i=e.api,n=e.config,s=e.$el.tooltip;if(s&&"none"!==s.style("display")&&(!n.tooltip_doNotHide||t)){var a;const t=JSON.parse(null!=(a=s.datum().current)?a:{});$(n.tooltip_onhide,i,t),s.style("display","none").style("visibility","hidden").datum(null),$(n.tooltip_onhidden,i,t)}},_handleLinkedCharts:function(t,e){var n=this;const s=this,a=s.charts,o=s.config,c=s.state.event;if(null!=c&&c.isTrusted&&o.tooltip_linked&&a.length>1){const c=o.tooltip_linked_name;a.filter(function(t){return i(this,n),t!==s.api}.bind(this)).forEach(function(s){i(this,n);const a=s.internal,o=a.config,l=a.$el,d=o.tooltip_linked,u=o.tooltip_linked_name,h=r.body.contains(l.chart.node());if(d&&c===u&&h){const i=l.tooltip.data()[0],n=e!==(null==i?void 0:i.index);try{s.tooltip[t&&n?"show":"hide"]({index:e})}catch(t){}}}.bind(this))}},updateTooltipOnRedraw:function(t,e){var n=this;const a=this,o=a.config,c=a.$el,l=c.eventRect,d=c.svg,u=c.tooltip,h=a.state,g=h.event,f=h.hasAxis,p=h.hasRadar,x=h.hasTreemap;if("block"===(null==u?void 0:u.style("display"))&&g){var b;const c=null!=t?t:null==(b=p?d:l)?void 0:b.node();if(f||p)if(a.isMultipleX())a.selectRectForMultipleXs(c,!1);else{const t=null!=e?e:a.getDataIndexFromEvent(g);-1===e?a.api.tooltip.hide():(a.selectRectForSingle(c,t),a.setExpand(t,null,!0))}else{const t=g.clientX,e=g.clientY;setTimeout(function(){i(this,n);let o=r.elementFromPoint(t,e);const c=(0,s.select)(o).datum();if(c){const t=a.hasArcType()?a.convertToArcData(a.updateAngle(c)):null==c?void 0:c.data;x&&(o=d.node()),t&&a.showTooltip([t],o)}else a.api.tooltip.hide()}.bind(this),o.transition_duration)}}}},ii={getTranslate:function(t,e){void 0===e&&(e=0);const i=this,n=i.config,s=i.state,a=n.axis_rotated;let r,o,c=0;if(e&&/^(x|y2?)$/.test(t)&&(c=i.getAxisSize(t)*e),"main"===t)r=O(s.margin.left),o=O(s.margin.top);else if("context"===t)r=O(s.margin2.left),o=O(s.margin2.top);else if("legend"===t)r=s.margin3.left,o=s.margin3.top;else if("x"===t)r=a?-c:0,o=a?0:s.height+c;else if("y"===t)r=a?0:-c,o=a?s.height+c:0;else if("y2"===t)r=a?0:s.width+c,o=a?-c-1:0;else if("subX"===t)r=0,o=a?0:s.height2;else if("arc"===t)r=s.arcWidth/2,o=s.arcHeight/2;else if("polar"===t)r=s.arcWidth/2,o=s.arcHeight/2;else if("radar"===t){const t=i.getRadarSize()[0];r=s.width/2-t,o=O(s.margin.top)}return"translate("+r+", "+o+")"},transformMain:function(t,e){const i=this,n=i.$el.main,s=i.$T,a=null!=e&&e.axisX?e.axisX:s(n.select("."+xt.axisX),t),r=null!=e&&e.axisY?e.axisY:s(n.select("."+xt.axisY),t),o=null!=e&&e.axisY2?e.axisY2:s(n.select("."+xt.axisY2),t);s(n,t).attr("transform",i.getTranslate("main")),a.attr("transform",i.getTranslate("x")),r.attr("transform",i.getTranslate("y")),o.attr("transform",i.getTranslate("y2")),n.select("."+ft.chartArcs).attr("transform",i.getTranslate("arc"))},transformAll:function(t,e){const i=this,n=i.config,s=i.state,a=s.hasAxis,r=s.hasTreemap,o=i.$el;r||i.transformMain(t,e),a&&n.subchart_show&&i.transformContext(t,e),o.legend&&i.transformLegend(t)}},ni={isValidChartType:function(t){return!!(t&&Object.values(d).indexOf(t)>-1)},setTargetType:function(t,e){var n=this;const s=this,a=s.config,r=s.state.withoutFadeIn;s.mapToTargetIds(t).forEach(function(t){i(this,n),r[t]=e===a.data_types[t],a.data_types[t]=e}.bind(this)),t||(a.data_type=e)},updateTypesElements:function(){var t=this;const e=this,n=e.state.current;Object.keys(d).forEach(function(s){i(this,t);const a=d[s],r=e.hasType(a,null,!0),o=n.types.indexOf(a);-1===o&&r?n.types.push(a):o>-1&&!r&&n.types.splice(o,1)}.bind(this)),e.setChartElements()},hasType:function(t,e,n){var s,a=this;void 0===n&&(n=!1);const r=this,o=r.config,c=r.state.current,l=o.data_types,d=e||r.data.targets;let u=!1;return!n&&(null==(s=c.types)?void 0:s.indexOf(t))>-1?u=!0:null!=d&&d.length?d.forEach(function(e){i(this,a);const n=l[e.id];(n===t||!n&&"line"===t)&&(u=!0)}.bind(this)):Object.keys(l).length?Object.keys(l).forEach(function(e){i(this,a),l[e]===t&&(u=!0)}.bind(this)):u=o.data_type===t,u},hasTypeOf:function(t,e,n){var s=this;return void 0===n&&(n=[]),t in h&&!h[t].filter(function(t){return i(this,s),-1===n.indexOf(t)}.bind(this)).every(function(t){return i(this,s),!this.hasType(t,e)}.bind(this))},isTypeOf:function(t,e){const i=A(t)?t:t.id,n=this.config.data_types[i]||this.config.data_type;return z(e)?e.indexOf(n)>=0:n===e},hasPointType:function(){const t=this;return t.hasTypeOf("Line")||t.hasType("bubble")||t.hasType("scatter")},hasArcType:function(t,e){return this.hasTypeOf("Arc",t,e)},hasMultiArcGauge:function(){return this.hasType("gauge")&&"multi"===this.config.gauge_type},isLineType:function(t){const e=A(t)?t:t.id;return!this.config.data_types[e]||this.isTypeOf(e,h.Line)},isStepType:function(t){return this.isTypeOf(t,h.Step)},isSplineType:function(t){return this.isTypeOf(t,h.Spline)},isAreaType:function(t){return this.isTypeOf(t,h.Area)},isAreaRangeType:function(t){return this.isTypeOf(t,h.AreaRange)},isBarType:function(t){return this.isTypeOf(t,"bar")},isBubbleType:function(t){return this.isTypeOf(t,"bubble")},isCandlestickType:function(t){return this.isTypeOf(t,"candlestick")},isScatterType:function(t){return this.isTypeOf(t,"scatter")},isTreemapType:function(t){return this.isTypeOf(t,"treemap")},isPieType:function(t){return this.isTypeOf(t,"pie")},isGaugeType:function(t){return this.isTypeOf(t,"gauge")},isDonutType:function(t){return this.isTypeOf(t,"donut")},isPolarType:function(t){return this.isTypeOf(t,"polar")},isRadarType:function(t){return this.isTypeOf(t,"radar")},isArcType:function(t){return this.isPieType(t)||this.isDonutType(t)||this.isGaugeType(t)||this.isPolarType(t)||this.isRadarType(t)},isCirclePoint:function(t){const e=this.config,i=e.point_pattern;let n=!1;return n="circle"===(null==t?void 0:t.tagName)||"circle"===e.point_type&&(!i||z(i)&&0===i.length),n},lineData:function(t){return this.isLineType(t)?[t]:[]},arcData:function(t){return this.isArcType(t.data)?[t]:[]},labelishData:function(t){var e=this;return this.isBarType(t)||this.isLineType(t)||this.isScatterType(t)||this.isBubbleType(t)||this.isCandlestickType(t)||this.isRadarType(t)||this.isTreemapType(t)?t.values.filter(function(t){return i(this,e),S(t.value)||!!t.value}.bind(this)):[]},barLineBubbleData:function(t){return this.isBarType(t)||this.isLineType(t)||this.isBubbleType(t)?t.values:[]},isInterpolationType:function(t){return["basis","basis-closed","basis-open","bundle","cardinal","cardinal-closed","cardinal-open","catmull-rom","catmull-rom-closed","catmull-rom-open","linear","linear-closed","monotone-x","monotone-y","natural"].indexOf(t)>=0}};let si=function(){function t(t){this.api=void 0,this.config=void 0,this.cache=void 0,this.$el=void 0,this.state=void 0,this.charts=void 0,this.data={xs:{},targets:[]},this.axis=void 0,this.scale={x:null,y:null,y2:null,subX:null,subY:null,subY2:null,zoom:null},this.org={xScale:null,xDomain:null},this.color=void 0,this.patterns=void 0,this.levelColor=void 0,this.point=void 0,this.brush=void 0,this.format={extraLineClasses:null,xAxisTick:null,dataTime:null,defaultAxisTime:null,axisTime:null};const e=this;e.api=t,e.config=new te,e.cache=new ue;const i=new Nt;e.$el=i.getStore("element"),e.state=i.getStore("state"),e.$T=e.$T.bind(e)}var e=t.prototype;return e.$T=function(t,e,i){const n=this.config,a=this.state,r=n.transition_duration,o=n.subchart_show;let c=t;if(c){"tagName"in c&&(c=(0,s.select)(c));c=(!1!==e&&r||e)&&(!a.zooming||a.dragging)&&!a.resizing&&a.rendered&&!o?c.transition(i).duration(r):c}return c},e.beforeInit=function(){const t=this;t.callPluginHook("$beforeInit"),$(t.config.onbeforeinit,t.api)},e.afterInit=function(){const t=this;t.callPluginHook("$afterInit"),$(t.config.onafterinit,t.api)},e.init=function(){const t=this,e=t.config,i=t.state,n=t.$el,a=e.boost_useCssRule;if(dt(t),i.hasRadar=!i.hasAxis&&t.hasType("radar"),i.hasTreemap=!i.hasAxis&&t.hasType("treemap"),i.hasAxis=!t.hasArcType()&&!i.hasTreemap,i.datetimeId="bb-"+ +new Date*H(),a){const t=r.createElement("style");t.type="text/css",r.head.appendChild(t),i.style={rootSelctor:"."+i.datetimeId,sheet:t.sheet},n.style=t}const o={element:e.bindto,classname:"bb"};M(e.bindto)&&(o.element=e.bindto.element||"#chart",o.classname=e.bindto.classname||o.classname),n.chart=w(o.element.node)?e.bindto.element:(0,s.select)(o.element||[]),n.chart.empty()&&(n.chart=(0,s.select)(r.body.appendChild(r.createElement("div")))),n.chart.html("").classed(o.classname,!0).classed(i.datetimeId,a).style("position","relative"),t.initParams(),t.initToRender()},e.initToRender=function(t){var e=this;const n=this,s=n.config,r=n.state,o=n.$el.chart,c=function(){return i(this,e),"none"===o.style("display")||"hidden"===o.style("visibility")}.bind(this),l=s.render.lazy||c(),d=a.MutationObserver;l&&d&&!1!==s.render.observe&&!t&&new d(function(t,s){i(this,e),c()||(s.disconnect(),r.rendered||n.initToRender(!0))}.bind(this)).observe(o.node(),{attributes:!0,attributeFilter:["class","style"]}),l&&!t||n.convertData(s,function(t){i(this,e),n.initWithData(t),n.afterInit()}.bind(this))},e.initParams=function(){var t=this;const e=this,s=e.config,o=e.format,c=e.state,l=s.axis_rotated;if(e.color=e.generateColor(),e.levelColor=e.generateLevelColor(),!1===s.padding&&(s.axis_x_show=!1,s.axis_y_show=!1,s.axis_y2_show=!1,s.subchart_show=!1),e.hasPointType()&&(e.point=e.generatePoint()),c.hasAxis){e.initClip(),o.extraLineClasses=e.generateExtraLineClass(),o.dataTime=s.data_xLocaltime?n.timeParse:n.utcParse,o.axisTime=s.axis_x_localtime?n.timeFormat:n.utcFormat;const a=e.config.zoom_enabled&&"drag"===e.config.zoom_type;o.defaultAxisTime=function(n){i(this,t);const s=e.scale,r=s.x,c=s.zoom,l=a?c:c&&r.orgDomain().toString()!==c.domain().toString(),d=(n.getMilliseconds()?".%L":n.getSeconds()&&".:%S")||n.getMinutes()&&"%I:%M"||n.getHours()&&"%I %p"||1!==n.getDate()&&"%b %d"||l&&1===n.getDate()&&"%b'%y"||n.getMonth()&&"%-m/%-d"||"%Y";return o.axisTime(d)(n)}.bind(this)}c.isLegendRight="right"===s.legend_position,c.isLegendInset="inset"===s.legend_position,c.isLegendTop="top-left"===s.legend_inset_anchor||"top-right"===s.legend_inset_anchor,c.isLegendLeft="top-left"===s.legend_inset_anchor||"bottom-left"===s.legend_inset_anchor,c.rotatedPadding.top=e.getResettedPadding(c.rotatedPadding.top),c.rotatedPadding.right=l&&!s.axis_x_show?0:30,c.inputType=function(t,e){var n=this;const s=a.DocumentTouch,o=a.matchMedia,c=a.navigator;let l=!1;if(e)if(c&&"maxTouchPoints"in c)l=c.maxTouchPoints>0;else if("ontouchmove"in a||s&&r instanceof s)l=!0;else if(null!=o&&o("(pointer:coarse)").matches)l=!0;else{const t=c.userAgent;l=/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(t)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(t)}return(t&&["any-hover:hover","any-pointer:fine"].some(function(t){return i(this,n),null==o?void 0:o("("+t+")").matches}.bind(this))?"mouse":l&&"touch")||"mouse"}(s.interaction_inputType_mouse,s.interaction_inputType_touch)},e.initWithData=function(t){var e=this;const n=this,s=n.config,a=n.scale,r=n.state,o=n.$el,c=n.org,l=r,d=l.hasAxis,u=l.hasTreemap,h=s.interaction_enabled,g=n.hasType("polar");if(d&&(n.axis=n.getAxisInstance(),s.zoom_enabled&&n.initZoom()),n.data.xs={},n.data.targets=n.convertDataToTargets(t),s.data_filter&&(n.data.targets=n.data.targets.filter(s.data_filter.bind(n.api))),s.data_hide&&n.addHiddenTargetIds(!0===s.data_hide?n.mapToIds(n.data.targets):s.data_hide),s.legend_hide&&n.addHiddenLegendIds(!0===s.legend_hide?n.mapToIds(n.data.targets):s.legend_hide),n.updateSizes(),n.updateScales(!0),d){const t=a.x,e=a.y,i=a.y2,r=a.subX,o=a.subY,l=a.subY2;t&&(t.domain(it(n.getXDomain(n.data.targets),!s.axis_x_inverted)),r.domain(t.domain()),c.xDomain=t.domain()),e&&(e.domain(n.getYDomain(n.data.targets,"y")),o.domain(e.domain())),i&&(i.domain(n.getYDomain(n.data.targets,"y2")),l&&l.domain(i.domain()))}if(o.svg=o.chart.append("svg").style("overflow","hidden").style("display","block"),h&&r.inputType){const t="touch"===r.inputType,e=s.onclick,i=s.onover,a=s.onout;o.svg.on("click",(null==e?void 0:e.bind(n.api))||null).on(t?"touchstart":"mouseenter",(null==i?void 0:i.bind(n.api))||null).on(t?"touchend":"mouseleave",(null==a?void 0:a.bind(n.api))||null)}s.svg_classname&&o.svg.attr("class",s.svg_classname);const f=w(s.color_tiles)&&n.patterns;(d||f||g||u||s.data_labels_backgroundColors)&&(o.defs=o.svg.append("defs"),d&&["id","idXAxis","idYAxis","idGrid"].forEach(function(t){i(this,e),n.appendClip(o.defs,r.clip[t])}.bind(this)),n.generateDataLabelBackgroundColorFilter(),f&&n.patterns.forEach(function(t){var n=this;return i(this,e),o.defs.append(function(){return i(this,n),t.node}.bind(this))}.bind(this))),n.updateSvgSize(),n.bindResize();const p=o.svg.append("g").classed(gt.main,!0).attr("transform",u?null:n.getTranslate("main"));var x;(o.main=p,s.subchart_show&&n.initSubchart(),s.tooltip_show&&n.initTooltip(),s.title_text&&n.initTitle(),!u&&s.legend_show&&n.initLegend(),s.data_empty_label_text&&p.append("text").attr("class",zt.text+" "+gt.empty).attr("text-anchor","middle").attr("dominant-baseline","middle"),d&&(s.regions.length&&n.initRegion(),s.clipPath||n.axis.init()),p.append("g").classed(gt.chart,!0).attr("clip-path",d?r.clip.path:null),n.callPluginHook("$init"),n.initChartElements(),d)&&(h&&(null==n.initEventRect||n.initEventRect()),n.initGrid(),s.clipPath&&(null==(x=n.axis)||x.init()));if(n.updateTargets(n.data.targets),n.updateDimension(),$(s.oninit,n.api),n.setBackground(),n.redraw({withTransition:!1,withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransitionForAxis:!1,initializing:!0}),s.data_onmin||s.data_onmax){const t=n.getMinMaxData();$(s.data_onmin,n.api,t.min),$(s.data_onmax,n.api,t.max)}s.tooltip_show&&n.initShowTooltip(),r.rendered=!0},e.initChartElements=function(){var t=this;const e=this,n=e.state,s=n.hasAxis,a=n.hasRadar,r=n.hasTreemap,o=[];if(s){const n=["bar","bubble","candlestick","line"];e.config.bar_front&&n.push(n.shift()),n.forEach(function(n){i(this,t);const s=q(n);("line"===n&&e.hasTypeOf(s)||e.hasType(n))&&o.push(s)}.bind(this))}else if(r)o.push("Treemap");else{const t=e.hasType("polar");a||o.push("Arc","Pie"),e.hasType("gauge")?o.push("Gauge"):a?o.push("Radar"):t&&o.push("Polar")}o.forEach(function(n){i(this,t),e["init"+n]()}.bind(this)),D(e.config.data_labels)&&!e.hasArcType(null,["radar"])&&e.initText()},e.setChartElements=function(){const t=this.$el,e=t.chart,i=t.svg,n=t.defs,s=t.main,a=t.tooltip,r=t.legend,o=t.title,c=t.grid,l=t.needle,d=t.arcs,u=t.circle,h=t.bar,g=t.candlestick,f=t.line,p=t.area,x=t.text;this.api.$={chart:e,svg:i,defs:n,main:s,tooltip:a,legend:r,title:o,grid:c,arc:d,circles:u,bar:{bars:h},candlestick:g,line:{lines:f,areas:p},needle:l,text:{texts:x}}},e.setBackground=function(){const t=this,e=t.config.background,i=t.state,n=t.$el.svg;if(D(e)){const t=n.select("g").insert(e.imgUrl?"image":"rect",":first-child");e.imgUrl?t.attr("href",e.imgUrl):e.color&&t.style("fill",e.color).attr("clip-path",i.clip.path),t.attr("class",e.class||null).attr("width","100%").attr("height","100%")}},e.updateTargets=function(t){var e=this;const n=this,s=n.state,a=s.hasAxis,r=s.hasRadar,o=s.hasTreemap,c=function(s){return i(this,e),n["updateTargetsFor"+s](t.filter(n["is"+s+"Type"].bind(n)))}.bind(this);if(n.updateTargetsForText(t),a)["bar","candlestick","line"].forEach(function(t){i(this,e);const s=q(t);("line"===t&&n.hasTypeOf(s)||n.hasType(t))&&c(s)}.bind(this)),n.updateTargetsForSubchart&&n.updateTargetsForSubchart(t);else if(n.hasArcType(t)){let t="Arc";r?t="Radar":n.hasType("polar")&&(t="Polar"),c(t)}else o&&c("Treemap");const l=n.hasType("bubble")||n.hasType("scatter");l&&(null==n.updateTargetForCircle||n.updateTargetForCircle()),n.filterTargetsToShowAtInit(l)},e.filterTargetsToShowAtInit=function(t){var e=this;void 0===t&&(t=!1);const n=this,s=n.$el.svg,a=n.$T;let r="."+gt.target;t&&(r+=", ."+_t.chartCircles+" > ."+_t.circles),a(s.selectAll(r).filter(function(t){return i(this,e),n.isTargetToShow(t.id)}.bind(this))).style("opacity",null)},e.getWithOption=function(t){var e=this;const n={Dimension:!0,EventRect:!0,Legend:!1,Subchart:!0,Transform:!1,Transition:!0,TrimXDomain:!0,UpdateXAxis:"UpdateXDomain",UpdateXDomain:!1,UpdateOrgXDomain:!1,TransitionForExit:"Transition",TransitionForAxis:"Transition",Y:!0};return Object.keys(n).forEach(function(s){i(this,e);let a=n[s];A(a)&&(a=n[a]),n[s]=X(t,"with"+s,a)}.bind(this)),n},e.initialOpacity=function(t){const e=this.state.withoutFadeIn;return null!==this.getBaseValue(t)&&e[t.id]?null:"0"},e.bindResize=function(){var t=this;const e=this,n=e.config,s=e.state,r=function(t){var e=this;const n=[];let s;const a=function(){var e=this;a.clear(),!1===t?l(function(){var t=this;i(this,e),n.forEach(function(e){return i(this,t),e()}.bind(this))}.bind(this),{timeout:200}):s=he(function(){var t=this;i(this,e),n.forEach(function(e){return i(this,t),e()}.bind(this))}.bind(this),S(t)?t:200)};return a.clear=function(){i(this,e),s&&(ge(s),s=null)}.bind(this),a.add=function(t){return i(this,e),n.push(t)}.bind(this),a.remove=function(t){return i(this,e),n.splice(n.indexOf(t),1)}.bind(this),a}(n.resize_timer),o=[];o.push(function(){return i(this,t),$(n.onresize,e.api)}.bind(this)),n.resize_auto&&o.push(function(){i(this,t),s.resizing=!0,n.legend_show&&(e.updateSizes(),e.updateLegend()),e.api.flush(!1)}.bind(this)),o.push(function(){i(this,t),$(n.onresized,e.api),s.resizing=!1}.bind(this)),o.forEach(function(e){return i(this,t),r.add(e)}.bind(this)),e.resizeFunction=r,a.addEventListener("resize",e.resizeFunction=r)},e.callPluginHook=function(t){for(var e=this,n=arguments.length,s=Array(n>1?n-1:0),a=1;a\n\t\t\t\n\t\t\t\t'+x+"\n\t\t\t\t"+f.replace(/(url\()[^#]+/g,"$1")+"\n\t\t\t";return"data:image/svg+xml;base64,"+li(b)}function ui(t){var e=this;const n=t.getBoundingClientRect(),s=n.left,r=n.top,o=function(t){return i(this,e),t.textContent||t.childElementCount}.bind(this),c=[];return K(t.querySelectorAll("text")).filter(o).forEach(function(t){var n=this;i(this,e);const l=function(t){var e;i(this,n);const o=a.getComputedStyle(t),c=o.fill,l=o.fontFamily,d=o.fontSize,u=o.textAnchor,h=o.transform,g=function(t,e){const i=e.top,n=e.left,s=t.getBBox(),a=s.x,r=s.y,o=t.getScreenCTM(),c=o.a,l=o.b,d=o.c,u=o.d,h=o.e,g=o.f,f=t.getBoundingClientRect(),p=f.width,x=f.height;return{x:c*a+d*r+h-n,y:l*a+u*r+g-i+(x-Math.round(x/4)),width:p,height:x}}(t,{left:s,top:r}),f=g.x,p=g.y,x=g.width,b=g.height;return(e={})[t.textContent]={x:f,y:p,width:x,height:b,fill:c,fontFamily:l,fontSize:d,textAnchor:u,transform:h},e}.bind(this);if(t.childElementCount>1)return K(t.querySelectorAll("tspan")).filter(o).forEach(function(t){i(this,n),c.push(l(t))}.bind(this)),[];c.push(l(t))}.bind(this)),c}var hi={export:function(t,e){var n=this;const s=this.internal,a=s.state,o=s.$el,c=o.chart,l=o.svg,d=a.current,u=d.width,h=d.height,g=et({width:u,height:h,preserveAspectRatio:!0,preserveFontStyle:!1,mimeType:"image/png"},t),f=di(c.node(),g,{width:u,height:h}),p=g.preserveFontStyle?ui(l.node()):[];if(e&&w(e)){const t=new Image;t.crossOrigin="Anonymous",t.onload=function(){i(this,n);const s=r.createElement("canvas"),a=s.getContext("2d");s.width=g.width||u,s.height=g.height||h,a.drawImage(t,0,0),p.length&&(!function(t,e){var n=this;e.forEach(function(e){var s=this;i(this,n),Object.keys(e).forEach(function(n){var a=this;i(this,s);const r=e[n],o=r.x,c=r.y,l=r.width,d=r.height,u=r.fill,h=r.fontFamily,g=r.fontSize,f=r.transform;if(t.save(),t.font=g+" "+h,t.fillStyle=u,"none"===f)t.fillText(n,o,c);else{const e=f.replace(/(matrix|\(|\))/g,"").split(",");e.splice(4).every(function(t){return i(this,a),0==+t}.bind(this))?(e.push(o+l-l/4),e.push(c-d+d/3)):(e.push(o),e.push(c)),t.transform.apply(t,e),t.fillText(n,0,0)}t.restore()}.bind(this))}.bind(this))}(a,p),p.length=0),e.bind(this)(s.toDataURL(g.mimeType))}.bind(this),t.src=f}return f}},gi={focus:function(t){var e=this;const n=this.internal,s=n.state,a=n.mapToTargetIds(t),r=n.$el.svg.selectAll(n.selectorTargets(a.filter(n.isTargetToShow,n)));this.revert(),this.defocus(),r.classed(kt.focused,!0).classed(kt.defocused,!1),n.hasArcType()&&!s.hasRadar&&(n.expandArc(a),n.hasType("gauge")&&n.markOverlapped(t,n,"."+Tt.gaugeValue)),n.toggleFocusLegend(a,!0),s.focusedTargetIds=a,s.defocusedTargetIds=s.defocusedTargetIds.filter(function(t){return i(this,e),a.indexOf(t)<0}.bind(this))},defocus:function(t){var e=this;const n=this.internal,s=n.state,a=n.mapToTargetIds(t);n.$el.svg.selectAll(n.selectorTargets(a.filter(n.isTargetToShow,n))).classed(kt.focused,!1).classed(kt.defocused,!0),n.hasArcType(null,["polar"])&&(n.unexpandArc(a),n.hasType("gauge")&&n.undoMarkOverlapped(n,"."+Tt.gaugeValue)),n.toggleFocusLegend(a,!1),s.focusedTargetIds=s.focusedTargetIds.filter(function(t){return i(this,e),a.indexOf(t)<0}.bind(this)),s.defocusedTargetIds=a},revert:function(t){const e=this.internal,i=e.config,n=e.state,a=e.$el,r=e.mapToTargetIds(t);a.svg.selectAll(e.selectorTargets(r)).classed(kt.focused,!1).classed(kt.defocused,!1),e.hasArcType(null,["polar"])&&e.unexpandArc(r),i.legend_show&&(e.showLegend(r.filter(e.isLegendToShow.bind(e))),a.legend.selectAll(e.selectorLegends(r)).filter((function(){return(0,s.select)(this).classed(kt.legendItemFocused)})).classed(kt.legendItemFocused,!1)),n.focusedTargetIds=[],n.defocusedTargetIds=[]}};var fi={legend:{show:function(t){const e=this.internal;e.showLegend(e.mapToTargetIds(t)),e.updateAndRedraw({withLegend:!0})},hide:function(t){const e=this.internal;e.hideLegend(e.mapToTargetIds(t)),e.updateAndRedraw({withLegend:!0})}}},pi={load:function(t){var e=this;const n=this.internal,s=n.config;t.xs&&n.addXs(t.xs),"names"in t&&this.data.names(t.names),"classes"in t&&Object.keys(t.classes).forEach(function(n){i(this,e),s.data_classes[n]=t.classes[n]}.bind(this)),"categories"in t&&n.axis.isCategorized()&&(s.axis_x_categories=t.categories),"axes"in t&&Object.keys(t.axes).forEach(function(n){i(this,e),s.data_axes[n]=t.axes[n]}.bind(this)),"colors"in t&&Object.keys(t.colors).forEach(function(n){i(this,e),s.data_colors[n]=t.colors[n]}.bind(this)),"unload"in t&&!1!==t.unload?n.unload(n.mapToTargetIds(!0===t.unload?null:t.unload),function(){var s=this;i(this,e),l(function(){return i(this,s),n.loadFromArgs(t)}.bind(this))}.bind(this)):n.loadFromArgs(t)},unload:function(t){var e=this;const n=this.internal;let s=t||{};I(s)&&this.tooltip.hide(),z(s)?s={ids:s}:A(s)&&(s={ids:[s]});const a=n.mapToTargetIds(s.ids);n.unload(a,function(){i(this,e),n.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),n.cache.remove(a),Ce.call(n,s.done,s.resizeAfter)}.bind(this))}};function xi(t,e,n){var s=this;const a=this.internal,r=a.mapToTargetIds(e),o=a.state.hiddenTargetIds.map(function(t){return i(this,s),r.indexOf(t)>-1&&t}.bind(this)).filter(Boolean);a.state.toggling=!0,a[(t?"remove":"add")+"HiddenTargetIds"](r);const c=a.$el.svg.selectAll(a.selectorTargets(r)),l=t?null:"0";t&&o.length&&(c.style("display",null),$(a.config.data_onshown,this,o)),a.$T(c).style("opacity",l,"important").call(F,function(){i(this,s),t||0!==o.length||(c.style("display","none"),$(a.config.data_onhidden,this,r)),c.style("opacity",l)}.bind(this)),n.withLegend&&a[(t?"show":"hide")+"Legend"](r),a.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),a.state.toggling=!1}var bi={show:function(t,e){void 0===e&&(e={}),xi.call(this,!0,t,e)},hide:function(t,e){void 0===e&&(e={}),xi.call(this,!1,t,e)},toggle:function(t,e){var n=this;void 0===e&&(e={});const s=this.internal,a={show:[],hide:[]};s.mapToTargetIds(t).forEach(function(t){return i(this,n),a[s.isTargetToShow(t)?"hide":"show"].push(t)}.bind(this)),a.show.length&&this.show(a.show,e),a.hide.length&&setTimeout(function(){return i(this,n),this.hide(a.hide,e)}.bind(this),0)}};const mi={show:function(t){var e=this;const n=this.internal,s=n.$el,a=n.config,r=n.state,o=r.eventReceiver,c=r.hasTreemap,l=r.inputType;let d,u;if(t.mouse&&(u=t.mouse),t.data){var h;const e=t.data,i=null==(h=n.getYScaleById(e.id))?void 0:h(e.value);if(c&&e.id)o.rect=s.main.select(""+n.selectorTarget(e.id,void 0,"rect"));else if(n.isMultipleX())u=[n.xx(e),i];else{var g,f;a.tooltip_grouped||(u=[0,i]),d=null!=(g=e.index)?g:n.hasArcType()&&e.id?null==(f=n.getArcElementByIdOrIndex(e.id))?void 0:f.datum().index:n.getIndexByX(e.x)}}else C(t.x)?d=n.getIndexByX(t.x):C(t.index)&&(d=t.index);("mouse"===l?["mouseover","mousemove"]:["touchstart"]).forEach(function(t){i(this,e),n.dispatchEvent(t,d,u)}.bind(this))},hide:function(){var t=this;const e=this.internal,n=e.state.inputType,s=e.$el.tooltip,a=null==s?void 0:s.datum();if(a){const s=JSON.parse(a.current)[0].index;("mouse"===n?["mouseout"]:["touchend"]).forEach(function(n){i(this,t),e.dispatchEvent(n,s)}.bind(this))}"touch"===n&&e.callOverOutForTouch(),e.hideTooltip(!0),null==e.hideGridFocus||e.hideGridFocus(),null==e.unexpandCircles||e.unexpandCircles(),null==e.expandBarTypeShapes||e.expandBarTypeShapes(!1)}};var _i={tooltip:mi};let vi=function t(e){this.plugins=[],this.internal=void 0;const n=new si(this);this.internal=n,function t(e,n,s){var a=this;Object.keys(e).forEach(function(r){i(this,a);const o=w(e[r]),c=n!==s,l=D(e[r]),d=l&&Object.keys(e[r]).length>0;n[r]=o&&(!c&&d||c)?e[r].bind(s):l&&!o?{}:e[r],d&&t(e[r],n[r],s)}.bind(this))}(t.prototype,this,this),ai.call(n,e),n.beforeInit(),n.init()};function yi(t,e,n){var s=this;const a=t.config,r=function(t,n){i(this,s);const r=S(n)?n:!1===n?void 0:null;null!==r&&(a["axis_"+t+"_"+e]=r)}.bind(this);C(n)&&(P(n)?Object.keys(n).forEach(function(t){i(this,s),r(t,n[t])}.bind(this)):(S(n)||!1===n)&&["y","y2"].forEach(function(t){i(this,s),r(t,n)}.bind(this)),t.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))}function Ti(t,e){const i=t.config;return{x:i["axis_x_"+e],y:i["axis_y_"+e],y2:i["axis_y2_"+e]}}Z(vi.prototype,[ri,{color:function(t){return this.internal.color(t)}},ci,hi,gi,fi,pi,bi,_i]);const wi={labels:function(t){var e=this;const n=this.internal;let s;return t&&(Object.keys(t).forEach(function(s){i(this,e),n.axis.setLabelText(s,t[s])}.bind(this)),n.axis.updateLabels()),["x","y","y2"].forEach(function(t){i(this,e);const a=n.axis.getLabelText(t);a&&(s||(s={}),s[t]=a)}.bind(this)),s},min:function(t){const e=this.internal;return T(t)||!1===t?yi(e,"min",t):Ti(e,"min")},max:function(t){const e=this.internal;return T(t)||!1===t?yi(e,"max",t):Ti(e,"max")},range:function(t){const e=this.axis;if(!arguments.length)return{max:e.max(),min:e.min()};{const i=t.min,n=t.max;C(n)&&e.max(n),C(i)&&e.min(i)}}};var Ai={axis:wi},Si={category:function(t,e){const i=this.internal,n=i.config;return arguments.length>1&&(n.axis_x_categories[t]=e,i.redraw()),n.axis_x_categories[t]},categories:function(t){const e=this.internal,i=e.config;if(!t||!Array.isArray(t)){const t=i.axis_x_categories;return I(t)?Object.values(e.data.xs)[0]:t}return i.axis_x_categories=t,e.redraw(),i.axis_x_categories}};function ki(t,e){const i=this.internal,n=i.config,s=n.transition_duration&&ct(),a="grid_"+e+"_lines";return t?(n[a]=t,i.updateGrid(),i.redrawGrid(s),n[a]):n[a]}function Ci(t,e){return ki.bind(this)(this.internal.config["grid_"+e+"_lines"].concat(t||[]),e)}function Ri(t,e){this.internal.removeGridLines(t,e)}const Ei=function(t){return ki.bind(this)(t,"x")};Z(Ei,{add:function(t){return Ci.bind(this)(t,"x")},remove:function(t){return Ri.bind(this)(t,!0)}});const Oi=function(t){return ki.bind(this)(t,"y")};Z(Oi,{add:function(t){return Ci.bind(this)(t,"y")},remove:function(t){return Ri.bind(this)(t,!1)}});var Li={xgrids:Ei,ygrids:Oi},Pi={groups:function(t){const e=this.internal,i=e.config;return k(t)||(i.data_groups=t,e.redraw()),i.data_groups}};function Ii(t,e){void 0===e&&(e=!1);const i=this.internal,n=i.config,s=n.transition_duration&&ct();return t?(n.regions=e?n.regions.concat(t):t,i.updateRegion(),i.redrawRegion(s),e?n.regions:t):n.regions}const Di=function(t){return Ii.bind(this)(t)};Z(Di,{add:function(t){return Ii.bind(this)(t,!0)},remove:function(t){var e=this;const n=this.internal,s=n.config,a=n.$T,r=t||{},o=X(r,"classes",[Lt.region]);let c=n.$el.main.select("."+Lt.regions).selectAll(o.map(function(t){return i(this,e),"."+t}.bind(this)));return a(c).style("opacity","0").remove(),c=s.regions,Object.keys(r).length?(c=c.filter(function(t){var n=this;i(this,e);let s=!1;return!t.class||(t.class.split(" ").forEach(function(t){i(this,n),o.indexOf(t)>=0&&(s=!0)}.bind(this)),!s)}.bind(this)),s.regions=c):s.regions=[],c}});var zi={regions:Di},Mi={x:function(t){const e=this.internal,i=e.axis,n=e.data,s=i.isCustomX()&&i.isCategorized();return z(t)&&(s?this.categories(t):(e.updateTargetX(n.targets,t),e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))),s?this.categories():n.xs},xs:function(t){const e=this.internal;return M(t)&&(e.updateTargetXs(e.data.targets,t),e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),e.data.xs}},Xi={flow:function(t){var e=this;const n=this.internal;let s;(t.json||t.rows||t.columns)&&n.convertData(t,function(a){i(this,e),s=a,function(){var e=this;let a,r,o,c=0,l=0;if(n.state.redrawing||!s||!ct())return;const d=[],u=n.getMaxDataCount(),h=n.convertDataToTargets(s,!0),g=n.axis.isTimeSeries();n.data.targets.forEach(function(t){i(this,e);let n=!1;for(let e=0;e1?f.values[f.values.length-1].x-p.x:p.x-n.getXDomain(n.data.targets)[0]:1,a=[p.x-r,p.x]);a&&n.updateXDomain(null,!0,!0,!1,a),n.updateTargets(n.data.targets),n.redraw({flow:{index:p.index,length:c,duration:T(t.duration)?t.duration:n.config.transition_duration,done:t.done,orgDataCount:u},withLegend:!0,withTransition:u>1,withTrimXDomain:!1,withUpdateXAxis:!0})}()}.bind(this))}},$i=p(10);let Fi=function(){function t(t){this.owner=void 0,this.config=void 0,this.scale=void 0;const e=Ge(),i=t.config,n=t.params;this.owner=t,this.config=i,this.scale=e,!i.noTransition&&n.config.transition_duration||(i.withoutTransition=!0),i.range=this.scaleExtent((n.orgXScale||e).range())}t.getSizeFor1Char=function(t){var e=this;const n={w:5.5,h:11.5};return t.empty()||t.select("text").text("0").call(function(t){i(this,e);try{const e=t.node().getBBox(),i=e.width,s=e.height;i&&s&&(n.w=i,n.h=s)}catch(t){}finally{t.text("")}}.bind(this)),this.getSizeFor1Char=function(){return i(this,e),n}.bind(this),n};var e=t.prototype;return e.getTickTransformSetter=function(t){var e=this;const n=this.config,s="x"===t?function(t){return i(this,e),"translate("+(t+n.tickOffset)+",0)"}.bind(this):function(t){return i(this,e),"translate(0,"+t+")"}.bind(this);return function(t,n){var a=this;i(this,e),t.attr("transform",function(t){return i(this,a),T(t)?s(Math.ceil(n(t))):null}.bind(this))}.bind(this)},e.scaleExtent=function(t){const e=t[0],i=t[t.length-1];return e0?r:1,o]).range(t.range());c=e.ticks();for(let t=o.toFixed().length;c.length>15;t--)c=e.ticks(t);c.splice(0,1,r),c.splice(c.length-1,1,o)}c=c.map(function(t){i(this,n);return A(t)&&S(t)&&!isNaN(t)&&Math.round(10*t)/10||t}.bind(this))}return c},e.copyScale=function(){const t=this.scale.copy();return t.domain().length||t.domain(this.scale.domain()),t.type=this.scale.type,t},e.textFormatted=function(t){const e=this.config.tickFormat,i=/\d+\.\d+0{5,}\d$/.test(t)?+(t+"").replace(/0+\d$/,""):t,n=e?e(i):i;return C(n)?n:""},e.transitionise=function(t){const e=this.config;let i=t;if(e.withoutTransition)i=t.interrupt();else if(e.transition||!this.owner.params.noTransition)try{i=t.transition(e.transition)}catch(t){}return i},t}(),Bi=function(){function t(t){void 0===t&&(t={}),this.helper=void 0,this.config=void 0,this.params=void 0,this.g=void 0,this.generatedTicks=void 0;const e={innerTickSize:6,outerTickSize:t.outerTick?6:0,orient:"bottom",range:[],tickArguments:null,tickCentered:null,tickCulling:!0,tickFormat:null,tickLength:9,tickOffset:0,tickPadding:3,tickValues:null,transition:null,noTransition:t.noTransition};e.tickLength=Math.max(e.innerTickSize,0)+e.tickPadding,this.config=e,this.params=t,this.helper=new Fi(this)}var e=t.prototype;return e.create=function(t){const e=this,n=e.config,a=e.helper,r=e.params,o=a.scale,c=n.orient,l=this.splitTickText.bind(e),d=/^(left|right)$/.test(c),u=/^(top|bottom)$/.test(c),h=a.getTickTransformSetter(u?"x":"y"),g=h===a.axisX?"y":"x",f=/^(top|left)$/.test(c)?-1:1,p=r.tickTextRotate;this.config.range=o.rangeExtent?o.rangeExtent():a.scaleExtent((r.orgXScale||o).range());const x=n.innerTickSize,b=n.tickLength,m=n.range,_=r.id,v=_&&/^(x|y|y2)$/.test(_)?r.config["axis_"+_+"_tick_text_position"]:{x:0,y:0},y="subX"===_?"subchart_axis_x":"axis_"+_,T=r.config[y+"_show"],w=!!T&&r.config[y+"_tick_show"],A=!!T&&r.config[y+"_tick_text_show"];let k;t.each((function(){var t=this;const _=(0,s.select)(this);let y=this.__chart__||o,T=a.copyScale();k=_,this.__chart__=T,n.tickOffset=r.isCategory?Math.ceil((T(1)-T(0))/2):0;const C=_.selectAll(".domain").data([0]);if(C.enter().append("path").attr("class","domain").merge(C).attr("d",function(){i(this,t);const e=n.outerTickSize*f;return u?"M"+m[0]+","+e+"V0H"+m[1]+"V"+e:"M"+e+","+m[0]+"H0V"+m[1]+"H"+e}.bind(this)),w||A){const s=n.tickValues||a.generateTicks(T,d);e.generatedTicks=s;let o=_.selectAll(".tick").data(s,T);const m=o.enter().insert("g",".domain").attr("class","tick"),k=o.exit().remove();o=m.merge(o),w&&m.append("line"),A&&m.append("text");const C=Fi.getSizeFor1Char(o),R=[];let E=o.select("text").selectAll("tspan").data(function(e,n){var o=this;i(this,t);const c=r.tickMultiline?l(e,T,s,d,C.w):z(a.textFormatted(e))?a.textFormatted(e).concat():[a.textFormatted(e)];return R[n]=c.length,c.map(function(t){return i(this,o),{index:n,splitted:t}}.bind(this))}.bind(this));E.exit().remove(),E=E.enter().append("tspan").merge(E).text(function(e){return i(this,t),e.splitted}.bind(this)),E.attr("x",u?0:b*f).attr("dx",function(){i(this,t);let e=0;return/(top|bottom)/.test(c)&&p&&(e=8*Math.sin(Math.PI*(p/180))*("top"===c?-1:1)),e+(v.x||0)}.bind(this)()).attr("dy",function(e,n){i(this,t);let s=0;return"top"!==c&&(s=C.h,0===n&&(s=d?-((R[e.index]-1)*(C.h/2)-3):0===v.y?".71em":0)),S(s)&&v.y?s+v.y:s||".71em"}.bind(this));const O=o.select("line"),L=o.select("text");if(m.select("line").attr(g+"2",x*f),m.select("text").attr(g,b*f),e.setTickLineTextPosition(O,L),r.tickTitle){const e=L.select("title");(e.empty()?L.append("title"):e).text(function(e){return i(this,t),r.tickTitle[e]}.bind(this))}if(T.bandwidth){const e=T,n=e.bandwidth()/2;y=function(s){return i(this,t),e(s)+n}.bind(this),T=y}else y.bandwidth?y=T:h(k,T);o=r.owner.state.flowing?a.transitionise(o):r.owner.$T(o),h(m,y),h(o.style("opacity",null),T)}})),this.g=k},e.getGeneratedTicks=function(t){var e,n=this;const s=(null==(e=this.generatedTicks)?void 0:e.length)-1;let a=this.generatedTicks;if(s>t){const e=Math.round(s/t+.1);a=this.generatedTicks.map(function(t,s){return i(this,n),s%e==0?t:null}.bind(this)).filter(function(t){return i(this,n),null!==t}.bind(this)).splice(0,t)}return a},e.getTickXY=function(){const t=this.config,e={x:0,y:0};return this.params.isCategory&&(e.x=t.tickCentered?0:t.tickOffset,e.y=t.tickCentered?t.tickOffset:0),e},e.getTickSize=function(t){const e=this.helper.scale,i=this.config,n=i,s=n.innerTickSize,a=n.range,r=e(t)+(i.tickCentered?0:i.tickOffset);return a[0]0?0:1]:"middle"}.bind(this),h=function(t){return i(this,n),t?"rotate("+t+")":null}.bind(this),g=function(t){i(this,n);return t?11.5-2.5*(t/("bottom"===o?15:23))*(t>0?1:-1):c}.bind(this);switch(o){case"bottom":t.attr("x1",s.x).attr("x2",s.x).attr("y2",this.getTickSize.bind(this)),e.attr("x",0).attr("y",g(d)).style("text-anchor",u(d)).attr("transform",h(d));break;case"top":t.attr("x2",0).attr("y2",-r),e.attr("x",0).attr("y",2*-g(d)).style("text-anchor",u(d)).attr("transform",h(d));break;case"left":t.attr("x2",-r).attr("y1",s.y).attr("y2",s.y),e.attr("x",-c).attr("y",l).style("text-anchor","end");break;case"right":t.attr("x2",r).attr("y2",0),e.attr("x",c).attr("y",0).style("text-anchor","start")}},e.splitTickText=function(t,e,i,n,s){const a=this.params,r=this.helper.textFormatted(t),o=A(r)&&r.indexOf("\n")>-1?r.split("\n"):[];if(o.length)return o;if(z(r))return r;let c=a.tickWidth;return(!c||c<=0)&&(c=n?95:a.isCategory?Math.ceil(a.isInverted?e(i[0])-e(i[1]):e(i[1])-e(i[0]))-12:110),function t(e,i){let n,a,r;for(let o=1;o=0||i.hasRadar},e.isCustomX=function(){const t=this.owner.config;return!this.isTimeSeries()&&(t.data_x||D(t.data_xs))},e.isTimeSeries=function(t){return void 0===t&&(t="x"),"timeseries"===this.owner.config["axis_"+t+"_type"]},e.isLog=function(t){return void 0===t&&(t="x"),"log"===this.owner.config["axis_"+t+"_type"]},e.isTimeSeriesY=function(){return this.isTimeSeries("y")},e.getAxisType=function(t){void 0===t&&(t="x");let e="linear";return this.isTimeSeries(t)?e=this.owner.config.axis_x_localtime?"time":"utc":this.isLog(t)&&(e="log"),e},e.init=function(){var t=this;const e=this.owner,n=e.config,s=e.$el,a=s.main,r=s.axis,o=e.state.clip,c=n.axis_rotated,l=["x","y"];n.axis_y2_show&&l.push("y2"),l.forEach(function(s){var l=this;i(this,t);const d=this.getAxisClassName(s),u=xt["axis"+s.toUpperCase()+"Label"];r[s]=a.append("g").attr("class",d).attr("clip-path",function(){i(this,l);let t=null;return"x"===s?t=o.pathXAxis:"y"===s&&(t=o.pathYAxis),t}.bind(this)).attr("transform",e.getTranslate(s)).style("visibility",n["axis_"+s+"_show"]?null:"hidden"),r[s].append("text").attr("class",u).attr("transform",["rotate(-90)",null]["x"===s?+!c:+c]).style("text-anchor",function(){return i(this,l),this.textAnchorForAxisLabel(s)}.bind(this)),this.generateAxes(s)}.bind(this))},e.setOrient=function(){const t=this.owner.config,e=t.axis_rotated,i=t.axis_y_inner,n=t.axis_y2_inner;this.orient={x:e?"left":"bottom",y:e?i?"top":"bottom":i?"right":"left",y2:e?n?"bottom":"top":n?"left":"right",subX:e?"left":"bottom"}},e.generateAxes=function(t){var e=this;const n=this.owner,s=n.config,a=[],r=s["axis_"+t+"_axes"],o=s.axis_rotated;let c;"x"===t?c=o?$i.axisLeft:$i.axisBottom:"y"===t?c=o?$i.axisBottom:$i.axisLeft:"y2"===t&&(c=o?$i.axisTop:$i.axisRight),r.length&&r.forEach(function(s){var r=this;i(this,e);const o=s.tick||{},l=n.scale[t].copy();s.domain&&l.domain(s.domain),a.push(c(l).ticks(o.count).tickFormat(w(o.format)?o.format.bind(n.api):function(t){return i(this,r),t}.bind(this)).tickValues(o.values).tickSizeOuter(!1===o.outer?0:6))}.bind(this)),this.axesList[t]=a},e.updateAxes=function(){var t=this;const e=this.owner,n=e.config,s=e.$el.main,a=e.$T;Object.keys(this.axesList).forEach(function(r){var o=this;i(this,t);const c=n["axis_"+r+"_axes"],l=e.scale[r].copy(),d=l.range();this.axesList[r].forEach(function(t,u){var h=this;i(this,o);const g=t.scale().range();d.every(function(t,e){return i(this,h),t===g[e]}.bind(this))||t.scale().range(d);const f=this.getAxisClassName(r)+"-"+(u+1);let p=s.select("."+f.replace(/\s/,"."));p.empty()?p=s.append("g").attr("class",f).style("visibility",n["axis_"+r+"_show"]?null:"hidden").call(t):(c[u].domain&&l.domain(c[u].domain),a(p).call(t.scale(l))),p.attr("transform",e.getTranslate(r,u+1))}.bind(this))}.bind(this))},e.setAxis=function(t,e,i,n){const s=this.owner;"subX"!==t&&(this.tick[t]=this.getTickValues(t)),this[t]=this.getAxis(t,e,i,!("x"!==t||!(s.scale.zoom||s.config.subchart_show||s.state.resizing))||n)},e.getAxis=function(t,e,n,s,a){var r=this;const o=this.owner,c=o.config,l=/^(x|subX)$/.test(t),d=l?"x":t,u=l&&this.isCategorized(),h=this.orient[t],g=a?0:o.getAxisTickRotate(d);let f;if(l)f="subX"===t?o.format.subXAxisTick:o.format.xAxisTick;else{const e=c["axis_"+t+"_tick_format"];w(e)&&(f=e.bind(o.api))}let p=this.tick[d];const x=et({outerTick:n,noTransition:s,config:c,id:t,tickTextRotate:g,owner:o},l&&{isCategory:u,isInverted:c.axis_x_inverted,tickMultiline:c.axis_x_tick_multiline,tickWidth:c.axis_x_tick_width,tickTitle:u&&c.axis_x_tick_tooltip&&o.api.categories(),orgXScale:o.scale.x});l||(x.tickStepSize=c["axis_"+d+"_tick_stepSize"]);const b=new Bi(x).scale(l&&o.scale.zoom||e).orient(h);if(l&&this.isTimeSeries()&&p&&!w(p)){const t=ot.bind(o);p=p.map(function(e){return i(this,r),t(e)}.bind(this))}else!l&&this.isTimeSeriesY()&&(b.ticks(c.axis_y_tick_time_value),p=null);p&&b.tickValues(p),b.tickFormat(f||!l&&o.isStackNormalized()&&function(t){return i(this,r),t+"%"}.bind(this)),u&&(b.tickCentered(c.axis_x_tick_centered),I(c.axis_x_tick_culling)&&(c.axis_x_tick_culling=!1));const m=c["axis_"+d+"_tick_count"];return m&&b.ticks(m),b},e.updateXAxisTickValues=function(t,e){const i=this.owner,n=i.config,s=n.axis_x_tick_fit;let a,r=n.axis_x_tick_count;if((s||r&&s)&&(a=i.mapTargetsToUniqueXs(t),this.isCategorized()&&r>a.length&&(r=a.length),a=this.generateTickValues(a,r,this.isTimeSeries())),e)e.tickValues(a);else if(this.x){var o;this.x.tickValues(a),null==(o=this.subX)||o.tickValues(a)}return a},e.getId=function(t){const e=this.owner,i=e.config,n=e.scale;let s=i.data_axes[t];return s&&n[s]||(s="y"),s},e.getXAxisTickFormat=function(t){var e=this;const n=this.owner,s=n.config,a=n.format,r=t&&s.subchart_axis_x_tick_format||s.axis_x_tick_format,o=this.isTimeSeries(),c=this.isCategorized();let l;return r?w(r)?l=r.bind(n.api):o&&(l=function(t){return i(this,e),t?a.axisTime(r)(t):""}.bind(this)):l=o?a.defaultAxisTime:c?n.categoryName:function(t){return i(this,e),t<0?t.toFixed(0):t}.bind(this),w(l)?function(t){return i(this,e),l.apply(n,c?[t,n.categoryName(t)]:[t])}.bind(this):l},e.getTickValues=function(t){const e=this.owner,i=e.config["axis_"+t+"_tick_values"],n=e[t+"Axis"];return(w(i)?i.call(e.api):i)||(n?n.tickValues():void 0)},e.getLabelOptionByAxisId=function(t){return this.owner.config["axis_"+t+"_label"]},e.getLabelText=function(t){const e=this.getLabelOptionByAxisId(t);return A(e)?e:e?e.text:null},e.setLabelText=function(t,e){const i=this.owner.config,n=this.getLabelOptionByAxisId(t);A(n)?i["axis_"+t+"_label"]=e:n&&(n.text=e)},e.getLabelPosition=function(t,e){var n=this;const s=this.owner.config.axis_rotated,a=this.getLabelOptionByAxisId(t),r=P(a)&&a.position?a.position:e[+!s],o=function(t){return i(this,n),!!~r.indexOf(t)}.bind(this);return{isInner:o("inner"),isOuter:o("outer"),isLeft:o("left"),isCenter:o("center"),isRight:o("right"),isTop:o("top"),isMiddle:o("middle"),isBottom:o("bottom")}},e.getAxisLabelPosition=function(t){return this.getLabelPosition(t,"x"===t?["inner-top","inner-right"]:["inner-right","inner-top"])},e.getLabelPositionById=function(t){return this.getAxisLabelPosition(t)},e.xForAxisLabel=function(t){const e=this.owner,i=e.state,n=i.width,s=i.height,a=this.getAxisLabelPosition(t);let r=a.isMiddle?-s/2:0;return this.isHorizontal(e,"x"!==t)?r=a.isLeft?0:a.isCenter?n/2:n:a.isBottom&&(r=-s),r},e.dxForAxisLabel=function(t){const e=this.owner,i=this.getAxisLabelPosition(t);let n=i.isBottom?"0.5em":"0";return this.isHorizontal(e,"x"!==t)?n=i.isLeft?"0.5em":i.isRight?"-0.5em":"0":i.isTop&&(n="-0.5em"),n},e.textAnchorForAxisLabel=function(t){const e=this.owner,i=this.getAxisLabelPosition(t);let n=i.isMiddle?"middle":"end";return this.isHorizontal(e,"x"!==t)?n=i.isLeft?"start":i.isCenter?"middle":"end":i.isBottom&&(n="start"),n},e.dyForAxisLabel=function(t){const e=this.owner,i=e.config,n=i.axis_rotated,s=this.getAxisLabelPosition(t).isInner,a=i["axis_"+t+"_tick_rotate"]?e.getHorizontalAxisHeight(t):0,r=this.getMaxTickSize(t).width;let o;if("x"===t){const t=i.axis_x_height;o=n?s?"1.2em":-25-r:s?"-0.5em":t?t-10:a?a-10:"3em"}else o={y:["-0.5em",10,"3em","1.2em",10],y2:["1.2em",-20,"-2.2em","-0.5em",15]}[t],o=n?s?o[0]:a?a*("y2"===t?-1:1)-o[1]:o[2]:s?o[3]:(o[4]+(i["axis_"+t+"_inner"]?0:r+o[4]))*("y"===t?-1:1);return o},e.getMaxTickSize=function(t,e){var n=this;const s=this.owner,a=s.config,r=s.state.current,o=s.$el,c=o.svg,l=o.chart,d=r.maxTickSize[t],u="axis_"+t,h={width:0,height:0};if(e||!a[u+"_show"]||d.width>0&&0===s.filterTargetsToShow().length)return d;if(c){const e=/^y2?$/.test(t),r=s.filterTargetsToShow(s.data.targets),o=s.scale[t].copy().domain(s["get"+(e?"Y":"X")+"Domain"](r,t)),c=o.domain(),g=c[0]===c[1]&&c.every(function(t){return i(this,n),t>0}.bind(this)),f=z(d.domain)&&d.domain[0]===d.domain[1]&&d.domain.every(function(t){return i(this,n),t>0}.bind(this));if(g||f)return d.size;d.domain=c,e||d.ticks.splice(0);const p=this.getAxis(t,o,!1,!1,!0),x=a[u+"_tick_rotate"],b=a[u+"_tick_count"];!a[u+"_tick_values"]&&b&&p.tickValues(this.generateTickValues(c,b,e?this.isTimeSeriesY():this.isTimeSeries())),e||this.updateXAxisTickValues(r,p);const m=l.append("svg").style("visibility","hidden").style("position","fixed").style("top","0").style("left","0");p.create(m),m.selectAll("text").attr("transform",S(x)?"rotate("+x+")":null).each((function(t,i){const n=this.getBoundingClientRect(),s=n.width,a=n.height;h.width=Math.max(h.width,s),h.height=Math.max(h.height,a),e||(d.ticks[i]=s)})),m.remove()}return Object.keys(h).forEach(function(t){i(this,n),h[t]>0&&(d[t]=h[t])}.bind(this)),d},e.getXAxisTickTextY2Overflow=function(t){const e=this.owner,i=e.axis,n=e.config,s=e.state,a=e.getAxisTickRotate("x");if((i.isCategorized()||i.isTimeSeries())&&n.axis_x_tick_fit&&(!n.axis_x_tick_culling||I(n.axis_x_tick_culling))&&!n.axis_x_tick_multiline&&a>0&&a<90){const i=s.current.width-e.getCurrentPaddingByDirection("left"),n=this.getXAxisTickMaxOverflow(a,i-t),r=Math.max(0,n)+t;return Math.min(r,i/2)}return 0},e.getXAxisTickMaxOverflow=function(t,e){const i=this.owner,n=i.axis,s=i.config,a=i.state,r=n.isTimeSeries(),o=a.current.maxTickSize.x.ticks,c=o.length,l=a.axis.x.padding,d=l.left,u=l.right;let h=0;const g=c-(r&&s.axis_x_tick_fit?.5:0);for(let i=0;i2){const e=this.isCategorized(),s=i-2,r=t[0],o=t[t.length-1];let c;a=[r];for(let t=0;t=h)&&(g=!0,e.preventDefault())}.bind(this);r.on("touchstart",function(n){i(this,t),s.event=n,e.updateEventRect()}.bind(this)).on("touchstart.eventRect touchmove.eventRect",function(n){if(i(this,t),s.event=n,!r.empty()&&r.classed(St.eventRect)){if(s.dragging||s.flowing||e.hasArcType()||n.touches.length>1)return;f(n),c(r.node())}else l()}.bind(this),!0).on("touchend.eventRect",function(n){i(this,t),s.event=n,!r.empty()&&r.classed(St.eventRect)&&(e.hasArcType()||!e.toggleShape||s.cancelClick)&&s.cancelClick&&(s.cancelClick=!1)}.bind(this),!0),o.on("touchstart",function(e){i(this,t),s.event=e;const n=e.target;n&&n!==r.node()&&l()}.bind(this))},updateEventRect:function(t,e){var n=this;void 0===e&&(e=!1);const s=this.state,a=this.$el,r=s,o=r.eventReceiver,c=r.width,l=r.height,d=r.rendered,u=r.resizing,h=t||a.eventRect,g=function(){i(this,n),o&&(o.rect=h.node().getBoundingClientRect())}.bind(this);(!d||u||e)&&(h.attr("x",0).attr("y",0).attr("width",c).attr("height",l),d&&!e||h.classed(St.eventRect,!0)),g()},updateEventRectData:function(){var t=this;const e=this,n=e.config,s=e.scale,a=e.state,r=s.zoom||s.x,o=n.axis_rotated;let c,l,d,u;if(e.isMultipleX())c=0,l=0,d=a.width,u=a.height;else{let n,s;if(e.axis.isCategorized())n=e.getEventRectWidth(),s=function(e){return i(this,t),r(e.x)-n/2}.bind(this);else{const c=function(n){let s=n.index;return i(this,t),{prev:e.getPrevX(s),next:e.getNextX(s)}}.bind(this);n=function(e){var n=this;i(this,t);const s=c(e),l=r.domain();let d;return null===s.prev&&null===s.next?d=o?a.height:a.width:null===s.prev?d=(r(s.next)+r(e.x))/2:null===s.next?d=r(l[1])-(r(s.prev)+r(e.x))/2:(Object.keys(s).forEach(function(t,e){var a;i(this,n),s[t]=null!=(a=s[t])?a:l[e]}.bind(this)),d=Math.max(0,(r(s.next)-r(s.prev))/2)),d}.bind(this),s=function(e){i(this,t);const n=c(e);let s;return s=null===n.prev&&null===n.next?0:null===n.prev?r(r.domain()[0]):(r(e.x)+r(n.prev))/2,s}.bind(this)}c=o?0:s,l=o?s:0,d=o?a.width:n,u=o?n:a.height}const h=a.eventReceiver,g=function(e,n){return i(this,t),w(e)?e(n):e}.bind(this);h.coords.splice(h.data.length),h.data.forEach(function(e,n){i(this,t),h.coords[n]={x:g(c,e),y:g(l,e),w:g(d,e),h:g(u,e)}}.bind(this))},selectRectForSingle:function(t,e){var n=this;const s=this,a=s.config,r=s.$el,o=r.main,c=r.circle,l=a.data_selection_enabled,d=a.data_selection_grouped,u=a.data_selection_isselectable,h=a.tooltip_grouped,g=s.getAllValuesOnIndex(e);if(h&&(s.showTooltip(g,t),null==s.showGridFocus||s.showGridFocus(g),!l||d))return;c||o.selectAll("."+gt.EXPANDED+":not(."+It.shape+"-"+e+")").classed(gt.EXPANDED,!1);const f=o.selectAll("."+It.shape+"-"+e).classed(gt.EXPANDED,!0).style("cursor",u?"pointer":null).filter((function(t){return s.isWithinShape(this,t)}));f.empty()&&!h&&(null==s.hideGridFocus||s.hideGridFocus(),s.hideTooltip(),d||s.setExpand(e)),f.call(function(a){var r=this;i(this,n);const o=a.data();l&&(d||null!=u&&u.bind(s.api)(o))&&(t.style.cursor="pointer"),h||(s.showTooltip(o,t),null==s.showGridFocus||s.showGridFocus(o),null==s.unexpandCircles||s.unexpandCircles(),a.each(function(t){return i(this,r),s.setExpand(e,t.id)}.bind(this)))}.bind(this))},selectRectForMultipleXs:function(t,e){var n=this;void 0===e&&(e=!0);const s=this,a=s.config,r=s.state,o=s.filterTargetsToShow(s.data.targets);if(r.dragging||s.hasArcType(o))return;const c=G(r.event,t),l=s.findClosestFromTargets(o,c);if(!e||!r.mouseover||l&&l.id===r.mouseover.id||(a.data_onout.call(s.api,r.mouseover),r.mouseover=void 0),!l)return void s.unselectRect();const d=(s.isBubbleType(l)||s.isScatterType(l)||!a.tooltip_grouped?[l]:s.filterByX(o,l.x)).map(function(t){return i(this,n),s.addName(t)}.bind(this));s.showTooltip(d,t),s.setExpand(l.index,l.id,!0),s.showGridFocus(d);const u=s.dist(l,c);(s.isBarType(l.id)||u-1?r.data[s]:null}.bind(this);o.on("mouseover",function(t){i(this,e),a.event=t,n.updateEventRect()}.bind(this)).on("mousemove",(function(e){const i=t(e);if(a.event=e,!i)return;let o=i.index;const c=s.line_step_type;if(s.line_step_tooltipMatch&&n.hasType("step")&&/^step\-(before|after)$/.test(c)){const t=n.scale.zoom||n.scale.x,i=n.axis.xs[o],s=t.invert(G(e,this)[0]);"step-after"===c&&si&&(o+=1)}const l=s.tooltip_grouped&&o===r.currentIdx;a.dragging||a.flowing||n.hasArcType()||l?s.tooltip_show&&l&&n.setTooltipPosition():(o!==r.currentIdx&&(n.setOverOut(!1,r.currentIdx),r.currentIdx=o),-1===o?n.unselectRect():n.selectRectForSingle(this,o),n.setOverOut(-1!==o,o))})).on("mouseout",function(t){i(this,e),a.event=t,s&&!n.hasArcType()&&-1!==r.currentIdx&&(n.unselectRect(),n.setOverOut(!1,r.currentIdx),r.currentIdx=-1)}.bind(this))}return o},clickHandlerForSingleX:function(t,e){const i=e,n=i.config,s=i.state,a=i.$el.main;if(!t||i.hasArcType()||s.cancelClick)return void(s.cancelClick&&(s.cancelClick=!1));const r=t.index;a.selectAll("."+It.shape+"-"+r).each((function(t){(n.data_selection_grouped||i.isWithinShape(this,t))&&(null==i.toggleShape||i.toggleShape(this,t,r),n.data_onclick.bind(i.api)(t,this))}))},generateEventRectsForMultipleXs:function(t){var e=this;const n=this,s=n.state;t.on("click",(function(t){s.event=t,n.clickHandlerForMultipleXS.bind(this)(n)})),"mouse"===s.inputType&&t.on("mouseover mousemove",(function(t){s.event=t,n.selectRectForMultipleXs(this)})).on("mouseout",function(t){i(this,e),s.event=t,n.config&&!n.hasArcType()&&n.unselectRect()}.bind(this))},clickHandlerForMultipleXS:function(t){const e=t,i=e.config,n=e.state,s=e.filterTargetsToShow(e.data.targets);if(e.hasArcType(s))return;const a=G(n.event,this),r=e.findClosestFromTargets(s,a),o="radius"===i.point_sensitivity?r.r:i.point_sensitivity;r&&(e.isBarType(r.id)||e.dist(r,a)1&&(s=s[n[1]]),null!=(e=s)&&e.size()&&(c[t]=s)}.bind(this)),e.hideGridFocus(),e.setFlowList(c,t)}},setFlowList:function(t,e){var n=this;const s=this,a=e.flow,r=e.targets,o=a,c=o.duration,l=void 0===c?e.duration:c,d=o.index,u=o.length,h=o.orgDataCount,g=s.getFlowTransform(r,h,d,u),f=fe();let p;f.add(Object.keys(t).map(function(e){var a=this;return i(this,n),p=t[e].transition().ease(Vi.easeLinear).duration(l),p="axis.x"===e?p.call(function(t){i(this,a),s.axis.x.setTransition(t).create(t)}.bind(this)):"region.list"===e?p.filter(s.isRegionOnX).attr("transform",g):p.attr("transform",g),p}.bind(this))),p.call(f,function(){i(this,n),s.cleanUpFlow(t,e)}.bind(this))},cleanUpFlow:function(t,e){var n=this;const s=this,a=s.config,r=s.state,o=s.$el.svg,c=a.axis_rotated,l=e.flow,d=e.shape,u=e.xv,h=d.pos,g=h.cx,f=h.cy,p=h.xForText,x=h.yForText,b=l,m=b.done,_=void 0===m?function(){i(this,n)}.bind(this):m,v=b.length;v&&(["circle","text","shape","eventRect"].forEach(function(t){i(this,n);const e=[];for(let i=0;i=0?"":r.URL.split("#")[0])+"#"+t+")"},appendClip:function(t,e){e&&t.append("clipPath").attr("id",e).append("rect")},setXAxisClipPath:function(t){const e=this.config,i=this.state,n=i.margin,s=i.width,a=i.height,r=e.axis_rotated,o=Math.max(30,n.left)-(r?0:20),c=(r?n.top+a+10:n.bottom)+20,l=r?-(1+o):-(o-1),d=r?n.left+20:s+10+o;t.attr("x",l).attr("y",-15).attr("width",d).attr("height",c)},setYAxisClipPath:function(t){const e=this.config,i=this.state,n=i.margin,s=i.width,a=i.height,r=e.axis_rotated,o=Math.max(30,n.left)-(r?20:0),c=e.axis_y_inner,l=c&&!r?e.axis_y_label.text?-20:-1:r?-(1+o):-(o-1),d=-(r?20:n.top),u=(r?s+15+o:n.left+20)+(c?20:0),h=(r?n.bottom+10:n.top+a)+10;t.attr("x",l).attr("y",d).attr("width",u).attr("height",h)},updateXAxisTickClip:function(){const t=this,e=t.config,i=t.state,n=i.clip,s=i.xAxisHeight,a=t.$el.defs,r=t.getHorizontalAxisHeight("x");if(a&&!n.idXAxisTickTexts){const e=n.id+"-xaxisticktexts";t.appendClip(a,e),n.pathXAxisTickTexts=t.getClipPath(n.idXAxisTickTexts),n.idXAxisTickTexts=e}!e.axis_x_tick_multiline&&t.getAxisTickRotate("x")&&r!==s&&(t.setXAxisTickClipWidth(),t.setXAxisTickTextClipPathWidth()),t.state.xAxisHeight=r},setXAxisTickClipWidth:function(){const t=this,e=t.config,i=t.state.current.maxTickSize,n=t.getAxisTickRotate("x");if(!e.axis_x_tick_multiline&&n){const e=Math.sin(Math.PI/180*Math.abs(n));i.x.clipPath=(t.getHorizontalAxisHeight("x")-20)/e}else i.x.clipPath=null},setXAxisTickTextClipPathWidth:function(){const t=this.state,e=t.clip,i=t.current,n=this.$el.svg;n&&n.select("#"+e.idXAxisTickTexts+" rect").attr("width",i.maxTickSize.x.clipPath).attr("height",30)}},Ui=void 0;const Wi=function(t){return i(this,Ui),T(t.position)||"end"}.bind(void 0),Zi=function(t){return i(this,Ui),"start"===t.position?4:"middle"===t.position?0:-4}.bind(void 0);function qi(t,e,n){var s=this;return function(a){i(this,s);let r=t?0:e;return"start"===a.position?r=t?-n:0:"middle"===a.position&&(r=(t?-n:e)/2),r}.bind(this)}function Ki(t,e){"grid"===e&&t.each((function(){var t=this;const e=(0,s.select)(this);["x1","x2","y1","y2"].forEach(function(n){return i(this,t),e.attr(n,Math.ceil(+e.attr(n)))}.bind(this))}))}var Ji={hasGrid:function(){var t=this;const e=this.config;return["x","y"].some(function(n){return i(this,t),e["grid_"+n+"_show"]||e["grid_"+n+"_lines"].length}.bind(this))},initGrid:function(){const t=this;t.hasGrid()&&t.initGridLines(),t.initFocusGrid()},initGridLines:function(){const t=this,e=t.config,i=t.state.clip,n=t.$el;(e.grid_x_lines.length||e.grid_y_lines.length)&&(n.gridLines.main=n.main.insert("g","."+gt.chart+(e.grid_lines_front?" + *":"")).attr("clip-path",i.pathGrid).attr("class",Ct.grid+" "+Ct.gridLines),n.gridLines.main.append("g").attr("class",Ct.xgridLines),n.gridLines.main.append("g").attr("class",Ct.ygridLines),n.gridLines.x=(0,s.selectAll)([]))},updateXGrid:function(t){var e=this;const n=this,a=n.config,r=n.scale,o=n.state,c=n.$el,l=c.main,d=c.grid,u=a.axis_rotated,h=n.generateGridData(a.grid_x_type,r.x),g=n.axis.isCategorized()?n.axis.x.tickOffset():0,f=function(t){return i(this,e),(r.zoom||r.x)(t)+g*(u?-1:1)}.bind(this);o.xgridAttr=u?{x1:0,x2:o.width,y1:f,y2:f}:{x1:f,x2:f,y1:0,y2:o.height},d.x=l.select("."+Ct.xgrids).selectAll("."+Ct.xgrid).data(h),d.x.exit().remove(),d.x=d.x.enter().append("line").attr("class",Ct.xgrid).merge(d.x),t||d.x.each((function(){var t=this;const e=(0,s.select)(this);Object.keys(o.xgridAttr).forEach(function(n){var s=this;i(this,t),e.attr(n,o.xgridAttr[n]).style("opacity",function(){return i(this,s),e.attr(u?"y1":"x1")===(u?o.height:0)?"0":null}.bind(this))}.bind(this))}))},updateYGrid:function(){var t=this;const e=this,n=e.axis,s=e.config,a=e.scale,r=e.state,o=e.$el,c=o.grid,l=o.main,d=s.axis_rotated,u=function(e){return i(this,t),Math.ceil(a.y(e))}.bind(this),h=n.y.getGeneratedTicks(s.grid_y_ticks)||e.scale.y.ticks(s.grid_y_ticks);c.y=l.select("."+Ct.ygrids).selectAll("."+Ct.ygrid).data(h),c.y.exit().remove(),c.y=c.y.enter().append("line").attr("class",Ct.ygrid).merge(c.y),c.y.attr("x1",d?u:0).attr("x2",d?u:r.width).attr("y1",d?0:u).attr("y2",d?r.height:u),Ki(c.y,"grid")},updateGrid:function(){const t=this,e=t.$el,i=e.grid;e.gridLines.main||t.initGridLines(),i.main.style("visibility",t.hasArcType()?"hidden":null),t.hideGridFocus(),t.updateGridLines("x"),t.updateGridLines("y")},updateGridLines:function(t){var e=this;const n=this,a=n.config,r=n.$el,o=r.gridLines,c=r.main,l=n.$T,d=a.axis_rotated;a["grid_"+t+"_show"]&&n["update"+t.toUpperCase()+"Grid"]();let u=c.select("."+Ct[t+"gridLines"]).selectAll("."+Ct[t+"gridLine"]).data(a["grid_"+t+"_lines"]);l(u.exit()).style("opacity","0").remove();const h=u.enter().append("g");h.append("line").style("opacity","0"),u=h.merge(u),u.each((function(t){const e=(0,s.select)(this);e.select("text").empty()&&t.text&&e.append("text").style("opacity","0")})),l(u.attr("class",function(n){return i(this,e),(Ct[t+"gridLine"]+" "+(n.class||"")).trim()}.bind(this)).select("text").attr("text-anchor",Wi).attr("transform",function(){return i(this,e),"x"===t?d?null:"rotate(-90)":d?"rotate(-90)":null}.bind(this)).attr("dx",Zi).attr("dy",-5)).text((function(t){var e;return null!=(e=t.text)?e:this.remove()})),o[t]=u},redrawGrid:function(t){const e=this,i=e.config.axis_rotated,n=e.state,s=n.width,a=n.height,r=e.$el.gridLines,o=e.$T,c=e.xv.bind(e),l=e.yv.bind(e);let d=r.x.select("line"),u=r.x.select("text"),h=r.y.select("line"),g=r.y.select("text");return d=o(d,t).attr("x1",i?0:c).attr("x2",i?s:c).attr("y1",i?c:0).attr("y2",i?c:a),u=o(u,t).attr("x",qi(!i,s,a)).attr("y",c),h=o(h,t).attr("x1",i?l:0).attr("x2",i?l:s).attr("y1",i?0:l).attr("y2",i?a:l),g=o(g,t).attr("x",qi(i,s,a)).attr("y",l),[d.style("opacity",null),u.style("opacity",null),h.style("opacity",null),g.style("opacity",null)]},initFocusGrid:function(){const t=this,e=t.config,i=t.state.clip,n=t.$el,s=e.grid_front,a="."+(s&&n.gridLines.main?Ct.gridLines:gt.chart)+(s?" + *":""),r=n.main.insert("g",a).attr("clip-path",i.pathGrid).attr("class",Ct.grid);n.grid.main=r,e.grid_x_show&&r.append("g").attr("class",Ct.xgrids),e.grid_y_show&&r.append("g").attr("class",Ct.ygrids),e.interaction_enabled&&e.grid_focus_show&&(r.append("g").attr("class",kt.xgridFocus).append("line").attr("class",kt.xgridFocus),e.grid_focus_y&&!e.tooltip_grouped&&r.append("g").attr("class",kt.ygridFocus).append("line").attr("class",kt.ygridFocus))},showGridFocus:function(t){var e=this;const n=this,a=n.config,r=n.state,o=r.width,c=r.height,l=a.axis_rotated,d=n.$el.main.selectAll("line."+kt.xgridFocus+", line."+kt.ygridFocus),u=(t||[d.datum()]).filter(function(t){return i(this,e),t&&T(n.getBaseValue(t))}.bind(this));if(!a.tooltip_show||0===u.length||n.hasType("bubble")||n.hasArcType())return;const h=a.grid_focus_edge&&!a.tooltip_grouped,g=n.xx.bind(n);d.style("visibility",null).data(u.concat(u)).each((function(t){var e=this;const a=(0,s.select)(this),r={x:g(t),y:n.getYScaleById(t.id)(t.value)};let d;if(a.classed(kt.xgridFocus))d=l?[null,r.x,h?r.y:o,r.x]:[r.x,h?r.y:null,r.x,c];else{const e="y2"===n.axis.getId(t.id);d=l?[r.y,h&&!e?r.x:null,r.y,h&&e?r.x:c]:[h&&e?r.x:null,r.y,h&&!e?r.x:o,r.y]}["x1","y1","x2","y2"].forEach(function(t,n){return i(this,e),a.attr(t,d[n])}.bind(this))})),Ki(d,"grid"),null==n.showCircleFocus||n.showCircleFocus(t)},hideGridFocus:function(){const t=this,e=t.state,i=e.inputType,n=e.resizing,s=t.$el.main;"mouse"!==i&&n||(s.selectAll("line."+kt.xgridFocus+", line."+kt.ygridFocus).style("visibility","hidden"),null==t.hideCircleFocus||t.hideCircleFocus())},updateGridFocus:function(){const t=this,e=t.state,i=e.inputType,n=e.width,s=e.height,a=e.resizing,r=t.$el.grid.main.select("line."+kt.xgridFocus);if("touch"===i)r.empty()?a&&(null==t.showCircleFocus||t.showCircleFocus()):t.showGridFocus();else{const e=t.config.axis_rotated;r.attr("x1",e?0:-10).attr("x2",e?n:-10).attr("y1",e?-10:0).attr("y2",e?-10:s)}return!0},generateGridData:function(t,e){var n=this;const s=this,a=s.$el.main.select("."+xt.axisX).selectAll(".tick").size();let r=[];if("year"===t){const t=s.getXDomain().map(function(t){return i(this,n),t.getFullYear()}.bind(this)),e=t[0],a=t[1];for(let t=e;t<=a;t++)r.push(new Date(t+"-01-01 00:00:00"))}else r=e.ticks(10),r.length>a&&(r=r.filter(function(t){return i(this,n),(t+"").indexOf(".")<0}.bind(this)));return r},getGridFilterToRemove:function(t){var e=this;return t?function(n){var s=this;i(this,e);let a=!1;return(z(t)?t.concat():[t]).forEach(function(t){i(this,s),("value"in t&&n.value===t.value||"class"in t&&n.class===t.class)&&(a=!0)}.bind(this)),a}.bind(this):function(){return i(this,e),!0}.bind(this)},removeGridLines:function(t,e){var n=this;const s=this,a=s.config,r=s.$T,o=s.getGridFilterToRemove(t),c=function(t){return i(this,n),!o(t)}.bind(this),l=e?Ct.xgridLines:Ct.ygridLines,d=e?Ct.xgridLine:Ct.ygridLine;r(s.$el.main.select("."+l).selectAll("."+d).filter(o)).style("opacity","0").remove();const u="grid_"+(e?"x":"y")+"_lines";a[u]=a[u].filter(c)}},Qi={initRegion:function(){const t=this.$el;t.region.main=t.main.insert("g",":first-child").attr("clip-path",this.state.clip.path).attr("class",Lt.regions)},updateRegion:function(){const t=this,e=t.config,i=t.$el.region,n=t.$T;i.main||t.initRegion(),i.main.style("visibility",t.hasArcType()?"hidden":null);const a=i.main.selectAll("."+Lt.region).data(e.regions);n(a.exit()).style("opacity","0").remove();const r=a.enter().append("g");r.append("rect").style("fill-opacity","0"),i.list=r.merge(a).attr("class",t.classRegion.bind(t)),i.list.each((function(t){var e;(0,s.select)(this).select("text").empty()&&null!=(e=t.label)&&e.text&&(0,s.select)(this).append("text").style("opacity","0")}))},redrawRegion:function(t){var e=this;const n=this,a=n.$el.region,r=n.$T;let o=a.list.select("rect"),c=a.list.selectAll("text");return o=r(o,t).attr("x",n.regionX.bind(n)).attr("y",n.regionY.bind(n)).attr("width",n.regionWidth.bind(n)).attr("height",n.regionHeight.bind(n)),c=r(c,t).attr("transform",function(t){var s;i(this,e);const a=null!=(s=t.label)?s:{},r=a.x,o=void 0===r?0:r,c=a.y,l=void 0===c?0:c,d=a.rotated,u=void 0!==d&&d;return"translate("+(n.regionX.bind(n)(t)+o)+", "+(n.regionY.bind(n)(t)+l)+")"+(u?" rotate(-90)":"")}.bind(this)).attr("text-anchor",function(t){var n;return i(this,e),null!=(n=t.label)&&n.rotated?"end":null}.bind(this)).attr("dy","1em").style("fill",function(t){var n,s;return i(this,e),null!=(n=null==(s=t.label)?void 0:s.color)?n:null}.bind(this)).text(function(t){var n;return i(this,e),null==(n=t.label)?void 0:n.text}.bind(this)),[o.style("fill-opacity",function(t){return i(this,e),T(t.opacity)?t.opacity:null}.bind(this)).on("end",(function(){(0,s.select)(this.parentNode).selectAll("rect:not([x])").remove()})),c.style("opacity",null)]},getRegionXY:function(t,e){const i=this,n=i.config,s=i.scale,a=n.axis_rotated,r="x"===t;let o,c="start",l=0;return"y"===e.axis||"y2"===e.axis?(r||(c="end"),(r?a:!a)&&c in e&&(o=s[e.axis],l=o(e[c]))):(r?!a:a)&&c in e&&(o=s.zoom||s.x,l=o(i.axis.isTimeSeries()?ot.call(i,e[c]):e[c])),l},regionX:function(t){return this.getRegionXY("x",t)},regionY:function(t){return this.getRegionXY("y",t)},getRegionSize:function(t,e){const i=this,n=i.config,s=i.scale,a=i.state,r=n.axis_rotated,o="width"===t,c=i[o?"regionX":"regionY"](e);let l,d="end",u=a[t];return"y"===e.axis||"y2"===e.axis?(o||(d="start"),(o?r:!r)&&d in e&&(l=s[e.axis],u=l(e[d]))):(o?!r:r)&&d in e&&(l=s.zoom||s.x,u=l(i.axis.isTimeSeries()?ot.call(i,e[d]):e[d])),u13&&(g+=f.height-13),g+(n.axis.getLabelPositionById(t).isInner?0:10)+("y2"!==t||l?0:-10)},getEventRectWidth:function(){const t=this.config,e=this.axis,i=t.axis_x_inverted,n=e.x.tickInterval();return Math.max(0,i?Math.abs(n):n)},getAxisTickRotate:function(t){const e=this,i=e.axis,n=e.config,s=e.state,a=e.$el;let r=n["axis_"+t+"_tick_rotate"];if("x"===t){const t=i.isCategorized()||i.isTimeSeries();if(n.axis_x_tick_fit&&t){const t=n.axis_x_tick_count,i=s.current.maxTickSize.x.ticks.length;let a=0;if(t?a=t>i?i:t:i&&(a=i),a!==s.axis.x.tickCount){const t=e.data.targets;s.axis.x.padding=e.getXDomainPadding([e.getXDomainMinMax(t,"min"),e.getXDomainMinMax(t,"max")],a)}s.axis.x.tickCount=a}a.svg&&n.axis_x_tick_autorotate&&n.axis_x_tick_fit&&!n.axis_x_tick_multiline&&!n.axis_x_tick_culling&&t&&(r=e.needToRotateXAxisTickTexts()?n.axis_x_tick_rotate:0)}return r},needToRotateXAxisTickTexts:function(){const t=this,e=t.state,i=e.axis,n=e.current.width-t.getCurrentPaddingByDirection("left")-t.getCurrentPaddingByDirection("right"),s=i.x.tickCount+i.x.padding.left+i.x.padding.right;return t.axis.getMaxTickSize("x").width>(s?n/s:0)}},en={axis_y_clipPath:!0,axis_y_show:!0,axis_y_type:"indexed",axis_y_max:void 0,axis_y_min:void 0,axis_y_inverted:!1,axis_y_center:void 0,axis_y_inner:!1,axis_y_label:{},axis_y_tick_format:void 0,axis_y_tick_culling:!1,axis_y_tick_culling_max:5,axis_y_tick_culling_lines:!0,axis_y_tick_outer:!0,axis_y_tick_values:null,axis_y_tick_rotate:0,axis_y_tick_count:void 0,axis_y_tick_show:!0,axis_y_tick_stepSize:null,axis_y_tick_text_show:!0,axis_y_tick_text_position:{x:0,y:0},axis_y_tick_time_value:void 0,axis_y_padding:{},axis_y_default:void 0,axis_y_axes:[]},nn={axis_y2_show:!1,axis_y2_type:"indexed",axis_y2_max:void 0,axis_y2_min:void 0,axis_y2_inverted:!1,axis_y2_center:void 0,axis_y2_inner:!1,axis_y2_label:{},axis_y2_tick_format:void 0,axis_y2_tick_culling:!1,axis_y2_tick_culling_max:5,axis_y2_tick_culling_lines:!0,axis_y2_tick_outer:!0,axis_y2_tick_values:null,axis_y2_tick_rotate:0,axis_y2_tick_count:void 0,axis_y2_tick_show:!0,axis_y2_tick_stepSize:null,axis_y2_tick_text_show:!0,axis_y2_tick_text_position:{x:0,y:0},axis_y2_padding:{},axis_y2_default:void 0,axis_y2_axes:[]};function sn(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function an(t){for(var e,i=1;i360&&(e=2),e*Math.PI},getGaugeStartAngle:function(){const t=this.config,e=t.gauge_fullCircle,i=-1*Math.PI/2,n=Math.PI/2;let s=t.gauge_startingAngle;return!e&&s<=i?s=i:!e&&s>=n?s=n:(s>Math.PI||s<-1*Math.PI)&&(s=Math.PI),s},updateAngle:function(t){var e=this;const n=this,s=n.config,a=n.state;let r=n.pie,o=t,c=!1;if(!s)return null;const l=n.getGaugeStartAngle(),d=s.gauge_fullCircle?n.getArcLength():-2*l;if(o.data&&n.isGaugeType(o.data)&&!n.hasMultiArcGauge()){const t=s.gauge_min,e=s.gauge_max,i=n.getTotalDataSum(a.rendered);r=r.startAngle(l).endAngle(d*((i-t)/(e-t))+l)}if(r(n.filterTargetsToShow()).forEach(function(t,n){var s;i(this,e),c||t.data.id!==(null==(s=o.data)?void 0:s.id)||(c=!0,o=t,o.index=n)}.bind(this)),isNaN(o.startAngle)&&(o.startAngle=0),isNaN(o.endAngle)&&(o.endAngle=o.startAngle),o.data&&n.hasMultiArcGauge()){const t=s.gauge_min,e=s.gauge_max,i=o.value1){var c;let a=n.getRadius(t).outerRadius;n.hasType("polar")&&(a=n.getPolarOuterRadius(t,a));const l=this.svgArc.centroid(r).map(function(t){return i(this,e),isNaN(t)?0:t}.bind(this)),d=l[0],u=l[1],h=Math.sqrt(d*d+u*u);let g=null==(c=["donut","pie","polar"].filter(n.hasType.bind(n)).map(function(t){return i(this,e),s[t+"_label_ratio"]}.bind(this)))?void 0:c[0];g=g?w(g)?g.bind(n.api)(t,a,h):g:a&&(h?(36/a>.375?1.175-36/a:.8)*a/h:0),o="translate("+d*g+","+u*g+")"}return o},convertToArcData:function(t){return this.addName({id:"data"in t?t.data.id:t.id,value:t.value,ratio:this.getRatio("arc",t),index:t.index})},textForArcLabel:function(t){const e=this,i=e.hasType("gauge");e.shouldShowArcLabel()&&t.style("fill",e.updateTextColor.bind(e)).attr("filter",e.updateTextBackgroundColor.bind(e)).each((function(t){var n;const a=(0,s.select)(this),r=e.updateAngle(t),o=e.getRatio("arc",r);if(e.meetsLabelThreshold(o,null==(n=["donut","gauge","pie","polar"].filter(e.hasType.bind(e)))?void 0:n[0])){const n=(r||t).value;N(a,(e.getArcLabelFormat()||e.defaultArcValueFormat)(n,o,t.data.id).toString(),[-1,1],i)}else a.text("")}))},expandArc:function(t){var e=this;const n=this,a=n.state.transiting,r=n.$el;if(a){const s=setInterval(function(){i(this,e),a||(clearInterval(s),r.legend.selectAll("."+kt.legendItemFocused).size()>0&&n.expandArc(t))}.bind(this),10);return}const o=n.mapToTargetIds(t);r.svg.selectAll(n.selectorTargets(o,"."+ft.chartArc)).each((function(t){if(!n.shouldExpand(t.data.id))return;const e=n.getExpandConfig(t.data.id,"duration"),i=n.getSvgArcExpanded(n.getExpandConfig(t.data.id,"rate"));(0,s.select)(this).selectAll("path").transition().duration(e).attrTween("d",fn(n.svgArcExpanded.bind(n))).transition().duration(2*e).attrTween("d",fn(i.bind(n)))}))},unexpandArc:function(t){var e=this;const n=this,s=n.state.transiting,a=n.$el.svg;if(s)return;const r=n.mapToTargetIds(t);a.selectAll(n.selectorTargets(r,"."+ft.chartArc)).selectAll("path").transition().duration(function(t){return i(this,e),n.getExpandConfig(t.data.id,"duration")}.bind(this)).attrTween("d",fn(n.svgArc.bind(n))),a.selectAll(""+ft.arc).style("opacity",null)},getExpandConfig:function(t,e){const i=this,n=i.config;let s;return i.isDonutType(t)?s="donut":i.isGaugeType(t)?s="gauge":i.isPieType(t)&&(s="pie"),s?n[s+"_expand_"+e]:{duration:50,rate:.98}[e]},shouldExpand:function(t){const e=this,i=e.config;return e.isDonutType(t)&&i.donut_expand||e.isGaugeType(t)&&i.gauge_expand||e.isPieType(t)&&i.pie_expand},shouldShowArcLabel:function(){var t=this;const e=this,n=e.config;return["donut","gauge","pie","polar"].some(function(s){return i(this,t),e.hasType(s)&&n[s+"_label_show"]}.bind(this))},getArcLabelFormat:function(){var t=this;const e=this,n=e.config;let s=function(e){return i(this,t),e}.bind(this);return["donut","gauge","pie","polar"].filter(e.hasType.bind(e)).forEach(function(e){i(this,t),s=n[e+"_label_format"]}.bind(this)),w(s)?s.bind(e.api):s},updateTargetsForArc:function(t){var e=this;const n=this,s=n.$el,a=n.hasType("gauge"),r=n.getChartClass("Arc"),o=n.getClass("arcs",!0),c=n.classFocus.bind(n),l=s.main.select("."+ft.chartArcs),d=l.selectAll("."+ft.chartArc).data(n.pie(t)).attr("class",function(t){return i(this,e),r(t)+c(t.data)}.bind(this)),u=d.enter().append("g").attr("class",r).call(this.setCssRule(!1,"."+ft.chartArcs+" text",["pointer-events:none","text-anchor:middle"]));u.append("g").attr("class",o).merge(d),u.append("text").attr("dy",a&&!n.hasMultiTargets()?"-.1em":".35em").style("opacity","0").style("text-anchor",n.getStylePropValue("middle")).style("pointer-events",n.getStylePropValue("none")),s.text=l.selectAll("."+gt.target+" text")},initArc:function(){const t=this,e=t.$el;e.arcs=e.main.select("."+gt.chart).append("g").attr("class",ft.chartArcs).attr("transform",t.getTranslate("arc")),t.setArcTitle()},setArcTitle:function(t){const e=this,i=t||e.getArcTitle(),n=e.hasType("gauge");if(i){const t=n?Tt.chartArcsGaugeTitle:ft.chartArcsTitle;let s=e.$el.arcs.select("."+t);s.empty()&&(s=e.$el.arcs.append("text").attr("class",t).style("text-anchor","middle")),n&&s.attr("dy","-0.3em"),N(s,i,n?void 0:[-.6,1.35],!0)}},getArcTitle:function(){const t=this,e=t.hasType("donut")?"donut":t.hasType("gauge")&&"gauge";return e?t.config[e+"_title"]:""},getArcTitleWithNeedleValue:function(){const t=this,e=t.config,i=t.state,n=t.getArcTitle();if(n&&t.config.arc_needle_show&&/{=[A-Z_]+}/.test(n)){let t=i.current.needle;return S(t)||(t=e.arc_needle_value),rt(n,{NEEDLE_VALUE:S(t)?t:0})}return!1},redrawArc:function(t,e,n){var a=this;const r=this,o=r.config,c=r.state,l=r.$el.main,d=o.interaction_enabled,u=d&&o.data_selection_isselectable;let h=l.selectAll("."+ft.arcs).selectAll("."+ft.arc).data(r.arcData.bind(r));h.exit().transition().duration(e).style("opacity","0").remove(),h=h.enter().append("path").attr("class",r.getClass("arc",!0)).style("fill",function(t){return i(this,a),r.color(t.data)}.bind(this)).style("cursor",function(t){return i(this,a),null!=u&&null!=u.bind&&u.bind(r.api)(t)?"pointer":null}.bind(this)).style("opacity","0").each((function(t){r.isGaugeType(t.data)&&(t.startAngle=o.gauge_startingAngle,t.endAngle=o.gauge_startingAngle),this._current=t})).merge(h),r.hasType("gauge")&&(r.updateGaugeMax(),r.hasMultiArcGauge()&&r.redrawMultiArcGauge()),h.attr("transform",function(t){return i(this,a),!r.isGaugeType(t.data)&&n?"scale(0)":""}.bind(this)).style("opacity",(function(t){return t===this._current?"0":null})).each(function(){i(this,a),c.transiting=!0}.bind(this)).transition().duration(t).attrTween("d",(function(t){var e=this;const n=r.updateAngle(t);if(!n)return function(){return i(this,e),"M 0 0"}.bind(this);isNaN(this._current.startAngle)&&(this._current.startAngle=0),isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle);const s=(0,dn.interpolate)(this._current,n);return this._current=s(0),function(e){const i=s(e);return i.data=t.data,r.getArc(i,!0)}})).attr("transform",n?"scale(1)":"").style("fill",function(t){let e;return i(this,a),r.levelColor?(e=r.levelColor(t.data.values[0].value),o.data_colors[t.data.id]=e):e=r.color(t.data),e}.bind(this)).style("opacity",null).call(F,(function(){if(r.levelColor){const t=(0,s.select)(this),e=t.datum(this._current);r.updateLegendItemColor(e.data.id,t.style("fill"))}c.transiting=!1,$(o.onrendered,r.api)})),d&&r.bindArcEvent(h),r.hasType("polar")&&r.redrawPolar(),r.hasType("gauge")&&r.redrawBackgroundArcs(),o.arc_needle_show&&r.redrawNeedle(),r.redrawArcText(t)},redrawNeedle:function(){var t=this;const e=this,n=e.$el,s=e.config,a=e.state,r=a.hiddenTargetIds,o=(a.radius-1)/100*s.arc_needle_length,c=r.length!==e.data.targets.length;let l=e.$el.arcs.select("."+ft.needle);const d=s.arc_needle_path,u=s.arc_needle_bottom_width/2,h=s.arc_needle_top_width/2,g=s.arc_needle_top_rx,f=s.arc_needle_top_ry,p=s.arc_needle_bottom_len,x=s.arc_needle_bottom_rx,b=s.arc_needle_bottom_ry,m=e.getNeedleAngle(),_=function(){i(this,t);const n=e.getArcTitleWithNeedleValue();n&&e.setArcTitle(n)}.bind(this);if(_(),l.empty()&&(l=n.arcs.append("path").classed(ft.needle,!0),n.needle=l,n.needle.updateHelper=function(a,r){var o=this;void 0===r&&(r=!1),i(this,t),"none"!==n.needle.style("display")&&e.$T(n.needle).style("transform","rotate("+e.getNeedleAngle(a)+"deg)").call(F,function(){i(this,o),r&&(s.arc_needle_value=a),_()}.bind(this))}.bind(this)),c){const t=w(d)?d.call(e,o):"M-"+u+" "+p+" A"+x+" "+b+" 0 0 0 "+u+" "+p+" L"+h+" -"+o+" A"+g+" "+f+" 0 0 0 -"+h+" -"+o+" L-"+u+" "+p+" Z";e.$T(l).attr("d",t).style("fill",s.arc_needle_color).style("display",null).style("transform","rotate("+m+"deg)")}else l.style("display","none")},getNeedleAngle:function(t){const e=this,i=e.config,n=e.state,s=e.getArcLength(),a=e.hasType("gauge"),r=e.getTotalDataSum(!0);let o=C(t)?t:i.arc_needle_value,c=i[i.data_type+"_startingAngle"]||0,l=0;if(S(o)||(o=a&&1===e.data.targets.length?r:0),n.current.needle=o,a){c=e.getGaugeStartAngle();const t=i.gauge_fullCircle?s:-2*c,n=i.gauge_min;l=t*((o-n)/(i.gauge_max-n))}else l=s*(o/r);return(c+l)*(180/Math.PI)},redrawBackgroundArcs:function(){var t=this;const e=this,n=e.config,s=e.state,a=e.hasMultiArcGauge(),r=n.gauge_fullCircle,o=0===e.filterTargetsToShow(e.data.targets).length&&!!n.data_empty_label_text,c=e.getGaugeStartAngle(),l=r?c+e.getArcLength():-1*c;let d=e.$el.arcs.select((a?"g":"")+"."+ft.chartArcsBackground);if(a){let a=0;d=d.selectAll("path."+ft.chartArcsBackground).data(e.data.targets),d.enter().append("path").attr("class",function(e,n){return i(this,t),ft.chartArcsBackground+" "+ft.chartArcsBackground+"-"+n}.bind(this)).merge(d).style("fill",n.gauge_background||null).attr("d",function(r){let d=r.id;if(i(this,t),o||s.hiddenTargetIds.indexOf(d)>=0)return"M 0 0";const u={data:[{value:n.gauge_max}],startAngle:c,endAngle:l,index:a++};return e.getArc(u,!0,!0)}.bind(this)),d.exit().remove()}else d.attr("d",o?"M 0 0":function(){i(this,t);const s={data:[{value:n.gauge_max}],startAngle:c,endAngle:l};return e.getArc(s,!0,!0)}.bind(this))},bindArcEvent:function(t){var e=this;const n=this,a=n.config,o=n.state,c="touch"===o.inputType,l="mouse"===o.inputType;function d(t,e,i){n.expandArc(i),n.api.focus(i),n.toggleFocusLegend(i,!0),n.showTooltip([e],t)}function u(t){const e=(null==t?void 0:t.id)||void 0;n.unexpandArc(e),n.api.revert(),n.revertLegend(),n.hideTooltip()}if(t.on("click",(function(t,e,i){const s=n.updateAngle(e);let r;s&&(r=n.convertToArcData(s),null==n.toggleShape||n.toggleShape(this,r,i),a.data_onclick.bind(n.api)(r,this))})),l&&t.on("mouseover",(function(t,e){var i;if(o.transiting)return;o.event=t;const s=n.updateAngle(e),a=s?n.convertToArcData(s):null;d(this,a,(null==(i=a)?void 0:i.id)||void 0),n.setOverOut(!0,a)})).on("mouseout",function(t,s){if(i(this,e),o.transiting)return;o.event=t;const a=n.updateAngle(s),r=a?n.convertToArcData(a):null;u(),n.setOverOut(!1,r)}.bind(this)).on("mousemove",(function(t,e){const i=n.updateAngle(e),s=i?n.convertToArcData(i):null;o.event=t,n.showTooltip([s],this)})),c&&n.hasArcType()&&!n.radars){const t=function(t){var n,a;i(this,e);const o=null!=(n=null==(a=t.changedTouches)?void 0:a[0])?n:{clientX:0,clientY:0},c=o.clientX,l=o.clientY;return(0,s.select)(r.elementFromPoint(c,l))}.bind(this);n.$el.svg.on("touchstart touchmove",(function(e){var i,s;if(o.transiting)return;o.event=e;const a=t(e).datum(),r=null!=(i=a)&&i.data&&a.data.id?n.updateAngle(a):null,c=r?n.convertToArcData(r):null,l=(null==(s=c)?void 0:s.id)||void 0;n.callOverOutForTouch(c),k(l)?u():d(this,c,l)}))}},redrawArcText:function(t){var e=this;const n=this,s=n.config,a=n.state,r=n.$el,o=r.main,c=r.arcs,l=n.hasType("gauge"),d=n.hasMultiArcGauge();let u;if(l&&1===n.data.targets.length&&s.gauge_title||(u=o.selectAll("."+ft.chartArc).select("text").style("opacity","0").attr("class",function(t){return i(this,e),n.isGaugeType(t.data)?Tt.gaugeValue:null}.bind(this)).call(n.textForArcLabel.bind(n)).attr("transform",n.transformForArcLabel.bind(n)).style("font-size",function(t){return i(this,e),n.isGaugeType(t.data)&&1===n.data.targets.length&&!d?Math.round(a.radius/5)+"px":null}.bind(this)).transition().duration(t).style("opacity",function(t){return i(this,e),n.isTargetToShow(t.data.id)&&n.isArcType(t.data)?null:"0"}.bind(this)),d&&u.attr("dy","-.1em")),o.select("."+ft.chartArcsTitle).style("opacity",n.hasType("donut")||l?null:"0"),l){var h;const t=s.gauge_fullCircle;t&&(null==(h=u)||h.attr("dy",""+(d?0:Math.round(a.radius/14)))),s.gauge_label_show&&(c.select("."+Tt.chartArcsGaugeUnit).attr("dy",(t?1.5:.75)+"em").text(s.gauge_units),c.select("."+Tt.chartArcsGaugeMin).attr("dx",-1*(a.innerRadius+(a.radius-a.innerRadius)/(t?1:2))+"px").attr("dy","1.2em").text(n.textForGaugeMinMax(s.gauge_min,!1)),t||c.select("."+Tt.chartArcsGaugeMax).attr("dx",a.innerRadius+(a.radius-a.innerRadius)/2+"px").attr("dy","1.2em").text(n.textForGaugeMinMax(s.gauge_max,!0)))}},getArcElementByIdOrIndex:function(t){var e=this;const n=this.$el.arcs,s=S(t)?function(n){return i(this,e),n.index===t}.bind(this):function(n){return i(this,e),n.data.id===t}.bind(this);return null==n?void 0:n.selectAll("."+gt.target+" path").filter(s)}},xn={initArea:function(t){const e=this.config;t.insert("g","."+(e.area_front?_t.circles:At.lines)).attr("class",this.getClass("areas",!0))},updateAreaColor:function(t){const e=this;return e.config.area_linearGradient?e.getGradienColortUrl(t.id):e.color(t)},updateArea:function(t,e){void 0===e&&(e=!1);const i=this,n=i.config,a=i.state,r=i.$el,o=i.$T,c=e?r.subchart:r;n.area_linearGradient&&i.updateLinearGradient();const l=c.main.selectAll("."+pt.areas).selectAll("."+pt.area).data(i.lineData.bind(i));o(l.exit(),t).style("opacity","0").remove(),c.area=l.enter().append("path").attr("class",i.getClass("area",!0)).style("fill",i.updateAreaColor.bind(i)).style("opacity",(function(){return a.orgAreaOpacity=(0,s.select)(this).style("opacity"),"0"})).merge(l),l.style("opacity",a.orgAreaOpacity),i.setRatioForGroupedData(c.area.data())},redrawArea:function(t,e,n){var s=this;void 0===n&&(n=!1);const a=this,r=(n?this.$el.subchart:this.$el).area,o=a.state.orgAreaOpacity;return[a.$T(r,e,H()).attr("d",t).style("fill",a.updateAreaColor.bind(a)).style("opacity",function(t){return i(this,s),(a.isAreaRangeType(t)?o/1.75:o)+""}.bind(this))]},generateDrawArea:function(t,e){var n=this;const s=this,a=s.config,r=a.line_connectNull,o=a.axis_rotated,c=s.generateGetAreaPoints(t,e),l=s.getYScaleById.bind(s),d=function(t){return i(this,n),(e?s.subxx:s.xx).call(s,t)}.bind(this),u=function(t,a){return i(this,n),s.isGrouped(t.id)?c(t,a)[0][1]:l(t.id,e)(s.isAreaRangeType(t)?s.getRangedData(t,"high"):s.getShapeYMin(t.id))}.bind(this),h=function(t,a){return i(this,n),s.isGrouped(t.id)?c(t,a)[1][1]:l(t.id,e)(s.isAreaRangeType(t)?s.getRangedData(t,"low"):t.value)}.bind(this);return function(t){var e=this;i(this,n);let c,l=r?s.filterRemoveNull(t.values):t.values,g=0,f=0;if(s.isAreaType(t)){let n=(0,Ye.area)();n=o?n.y(d).x0(u).x1(h):n.x(d).y0(a.area_above?0:a.area_below?s.state.height:u).y1(h),r||(n=n.defined(function(t){return i(this,e),null!==s.getBaseValue(t)}.bind(this))),s.isStepType(t)&&(l=s.convertValuesToStep(l)),c=n.curve(s.getCurve(t))(l)}else l[0]&&(g=s.scale.x(l[0].x),f=s.getYScaleById(t.id)(l[0].value)),c=o?"M "+f+" "+g:"M "+g+" "+f;return c||"M 0 0"}.bind(this)},generateGetAreaPoints:function(t,e){const i=this,n=i.config,s=i.getShapeX(0,t,e),a=i.getShapeY(!!e),r=i.getShapeOffset(i.isAreaType,t,e),o=i.getYScaleById.bind(i);return function(t,c){const l=o.call(i,t.id,e)(i.getShapeYMin(t.id)),d=r(t,c)||l,u=s(t),h=t.value;let g=a(t);return n.axis_rotated&&(h>0&&g0?function(){return i(this,n),c}.bind(this):S(l)?function(t){return i(this,n),t*l}.bind(this):null;return function(t,e){i(this,n);const c=r(t,e),l=+o,u=+!l,h=t.value<0,g=a["axis_"+s.axis.getId(t.id)+"_inverted"],f=!g&&h||g&&!h,p=["",""];let x=0;const b=s.isGrouped(t.id),m=!(!d||!b)&&s.isStackingRadiusData(t);if(d){const t=o?u:l,e=c[2][t]-c[0][t];x=!b||m?d(e):0;const i="a"+x+","+x+" "+(f?"1 0 0":"0 0 1")+" ";p[+!o]=""+i+x+","+x,p[+o]=""+i+[-x,x][o?"sort":"reverse"](),f&&p.reverse()}const _=o?"H"+(c[1][l]+(f?x:-x))+" "+p[0]+"V"+(c[2][u]-x)+" "+p[1]+"H"+c[3][l]:"V"+(c[1][u]+(f?-x:x))+" "+p[0]+"H"+(c[2][l]-x)+" "+p[1]+"V"+c[3][u];return"M"+c[0][l]+","+c[0][u]+_+"z"}.bind(this)},isStackingRadiusData:function(t){var e=this;const n=this,s=n.$el,a=n.config,r=n.data,o=n.state,c=t.id,l=t.index,d=t.value;if(o.hiddenTargetIds.indexOf(c)>-1){const t=s.bar.filter(function(t){return i(this,e),t.id===c&&t.value===d}.bind(this));return!t.empty()&&/a\d+/i.test(t.attr("d"))}const u=a.data_groups.find(function(t){return i(this,e),t.indexOf(c)>-1}.bind(this)),h=n.orderTargets(n.filterTargetsToShow(r.targets.filter(n.isBarType,n))).filter(function(t){return i(this,e),u.indexOf(t.id)>-1}.bind(this)).map(function(t){var n=this;return i(this,e),t.values.filter(function(t){return i(this,n),t.index===l&&(S(d)&&d>0?t.value>0:t.value<0)}.bind(this))[0]}.bind(this)).filter(Boolean).map(function(t){return i(this,e),t.id}.bind(this));return 0!==d&&h.indexOf(c)===h.length-1},generateGetBarPoints:function(t,e){var n=this;const s=this,a=s.config,r=e?s.axis.subX:s.axis.x,o=s.getIndicesMax(t)+1,c=s.getBarW("bar",r,o),l=s.getShapeX(c,t,!!e),d=s.getShapeY(!!e),u=s.getShapeOffset(s.isBarType,t,!!e),h=s.getYScaleById.bind(s);return function(t,r){i(this,n);const o=t.id,g=h.call(s,o,e)(s.getShapeYMin(o)),f=u(t,r)||g,p=S(c)?c:c[t.id]||c._$width,x=a["axis_"+s.axis.getId(o)+"_inverted"],b=t.value,m=l(t);let _=d(t);a.axis_rotated&&!x&&(b>0&&_=e.open),e||null}},vn={initGauge:function(){var t=this;const e=this,n=e.config,s=e.$el.arcs,a=function(e){i(this,t),s.append("text").attr("class",e).style("text-anchor","middle").style("pointer-events","none")}.bind(this);if(e.hasType("gauge")){const t=e.hasMultiArcGauge();s.append(t?"g":"path").attr("class",ft.chartArcsBackground).style("fill",!t&&n.gauge_background||null),n.gauge_units&&a(Tt.chartArcsGaugeUnit),n.gauge_label_show&&(a(Tt.chartArcsGaugeMin),n.gauge_fullCircle||a(Tt.chartArcsGaugeMax))}},updateGaugeMax:function(){const t=this,e=t.config,i=t.state,n=t.hasMultiArcGauge()?t.getMinMaxData().max[0].value:t.getTotalDataSum(i.rendered);n+e.gauge_min*(e.gauge_min>0?-1:1)>e.gauge_max&&(e.gauge_max=n-e.gauge_min)},redrawMultiArcGauge:function(){var t=this;const e=this,n=e.config,a=e.state,r=e.$el,o=e.state.hiddenTargetIds,c=r.main.selectAll("."+ft.arcs).selectAll("."+ft.arcLabelLine).data(e.arcData.bind(e));c.enter().append("rect").attr("class",function(e){return i(this,t),ft.arcLabelLine+" "+gt.target+" "+gt.target+"-"+e.data.id}.bind(this)).merge(c).style("fill",function(n){return i(this,t),e.levelColor?e.levelColor(n.data.values[0].value):e.color(n.data)}.bind(this)).style("display",n.gauge_label_show?null:"none").each((function(t){let i=0,n=0,r=0,c="";if(o.indexOf(t.data.id)<0){const s=e.updateAngle(t),o=a.gaugeArcWidth/e.filterTargetsToShow(e.data.targets).length*(s.index+1),l=s.endAngle-Math.PI/2,d=a.radius-o,u=l-(0===d?0:1/d);i=a.radiusExpanded-a.radius+o,n=Math.cos(u)*d,r=Math.sin(u)*d,c="rotate("+180*l/Math.PI+", "+n+", "+r+")"}(0,s.select)(this).attr("x",n).attr("y",r).attr("width",i).attr("height",2).attr("transform",c).style("stroke-dasharray","0, "+(i+2)+", 0")}))},textForGaugeMinMax:function(t,e){const i=this.config.gauge_label_extents;return w(i)?i.bind(this.api)(t,e):t},getGaugeLabelHeight:function(){const t=this.config;return this.config.gauge_label_show&&!t.gauge_fullCircle?20:0},getPaddingBottomForGauge:function(){return this.getGaugeLabelHeight()*(this.config.gauge_label_show?2:2.5)}},yn={initBubble:function(){const t=this.config;this.hasType("bubble")&&(t.point_show=!0,t.point_type="circle")},getBaseLength:function(){const t=this,e=t.state,i=e.width,n=e.height,s=ee;let a=t.cache.get(s);return a||t.cache.add(s,a=nt("min",[i,n])),a},getBubbleR:function(t){var e=this;const n=this;let s=n.config.bubble_maxR;w(s)?s=s.bind(n.api)(t):S(s)||(s=n.getBaseLength()/(2*n.getMaxDataCount())+12);const a=nt("max",n.getMinMaxData().max.map(function(t){return i(this,e),n.isBubbleZType(t)?n.getBubbleZData(t.value,"y"):M(t.value)?t.value.mid:t.value}.bind(this))),r=s*s*Math.PI,o=(n.isBubbleZType(t)?n.getBubbleZData(t.value,"z"):t.value)*(r/a);return Math.sqrt(o/Math.PI)},getBubbleZData:function(t,e){return M(t)?t[e]:t["y"===e?0:1]}},Tn={initLine:function(){const t=this.$el;t.line=t.main.select("."+gt.chart).append("g").attr("class",At.chartLines).call(this.setCssRule(!1,"."+At.chartLines,["pointer-events:none"]))},updateTargetsForLine:function(t){var e=this;const n=this,s=n.$el,a=s.area,r=s.line,o=s.main,c=n.getChartClass("Line"),l=n.getClass("lines",!0),d=n.classFocus.bind(n);r||n.initLine();const u=t.filter(function(t){return i(this,e),!(n.isScatterType(t)||n.isBubbleType(t))}.bind(this)),h=o.select("."+At.chartLines).selectAll("."+At.chartLine).data(u).attr("class",function(t){return i(this,e),c(t)+d(t)}.bind(this)),g=h.enter().append("g").attr("class",c).style("opacity","0").style("pointer-events",n.getStylePropValue("none"));if(g.append("g").attr("class",l),n.hasTypeOf("Area")){const t=(!a&&g.empty()?h:g).filter(n.isAreaType.bind(n));n.initArea(t)}n.updateTargetForCircle(u,g)},updateLine:function(t,e){var n=this;void 0===e&&(e=!1);const s=this,a=s.format.extraLineClasses,r=s.$el,o=s.$T,c=e?r.subchart:r,l=c.main.selectAll("."+At.lines).selectAll("."+At.line).data(s.lineData.bind(s));o(l.exit(),t).style("opacity","0").remove(),c.line=l.enter().append("path").attr("class",function(t){return i(this,n),s.getClass("line",!0)(t)+" "+(a(t)||"")}.bind(this)).style("stroke",s.color).merge(l).style("opacity",s.initialOpacity.bind(s)).attr("transform",null)},redrawLine:function(t,e,i){void 0===i&&(i=!1);const n=this.$el;return[(0,this.$T)((i?n.subchart:n).line,e,H()).attr("d",t).style("stroke",this.color).style("opacity",null)]},getCurve:function(t){var e=this;const n=this;return n.config.axis_rotated&&n.isStepType(t)?function(s){i(this,e);const a=n.getInterpolate(t)(s);return a.orgPoint=a.point,a.pointRotated=function(t,e){1===this._point&&(this._point=2);const i=this._y*(1-this._t)+e*this._t;this._context.lineTo(this._x,i),this._context.lineTo(t,i),this._x=t,this._y=e},a.point=function(t,e){0===this._point?this.orgPoint(t,e):this.pointRotated(t,e)},a}.bind(this):n.getInterpolate(t)},generateDrawLine:function(t,e){var n=this;const s=this,a=s.config,r=s.scale,o=a.line_connectNull,c=a.axis_rotated,l=s.generateGetLinePoints(t,e),d=s.getYScaleById.bind(s),u=function(t){return i(this,n),(e?s.subxx:s.xx).call(s,t)}.bind(this),h=function(t,a){return i(this,n),s.isGrouped(t.id)?l(t,a)[0][1]:d(t.id,e)(s.getBaseValue(t))}.bind(this);let g=(0,Ye.line)();g=c?g.x(h).y(u):g.x(u).y(h),o||(g=g.defined(function(t){return i(this,n),null!==s.getBaseValue(t)}.bind(this)));const f=e?r.subX:r.x;return function(t){i(this,n);const l=d(t.id,e);let u,h=o?s.filterRemoveNull(t.values):t.values,p=0,x=0;if(s.isLineType(t)){const e=a.data_regions[t.id];e?u=s.lineWithRegions(h,r.zoom||f,l,e):(s.isStepType(t)&&(h=s.convertValuesToStep(h)),u=g.curve(s.getCurve(t))(h))}else h[0]&&(p=f(h[0].x),x=l(h[0].value)),u=c?"M "+x+" "+p:"M "+p+" "+x;return u||"M 0 0"}.bind(this)},lineWithRegions:function(t,e,n,s){var a=this;const r=this,o=r.config.axis_rotated,c=r.axis.isTimeSeries(),l=[];let d,u,h,g;if(C(s)){const e=function(t,e){return i(this,a),k(t)?e:c?ot.call(r,t):t}.bind(this);for(let i,n=0;i=s[n];n++){const s=e(i.start,t[0].x),a=e(i.end,t[t.length-1].x),r=i.style||{dasharray:"2 2"};l[n]={start:s,end:a,style:r}}}const f=o?function(t){return i(this,a),n(t.value)}.bind(this):function(t){return i(this,a),e(t.x)}.bind(this),p=o?function(t){return i(this,a),e(t.x)}.bind(this):function(t){return i(this,a),n(t.value)}.bind(this),x=function(t){return i(this,a),"M"+t[0][0]+","+t[0][1]+"L"+t[1][0]+","+t[1][1]}.bind(this),b=c?function(t,s,r,c){i(this,a);const l=t.x.getTime(),d=s.x-t.x,g=new Date(l+d*r),f=new Date(l+d*(r+c)),p=o?[[n(u(r)),e(g)],[n(u(r+h)),e(f)]]:[[e(g),n(u(r))],[e(f),n(u(r+h))]];return x(p)}.bind(this):function(t,s,r,c){i(this,a);const l=o?[[n(u(r),!0),e(d(r))],[n(u(r+c),!0),e(d(r+c))]]:[[e(d(r),!0),n(u(r))],[e(d(r+c),!0),n(u(r+c))]];return x(l)}.bind(this),m={x:r.axis.getAxisType("x"),y:r.axis.getAxisType("y")};let _="";for(let i,s=0;i=t[s];s++){const a=t[s-1],o=a&&T(a.value);let c=r.isWithinRegions(i.x,l);if(T(i.value))if(!k(l)&&c&&o){if(o){try{c=c.dasharray.split(" ")}catch(t){c="2 2".split(" ")}d=Ge(m.x,a.x,i.x),u=Ge(m.y,a.value,i.value);const t=e(i.x)-e(a.x),s=n(i.value)-n(a.value),r=Math.sqrt(Math.pow(t,2)+Math.pow(s,2));h=c[0]/r,g=h*c[1];for(let t=h;t<=1;t+=g)_+=b(a,i,t,h),t+g>=1&&(_+=b(a,i,1,0))}}else _+=(s&&o?"L":"M")+f(i)+","+p(i)}return _},isWithinRegions:function(t,e){for(let i,n=0;i=e[n];n++)if(i.start-1?"0":null})),l&&h.forEach(function(t){var e=this;i(this,n),c.main.selectAll("."+Pt.selectedCircles+a.getTargetSelectorSuffix(t.id)).selectAll(""+Pt.selectedCircle).each(function(n){i(this,e),n.value=t.values[n.index].value}.bind(this))}.bind(this))},updateCircle:function(t){var e=this;void 0===t&&(t=!1);const n=this,s=n.config,a=n.state,r=n.$el,o=n.isPointFocusOnly(),c=t?r.subchart:r;if(s.point_show&&!a.toggling){s.point_radialGradient&&n.updateLinearGradient();const t=c.main.selectAll("."+_t.circles).selectAll("."+_t.circle).data(function(t){return i(this,e),n.isLineType(t)&&n.shouldDrawPointsForLine(t)||n.isBubbleType(t)||n.isRadarType(t)||n.isScatterType(t)?o?[t.values[0]]:t.values:[]}.bind(this));t.exit().remove(),t.enter().filter(Boolean).append(n.point("create",this,n.pointR.bind(n),n.updateCircleColor.bind(n))),c.circle=c.main.selectAll("."+_t.circles+" ."+_t.circle).style("stroke",n.getStylePropValue(n.color)).style("opacity",n.initialOpacityForCircle.bind(n))}},updateCircleColor:function(t){const e=this,i=e.getStylePropValue(e.color);return e.config.point_radialGradient?e.getGradienColortUrl(t.id):i?i(t):null},redrawCircle:function(t,e,i,n,s){void 0===s&&(s=!1);const a=this,r=a.state.rendered,o=a.$el,c=a.$T,l=s?o.subchart:o,d=l.main.selectAll("."+Pt.selectedCircle);if(!a.config.point_show)return[];const u=a.point("update",a,t,e,a.updateCircleColor.bind(a),i,n,d),h=a.isCirclePoint()?"c":"",g=H(),f=a.opacityForCircle.bind(a),p=[];return l.circle.each((function(t){let e=u.bind(this)(t);e=c(e,i||!r,g).style("opacity",f),p.push(e)})),[p,c(d,i).attr(h+"x",t).attr(h+"y",e)]},showCircleFocus:function(t){const e=this,n=e.state,a=n.hasRadar,r=n.resizing,o=n.toggling,c=n.transiting;let l=e.$el.circle;if(!1===c&&l&&e.isPointFocusOnly()){const n=(a?e.radarCircleX:e.circleX).bind(e),c=(a?e.radarCircleY:e.circleY).bind(e),d=o||k(t),u=e.point("update",e,n,c,e.getStylePropValue(e.color),!r&&d);t&&(l=l.filter((function(e){var n=this;const a=null==t.filter?void 0:t.filter(function(t){return i(this,n),t.id===e.id}.bind(this));return!!a.length&&(0,s.select)(this).datum(a[0])}))),l.attr("class",this.updatePointClass.bind(this)).style("opacity",null).each((function(t){const i=t.id,n=t.index,s=t.value;let a="hidden";T(s)&&(u.bind(this)(t),e.expandCircles(n,i),a=""),this.style.visibility=a}))}},hideCircleFocus:function(){const t=this,e=t.$el.circle;t.isPointFocusOnly()&&e&&(t.unexpandCircles(),e.style("visibility","hidden"))},circleX:function(t){return this.xx(t)},updateCircleY:function(t){var e=this;void 0===t&&(t=!1);const n=this,s=n.generateGetLinePoints(n.getShapeIndices(n.isLineType),t);return function(a,r){i(this,e);const o=a.id;return n.isGrouped(o)?s(a,r)[0][1]:n.getYScaleById(o,t)(n.getBaseValue(a))}.bind(this)},expandCircles:function(t,e,i){const n=this,a=n.pointExpandedR.bind(n);i&&n.unexpandCircles();const r=n.getShapeByIndex("circle",t,e).classed(gt.EXPANDED,!0),o=a(r)/n.config.point_r,c=1-o;n.isCirclePoint()?r.attr("r",a):r.each((function(){const t=(0,s.select)(this);if("circle"===this.tagName)t.attr("r",a);else{const e=this.getBBox(),i=e.width,n=e.height,s=c*(+t.attr("x")+i/2),a=c*(+t.attr("y")+n/2);t.attr("transform","translate("+s+" "+a+") scale("+o+")")}}))},unexpandCircles:function(t){const e=this,i=e.pointR.bind(e),n=e.getShapeByIndex("circle",t).filter((function(){return(0,s.select)(this).classed(gt.EXPANDED)})).classed(gt.EXPANDED,!1);if(n.attr("r",i),!e.isCirclePoint()){const t=i(n)/e.config.point_r;n.attr("transform",1!==t?"scale("+t+")":null)}},pointR:function(t){const e=this,i=e.config.point_r;let n=i;return e.isBubbleType(t)?n=e.getBubbleR(t):w(i)&&(n=i.bind(e.api)(t)),t.r=n,n},pointExpandedR:function(t){const e=this,i=e.config,n=e.isBubbleType(t)?1.15:1.75;return i.point_focus_expand_enabled?i.point_focus_expand_r||e.pointR(t)*n:e.pointR(t)},pointSelectR:function(t){const e=this.config.point_select_r;return w(e)?e(t):e||4*this.pointR(t)},isPointFocusOnly:function(){const t=this;return t.config.point_focus_only&&!t.hasType("bubble")&&!t.hasType("scatter")&&!t.hasArcType(null,["radar"])},isWithinCircle:function(t,e){const i=this.config,n=G(this.state.event,t),a=(0,s.select)(t),r=this.isCirclePoint(t)?"c":"",o="radius"===i.point_sensitivity?t.getAttribute("r"):i.point_sensitivity;let c=+a.attr(r+"x"),l=+a.attr(r+"y");if(!c&&!l&&1===t.nodeType){const e=Y(t);c=e.x,l=e.y}return Math.sqrt(Math.pow(c-n[0],2)+Math.pow(l-n[1],2))<(e||o)},getPointSensitivity:function(t){const e=this;let i=e.config.point_sensitivity;return w(i)?i=i.call(e.api,t):"radius"===i&&(i=t.r),i},insertPointInfoDefs:function(t,e){var n,a=this;const o=function(t,e){i(this,a);const n=t.attributes;for(let i,s=0;i=n[s];s++)i=i.name,e.setAttribute(i,t.getAttribute(i))}.bind(this),c=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement,l=r.createElementNS(s.namespaces.svg,c.nodeName.toLowerCase());if(l.id=e,l.style.fill="inherit",l.style.stroke="inherit",o(c,l),null!=(n=c.childNodes)&&n.length){const t=(0,s.select)(l);"innerHTML"in l?t.html(c.innerHTML):K(c.childNodes).forEach(function(e){i(this,a),o(e,t.append(e.tagName).node())}.bind(this))}this.$el.defs.node().appendChild(l)},pointFromDefs:function(t){return this.$el.defs.select("#"+t)},updatePointClass:function(t){const e=this,i=e.$el.circle;let n=!1;return(M(t)||i)&&(n=!0===t?i.each((function(t){let i=e.getClass("circle",!0)(t);this.getAttribute("class").indexOf(gt.EXPANDED)>-1&&(i+=" "+gt.EXPANDED),this.setAttribute("class",i)})):e.getClass("circle",!0)(t)),n},generateGetLinePoints:function(t,e){var n=this;const s=this,a=s.config,r=s.getShapeX(0,t,e),o=s.getShapeY(e),c=s.getShapeOffset(s.isLineType,t,e),l=s.getYScaleById.bind(s);return function(t,d){i(this,n);const u=l.call(s,t.id,e)(s.getShapeYMin(t.id)),h=c(t,d)||u,g=r(t);let f=o(t);a.axis_rotated&&(t.value>0&&f2?o-2:0),l=2;li&&(i=e),i}var kn={initPolar:function(){const t=this,e=t.$el.arcs,i=t.config,n=i.polar_level_text_show,s=i.polar_level_text_backgroundColor;e.levels=e.append("g").attr("class",Et),n&&s&&t.generateDataLabelBackgroundColorFilter(s)},getPolarOuterRadius:function(t,e){var i;const n=Sn(this);return(null!=(i=null==t?void 0:t.data.values[0].value)?i:0)/n*e},updateTargetsForPolar:function(t){this.updateTargetsForArc(t)},redrawPolar:function(){this.config.polar_level_show&&this.updatePolarLevel()},updatePolarLevel:function(){var t=this;const e=this,n=e.config,s=e.state,a=e.$el.arcs.levels,r=n.polar_level_depth,o=Sn(e),c=st(0,r),l=s.radius,d=c.map(function(e){return i(this,t),l*((e+1)/r)}.bind(this)),u=(n.polar_level_text_format||function(){}).bind(e.api),h=a.selectAll("."+Rt).data(c);h.exit().remove();const g=h.enter().append("g").attr("class",function(e,n){return i(this,t),Rt+" "+Rt+"-"+n}.bind(this));if(g.append("circle"),g.merge(h).selectAll("circle").style("visibility",n.polar_level_show?null:"hidden").attr("cx",0).attr("cy",0).attr("r",function(e){return i(this,t),d[e]}.bind(this)),n.polar_level_text_show){const a=n.polar_level_text_backgroundColor,r="#"+s.datetimeId+"-labels-bg"+e.getTargetSelectorSuffix(a);g.append("text").style("text-anchor","middle"),g.merge(h).selectAll("text").attr("dy",function(e){return i(this,t),5-d[e]}.bind(this)).attr("filter",a?"url("+r+")":null).text(function(e){return i(this,t),u(o/c.length*(e+1))}.bind(this))}}};const Cn=oe;var Rn={initRadar:function(){const t=this,e=t.config,i=t.state.current,n=t.$el;t.hasType("radar")&&(n.radar=n.main.select("."+gt.chart).append("g").attr("class",Ot.chartRadars),n.radar.levels=n.radar.append("g").attr("class",Et),n.radar.axes=n.radar.append("g").attr("class",xt.axis),n.radar.shapes=n.radar.append("g").attr("class",It.shapes),i.dataMax=e.radar_axis_max||t.getMinMaxData().max[0].value)},getRadarSize:function(){const t=this.config,e=this.state,i=e.arcWidth,n=e.arcHeight,s=t.axis_x_categories.length<4?-20:10,a=(Math.min(i,n)-s)/2;return[a,a]},updateTargetsForRadar:function(t){var e=this;const n=this.config;I(n.axis_x_categories)&&(n.axis_x_categories=st(0,nt("max",t.map(function(t){return i(this,e),t.values.length}.bind(this))))),this.generateRadarPoints()},getRadarPosition:function(t,e,n,s){var a=this;const r=this.config,o=this.getRadarSize(),c=o[0],l=o[1],d=r.axis_x_categories.length,u=r.radar_direction_clockwise,h=K(t).map(function(o){return i(this,a),function(t,e,i,n,s,a){const r=t&&n>0?i-n:n,o=2*Math.PI;return s*(1-a*("x"===e?Math.sin:Math.cos)(r*o/i))}(u,o,d,e,C(n)?n:"x"===t?c:l,S(s)?s:r.radar_size_ratio)}.bind(this));return 1===h.length?h[0]:h},generateRadarPoints:function(){var t=this;const e=this,n=e.data.targets,s=e.getRadarSize(),a=s[0],r=s[1],o=e.cache.get(Cn)||{},c=o._size;(!c||c.width!==a&&c.height!==r)&&(n.forEach(function(n){var s=this;i(this,t),o[n.id]=n.values.map(function(t,n){return i(this,s),e.getRadarPosition(["x","y"],n,void 0,e.getRatio("radar",t))}.bind(this))}.bind(this)),o._size={width:a,height:r},e.cache.add(Cn,o))},redrawRadar:function(){const t=this,e=t.$el,i=e.radar,n=e.main,s=t.getTranslate("radar");s&&(i.attr("transform",s),n.select("."+zt.chartTexts).attr("transform",s),t.generateRadarPoints(),t.updateRadarLevel(),t.updateRadarAxes(),t.updateRadarShape())},generateGetRadarPoints:function(){var t=this;const e=this.cache.get(Cn);return function(n,s){i(this,t);const a=e[n.id][s];return[a,a,a,a]}.bind(this)},updateRadarLevel:function(){var t=this;const e=this,n=e.config,s=e.state,a=e.$el.radar,r=e.getRadarSize(),o=r[0],c=r[1],l=n.radar_level_depth,d=n.axis_x_categories.length,u=n.radar_level_text_show,h=a.levels,g=st(0,l),f=n.radar_size_ratio*Math.min(o,c),p=g.map(function(e){return i(this,t),f*((e+1)/l)}.bind(this)),x=(n.radar_level_text_format||function(){}).bind(e.api),b=g.map(function(n){var s=this;i(this,t);const a=p[n];return st(0,d).map(function(t){return i(this,s),e.getRadarPosition(["x","y"],t,a,1).join(",")}.bind(this)).join(" ")}.bind(this)),m=h.selectAll("."+Rt).data(g);m.exit().remove();const _=m.enter().append("g").attr("class",function(e,n){return i(this,t),Rt+" "+Rt+"-"+n}.bind(this));_.append("polygon").style("visibility",n.radar_level_show?null:"hidden"),u&&(h.select("text").empty()&&h.append("text").attr("dx","-.5em").attr("dy","-.7em").style("text-anchor","end").text(function(){return i(this,t),x(0)}.bind(this)),_.append("text").attr("dx","-.5em").style("text-anchor","end").text(function(e){return i(this,t),x(s.current.dataMax/g.length*(e+1))}.bind(this))),_.merge(m).attr("transform",function(e){return i(this,t),"translate("+(o-p[e])+", "+(c-p[e])+")"}.bind(this)).selectAll("polygon").attr("points",function(e){return i(this,t),b[e]}.bind(this)),u&&h.selectAll("text").attr("x",function(e){return i(this,t),k(e)?o:b[e].split(",")[0]}.bind(this)).attr("y",function(e){return i(this,t),k(e)?c:0}.bind(this))},updateRadarAxes:function(){var t=this;const e=this,n=e.config,a=e.$el.radar,r=e.getRadarSize(),o=r[0],c=r[1],l=n.axis_x_categories;let d=a.axes.selectAll("g").data(l);d.exit().remove();const u=d.enter().append("g").attr("class",function(e,n){return i(this,t),xt.axis+"-"+n}.bind(this));if(n.radar_axis_line_show&&u.append("line"),n.radar_axis_text_show&&u.append("text"),d=u.merge(d),n.radar_axis_line_show&&d.select("line").attr("x1",o).attr("y1",c).attr("x2",function(n,s){return i(this,t),e.getRadarPosition("x",s)}.bind(this)).attr("y2",function(n,s){return i(this,t),e.getRadarPosition("y",s)}.bind(this)),n.radar_axis_text_show){const a=n.radar_axis_text_position,r=a.x,l=void 0===r?0:r,u=a.y,h=void 0===u?0:u;d.select("text").style("text-anchor","middle").attr("dy",".5em").call(function(e){i(this,t),e.each((function(t){N((0,s.select)(this),t+"",[-.6,1.2])}))}.bind(this)).datum(function(e,n){return i(this,t),{index:n}}.bind(this)).attr("transform",(function(t){k(this.width)&&(this.width=this.getBoundingClientRect().width/2);let i=e.getRadarPosition("x",t.index,void 0,1),n=Math.round(e.getRadarPosition("y",t.index,void 0,1));return i>o?i+=this.width+l:Math.round(i)c?(n/2===c&&"tspan"===this.firstChild.tagName&&this.firstChild.setAttribute("dy","0em"),n+=h):n=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ln(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i=0,p=!i||i.indexOf(h)>=0,x=o.classed(Pt.SELECTED);o.classed(At.line)||o.classed(pt.area)||(t?f&&p&&l(r)&&!x?g(!0,o.classed(Pt.SELECTED,!0),r,h):C(n)&&n&&x&&g(!1,o.classed(Pt.SELECTED,!1),r,h):f&&p&&l(r)&&x&&g(!1,o.classed(Pt.SELECTED,!1),r,h))}))}var _s={selected:function(t){var e=this;const n=this.internal,a=[];return n.$el.main.selectAll("."+(It.shapes+n.getTargetSelectorSuffix(t))).selectAll("."+It.shape).filter((function(){return(0,s.select)(this).classed(Pt.SELECTED)})).each(function(t){return i(this,e),a.push(t)}.bind(this)),a},select:function(t,e,i){const n=this.internal;ms.bind(n)(!0,t,e,i)},unselect:function(t,e){const i=this.internal;ms.bind(i)(!1,t,e)}};const vs=function(t){var e=this;const n=this.internal,s=n.axis,a=n.brush,r=n.config,o=n.scale,c=o.x,l=o.subX,d=n.state;let u;if(r.subchart_show)if(u=t,Array.isArray(u)){s.isTimeSeries()&&(u=u.map(function(t){return i(this,e),ot.bind(n)(t)}.bind(this)));n.withinRange(u,n.getZoomDomain("subX",!0),n.getZoomDomain("subX"))&&(d.domain=u,a.move(a.getSelection(),u.map(l)))}else{var h;u=null!=(h=d.domain)?h:c.orgDomain()}return u};Z(vs,{show:function(){const t=this.internal,e=t.$el.subchart,i=t.config,n=i.subchart_show;if(!n){var s,a;t.unbindZoomEvent(),i.subchart_show=!n,e.main||t.initSubchart();let o=e.main.selectAll("."+gt.target);var r;if(t.data.targets.length!==o.size())t.updateSizes(),t.updateTargetsForSubchart(t.data.targets),o=null==(r=e.main)?void 0:r.selectAll("."+gt.target);null==(s=o)||s.style("opacity",null),null==(a=e.main)||a.style("display",null),this.resize()}},hide:function(){const t=this.internal,e=t.$el.subchart.main,i=t.config;i.subchart_show&&"none"!==(null==e?void 0:e.style("display"))&&(i.subchart_show=!1,e.style("display","none"),this.resize())},toggle:function(){const t=this.internal.config;this.subchart[t.subchart_show?"hide":"show"]()},reset:function(){const t=this.internal.brush;t.clear(t.getSelection())}});var ys={subchart:vs},Ts=p(14);const ws=function(t){var e,n=this;const s=this.internal,a=s.$el,r=s.axis,o=s.config,c=s.org,l=s.scale,d=s.state,u=o.axis_rotated,h=r.isCategorized();let g;if(o.zoom_enabled)if(g=t,Array.isArray(g)){r.isTimeSeries()&&(g=g.map(function(t){return i(this,n),ot.bind(s)(t)}.bind(this)));if(s.withinRange(g,s.getZoomDomain("zoom",!0),s.getZoomDomain("zoom"))){if(d.domain=g,h&&(g=g.map(function(t,e){return i(this,n),+t+(0===e?0:1)}.bind(this))),s.api.tooltip.hide(),o.subchart_show){const t=l.zoom||l.x;s.brush.getSelection().call(s.brush.move,g.map(t))}else{var f;const t=h?l.x.orgScale():c.xScale||l.x,e=[-t(g[0]),0],i=(f=Ts.zoomIdentity.scale(t.range()[1]/(t(g[1])-t(g[0])))).translate.apply(f,u?e.reverse():e);a.eventRect.call(s.zoom.transform,i)}s.setZoomResetButton()}}else g=s.zoom.getDomain();return null!=(e=d.domain)?e:g};Z(ws,{enable:function(t){const e=this.internal,i=e.config;/^(drag|wheel)$/.test(t)&&(i.zoom_type=t),i.zoom_enabled=!!t,e.zoom?!1===t&&e.bindZoomEvent(!1):(e.initZoom(),e.bindZoomEvent()),e.updateAndRedraw()},max:function(t){const e=this.internal,i=e.config,n=e.org.xDomain;return(0===t||t)&&(i.zoom_x_max=nt("max",[n[1],t])),i.zoom_x_max},min:function(t){const e=this.internal,i=e.config,n=e.org.xDomain;return(0===t||t)&&(i.zoom_x_min=nt("min",[n[0],t])),i.zoom_x_min},range:function(t){const e=this.zoom;if(M(t)){const i=t.min,n=t.max;C(i)&&e.min(i),C(n)&&e.max(n)}return{min:e.min(),max:e.max()}}});var As={zoom:ws,unzoom:function(){const t=this.internal,e=t.config,i=t.$el,n=i.eventRect,s=i.zoomResetBtn,a=t.state;t.scale.zoom&&(e.subchart_show?t.brush.getSelection().call(t.brush.move,null):t.zoom.updateTransformScale(Ts.zoomIdentity),t.updateZoom(!0),null==s||s.style("display","none"),(0,Ts.zoomTransform)(n.node())!==Ts.zoomIdentity&&t.zoom.transform(n,Ts.zoomIdentity),a.domain=void 0)}},Ss={drag:function(t){var e=this;const n=this,a=n.config,r=n.state,o=n.$el.main,c=a.data_selection_grouped,l=a.interaction_enabled&&a.data_selection_isselectable;if(n.hasArcType()||!a.data_selection_enabled||a.zoom_enabled&&!n.zoom.altDomain||!a.data_selection_multiple)return;const d=r.dragStart||[0,0],u=d[0],h=d[1],g=t[0],f=t[1],p=Math.min(u,g),x=Math.max(u,g),b=c?r.margin.top:Math.min(h,f),m=c?r.height:Math.max(h,f);o.select("."+yt.dragarea).attr("x",p).attr("y",b).attr("width",x-p).attr("height",m-b),o.selectAll("."+It.shapes).selectAll("."+It.shape).filter(function(t){return i(this,e),null==l?void 0:l.bind(n.api)(t)}.bind(this)).each((function(t,e){const i=(0,s.select)(this),a=i.classed(Pt.SELECTED),r=i.classed(yt.INCLUDED);let o,c=!1;if(i.classed(_t.circle)){const t=1*+i.attr("cx"),e=1*+i.attr("cy");o=n.togglePoint,c=p0?a:e]}.bind(this))),c&&r[1].reverse(),this.extent(r),this.update()},e.brush.getSelection=function(){return i(this,t),r.main?r.main.select("."+Ft.brush):(0,s.select)([])}.bind(this)},initSubchart:function(){var t=this;const e=this,n=e.config,s=e.state,a=s.clip,r=s.hasAxis,o=e.$el,c=o.defs,l=o.svg,d=o.subchart,u=o.axis;if(!r)return;const h=n.subchart_show?null:"hidden",g=a.id+"-subchart",f=e.getClipPath(g);a.idSubchart=g,e.appendClip(c,g),e.initBrush(),d.main=l.append("g").classed(Ft.subchart,!0).attr("transform",e.getTranslate("context"));const p=d.main;p.style("visibility",h),p.append("g").attr("clip-path",f).attr("class",Ft.chart),["bar","line","bubble","candlestick","scatter"].forEach(function(n){i(this,t);const s=q(/^(bubble|scatter)$/.test(n)?"circle":n);if(e.hasType(n)||e.hasTypeOf(s)){const t=p.select("."+Ft.chart),e=Ft["chart"+s+"s"];t.select("."+e).empty()&&t.append("g").attr("class",e)}}.bind(this));const x=p.append("g").attr("clip-path",f).attr("class",Ft.brush).call(e.brush);n.subchart_showHandle&&e.addBrushHandle(x),u.subX=p.append("g").attr("class",Ft.axisX).attr("transform",e.getTranslate("subX")).attr("clip-path",n.axis_rotated?"":a.pathXAxis).style("visibility",n.subchart_axis_x_show?h:"hidden")},addBrushHandle:function(t){var e=this;const n=this.config,s=n.axis_rotated,a=n.subchart_init_range,r=s?["M8.5 0 a6 6 0 0 0 -6 -6.5 H-2.5 a 6 6 0 0 0 -6 6.5 z m-5 -2 H-3.5 m7 -2 H-3.5z","M8.5 0 a6 -6 0 0 1 -6 6.5 H-2.5 a 6 -6 0 0 1 -6 -6.5z m-5 2 H-3.5 m7 2 H-3.5z"]:["M0 -8.5 A6 6 0 0 0 -6.5 -3.5 V2.5 A6 6 0 0 0 0 8.5 Z M-2 -3.5 V3.5 M-4 -3.5 V3.5z","M0 -8.5 A6 6 0 0 1 6.5 -3.5 V2.5 A6 6 0 0 1 0 8.5 Z M2 -3.5 V3.5 M4 -3.5 V3.5z"];this.brush.handle=t.selectAll(".handle--custom").data(s?[{type:"n"},{type:"s"}]:[{type:"w"},{type:"e"}]).enter().append("path").attr("class","handle--custom").attr("cursor",(s?"ns":"ew")+"-resize").attr("d",function(t){return i(this,e),r[+/[se]/.test(t.type)]}.bind(this)).attr("display",a?null:"none")},updateTargetsForSubchart:function(t){var e=this;const n=this,s=n.config,a=n.state,r=n.$el.subchart.main;s.subchart_show&&(["bar","line","bubble","candlestick","scatter"].filter(function(t){return i(this,e),n.hasType(t)||n.hasTypeOf(q(t))}.bind(this)).forEach(function(s){i(this,e);const a=/^(bubble|scatter)$/.test(s),o=q(a?"circle":s),c=n.getChartClass(o,!0),l=n.getClass(a?"circles":s+"s",!0),d=r.select("."+Ft["chart"+o+"s"]);if(a){const e=d.selectAll("."+Ft.circles).data(t.filter(n["is"+q(s)+"Type"].bind(n))).attr("class",l);e.exit().remove(),e.enter().append("g").attr("class",l)}else{const e=d.selectAll("."+Ft["chart"+o]).attr("class",c).data(t.filter(n["is"+o+"Type"].bind(n))),i=e.enter().append("g").style("opacity","0").attr("class",c).append("g").attr("class",l);e.exit().remove(),"line"===s&&n.hasTypeOf("Area")&&i.append("g").attr("class",n.getClass("areas",!0))}}.bind(this)),r.selectAll("."+Ft.brush+" rect").attr(s.axis_rotated?"width":"height",s.axis_rotated?a.width2:a.height2))},redrawSubchart:function(t,e,n){var s=this;const a=this,r=a.config,o=a.$el.subchart.main,c=a.state,l=!!e;var d;if((o.style("visibility",r.subchart_show?null:"hidden"),r.subchart_show)&&("zoom"===(null==(d=c.event)?void 0:d.type)&&a.brush.update(),t)){const t=r.subchart_init_range;if(W(a)||a.brush.update(),Object.keys(n.type).forEach(function(t){i(this,s);const e=q(t),r=a["generateDraw"+e](n.indices[t],!0);a["update"+e](l,!0),a["redraw"+e](r,l,!0)}.bind(this)),a.hasType("bubble")||a.hasType("scatter")){const t=n.pos.cx,e=a.updateCircleY(!0);a.updateCircle(!0),a.redrawCircle(t,e,l,void 0,!0)}!c.rendered&&t&&(c.domain=t,a.brush.move(a.brush.getSelection(),t.map(a.scale.x)))}},redrawForBrush:function(t){var e;void 0===t&&(t=!0);const i=this,n=i.config,s=n.subchart_onbrush,a=n.zoom_rescale,r=i.scale,o=i.state;i.redraw({withTransition:!1,withY:a,withSubchart:!1,withUpdateXDomain:!0,withDimension:!1}),t&&o.rendered&&s.bind(i.api)(null!=(e=o.domain)?e:r.x.orgDomain())},transformContext:function(t,e){const i=this,n=i.$el.subchart,s=i.$T,a=null!=e&&e.axisSubX?e.axisSubX:s(n.main.select("."+Ft.axisX),t);n.main.attr("transform",i.getTranslate("context")),a.attr("transform",i.getTranslate("subX"))},getExtent:function(){var t=this;const e=this,n=e.config,s=e.scale;let a=n.axis_x_extent;if(a)if(w(a))a=a.bind(e.api)(e.getXDomain(e.data.targets),s.subX);else if(e.axis.isTimeSeries()&&a.every(isNaN)){const n=ot.bind(e);a=a.map(function(e){return i(this,t),s.subX(n(e))}.bind(this))}return a}},Os={initZoom:function(){const t=this;t.scale.zoom=null,t.generateZoom(),t.initZoomBehaviour()},bindZoomEvent:function(t){void 0===t&&(t=!0);const e=this,i=e.config;i.zoom_enabled&&t?i.subchart_show||e.bindZoomOnEventRect():!1===t&&(e.api.unzoom(),e.unbindZoomEvent())},generateZoom:function(){var t=this;const e=this,n=e.config,s=e.org,a=e.scale,r=(0,Ts.zoom)().duration(0).on("start",e.onZoomStart.bind(e)).on("zoom",e.onZoom.bind(e)).on("end",e.onZoomEnd.bind(e));r.orgScaleExtent=function(){i(this,t);const s=n.zoom_extent||[1,10];return[s[0],Math.max(e.getMaxDataCount()/s[1],s[1])]}.bind(this),r.updateScaleExtent=function(){const t=L(e.scale.x.orgDomain())/L(e.getZoomDomain()),i=this.orgScaleExtent();return this.scaleExtent([i[0]*t,i[1]*t]),this},r.updateTransformScale=function(r,o){var c;i(this,t);const l=n.axis_rotated;null==(c=s.xScale)||c.range(a.x.range());const d=r[l?"rescaleY":"rescaleX"](s.xScale||a.x),u=e.trimXDomain(d.domain()),h=n.zoom_rescale;if(d.domain(u,s.xDomain),o){const t=d(a.x.domain()[0]),i=l?r.x:t,n=l?t:r.y;e.$el.eventRect.property("__zoom",Ts.zoomIdentity.translate(i,n).scale(r.k))}e.state.xTickOffset||(e.state.xTickOffset=e.axis.x.tickOffset()),a.zoom=e.getCustomizedXScale(d),e.axis.x.scale(a.zoom),h&&(s.xScale||(s.xScale=a.x.copy()),a.x.domain(u))}.bind(this),r.getDomain=function(){i(this,t);const n=a[a.zoom?"zoom":"subX"].domain();return e.axis.isCategorized()&&(n[1]-=2),n}.bind(this),e.zoom=r},onZoomStart:function(t){const e=this,i=t.sourceEvent;i&&(e.zoom.startEvent=i,e.state.zooming=!0,$(e.config.zoom_onzoomstart,e.api,t))},onZoom:function(t){var e,n=this;const s=this,a=s.config,r=s.scale,o=s.state,c=s.org,l=t.sourceEvent,d=(null==t?void 0:t.transform)===Ts.zoomIdentity;if(!a.zoom_enabled||0===s.filterTargetsToShow(s.data.targets).length||!r.zoom&&(null==l?void 0:l.type.indexOf("touch"))>-1&&1===(null==l?void 0:l.touches.length))return;t.sourceEvent&&(o.zooming=!0,o.domain=void 0);const u="mousemove"===(null==l?void 0:l.type),h=(null==l?void 0:l.wheelDelta)<0,g=t.transform;!u&&h&&r.x.domain().every(function(t,e){return i(this,n),t!==c.xDomain[e]}.bind(this))&&r.x.domain(c.xDomain),s.zoom.updateTransformScale(g,"wheel"===a.zoom_type&&l);const f=a.transition_duration>0&&!a.subchart_show&&(o.dragging||d||!t.sourceEvent);s.redraw({withTransition:f,withY:a.zoom_rescale,withSubchart:!1,withEventRect:!1,withDimension:!1}),s.state.cancelClick=u,d||$(a.zoom_onzoom,s.api,null!=(e=s.state.domain)?e:s.zoom.getDomain())},onZoomEnd:function(t){var e,i;const n=this,s=n.config,a=n.state;let r=n.zoom.startEvent,o=null==t?void 0:t.sourceEvent;const c=(null==t?void 0:t.transform)===Ts.zoomIdentity;var l;(null==(e=r)?void 0:e.type.indexOf("touch"))>-1&&(r=r.changedTouches[0],o=null==(l=o)||null==(l=l.changedTouches)?void 0:l[0]);"drag"===s.zoom_type&&o&&r.clientX===o.clientX&&r.clientY===o.clientY||(n.redrawEventRect(),n.updateZoom(),a.zooming=!1,!c&&(o||a.dragging)&&$(s.zoom_onzoomend,n.api,null!=(i=n.state.domain)?i:n.zoom.getDomain()))},updateZoom:function(t){const e=this,i=e.scale,n=i.subX,s=i.x,a=i.zoom;if(a){const i=a.domain(),r=n.domain(),o=.015,c=e.config.axis_x_inverted?(i[0]>=r[0]||i[0]+o>=r[0])&&(r[1]>=i[1]||r[1]>=i[1]+o):(i[0]<=r[0]||i[0]-o<=r[0])&&(r[1]<=i[1]||r[1]<=i[1]-o);(t||c)&&(e.axis.x.scale(n),s.domain(n.orgDomain()),e.scale.zoom=null)}},bindZoomOnEventRect:function(){var t=this;const e=this,n=e.config,s=e.$el.eventRect,a="drag"===n.zoom_type?e.zoomBehaviour:e.zoom;e.$el.svg.on("wheel",function(){i(this,t)}.bind(this)),null==s||s.call(a).on("dblclick.zoom",null)},initZoomBehaviour:function(){var t=this;const e=this,n=e.config,s=e.state,a=n.axis_rotated;let r,o=0,c=0;const l={axis:a?"y":"x",attr:a?"height":"width",index:a?1:0};e.zoomBehaviour=(0,Ee.drag)().clickDistance(4).on("start",(function(t){s.event=t,e.setDragStatus(!0),e.unselectRect(),r||(r=e.$el.main.append("rect").attr("clip-path",s.clip.path).attr("class",$t.zoomBrush).attr("width",a?s.width:0).attr("height",a?0:s.height)),o=G(t,this)[l.index],c=o,r.attr(l.axis,o).attr(l.attr,0),e.onZoomStart(t)})).on("drag",(function(t){c=G(t,this)[l.index],r.attr(l.axis,Math.min(o,c)).attr(l.attr,Math.abs(c-o))})).on("end",function(n){var a=this;i(this,t);const d=e.scale.zoom||e.scale.x;if(s.event=n,r.attr(l.axis,0).attr(l.attr,0),o>c){var u=[c,o];o=u[0],c=u[1]}o<0&&(c+=Math.abs(o),o=0),o!==c&&e.api.zoom([o,c].map(function(t){return i(this,a),d.invert(t)}.bind(this))),e.setDragStatus(!1)}.bind(this))},setZoomResetButton:function(){const t=this,e=t.config,i=t.$el,n=e.zoom_resetButton;n&&"drag"===e.zoom_type&&(i.zoomResetBtn?i.zoomResetBtn.style("display",null):i.zoomResetBtn=t.$el.chart.append("div").classed(gt.button,!0).append("span").on("click",(function(){w(n.onclick)&&n.onclick.bind(t.api)(this),t.api.unzoom()})).classed($t.buttonZoomReset,!0).text(n.text||"Reset Zoom"))}},Ls=void 0,Ps={data_selection_enabled:!1,data_selection_grouped:!1,data_selection_isselectable:function(){return i(this,Ls),!0}.bind(void 0),data_selection_multiple:!0,data_selection_draggable:!1,data_onselected:function(){i(this,Ls)}.bind(void 0),data_onunselected:function(){i(this,Ls)}.bind(void 0)},Is={subchart_show:!1,subchart_showHandle:!1,subchart_size_height:60,subchart_axis_x_show:!0,subchart_axis_x_tick_show:!0,subchart_axis_x_tick_format:void 0,subchart_axis_x_tick_text_show:!0,subchart_init_range:void 0,subchart_onbrush:function(){i(this,undefined)}.bind(void 0)},Ds={zoom_enabled:!1,zoom_type:"wheel",zoom_extent:void 0,zoom_privileged:!1,zoom_rescale:!1,zoom_onzoom:void 0,zoom_onzoomstart:void 0,zoom_onzoomend:void 0,zoom_resetButton:!0,zoom_x_min:void 0,zoom_x_max:void 0},zs=void 0;let Ms=function(){var t=this;return i(this,zs),Z(si.prototype,Rs),Z(vi.prototype,_s),te.setOptions([Ps]),(Ms=function(){return i(this,t),!0}.bind(this))()}.bind(void 0),Xs=function(){var t=this;return i(this,zs),Z(si.prototype,Es),Z(vi.prototype,ys),te.setOptions([Is]),(Xs=function(){return i(this,t),!0}.bind(this))()}.bind(void 0),$s=function(){var t=this;return i(this,zs),Z(si.prototype,Os),Z(vi.prototype,As),te.setOptions([Ds]),($s=function(){return i(this,t),!0}.bind(this))()}.bind(void 0),Fs={};const Bs={version:"3.10.3",generate:function(t){const e=et({},Fs,t),i=new vi(e);return i.internal.charts=this.instance,this.instance.push(i),i},defaults:function(t){return M(t)&&(Fs=t),Fs},instance:[],plugin:{}};var Ns=void 0;Object.keys(t).forEach(function(e){return i(this,Ns),t[e]()}.bind(void 0)),Object.keys(e).forEach(function(t){return i(this,Ns),e[t]()}.bind(void 0))}(),x}()}));
\ No newline at end of file
diff --git a/org.idempiere.zk.billboard/src/web/js/zul/billboard/ext/billboard.src.js b/org.idempiere.zk.billboard/src/web/js/zul/billboard/ext/billboard.src.js
index b5f64f1484..fdb167980c 100644
--- a/org.idempiere.zk.billboard/src/web/js/zul/billboard/ext/billboard.src.js
+++ b/org.idempiere.zk.billboard/src/web/js/zul/billboard/ext/billboard.src.js
@@ -5,7 +5,7 @@
* billboard.js, JavaScript chart library
* https://naver.github.io/billboard.js/
*
- * @version 3.9.0
+ * @version 3.10.3
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
@@ -218,7 +218,6 @@ var external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format
var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(2);
;// CONCATENATED MODULE: ./src/module/browser.ts
-var _this = undefined;
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
@@ -229,26 +228,43 @@ var _this = undefined;
*/
/* eslint-disable no-new-func, no-undef */
-var win = function () {
- _newArrowCheck(this, _this);
- var root = typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis || typeof global === "object" && global !== null && global.Object === Object && global || typeof self === "object" && self !== null && self.Object === Object && self;
- return root || Function("return this")();
- }.bind(undefined)(),
- hasRAF = typeof win.requestAnimationFrame === "function",
- hasRIC = typeof win.requestIdleCallback === "function",
- requestAnimationFrame = hasRAF ? win.requestAnimationFrame : function (cb) {
- _newArrowCheck(this, _this);
- return setTimeout(cb, 1);
- }.bind(undefined),
- cancelAnimationFrame = hasRAF ? win.cancelAnimationFrame : function (id) {
- _newArrowCheck(this, _this);
- return clearTimeout(id);
- }.bind(undefined),
- requestIdleCallback = hasRIC ? win.requestIdleCallback : requestAnimationFrame,
- cancelIdleCallback = hasRIC ? win.cancelIdleCallback : cancelAnimationFrame,
- browser_doc = win == null ? void 0 : win.document;
-/* eslint-enable no-new-func, no-undef */
-// fallback for non-supported environments
+
+/**
+ * Get global object
+ * @returns {object} window object
+ * @private
+ */
+function getGlobal() {
+ return typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis || typeof global === "object" && global !== null && global.Object === Object && global || typeof self === "object" && self !== null && self.Object === Object && self || Function("return this")();
+}
+
+/**
+ * Get fallback object
+ * @param {object} w global object
+ * @returns {Array} fallback object array
+ * @private
+ */
+function getFallback(w) {
+ var _this = this;
+ const hasRAF = typeof (w == null ? void 0 : w.requestAnimationFrame) === "function" && typeof (w == null ? void 0 : w.cancelAnimationFrame) === "function",
+ hasRIC = typeof (w == null ? void 0 : w.requestIdleCallback) === "function" && typeof (w == null ? void 0 : w.cancelIdleCallback) === "function",
+ request = function (cb) {
+ _newArrowCheck(this, _this);
+ return setTimeout(cb, 1);
+ }.bind(this),
+ cancel = function (id) {
+ _newArrowCheck(this, _this);
+ return clearTimeout(id);
+ }.bind(this);
+ return [hasRAF ? w.requestAnimationFrame : request, hasRAF ? w.cancelAnimationFrame : cancel, hasRIC ? w.requestIdleCallback : request, hasRIC ? w.cancelIdleCallback : cancel];
+}
+const win = getGlobal(),
+ browser_doc = win == null ? void 0 : win.document,
+ _getFallback = getFallback(win),
+ requestAnimationFrame = _getFallback[0],
+ cancelAnimationFrame = _getFallback[1],
+ requestIdleCallback = _getFallback[2],
+ cancelIdleCallback = _getFallback[3];
;// CONCATENATED MODULE: ./src/config/const.ts
/**
* Copyright (c) 2017 ~ present NAVER Corp.
@@ -258,7 +274,7 @@ var win = function () {
* Chart type constant
* @private
*/
-var TYPE = {
+const TYPE = {
AREA: "area",
AREA_LINE_RANGE: "area-line-range",
AREA_SPLINE: "area-spline",
@@ -283,7 +299,7 @@ var TYPE = {
* Chart type module and its method from ChartInternal class, needed to be initialized.
* @private
*/
-var TYPE_METHOD_NEEDED = {
+const TYPE_METHOD_NEEDED = {
AREA: "initArea",
AREA_LINE_RANGE: "initArea",
AREA_SPLINE: "initArea",
@@ -308,7 +324,7 @@ var TYPE_METHOD_NEEDED = {
* chart types by category
* @private
*/
-var TYPE_BY_CATEGORY = {
+const TYPE_BY_CATEGORY = {
Area: [TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.AREA_STEP],
AreaRange: [TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE],
Arc: [TYPE.PIE, TYPE.DONUT, TYPE.GAUGE, TYPE.POLAR, TYPE.RADAR],
@@ -317,14 +333,14 @@ var TYPE_BY_CATEGORY = {
Spline: [TYPE.SPLINE, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE]
};
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
-function _typeof(obj) {
+function _typeof(o) {
"@babel/helpers - typeof";
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- }, _typeof(obj);
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
+ return typeof o;
+ } : function (o) {
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
+ }, _typeof(o);
}
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js
@@ -366,9 +382,9 @@ var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webp
;// CONCATENATED MODULE: ./src/module/util.ts
-var util_this = undefined;
-function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
-function _objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+var _this = undefined;
+function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
+function _objectSpread(e) { for (var r = 1, t; r < arguments.length; r++) { t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
@@ -378,64 +394,64 @@ function _objectSpread(target) { for (var i = 1, source; i < arguments.length; i
-var isValue = function (v) {
- _newArrowCheck(this, util_this);
+const isValue = function (v) {
+ _newArrowCheck(this, _this);
return v || v === 0;
}.bind(undefined),
isFunction = function (v) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return typeof v === "function";
}.bind(undefined),
isString = function (v) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return typeof v === "string";
}.bind(undefined),
isNumber = function (v) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return typeof v === "number";
}.bind(undefined),
isUndefined = function (v) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return typeof v === "undefined";
}.bind(undefined),
isDefined = function (v) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return typeof v !== "undefined";
}.bind(undefined),
isboolean = function (v) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return typeof v === "boolean";
}.bind(undefined),
ceil10 = function (v) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return Math.ceil(v / 10) * 10;
}.bind(undefined),
asHalfPixel = function (n) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return Math.ceil(n) + .5;
}.bind(undefined),
diffDomain = function (d) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return d[1] - d[0];
}.bind(undefined),
isObjectType = function (v) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return typeof v === "object";
}.bind(undefined),
isEmpty = function (o) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
}.bind(undefined),
notEmpty = function (o) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return !isEmpty(o);
}.bind(undefined),
isArray = function (arr) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return Array.isArray(arr);
}.bind(undefined),
isObject = function (obj) {
- _newArrowCheck(this, util_this);
+ _newArrowCheck(this, _this);
return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
}.bind(undefined);
/**
@@ -471,8 +487,8 @@ function getOption(options, key, defaultValue) {
* @private
*/
function hasValue(dict, value) {
- var _this2 = this,
- found = !1;
+ var _this2 = this;
+ let found = !1;
Object.keys(dict).forEach(function (key) {
_newArrowCheck(this, _this2);
return dict[key] === value && (found = !0);
@@ -489,7 +505,7 @@ function hasValue(dict, value) {
* @private
*/
function callFn(fn, thisArg) {
- var isFn = isFunction(fn);
+ const isFn = isFunction(fn);
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
@@ -504,14 +520,15 @@ function callFn(fn, thisArg) {
* @private
*/
function endall(transition, cb) {
- var _this3 = this,
- n = 0,
- end = function () {
- for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
- args[_key2] = arguments[_key2];
- }
- --n || cb.apply.apply(cb, [this].concat(args));
- };
+ var _this3 = this;
+ let n = 0;
+ const end = function () {
+ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ args[_key2] = arguments[_key2];
+ }
+ --n || cb.apply.apply(cb, [this].concat(args));
+ };
+
// if is transition selection
if ("duration" in transition) {
transition.each(function () {
@@ -530,8 +547,8 @@ function endall(transition, cb) {
* @returns {string}
* @private
*/
-function sanitise(str) {
- return isString(str) ? str.replace(//g, ">") : str;
+function sanitize(str) {
+ return isString(str) ? str.replace(/<(script|img)?/ig, "<").replace(/(script)?>/ig, ">") : str;
}
/**
@@ -556,12 +573,12 @@ function setTextValue(node, text, dy, toMiddle) {
if (text.indexOf("\n") === -1) {
node.text(text);
} else {
- var diff = [node.text(), text].map(function (v) {
+ const diff = [node.text(), text].map(function (v) {
_newArrowCheck(this, _this4);
return v.replace(/[\s\n]/g, "");
}.bind(this));
if (diff[0] !== diff[1]) {
- var multiline = text.split("\n"),
+ const multiline = text.split("\n"),
len = toMiddle ? multiline.length - 1 : 1;
// reset possible text
node.html("");
@@ -587,7 +604,7 @@ function getRectSegList(path) {
* | |
* seg0 ---------- seg3
* */
- var _path$getBBox = path.getBBox(),
+ const _path$getBBox = path.getBBox(),
x = _path$getBBox.x,
y = _path$getBBox.y,
width = _path$getBBox.width,
@@ -621,7 +638,7 @@ function getRectSegList(path) {
* @private
*/
function getPathBox(path) {
- var _path$getBoundingClie = path.getBoundingClientRect(),
+ const _path$getBoundingClie = path.getBoundingClientRect(),
width = _path$getBoundingClie.width,
height = _path$getBoundingClie.height,
items = getRectSegList(path),
@@ -644,9 +661,12 @@ function getPathBox(path) {
*/
function getPointer(event, element) {
var _ref,
- touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]),
- pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element),
_this5 = this;
+ const touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]);
+ let pointer = [0, 0];
+ try {
+ pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element);
+ } catch (e) {}
return pointer.map(function (v) {
_newArrowCheck(this, _this5);
return isNaN(v) ? 0 : v;
@@ -660,10 +680,10 @@ function getPointer(event, element) {
* @private
*/
function getBrushSelection(ctx) {
- var event = ctx.event,
+ const event = ctx.event,
$el = ctx.$el,
main = $el.subchart.main || $el.main;
- var selection;
+ let selection;
// check from event
if (event && event.type === "brush") {
@@ -683,7 +703,7 @@ function getBrushSelection(ctx) {
* @private
*/
function getBoundingRect(node) {
- var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
+ const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
}
@@ -705,7 +725,7 @@ function getRandom(asStr, min, max) {
if (max === void 0) {
max = 1e4;
}
- var crpt = win.crypto || win.msCrypto,
+ const crpt = win.crypto || win.msCrypto,
rand = crpt ? min + crpt.getRandomValues(new Uint32Array(1))[0] % (max - min + 1) : Math.floor(Math.random() * (max - min) + min);
return asStr ? rand + "" : rand;
}
@@ -724,8 +744,8 @@ function findIndex(arr, v, start, end, isRotated) {
if (start > end) {
return -1;
}
- var mid = Math.floor((start + end) / 2);
- var _arr$mid = arr[mid],
+ const mid = Math.floor((start + end) / 2);
+ let _arr$mid = arr[mid],
x = _arr$mid.x,
_arr$mid$w = _arr$mid.w,
w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
@@ -746,7 +766,7 @@ function findIndex(arr, v, start, end, isRotated) {
* @private
*/
function brushEmpty(ctx) {
- var selection = getBrushSelection(ctx);
+ const selection = getBrushSelection(ctx);
if (selection) {
// brush selected area
// two-dimensional: [[x0, y0], [x1, y1]]
@@ -763,17 +783,19 @@ function brushEmpty(ctx) {
* @private
*/
function deepClone() {
- for (var _this6 = this, _clone = function clone(v) {
- _newArrowCheck(this, _this6);
- if (isObject(v) && v.constructor) {
- var r = new v.constructor();
- for (var k in v) {
- r[k] = _clone(v[k]);
- }
- return r;
+ var _this6 = this;
+ const _clone = function clone(v) {
+ _newArrowCheck(this, _this6);
+ if (isObject(v) && v.constructor) {
+ const r = new v.constructor();
+ for (const k in v) {
+ r[k] = _clone(v[k]);
}
- return v;
- }.bind(this), _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
+ return r;
+ }
+ return v;
+ }.bind(this);
+ for (var _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
objectN[_key3] = arguments[_key3];
}
return objectN.map(function (v) {
@@ -805,7 +827,7 @@ function extend(target, source) {
}
// exclude name with only numbers
- for (var p in source) {
+ for (const p in source) {
if (/^\d+$/.test(p) || p in target) {
continue;
}
@@ -820,8 +842,8 @@ function extend(target, source) {
* @returns {string} capitalized string
* @private
*/
-var capitalize = function (str) {
- _newArrowCheck(this, util_this);
+const capitalize = function (str) {
+ _newArrowCheck(this, _this);
return str.charAt(0).toUpperCase() + str.slice(1);
}.bind(undefined);
@@ -849,8 +871,8 @@ function camelize(str, separator) {
* @returns {Array}
* @private
*/
-var toArray = function (v) {
- _newArrowCheck(this, util_this);
+const toArray = function (v) {
+ _newArrowCheck(this, _this);
return [].slice.call(v);
}.bind(undefined);
@@ -863,8 +885,8 @@ var toArray = function (v) {
* @private
*/
function addCssRules(style, selector, prop) {
- var _this9 = this,
- rootSelctor = style.rootSelctor,
+ var _this9 = this;
+ const rootSelctor = style.rootSelctor,
sheet = style.sheet,
getSelector = function (s) {
_newArrowCheck(this, _this9);
@@ -881,8 +903,8 @@ function addCssRules(style, selector, prop) {
* @private
*/
function getCssRules(styleSheets) {
- var _this10 = this,
- rules = [];
+ var _this10 = this;
+ let rules = [];
styleSheets.forEach(function (sheet) {
_newArrowCheck(this, _this10);
try {
@@ -891,7 +913,7 @@ function getCssRules(styleSheets) {
}
} catch (e) {
var _window$console;
- (_window$console = win.console) == null ? void 0 : _window$console.warn("Error while reading rules from " + sheet.href + ": " + e.toString());
+ (_window$console = win.console) == null || _window$console.warn("Error while reading rules from " + sheet.href + ": " + e.toString());
}
}.bind(this));
return rules;
@@ -904,7 +926,7 @@ function getCssRules(styleSheets) {
* @private
*/
function getTranslation(node) {
- var transform = node ? node.transform : null,
+ const transform = node ? node.transform : null,
baseVal = transform && transform.baseVal;
return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
a: 0,
@@ -923,8 +945,8 @@ function getTranslation(node) {
* @private
*/
function getUnique(data) {
- var _this11 = this,
- isDate = data[0] instanceof Date,
+ var _this11 = this;
+ const isDate = data[0] instanceof Date,
d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
_newArrowCheck(this, _this11);
return self.indexOf(v) === i;
@@ -963,11 +985,11 @@ function mergeObj(target) {
if (!objectN.length || objectN.length === 1 && !objectN[0]) {
return target;
}
- var source = objectN.shift();
+ const source = objectN.shift();
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach(function (key) {
_newArrowCheck(this, _this13);
- var value = source[key];
+ const value = source[key];
if (isObject(value)) {
target[key] || (target[key] = {});
target[key] = mergeObj(target[key], value);
@@ -991,7 +1013,7 @@ function sortValue(data, isAsc) {
if (isAsc === void 0) {
isAsc = !0;
}
- var fn;
+ let fn;
if (data[0] instanceof Date) {
fn = isAsc ? function (a, b) {
_newArrowCheck(this, _this14);
@@ -1024,11 +1046,11 @@ function sortValue(data, isAsc) {
* @private
*/
function getMinMax(type, data) {
- var _this15 = this,
- res = data.filter(function (v) {
- _newArrowCheck(this, _this15);
- return notEmpty(v);
- }.bind(this));
+ var _this15 = this;
+ let res = data.filter(function (v) {
+ _newArrowCheck(this, _this15);
+ return notEmpty(v);
+ }.bind(this));
if (res.length) {
if (isNumber(res[0])) {
res = Math[type].apply(Math, res);
@@ -1049,14 +1071,14 @@ function getMinMax(type, data) {
* @returns {Array}
* @private
*/
-var getRange = function (start, end, step) {
+const getRange = function (start, end, step) {
if (step === void 0) {
step = 1;
}
- _newArrowCheck(this, util_this);
- var res = [],
+ _newArrowCheck(this, _this);
+ const res = [],
n = Math.max(0, Math.ceil((end - start) / step)) | 0;
- for (var i = start; i < n; i++) {
+ for (let i = start; i < n; i++) {
res.push(start + i * step);
}
return res;
@@ -1064,8 +1086,8 @@ var getRange = function (start, end, step) {
emulateEvent = {
mouse: function () {
var _this16 = this;
- _newArrowCheck(this, util_this);
- var getParams = function () {
+ _newArrowCheck(this, _this);
+ const getParams = function () {
_newArrowCheck(this, _this16);
return {
bubbles: !1,
@@ -1093,7 +1115,7 @@ var getRange = function (start, end, step) {
params = getParams();
}
_newArrowCheck(this, _this16);
- var mouseEvent = browser_doc.createEvent("MouseEvent");
+ const mouseEvent = browser_doc.createEvent("MouseEvent");
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0,
@@ -1104,8 +1126,8 @@ var getRange = function (start, end, step) {
}
}.bind(undefined)(),
touch: function touch(el, eventType, params) {
- _newArrowCheck(this, util_this);
- var touchObj = new Touch(mergeObj({
+ _newArrowCheck(this, _this);
+ const touchObj = new Touch(mergeObj({
identifier: Date.now(),
target: el,
radiusX: 2.5,
@@ -1131,8 +1153,8 @@ var getRange = function (start, end, step) {
* @private
*/
function tplProcess(tpl, data) {
- var res = tpl;
- for (var x in data) {
+ let res = tpl;
+ for (const x in data) {
res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
}
return res;
@@ -1146,13 +1168,14 @@ function tplProcess(tpl, data) {
* @private
*/
function parseDate(date) {
- var parsedDate;
+ let parsedDate;
if (date instanceof Date) {
parsedDate = date;
} else if (isString(date)) {
- var _format$dataTime,
- config = this.config,
+ var _format$dataTime;
+ const config = this.config,
format = this.format;
+
// if fails to parse, try by new Date()
// https://github.com/naver/billboard.js/issues/1714
parsedDate = (_format$dataTime = format.dataTime(config.data_xFormat)(date)) != null ? _format$dataTime : new Date(date);
@@ -1182,11 +1205,11 @@ function isTabVisible() {
* @private
*/
function convertInputType(mouse, touch) {
- var _this17 = this,
- DocumentTouch = win.DocumentTouch,
+ var _this17 = this;
+ const DocumentTouch = win.DocumentTouch,
matchMedia = win.matchMedia,
- navigator = win.navigator,
- hasTouch = !1;
+ navigator = win.navigator;
+ let hasTouch = !1;
if (touch) {
// Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
if (navigator && "maxTouchPoints" in navigator) {
@@ -1202,7 +1225,7 @@ function convertInputType(mouse, touch) {
hasTouch = !0;
} else {
// Only as a last resort, fall back to user agent sniffing
- var UA = navigator.userAgent;
+ const UA = navigator.userAgent;
hasTouch = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
}
}
@@ -1211,7 +1234,7 @@ function convertInputType(mouse, touch) {
// Check if agent has mouse using any-hover, touch devices (e.g iPad) with external mouse will return true as long as mouse is connected
// https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
// Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
- var hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
+ const hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
_newArrowCheck(this, _this17);
return matchMedia == null ? void 0 : matchMedia("(" + v + ")").matches;
}.bind(this));
@@ -1255,14 +1278,14 @@ function runUntil(fn, conditionFn) {
* @private
*/
function checkModuleImport(ctx) {
- var $$ = ctx,
+ const $$ = ctx,
config = $$.config;
- var type = "";
+ let type = "";
if (isEmpty(config.data_type || config.data_types) && !$$[TYPE_METHOD_NEEDED.LINE]) {
type = "line";
} else {
- for (var x in TYPE_METHOD_NEEDED) {
- var t = TYPE[x];
+ for (const x in TYPE_METHOD_NEEDED) {
+ const t = TYPE[x];
if ($$.hasType(t) && !$$[TYPE_METHOD_NEEDED[x]]) {
type = t;
break;
@@ -1279,19 +1302,18 @@ function checkModuleImport(ctx) {
* @private
*/
function logError(head, tail) {
- var _window$console,
- prefix = "[billboard.js]",
- hasConsole = (_window$console = win.console) == null ? void 0 : _window$console.error;
+ var _window$console;
+ const hasConsole = (_window$console = win.console) == null ? void 0 : _window$console.error;
if (hasConsole) {
- console.error("\u274C " + prefix + " " + head, "background:red;color:white;display:block;font-size:15px", tail);
+ console.error("\u274C [billboard.js] " + head, "background:red;color:white;display:block;font-size:15px", tail);
console.info("%cℹ️", "font-size:15px", "https://github.com/naver/billboard.js/wiki/CHANGELOG-v2#modularization-by-its-functionality");
}
- throw Error(prefix + " " + head.replace(/\%c([a-z-]+)/i, "'$1' ") + " " + tail);
+ throw Error("[billboard.js] " + head.replace(/\%c([a-z-]+)/i, "'$1' ") + " " + tail);
}
;// CONCATENATED MODULE: ./src/config/classes.ts
-function classes_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
-function classes_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? classes_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : classes_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+function classes_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
+function classes_objectSpread(e) { for (var r = 1, t; r < arguments.length; r++) { t = null != arguments[r] ? arguments[r] : {}; r % 2 ? classes_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : classes_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
@@ -1300,7 +1322,7 @@ function classes_objectSpread(target) { for (var i = 1, source; i < arguments.le
* CSS class names definition
* @private
*/
-var $COMMON = {
+const $COMMON = {
button: "bb-button",
chart: "bb-chart",
empty: "bb-empty",
@@ -1308,7 +1330,7 @@ var $COMMON = {
target: "bb-target",
EXPANDED: "_expanded_"
};
-var $ARC = {
+const $ARC = {
arc: "bb-arc",
arcLabelLine: "bb-arc-label-line",
arcs: "bb-arcs",
@@ -1318,11 +1340,11 @@ var $ARC = {
chartArcsTitle: "bb-chart-arcs-title",
needle: "bb-needle"
};
-var $AREA = {
+const $AREA = {
area: "bb-area",
areas: "bb-areas"
};
-var $AXIS = {
+const $AXIS = {
axis: "bb-axis",
axisX: "bb-axis-x",
axisXLabel: "bb-axis-x-label",
@@ -1331,13 +1353,13 @@ var $AXIS = {
axisY2Label: "bb-axis-y2-label",
axisYLabel: "bb-axis-y-label"
};
-var $BAR = {
+const $BAR = {
bar: "bb-bar",
bars: "bb-bars",
chartBar: "bb-chart-bar",
chartBars: "bb-chart-bars"
};
-var $CANDLESTICK = {
+const $CANDLESTICK = {
candlestick: "bb-candlestick",
candlesticks: "bb-candlesticks",
chartCandlestick: "bb-chart-candlestick",
@@ -1345,27 +1367,27 @@ var $CANDLESTICK = {
valueDown: "bb-value-down",
valueUp: "bb-value-up"
};
-var $CIRCLE = {
+const $CIRCLE = {
chartCircles: "bb-chart-circles",
circle: "bb-circle",
circles: "bb-circles"
};
-var $COLOR = {
+const $COLOR = {
colorPattern: "bb-color-pattern",
colorScale: "bb-colorscale"
};
-var $DRAG = {
+const $DRAG = {
dragarea: "bb-dragarea",
INCLUDED: "_included_"
};
-var $GAUGE = {
+const $GAUGE = {
chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
gaugeValue: "bb-gauge-value"
};
-var $LEGEND = {
+const $LEGEND = {
legend: "bb-legend",
legendBackground: "bb-legend-background",
legendItem: "bb-legend-item",
@@ -1374,26 +1396,26 @@ var $LEGEND = {
legendItemPoint: "bb-legend-item-point",
legendItemTile: "bb-legend-item-tile"
};
-var $LINE = {
+const $LINE = {
chartLine: "bb-chart-line",
chartLines: "bb-chart-lines",
line: "bb-line",
lines: "bb-lines"
};
-var $EVENT = {
+const $EVENT = {
eventRect: "bb-event-rect",
eventRects: "bb-event-rects",
eventRectsMultiple: "bb-event-rects-multiple",
eventRectsSingle: "bb-event-rects-single"
};
-var $FOCUS = {
+const $FOCUS = {
focused: "bb-focused",
defocused: "bb-defocused",
legendItemFocused: "bb-legend-item-focused",
xgridFocus: "bb-xgrid-focus",
ygridFocus: "bb-ygrid-focus"
};
-var $GRID = {
+const $GRID = {
grid: "bb-grid",
gridLines: "bb-grid-lines",
xgrid: "bb-xgrid",
@@ -1405,32 +1427,32 @@ var $GRID = {
ygridLines: "bb-ygrid-lines",
ygrids: "bb-ygrids"
};
-var $LEVEL = {
+const $LEVEL = {
level: "bb-level",
levels: "bb-levels"
};
-var $RADAR = {
+const $RADAR = {
chartRadar: "bb-chart-radar",
chartRadars: "bb-chart-radars"
};
-var $REGION = {
+const $REGION = {
region: "bb-region",
regions: "bb-regions"
};
-var $SELECT = {
+const $SELECT = {
selectedCircle: "bb-selected-circle",
selectedCircles: "bb-selected-circles",
SELECTED: "_selected_"
};
-var $SHAPE = {
+const $SHAPE = {
shape: "bb-shape",
shapes: "bb-shapes"
};
-var $SUBCHART = {
+const $SUBCHART = {
brush: "bb-brush",
subchart: "bb-subchart"
};
-var $TEXT = {
+const $TEXT = {
chartText: "bb-chart-text",
chartTexts: "bb-chart-texts",
text: "bb-text",
@@ -1438,17 +1460,17 @@ var $TEXT = {
title: "bb-title",
TextOverlapping: "text-overlapping"
};
-var $TOOLTIP = {
+const $TOOLTIP = {
tooltip: "bb-tooltip",
tooltipContainer: "bb-tooltip-container",
tooltipName: "bb-tooltip-name"
};
-var $TREEMAP = {
+const $TREEMAP = {
treemap: "bb-treemap",
chartTreemap: "bb-chart-treemap",
chartTreemaps: "bb-chart-treemaps"
};
-var $ZOOM = {
+const $ZOOM = {
buttonZoomReset: "bb-zoom-reset",
zoomBrush: "bb-zoom-brush"
};
@@ -1464,7 +1486,7 @@ var $ZOOM = {
* @ignore
* @private
*/
-var Element = function () {
+let Element = function () {
return {
chart: null,
main: null,
@@ -1541,7 +1563,7 @@ var Element = function () {
* @ignore
* @private
*/
-var State = function () {
+let State = function () {
return {
// chart drawn area dimension, excluding axes
width: 0,
@@ -1575,23 +1597,28 @@ var State = function () {
// for data CSS rule index (used when boost.useCssRule is true)
cssRule: {},
current: {
+ // current domain value. Assigned when is zoom is called
+ domain: undefined,
// chart whole dimension
width: 0,
height: 0,
dataMax: 0,
- maxTickWidths: {
+ maxTickSize: {
x: {
- size: 0,
+ width: 0,
+ height: 0,
ticks: [],
clipPath: 0,
domain: ""
},
y: {
- size: 0,
+ width: 0,
+ height: 0,
domain: ""
},
y2: {
- size: 0,
+ width: 0,
+ height: 0,
domain: ""
}
},
@@ -1706,7 +1733,7 @@ var State = function () {
// mapping
-var Store_classes = {
+const Store_classes = {
element: Element,
state: State
};
@@ -1717,7 +1744,7 @@ var Store_classes = {
* @ignore
* @private
*/
-var Store = /*#__PURE__*/function () {
+let Store = /*#__PURE__*/function () {
function Store() {
var _this = this;
Object.keys(Store_classes).forEach(function (v) {
@@ -1737,6 +1764,7 @@ var Store = /*#__PURE__*/function () {
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
+
/**
* main config options
*/
@@ -1836,6 +1864,7 @@ var Store = /*#__PURE__*/function () {
size_height: undefined,
/**
* The padding of the chart element.
+ * - **NOTE:** for more information, see the "[`Understanding padding`](https://github.com/naver/billboard.js/wiki/Understanding-padding)"" wiki documentaion.
* @name padding
* @memberof Options
* @type {object}
@@ -2111,13 +2140,21 @@ var Store = /*#__PURE__*/function () {
* @memberof Options
* @type {Array}
* @default []
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Region.RegionLabel)
* @example
* regions: [
* {
* axis: "x",
* start: 1,
* end: 4,
- * class: "region-1-4"
+ * class: "region-1-4",
+ * label: {
+ * text: "Region Text",
+ * x: 5, // position relative of the initial x coordinate
+ * y: 5, // position relative of the initial y coordinate
+ * color: "red", // color string
+ * rotated: true // make text to show in vertical or horizontal
+ * }
* }
* ]
*/
@@ -2791,7 +2828,11 @@ var data_this = undefined;
* {name: "www.site4.com", upload: 400, download: 100, total: 500}
* ],
* keys: {
- * // x: "name", // it's possible to specify 'x' when category axis
+ * // case 1: specify 'x' key for category axis
+ * x: "name", // 'name' key will be used as category x axis values
+ * value: ["upload", "download"]
+ *
+ * // case 2: without 'x' key for non-category axis
* value: ["upload", "download"]
* }
* }
@@ -2989,7 +3030,11 @@ var data_this = undefined;
* {name: "www.site4.com", upload: 400, download: 100, total: 500}
* ],
* keys: {
- * // x: "name", // it's possible to specify 'x' when category axis
+ * // case 1: specify 'x' key for category axis
+ * x: "name", // 'name' key will be used as category x axis values
+ * value: ["upload", "download"]
+ *
+ * // case 2: without 'x' key for non-category axis
* value: ["upload", "download"]
* }
* }
@@ -3378,9 +3423,9 @@ var tooltip_this = undefined;
* Specified function receives x of the data point to show.
* @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.
* Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
- * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip. If undefined returned, the row of that value will be skipped to be called.
+ * @property {Function} [tooltip.format.value] Set format for the value of each data value in tooltip. If undefined returned, the row of that value will be skipped to be called.
* - Will pass following arguments to the given function:
- * - `value {string}`: Value of the data point
+ * - `value {string}`: Value of the data point. If data row contains multiple or ranged(ex. candlestick, area range, etc.) value, formatter will be called as value length.
* - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
* - `id {string}`: id of the data point
* - `index {number}`: Index of the data point
@@ -3419,7 +3464,7 @@ var tooltip_this = undefined;
* - The value array length should match with the data length
* @property {boolean} [tooltip.init.show=false] Show tooltip at the initialization.
* @property {number} [tooltip.init.x=0] Set x Axis index(or index for Arc(donut, gauge, pie) types) to be shown at the initialization.
- * @property {object} [tooltip.init.position={top: "0px",left: "50px"}] Set the position of tooltip at the initialization.
+ * @property {object} [tooltip.init.position] Set the position of tooltip at the initialization.
* @property {Function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
* @property {Function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
* @property {Function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
@@ -3436,6 +3481,7 @@ var tooltip_this = undefined;
* @see [Demo: Tooltip Grouping](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipGrouping)
* @see [Demo: Tooltip Format](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipFormat)
* @see [Demo: Linked Tooltip](https://naver.github.io/billboard.js/demo/#Tooltip.LinkedTooltips)
+ * @see [Demo: Tooltip Position](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipPosition)
* @see [Demo: Tooltip Template](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipTemplate)
* @example
* tooltip: {
@@ -3445,6 +3491,9 @@ var tooltip_this = undefined;
* format: {
* title: function(x) { return "Data " + x; },
* name: function(name, ratio, id, index) { return name; },
+ *
+ * // If data row contains multiple or ranged(ex. candlestick, area range, etc.) value,
+ * // formatter will be called as value length times.
* value: function(value, ratio, id, index) { return ratio; }
* },
* position: function(data, width, height, element, pos) {
@@ -3456,8 +3505,31 @@ var tooltip_this = undefined;
* // x: Current mouse event x position,
* // y: Current mouse event y position,
* // xAxis: Current x Axis position (the value is given for axis based chart type only)
+ * // yAxis: Current y Axis position value or function(the value is given for axis based chart type only)
* // }
- * return {top: 0, left: 0}
+ *
+ * // yAxis will work differently per data lenghts
+ * // - a) Single data: `yAxis` will return `number` value
+ * // - b) Multiple data: `yAxis` will return a function with property value
+ *
+ * // a) Single data:
+ * // Get y coordinate
+ * pos.yAxis; // y axis coordinate value of current data point
+ *
+ * // b) Multiple data:
+ * // Get y coordinate of value 500, where 'data1' scales(y or y2).
+ * // When 'data.axes' option is used, data can bound to different axes.
+ * // - when "data.axes={data1: 'y'}", wil return y value from y axis scale.
+ * // - when "data.axes={data1: 'y2'}", wil return y value from y2 axis scale.
+ * pos.yAxis(500, "data1"); // will return y coordinate value of data1
+ *
+ * pos.yAxis(500); // get y coordinate with value of 500, using y axis scale
+ * pos.yAxis(500, null, "y2"); // get y coordinate with value of 500, using y2 axis scale
+ *
+ * return {
+ * top: 0,
+ * left: 0
+ * }
* },
*
* contents: function(d, defaultTitleFormat, defaultValueFormat, color) {
@@ -3511,10 +3583,10 @@ var tooltip_this = undefined;
* // show at the initialization
* init: {
* show: true,
- * x: 2, // x Axis index(or index for Arc(donut, gauge, pie) types)
+ * x: 2, // x Axis index (or index for Arc(donut, gauge, pie) types)
* position: {
- * top: "150px",
- * left: "250px"
+ * top: "150px", // specify as number or as string with 'px' unit string
+ * left: 250 // specify as number or as string with 'px' unit string
* }
* },
*
@@ -3566,10 +3638,7 @@ var tooltip_this = undefined;
tooltip_contents: {},
tooltip_init_show: !1,
tooltip_init_x: 0,
- tooltip_init_position: {
- top: "0px",
- left: "50px"
- },
+ tooltip_init_position: undefined,
tooltip_linked: !1,
tooltip_linked_name: "",
tooltip_onshow: function tooltip_onshow() {
@@ -3589,8 +3658,8 @@ var tooltip_this = undefined;
;// CONCATENATED MODULE: ./src/config/Options/Options.ts
-function Options_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
-function Options_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? Options_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : Options_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+function Options_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
+function Options_objectSpread(e) { for (var r = 1, t; r < arguments.length; r++) { t = null != arguments[r] ? arguments[r] : {}; r % 2 ? Options_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : Options_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
@@ -3612,7 +3681,7 @@ function Options_objectSpread(target) { for (var i = 1, source; i < arguments.le
* @class Options
* @see {@link bb.generate} to use these options on generating the chart
*/
-var Options = /*#__PURE__*/function () {
+let Options = /*#__PURE__*/function () {
Options.setOptions = function setOptions(options) {
var _this = this;
this.data = options.reduce(function (a, c) {
@@ -3639,7 +3708,7 @@ Options.data = {};
* - NOTE: Prefixed with '$', will be resetted when .load() is called
* @private
*/
-var KEY = {
+const KEY = {
bubbleBaseLength: "$baseLength",
colorPattern: "__colorPattern__",
dataMinMax: "$dataMinMax",
@@ -3651,7 +3720,7 @@ var KEY = {
callOverOutForTouch: "callOverOutForTouch",
textRect: "textRect"
};
-var Cache = /*#__PURE__*/function () {
+let Cache = /*#__PURE__*/function () {
function Cache() {
this.cache = {};
}
@@ -3679,7 +3748,7 @@ var Cache = /*#__PURE__*/function () {
*/;
_proto.remove = function remove(key) {
var _this = this;
- toArray(key).forEach(function (v) {
+ (isString(key) ? [key] : key).forEach(function (v) {
_newArrowCheck(this, _this);
return delete this.cache[v];
}.bind(this));
@@ -3696,16 +3765,17 @@ var Cache = /*#__PURE__*/function () {
if (isDataType === void 0) {
isDataType = !1;
}
- if (isDataType) {
- var targets = [];
- for (var i = 0, id; id = key[i]; i++) {
+ // when is isDataType, key should be string array
+ if (isDataType && Array.isArray(key)) {
+ const targets = [];
+ for (let i = 0, id; id = key[i]; i++) {
if (id in this.cache) {
targets.push(this.cloneTarget(this.cache[id]));
}
}
return targets;
} else {
- var value = this.cache[key];
+ const value = this.cache[key];
return isValue(value) ? value : null;
}
}
@@ -3716,8 +3786,8 @@ var Cache = /*#__PURE__*/function () {
* @private
*/;
_proto.reset = function reset(all) {
- var $$ = this;
- for (var x in $$.cache) {
+ const $$ = this;
+ for (const x in $$.cache) {
// reset the prefixed '$' key(which is internal use data) only.
if (all || /^\$/.test(x)) {
$$.cache[x] = null;
@@ -3760,7 +3830,7 @@ var Cache = /*#__PURE__*/function () {
-var generator_setTimeout = win.setTimeout,
+const generator_setTimeout = win.setTimeout,
generator_clearTimeout = win.clearTimeout;
/**
@@ -3770,35 +3840,35 @@ var generator_setTimeout = win.setTimeout,
* @private
*/
function generateResize(option) {
- var _this4 = this,
- fn = [],
- timeout,
- callResizeFn = function () {
- var _this = this;
- // Delay all resize functions call, to prevent unintended excessive call from resize event
- callResizeFn.clear();
- if (option === !1) {
- requestIdleCallback(function () {
- var _this2 = this;
- _newArrowCheck(this, _this);
- fn.forEach(function (f) {
- _newArrowCheck(this, _this2);
- return f();
- }.bind(this));
- }.bind(this), {
- timeout: 200
- });
- } else {
- timeout = generator_setTimeout(function () {
- var _this3 = this;
- _newArrowCheck(this, _this);
- fn.forEach(function (f) {
- _newArrowCheck(this, _this3);
- return f();
- }.bind(this));
- }.bind(this), isNumber(option) ? option : 200);
- }
- };
+ var _this4 = this;
+ const fn = [];
+ let timeout;
+ const callResizeFn = function () {
+ var _this = this;
+ // Delay all resize functions call, to prevent unintended excessive call from resize event
+ callResizeFn.clear();
+ if (option === !1) {
+ requestIdleCallback(function () {
+ var _this2 = this;
+ _newArrowCheck(this, _this);
+ fn.forEach(function (f) {
+ _newArrowCheck(this, _this2);
+ return f();
+ }.bind(this));
+ }.bind(this), {
+ timeout: 200
+ });
+ } else {
+ timeout = generator_setTimeout(function () {
+ var _this3 = this;
+ _newArrowCheck(this, _this);
+ fn.forEach(function (f) {
+ _newArrowCheck(this, _this3);
+ return f();
+ }.bind(this));
+ }.bind(this), isNumber(option) ? option : 200);
+ }
+ };
callResizeFn.clear = function () {
_newArrowCheck(this, _this4);
if (timeout) {
@@ -3822,10 +3892,10 @@ function generateResize(option) {
* @private
*/
function generateWait() {
- var transitionsToWait = [];
+ let transitionsToWait = [];
// 'f' is called as selection.call(f, ...);
- var f = function (selection, callback) {
+ const f = function (selection, callback) {
var _this5 = this;
/**
* Check if transition is complete
@@ -3833,8 +3903,8 @@ function generateWait() {
* @private
*/
function loop() {
- var done = 0;
- for (var i = 0, t; t = transitionsToWait[i]; i++) {
+ let done = 0;
+ for (let i = 0, t; t = transitionsToWait[i]; i++) {
if (t === !0 || t.empty != null && t.empty()) {
done++;
continue;
@@ -3855,7 +3925,7 @@ function generateWait() {
}
runUntil(function () {
_newArrowCheck(this, _this5);
- callback == null ? void 0 : callback();
+ callback == null || callback();
}.bind(this), loop);
};
f.add = function (t) {
@@ -3871,7 +3941,7 @@ function generateWait() {
// Store blob in memory
-var blob = {};
+const blob = {};
/**
* Get Object URL
@@ -3881,7 +3951,7 @@ var blob = {};
* @private
*/
function getObjectURL(fn, depsFn) {
- var fnString = fn.toString(),
+ const fnString = fn.toString(),
key = fnString.replace(/(function|[\s\W\n])/g, "").substring(0, 15);
if (!(key in blob)) {
var _depsFn$map$join;
@@ -3893,6 +3963,23 @@ function getObjectURL(fn, depsFn) {
return win.URL.createObjectURL(blob[key]);
}
+/**
+ * Get WebWorker instance
+ * @param {string} src URL object as string
+ * @returns {object} WebWorker instance
+ * @private
+ */
+function getWorker(src) {
+ const worker = new win.Worker(src);
+
+ // handle error
+ worker.onerror = function (e) {
+ // eslint-disable-next-line no-console
+ console.error ? console.error(e) : console.log(e);
+ };
+ return worker;
+}
+
/**
* Create and run on Web Worker
* @param {boolean} useWorker Use Web Worker
@@ -3920,10 +4007,13 @@ function runWorker(useWorker, fn, callback, depsFn) {
if (useWorker === void 0) {
useWorker = !0;
}
- var runFn;
+ let runFn = function () {
+ const res = fn.apply(void 0, arguments);
+ callback(res);
+ };
if (win.Worker && useWorker) {
- var src = getObjectURL(fn, depsFn),
- worker = new win.Worker(src);
+ const src = getObjectURL(fn, depsFn),
+ worker = getWorker(src);
runFn = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
@@ -3938,22 +4028,13 @@ function runWorker(useWorker, fn, callback, depsFn) {
return callback(e.data);
};
- // handle error
- worker.onerror = function (e) {
- console.error(e);
- };
-
// return new Promise((resolve, reject) => {
// worker.onmessage = ({data}) => resolve(data);
// worker.onerror = reject;
// });
};
- } else {
- runFn = function () {
- var res = fn.apply(void 0, arguments);
- callback(res);
- };
}
+
return runFn;
}
// EXTERNAL MODULE: external {"commonjs":"d3-dsv","commonjs2":"d3-dsv","amd":"d3-dsv","root":"d3"}
@@ -3981,9 +4062,9 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
* @private
*/
function columns(columns) {
- var newRows = [];
+ const newRows = [];
columns.forEach(function (col, i) {
- var key = col[0];
+ const key = col[0];
col.forEach(function (v, j) {
if (j > 0) {
if (typeof newRows[j - 1] === "undefined") {
@@ -4006,11 +4087,11 @@ function columns(columns) {
* @private
*/
function rows(rows) {
- var keys = rows[0],
+ const keys = rows[0],
newRows = [];
rows.forEach(function (row, i) {
if (i > 0) {
- var newRow = {};
+ const newRow = {};
row.forEach(function (v, j) {
if (typeof v === "undefined") {
throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
@@ -4030,17 +4111,17 @@ function rows(rows) {
* @private
*/
function json(json, keysParam) {
- var newRows = [];
- var targetKeys, data;
+ const newRows = [];
+ let targetKeys, data;
if (Array.isArray(json)) {
- var findValueInJson = function (object, path) {
+ const findValueInJson = function (object, path) {
if (object[path] !== undefined) {
return object[path];
}
- var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"),
+ const convertedPath = path.replace(/\[(\w+)\]/g, ".$1"),
pathArray = convertedPath.replace(/^\./, "").split("."); // convert indexes to properties (replace [] with .)
// strip a leading dot
- var target = object;
+ let target = object;
pathArray.some(function (k) {
return !(target = target && k in target ? target[k] : undefined);
});
@@ -4053,9 +4134,9 @@ function json(json, keysParam) {
}
newRows.push(targetKeys);
json.forEach(function (o) {
- var newRow = targetKeys.map(function (key) {
+ const newRow = targetKeys.map(function (key) {
// convert undefined to null because undefined data will be removed in convertDataToTargets()
- var v = findValueInJson(o, key);
+ let v = findValueInJson(o, key);
if (typeof v === "undefined") {
v = null;
}
@@ -4066,26 +4147,14 @@ function json(json, keysParam) {
data = rows(newRows);
} else {
Object.keys(json).forEach(function (key) {
- var tmp = json[key].concat();
- tmp.unshift == null ? void 0 : tmp.unshift(key);
+ const tmp = json[key].concat();
+ tmp.unshift == null || tmp.unshift(key);
newRows.push(tmp);
});
data = columns(newRows);
}
return data;
}
-function jsonTreemap(json) {
- var _this = this,
- _convertKey = function convertKey(v) {
- _newArrowCheck(this, _this);
- if (v.children) {
- v.children.forEach(_convertKey);
- }
- v.name = v.id;
- }.bind(this);
- json.forEach(_convertKey);
- return json;
-}
/***** Functions can't be executed on Web Worker *****/
/**
@@ -4101,7 +4170,7 @@ function url(url, mimeType, headers, keys, done) {
if (mimeType === void 0) {
mimeType = "csv";
}
- var req = new XMLHttpRequest(),
+ const req = new XMLHttpRequest(),
converter = {
csv: csv,
tsv: tsv,
@@ -4116,7 +4185,7 @@ function url(url, mimeType, headers, keys, done) {
req.onreadystatechange = function () {
if (req.readyState === 4) {
if (req.status === 200) {
- var response = req.responseText;
+ const response = req.responseText;
response && done.call(this, converter[mimeType](mimeType === "json" ? JSON.parse(response) : response, keys));
} else {
throw new Error(url + ": Something went wrong loading!");
@@ -4134,13 +4203,13 @@ function url(url, mimeType, headers, keys, done) {
* @private
*/
function convertCsvTsvToData(parser, xsv) {
- var _this2 = this,
- rows = parser.rows(xsv),
- d;
+ var _this = this;
+ const rows = parser.rows(xsv);
+ let d;
if (rows.length === 1) {
d = [{}];
rows[0].forEach(function (id) {
- _newArrowCheck(this, _this2);
+ _newArrowCheck(this, _this);
d[0][id] = null;
}.bind(this));
} else {
@@ -4177,7 +4246,7 @@ function tsv(tsv) {
* @private
*/
function getDataKeyForJson(keysParam, config) {
- var keys = keysParam || (config == null ? void 0 : config.data_keys);
+ const keys = keysParam || (config == null ? void 0 : config.data_keys);
if (keys != null && keys.x) {
config.data_x = keys.x;
}
@@ -4197,15 +4266,15 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
convertData: function convertData(args, callback) {
- var _this = this,
- config = this.config,
- useWorker = config.boost_useWorker,
- data = args;
+ var _this = this;
+ const config = this.config,
+ useWorker = config.boost_useWorker;
+ let data = args;
if (args.bindto) {
data = {};
["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"].forEach(function (v) {
_newArrowCheck(this, _this);
- var key = "data_" + v;
+ const key = "data_" + v;
if (key in args) {
data[v] = args[key];
}
@@ -4224,13 +4293,13 @@ function getDataKeyForJson(keysParam, config) {
}
},
convertDataToTargets: function convertDataToTargets(data, appendXs) {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
axis = $$.axis,
config = $$.config,
state = $$.state,
- chartType = config.data_type,
- isCategorized = !1,
+ chartType = config.data_type;
+ let isCategorized = !1,
isTimeSeries = !1,
isCustomX = !1;
if (axis) {
@@ -4238,16 +4307,16 @@ function getDataKeyForJson(keysParam, config) {
isTimeSeries = axis.isTimeSeries();
isCustomX = axis.isCustomX();
}
- var dataKeys = Object.keys(data[0] || {}),
+ const dataKeys = Object.keys(data[0] || {}),
ids = dataKeys.length ? dataKeys.filter($$.isNotX, $$) : [],
xs = dataKeys.length ? dataKeys.filter($$.isX, $$) : [];
- var xsData;
+ let xsData;
// save x for update data by load when custom x and bb.x API
ids.forEach(function (id) {
var _this3 = this;
_newArrowCheck(this, _this2);
- var xKey = this.getXKey(id);
+ const xKey = this.getXKey(id);
if (isCustomX || isTimeSeries) {
// if included in input data
if (xs.indexOf(xKey) >= 0) {
@@ -4284,10 +4353,10 @@ function getDataKeyForJson(keysParam, config) {
}.bind(this));
// convert to target
- var targets = ids.map(function (id, index) {
+ const targets = ids.map(function (id, index) {
var _this4 = this;
_newArrowCheck(this, _this2);
- var convertedId = config.data_idConverter.bind($$.api)(id),
+ const convertedId = config.data_idConverter.bind($$.api)(id),
xKey = $$.getXKey(id),
isCategory = isCustomX && isCategorized,
hasCategory = isCategory && data.map(function (v) {
@@ -4305,8 +4374,8 @@ function getDataKeyForJson(keysParam, config) {
id_org: id,
values: data.map(function (d, i) {
_newArrowCheck(this, _this4);
- var rawX = d[xKey];
- var value = d[id],
+ const rawX = d[xKey];
+ let value = d[id],
x;
value = value !== null && !isNaN(value) && !isObject(value) ? +value : isArray(value) || isObject(value) ? value : null;
@@ -4350,7 +4419,7 @@ function getDataKeyForJson(keysParam, config) {
if (config.data_xSort) {
t.values = t.values.sort(function (v1, v2) {
_newArrowCheck(this, _this5);
- var x1 = v1.x || v1.x === 0 ? v1.x : Infinity,
+ const x1 = v1.x || v1.x === 0 ? v1.x : Infinity,
x2 = v2.x || v2.x === 0 ? v2.x : Infinity;
return x1 - x2;
}.bind(this));
@@ -4363,7 +4432,7 @@ function getDataKeyForJson(keysParam, config) {
}.bind(this));
// this needs to be sorted because its index and value.index is identical
- (_$$$data$xs$t$id = $$.data.xs[t.id]) == null ? void 0 : _$$$data$xs$t$id.sort(function (v1, v2) {
+ (_$$$data$xs$t$id = $$.data.xs[t.id]) == null || _$$$data$xs$t$id.sort(function (v1, v2) {
_newArrowCheck(this, _this5);
return v1 - v2;
}.bind(this));
@@ -4375,7 +4444,7 @@ function getDataKeyForJson(keysParam, config) {
// set target types
if (chartType && $$.isValidChartType(chartType)) {
- var targetIds = $$.mapToIds(targets).filter(function (id) {
+ const targetIds = $$.mapToIds(targets).filter(function (id) {
_newArrowCheck(this, _this2);
return !(id in config.data_types) || !$$.isValidChartType(config.data_types[id]);
}.bind(this));
@@ -4399,9 +4468,10 @@ function getDataKeyForJson(keysParam, config) {
+
/* harmony default export */ var data_data = ({
isX: function isX(key) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
dataKey = config.data_x && key === config.data_x,
existValue = notEmpty(config.data_xs) && hasValue(config.data_xs, key);
@@ -4411,27 +4481,33 @@ function getDataKeyForJson(keysParam, config) {
return !this.isX(key);
},
isStackNormalized: function isStackNormalized() {
- var config = this.config;
+ const config = this.config;
return !!(config.data_stack_normalize && config.data_groups.length);
},
+ /**
+ * Check if given id is grouped data or has grouped data
+ * @param {string} id Data id value
+ * @returns {boolean} is grouped data or has grouped data
+ * @private
+ */
isGrouped: function isGrouped(id) {
- var _this = this,
- groups = this.config.data_groups;
+ var _this = this;
+ const groups = this.config.data_groups;
return id ? groups.some(function (v) {
_newArrowCheck(this, _this);
return v.indexOf(id) >= 0 && v.length > 1;
}.bind(this)) : groups.length > 0;
},
getXKey: function getXKey(id) {
- var $$ = this,
+ const $$ = this,
config = $$.config;
return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null;
},
getXValuesOfXKey: function getXValuesOfXKey(key, targets) {
- var _this2 = this,
- $$ = this,
- ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : [],
- xValues;
+ var _this2 = this;
+ const $$ = this,
+ ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : [];
+ let xValues;
ids.forEach(function (id) {
_newArrowCheck(this, _this2);
if ($$.getXKey(id) === key) {
@@ -4448,27 +4524,27 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
getIndexByX: function getIndexByX(x, basedX) {
- var $$ = this;
+ const $$ = this;
return basedX ? basedX.indexOf(isString(x) ? x : +x) : ($$.filterByX($$.data.targets, x)[0] || {
index: null
}).index;
},
getXValue: function getXValue(id, i) {
- var $$ = this;
+ const $$ = this;
return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i;
},
getOtherTargetXs: function getOtherTargetXs() {
- var $$ = this,
+ const $$ = this,
idsForX = Object.keys($$.data.xs);
return idsForX.length ? $$.data.xs[idsForX[0]] : null;
},
getOtherTargetX: function getOtherTargetX(index) {
- var xs = this.getOtherTargetXs();
+ const xs = this.getOtherTargetXs();
return xs && index < xs.length ? xs[index] : null;
},
addXs: function addXs(xs) {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
config = $$.config;
Object.keys(xs).forEach(function (id) {
_newArrowCheck(this, _this3);
@@ -4479,9 +4555,9 @@ function getDataKeyForJson(keysParam, config) {
return notEmpty(this.config.data_xs) || this.hasType("bubble") || this.hasType("scatter");
},
addName: function addName(data) {
- var $$ = this,
+ const $$ = this,
config = $$.config;
- var name;
+ let name;
if (data) {
name = config.data_names[data.id];
data.name = name !== undefined ? name : data.id;
@@ -4500,8 +4576,8 @@ function getDataKeyForJson(keysParam, config) {
if (filterNull === void 0) {
filterNull = !1;
}
- var $$ = this;
- var value = $$.filterTargetsToShow($$.data.targets).map(function (t) {
+ const $$ = this;
+ let value = $$.filterTargetsToShow($$.data.targets).map(function (t) {
_newArrowCheck(this, _this4);
return $$.addName($$.getValueOnIndex(t.values, index));
}.bind(this));
@@ -4514,16 +4590,16 @@ function getDataKeyForJson(keysParam, config) {
return value;
},
getValueOnIndex: function getValueOnIndex(values, index) {
- var _this5 = this,
- valueOnIndex = values.filter(function (v) {
- _newArrowCheck(this, _this5);
- return v.index === index;
- }.bind(this));
+ var _this5 = this;
+ const valueOnIndex = values.filter(function (v) {
+ _newArrowCheck(this, _this5);
+ return v.index === index;
+ }.bind(this));
return valueOnIndex.length ? valueOnIndex[0] : null;
},
updateTargetX: function updateTargetX(targets, x) {
- var _this6 = this,
- $$ = this;
+ var _this6 = this;
+ const $$ = this;
targets.forEach(function (t) {
var _this7 = this;
_newArrowCheck(this, _this6);
@@ -4535,19 +4611,19 @@ function getDataKeyForJson(keysParam, config) {
}.bind(this));
},
updateTargetXs: function updateTargetXs(targets, xs) {
- var _this8 = this,
- $$ = this;
+ var _this8 = this;
+ const $$ = this;
targets.forEach(function (t) {
_newArrowCheck(this, _this8);
xs[t.id] && $$.updateTargetX([t], xs[t.id]);
}.bind(this));
},
generateTargetX: function generateTargetX(rawX, id, index) {
- var $$ = this,
+ const $$ = this,
axis = $$.axis;
- var x = axis != null && axis.isCategorized() ? index : rawX || index;
+ let x = axis != null && axis.isCategorized() ? index : rawX || index;
if (axis != null && axis.isTimeSeries()) {
- var fn = parseDate.bind($$);
+ const fn = parseDate.bind($$);
x = rawX ? fn(rawX) : fn($$.getXValue(id, index));
} else if (axis != null && axis.isCustomX() && !(axis != null && axis.isCategorized())) {
x = isValue(rawX) ? +rawX : $$.getXValue(id, index);
@@ -4564,11 +4640,11 @@ function getDataKeyForJson(keysParam, config) {
}
},
getPrevX: function getPrevX(i) {
- var x = this.axis.xs[i - 1];
+ const x = this.axis.xs[i - 1];
return isDefined(x) ? x : null;
},
getNextX: function getNextX(i) {
- var x = this.axis.xs[i + 1];
+ const x = this.axis.xs[i + 1];
return isDefined(x) ? x : null;
},
/**
@@ -4578,9 +4654,9 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
getBaseValue: function getBaseValue(data) {
- var $$ = this,
+ const $$ = this,
hasAxis = $$.state.hasAxis;
- var value = data.value;
+ let value = data.value;
// In case of area-range, data is given as: [low, mid, high] or {low, mid, high}
// will take the 'mid' as the base value
@@ -4600,16 +4676,15 @@ function getDataKeyForJson(keysParam, config) {
* @returns {{min: {number}, max: {number}}}
*/
getMinMaxValue: function getMinMaxValue(data) {
- var _this10 = this,
- getBaseValue = this.getBaseValue.bind(this),
- min,
- max;
+ var _this10 = this;
+ const getBaseValue = this.getBaseValue.bind(this);
+ let min, max;
(data || this.data.targets.map(function (t) {
_newArrowCheck(this, _this10);
return t.values;
}.bind(this))).forEach(function (v, i) {
_newArrowCheck(this, _this10);
- var value = v.map(getBaseValue).filter(isNumber);
+ const value = v.map(getBaseValue).filter(isNumber);
min = Math.min.apply(Math, [i ? min : Infinity].concat(value));
max = Math.max.apply(Math, [i ? max : -Infinity].concat(value));
}.bind(this));
@@ -4624,21 +4699,21 @@ function getDataKeyForJson(keysParam, config) {
* @returns {{min: Array, max: Array}}
*/
getMinMaxData: function getMinMaxData() {
- var _this11 = this,
- $$ = this,
- cacheKey = KEY.dataMinMax,
- minMaxData = $$.cache.get(cacheKey);
+ var _this11 = this;
+ const $$ = this,
+ cacheKey = KEY.dataMinMax;
+ let minMaxData = $$.cache.get(cacheKey);
if (!minMaxData) {
- var data = $$.data.targets.map(function (t) {
+ const data = $$.data.targets.map(function (t) {
_newArrowCheck(this, _this11);
return t.values;
}.bind(this)),
minMax = $$.getMinMaxValue(data);
- var min = [],
+ let min = [],
max = [];
data.forEach(function (v) {
_newArrowCheck(this, _this11);
- var minData = $$.getFilteredDataByValue(v, minMax.min),
+ const minData = $$.getFilteredDataByValue(v, minMax.min),
maxData = $$.getFilteredDataByValue(v, minMax.max);
if (minData.length) {
min = min.concat(minData);
@@ -4662,10 +4737,10 @@ function getDataKeyForJson(keysParam, config) {
* @returns {Array}
*/
getTotalPerIndex: function getTotalPerIndex() {
- var _this12 = this,
- $$ = this,
- cacheKey = KEY.dataTotalPerIndex,
- sum = $$.cache.get(cacheKey);
+ var _this12 = this;
+ const $$ = this,
+ cacheKey = KEY.dataTotalPerIndex;
+ let sum = $$.cache.get(cacheKey);
if (($$.config.data_groups.length || $$.isStackNormalized()) && !sum) {
sum = [];
$$.data.targets.forEach(function (row) {
@@ -4689,12 +4764,12 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
getTotalDataSum: function getTotalDataSum(subtractHidden) {
- var _this14 = this,
- $$ = this,
- cacheKey = KEY.dataTotalSum,
- total = $$.cache.get(cacheKey);
+ var _this14 = this;
+ const $$ = this,
+ cacheKey = KEY.dataTotalSum;
+ let total = $$.cache.get(cacheKey);
if (!isNumber(total)) {
- var sum = mergeArray($$.data.targets.map(function (t) {
+ const sum = mergeArray($$.data.targets.map(function (t) {
_newArrowCheck(this, _this14);
return t.values;
}.bind(this))).map(function (v) {
@@ -4718,11 +4793,11 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
getHiddenTotalDataSum: function getHiddenTotalDataSum() {
- var _this15 = this,
- $$ = this,
+ var _this15 = this;
+ const $$ = this,
api = $$.api,
- hiddenTargetIds = $$.state.hiddenTargetIds,
- total = 0;
+ hiddenTargetIds = $$.state.hiddenTargetIds;
+ let total = 0;
if (hiddenTargetIds.length) {
total = api.data.values.bind(api)(hiddenTargetIds).reduce(function (p, c) {
_newArrowCheck(this, _this15);
@@ -4755,12 +4830,12 @@ function getDataKeyForJson(keysParam, config) {
return Math.max.apply(Math, this.data.targets.map(function (t) {
_newArrowCheck(this, _this17);
return t.values.length;
- }.bind(this)));
+ }.bind(this)).concat([0]));
},
getMaxDataCountTarget: function getMaxDataCountTarget() {
- var _this18 = this,
- target = this.filterTargetsToShow() || [],
- length = target.length,
+ var _this18 = this;
+ let target = this.filterTargetsToShow() || [];
+ const length = target.length,
isInverted = this.config.axis_x_inverted;
if (length > 1) {
target = target.map(function (t) {
@@ -4793,12 +4868,12 @@ function getDataKeyForJson(keysParam, config) {
}.bind(this));
},
mapToTargetIds: function mapToTargetIds(ids) {
- var $$ = this;
+ const $$ = this;
return ids ? isArray(ids) ? ids.concat() : [ids] : $$.mapToIds($$.data.targets);
},
hasTarget: function hasTarget(targets, id) {
- var ids = this.mapToIds(targets);
- for (var i = 0, val; val = ids[i]; i++) {
+ const ids = this.mapToIds(targets);
+ for (let i = 0, val; val = ids[i]; i++) {
if (val === id) {
return !0;
}
@@ -4812,18 +4887,18 @@ function getDataKeyForJson(keysParam, config) {
return this.state.hiddenLegendIds.indexOf(targetId) < 0;
},
filterTargetsToShow: function filterTargetsToShow(targets) {
- var _this20 = this,
- $$ = this;
+ var _this20 = this;
+ const $$ = this;
return (targets || $$.data.targets).filter(function (t) {
_newArrowCheck(this, _this20);
return $$.isTargetToShow(t.id);
}.bind(this));
},
mapTargetsToUniqueXs: function mapTargetsToUniqueXs(targets) {
- var _this21 = this,
- $$ = this,
- axis = $$.axis,
- xs = [];
+ var _this21 = this;
+ const $$ = this,
+ axis = $$.axis;
+ let xs = [];
if (targets != null && targets.length) {
xs = getUnique(mergeArray(targets.map(function (t) {
var _this22 = this;
@@ -4847,8 +4922,8 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
addTargetIds: function addTargetIds(type, targetIds) {
- var _this23 = this,
- state = this.state,
+ var _this23 = this;
+ const state = this.state,
ids = isArray(targetIds) ? targetIds : [targetIds];
ids.forEach(function (v) {
_newArrowCheck(this, _this23);
@@ -4862,12 +4937,12 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
removeTargetIds: function removeTargetIds(type, targetIds) {
- var _this24 = this,
- state = this.state,
+ var _this24 = this;
+ const state = this.state,
ids = isArray(targetIds) ? targetIds : [targetIds];
ids.forEach(function (v) {
_newArrowCheck(this, _this24);
- var index = state[type].indexOf(v);
+ const index = state[type].indexOf(v);
index >= 0 && state[type].splice(index, 1);
}.bind(this));
},
@@ -4884,8 +4959,8 @@ function getDataKeyForJson(keysParam, config) {
this.removeTargetIds("hiddenLegendIds", targetIds);
},
getValuesAsIdKeyed: function getValuesAsIdKeyed(targets) {
- var _this25 = this,
- $$ = this,
+ var _this25 = this;
+ const $$ = this,
hasAxis = $$.state.hasAxis,
ys = {},
isMultipleX = $$.isMultipleX(),
@@ -4896,14 +4971,14 @@ function getDataKeyForJson(keysParam, config) {
targets.forEach(function (t) {
var _this26 = this;
_newArrowCheck(this, _this25);
- var data = [];
+ const data = [];
t.values.filter(function (_ref) {
- var value = _ref.value;
+ let value = _ref.value;
_newArrowCheck(this, _this26);
return isValue(value) || value === null;
}.bind(this)).forEach(function (v) {
_newArrowCheck(this, _this26);
- var value = v.value;
+ let value = v.value;
// exclude 'volume' value to correct mis domain calculation
if (value !== null && $$.isCandlestickType(v)) {
@@ -4928,11 +5003,11 @@ function getDataKeyForJson(keysParam, config) {
return ys;
},
checkValueInTargets: function checkValueInTargets(targets, checker) {
- var ids = Object.keys(targets);
- var values;
- for (var i = 0; i < ids.length; i++) {
+ const ids = Object.keys(targets);
+ let values;
+ for (let i = 0; i < ids.length; i++) {
values = targets[ids[i]].values;
- for (var j = 0; j < values.length; j++) {
+ for (let j = 0; j < values.length; j++) {
if (checker(values[j].value)) {
return !0;
}
@@ -4965,7 +5040,7 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
orderTargets: function orderTargets(targetsValue) {
- var $$ = this,
+ const $$ = this,
targets = [].concat(targetsValue),
fn = $$.getSortCompareFn();
fn && targets.sort(fn);
@@ -4982,20 +5057,20 @@ function getDataKeyForJson(keysParam, config) {
if (isReversed === void 0) {
isReversed = !1;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
order = config.data_order,
orderAsc = /asc/i.test(order),
orderDesc = /desc/i.test(order);
- var fn;
+ let fn;
if (orderAsc || orderDesc) {
- var reducer = function (p, c) {
+ const reducer = function (p, c) {
_newArrowCheck(this, _this29);
return p + Math.abs(c.value);
}.bind(this);
fn = function (t1, t2) {
_newArrowCheck(this, _this29);
- var t1Sum = "values" in t1 ? t1.values.reduce(reducer, 0) : t1.value,
+ const t1Sum = "values" in t1 ? t1.values.reduce(reducer, 0) : t1.value,
t2Sum = "values" in t2 ? t2.values.reduce(reducer, 0) : t2.value;
return isReversed ? orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum : orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum;
}.bind(this);
@@ -5037,7 +5112,7 @@ function getDataKeyForJson(keysParam, config) {
}.bind(this));
},
hasDataLabel: function hasDataLabel() {
- var dataLabels = this.config.data_labels;
+ const dataLabels = this.config.data_labels;
return isboolean(dataLabels) && dataLabels || isObjectType(dataLabels) && notEmpty(dataLabels);
},
/**
@@ -5046,24 +5121,34 @@ function getDataKeyForJson(keysParam, config) {
* @returns {number}
*/
getDataIndexFromEvent: function getDataIndexFromEvent(event) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
_$$$state = $$.state,
+ hasRadar = _$$$state.hasRadar,
inputType = _$$$state.inputType,
_$$$state$eventReceiv = _$$$state.eventReceiver,
coords = _$$$state$eventReceiv.coords,
- rect = _$$$state$eventReceiv.rect,
- isRotated = config.axis_rotated,
- e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event,
+ rect = _$$$state$eventReceiv.rect;
+ let index;
+ if (hasRadar) {
+ let target = event.target;
+
+ // in case of multilined axis text
+ if (/tspan/i.test(target.tagName)) {
+ target = target.parentNode;
+ }
+ const d = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
+ index = d && Object.keys(d).length === 1 ? d.index : undefined;
+ } else {
+ const isRotated = config.axis_rotated,
+ e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event; // get data based on the mouse coords
index = findIndex(coords, isRotated ? e.clientY - rect.top : e.clientX - rect.left, 0, coords.length - 1, isRotated);
-
- // get data based on the mouse coords
-
+ }
return index;
},
getDataLabelLength: function getDataLabelLength(min, max, key) {
- var _this34 = this,
- $$ = this,
+ var _this34 = this;
+ const $$ = this,
lengths = [0, 0];
$$.$el.chart.select("svg").selectAll(".dummy").data([min, max]).enter().append("text").text(function (d) {
_newArrowCheck(this, _this34);
@@ -5080,9 +5165,9 @@ function getDataKeyForJson(keysParam, config) {
return "data" in d && this.hasTarget(this.data.targets, d.data.id);
},
findSameXOfValues: function findSameXOfValues(values, index) {
- var targetX = values[index].x,
+ const targetX = values[index].x,
sames = [];
- var i;
+ let i;
for (i = index - 1; i >= 0; i--) {
if (targetX !== values[i].x) {
break;
@@ -5098,8 +5183,8 @@ function getDataKeyForJson(keysParam, config) {
return sames;
},
findClosestFromTargets: function findClosestFromTargets(targets, pos) {
- var _this35 = this,
- $$ = this,
+ var _this35 = this;
+ const $$ = this,
candidates = targets.map(function (target) {
_newArrowCheck(this, _this35);
return $$.findClosest(target.values, pos);
@@ -5109,26 +5194,14 @@ function getDataKeyForJson(keysParam, config) {
return $$.findClosest(candidates, pos);
},
findClosest: function findClosest(values, pos) {
- var _this36 = this,
- $$ = this,
- config = $$.config,
+ var _this36 = this;
+ const $$ = this,
main = $$.$el.main,
data = values.filter(function (v) {
_newArrowCheck(this, _this36);
return v && isValue(v.value);
- }.bind(this)),
- getSensitivity = function (d) {
- _newArrowCheck(this, _this36);
- var sensitivity = config.point_sensitivity;
- if (isFunction(sensitivity)) {
- sensitivity = sensitivity.call($$.api, d);
- } else if (sensitivity === "radius") {
- sensitivity = d.r;
- }
- return sensitivity;
- }.bind(this),
- minDist,
- closest;
+ }.bind(this));
+ let minDist, closest;
// find mouseovering bar/candlestick
// https://github.com/naver/billboard.js/issues/2434
data.filter(function (v) {
@@ -5136,7 +5209,7 @@ function getDataKeyForJson(keysParam, config) {
return $$.isBarType(v.id) || $$.isCandlestickType(v.id);
}.bind(this)).forEach(function (v) {
_newArrowCheck(this, _this36);
- var selector = $$.isBarType(v.id) ? "." + $BAR.chartBar + "." + $COMMON.target + $$.getTargetSelectorSuffix(v.id) + " ." + $BAR.bar + "-" + v.index : "." + $CANDLESTICK.chartCandlestick + "." + $COMMON.target + $$.getTargetSelectorSuffix(v.id) + " ." + $CANDLESTICK.candlestick + "-" + v.index + " path";
+ const selector = $$.isBarType(v.id) ? "." + $BAR.chartBar + "." + $COMMON.target + $$.getTargetSelectorSuffix(v.id) + " ." + $BAR.bar + "-" + v.index : "." + $CANDLESTICK.chartCandlestick + "." + $COMMON.target + $$.getTargetSelectorSuffix(v.id) + " ." + $CANDLESTICK.candlestick + "-" + v.index + " path";
if (!closest && $$.isWithinBar(main.select(selector).node())) {
closest = v;
}
@@ -5148,8 +5221,8 @@ function getDataKeyForJson(keysParam, config) {
return !$$.isBarType(v.id) && !$$.isCandlestickType(v.id);
}.bind(this)).forEach(function (v) {
_newArrowCheck(this, _this36);
- var d = $$.dist(v, pos);
- minDist = getSensitivity(v);
+ const d = $$.dist(v, pos);
+ minDist = $$.getPointSensitivity(v);
if (d < minDist) {
minDist = d;
closest = v;
@@ -5158,7 +5231,7 @@ function getDataKeyForJson(keysParam, config) {
return closest;
},
dist: function dist(data, pos) {
- var $$ = this,
+ const $$ = this,
isRotated = $$.config.axis_rotated,
scale = $$.scale,
y = $$.circleY(data, data.index),
@@ -5176,7 +5249,7 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
convertValuesToStep: function convertValuesToStep(values) {
- var $$ = this,
+ const $$ = this,
axis = $$.axis,
config = $$.config,
stepType = config.line_step_type,
@@ -5190,10 +5263,10 @@ function getDataKeyForJson(keysParam, config) {
// https://github.com/naver/billboard.js/issues/3124
if (converted.length) {
// insert & append cloning first/last value to be fully rendered covering on each gap sides
- var head = converted[0],
+ const head = converted[0],
tail = converted[converted.length - 1],
id = head.id;
- var x = head.x;
+ let x = head.x;
// insert head
converted.unshift({
@@ -5223,12 +5296,12 @@ function getDataKeyForJson(keysParam, config) {
return converted;
},
convertValuesToRange: function convertValuesToRange(values) {
- var _this37 = this,
- converted = isArray(values) ? values.concat() : [values],
+ var _this37 = this;
+ const converted = isArray(values) ? values.concat() : [values],
ranges = [];
converted.forEach(function (range) {
_newArrowCheck(this, _this37);
- var x = range.x,
+ const x = range.x,
id = range.id;
ranges.push({
x: x,
@@ -5244,8 +5317,8 @@ function getDataKeyForJson(keysParam, config) {
return ranges;
},
updateDataAttributes: function updateDataAttributes(name, attrs) {
- var _this38 = this,
- $$ = this,
+ var _this38 = this;
+ const $$ = this,
config = $$.config,
current = config["data_" + name];
if (isUndefined(attrs)) {
@@ -5261,21 +5334,29 @@ function getDataKeyForJson(keysParam, config) {
return current;
},
getRangedData: function getRangedData(d, key, type) {
+ var _this39 = this;
if (key === void 0) {
key = "";
}
if (type === void 0) {
type = "areaRange";
}
- var value = d == null ? void 0 : d.value;
+ const value = d == null ? void 0 : d.value;
if (isArray(value)) {
- // @ts-ignore
- var index = {
- areaRange: ["high", "mid", "low"],
- candlestick: ["open", "high", "low", "close", "volume"]
- }[type].indexOf(key);
- return index >= 0 && value ? value[index] : undefined;
- } else if (value) {
+ if (type === "bar") {
+ return value.reduce(function (a, c) {
+ _newArrowCheck(this, _this39);
+ return c - a;
+ }.bind(this));
+ } else {
+ // @ts-ignore
+ const index = {
+ areaRange: ["high", "mid", "low"],
+ candlestick: ["open", "high", "low", "close", "volume"]
+ }[type].indexOf(key);
+ return index >= 0 && value ? value[index] : undefined;
+ }
+ } else if (value && key) {
return value[key];
}
return value;
@@ -5286,20 +5367,20 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
setRatioForGroupedData: function setRatioForGroupedData(data) {
- var _this39 = this,
- $$ = this,
+ var _this40 = this;
+ const $$ = this,
config = $$.config;
// calculate ratio if grouped data exists
if (config.data_groups.length && data.some(function (d) {
- _newArrowCheck(this, _this39);
+ _newArrowCheck(this, _this40);
return $$.isGrouped(d.id);
}.bind(this))) {
- var setter = function (d) {
- _newArrowCheck(this, _this39);
+ const setter = function (d) {
+ _newArrowCheck(this, _this40);
return $$.getRatio("index", d, !0);
}.bind(this);
data.forEach(function (v) {
- _newArrowCheck(this, _this39);
+ _newArrowCheck(this, _this40);
"values" in v ? v.values.forEach(setter) : setter(v);
}.bind(this));
}
@@ -5313,15 +5394,15 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
getRatio: function getRatio(type, d, asPercent) {
- var _this40 = this;
+ var _this41 = this;
if (asPercent === void 0) {
asPercent = !1;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
api = $$.api;
- var ratio = 0;
+ let ratio = 0;
if (d && api.data.shown().length) {
ratio = d.ratio || d.value;
if (type === "arc") {
@@ -5331,43 +5412,43 @@ function getDataKeyForJson(keysParam, config) {
// otherwise, based on the rendered angle value
} else {
- var gaugeArcLength = config.gauge_fullCircle ? $$.getArcLength() : $$.getGaugeStartAngle() * -2,
+ const gaugeArcLength = config.gauge_fullCircle ? $$.getArcLength() : $$.getGaugeStartAngle() * -2,
arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
ratio = (d.endAngle - d.startAngle) / arcLength;
}
} else if (type === "index") {
- var dataValues = api.data.values.bind(api);
- var total = this.getTotalPerIndex();
+ const dataValues = api.data.values.bind(api);
+ let total = this.getTotalPerIndex();
if (state.hiddenTargetIds.length) {
- var hiddenSum = dataValues(state.hiddenTargetIds, !1);
+ let hiddenSum = dataValues(state.hiddenTargetIds, !1);
if (hiddenSum.length) {
hiddenSum = hiddenSum.reduce(function (acc, curr) {
- var _this41 = this;
- _newArrowCheck(this, _this40);
+ var _this42 = this;
+ _newArrowCheck(this, _this41);
return acc.map(function (v, i) {
- _newArrowCheck(this, _this41);
+ _newArrowCheck(this, _this42);
return (isNumber(v) ? v : 0) + curr[i];
}.bind(this));
}.bind(this));
total = total.map(function (v, i) {
- _newArrowCheck(this, _this40);
+ _newArrowCheck(this, _this41);
return v - hiddenSum[i];
}.bind(this));
}
}
- var divisor = total[d.index];
+ const divisor = total[d.index];
d.ratio = isNumber(d.value) && total && divisor ? d.value / divisor : 0;
ratio = d.ratio;
} else if (type === "radar") {
ratio = parseFloat(Math.max(d.value, 0) + "") / state.current.dataMax * config.radar_size_ratio;
} else if (type === "bar") {
- var yScale = $$.getYScaleById.bind($$)(d.id),
+ const yScale = $$.getYScaleById.bind($$)(d.id),
max = yScale.domain().reduce(function (a, c) {
- _newArrowCheck(this, _this40);
+ _newArrowCheck(this, _this41);
return c - a;
}.bind(this));
// when all data are 0, return 0
- ratio = max === 0 ? 0 : Math.abs(d.value) / max;
+ ratio = max === 0 ? 0 : Math.abs($$.getRangedData(d, null, type) / max);
} else if (type === "treemap") {
ratio /= $$.getTotalDataSum(!0);
}
@@ -5380,19 +5461,19 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
updateDataIndexByX: function updateDataIndexByX(tickValues) {
- var _this42 = this,
- $$ = this,
+ var _this43 = this;
+ const $$ = this,
tickValueMap = tickValues.reduce(function (out, tick, index) {
- _newArrowCheck(this, _this42);
+ _newArrowCheck(this, _this43);
out[+tick.x] = index;
return out;
}.bind(this), {});
$$.data.targets.forEach(function (t) {
- var _this43 = this;
- _newArrowCheck(this, _this42);
+ var _this44 = this;
+ _newArrowCheck(this, _this43);
t.values.forEach(function (value, valueIndex) {
- _newArrowCheck(this, _this43);
- var index = tickValueMap[+value.x];
+ _newArrowCheck(this, _this44);
+ let index = tickValueMap[+value.x];
if (index === undefined) {
index = valueIndex;
}
@@ -5407,7 +5488,7 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
isBubbleZType: function isBubbleZType(d) {
- var $$ = this;
+ const $$ = this;
return $$.isBubbleType(d) && (isObject(d.value) && ("z" in d.value || "y" in d.value) || isArray(d.value) && d.value.length >= 2);
},
/**
@@ -5417,11 +5498,11 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
isBarRangeType: function isBarRangeType(d) {
- var _this44 = this,
- $$ = this,
+ var _this45 = this;
+ const $$ = this,
value = d.value;
return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every(function (v) {
- _newArrowCheck(this, _this44);
+ _newArrowCheck(this, _this45);
return isNumber(v);
}.bind(this));
},
@@ -5432,8 +5513,8 @@ function getDataKeyForJson(keysParam, config) {
* @private
*/
getDataById: function getDataById(id) {
- var _d$,
- d = this.cache.get(id) || this.api.data(id);
+ var _d$;
+ const d = this.cache.get(id) || this.api.data(id);
return (_d$ = d == null ? void 0 : d[0]) != null ? _d$ : d;
}
});
@@ -5456,18 +5537,18 @@ function callDone(fn, resizeAfter) {
if (resizeAfter === void 0) {
resizeAfter = !1;
}
- var $$ = this,
+ const $$ = this,
api = $$.api;
resizeAfter && $$.api.flush(!0);
- fn == null ? void 0 : fn.call(api);
+ fn == null || fn.call(api);
}
/* harmony default export */ var load = ({
load: function load(rawTargets, args) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
data = $$.data,
- append = args.append,
- targets = rawTargets;
+ append = args.append;
+ let targets = rawTargets;
if (targets) {
// filter loading targets if needed
if (args.filter) {
@@ -5479,7 +5560,7 @@ function callDone(fn, resizeAfter) {
targets.forEach(function (t) {
var _args$types;
_newArrowCheck(this, _this);
- var type = ((_args$types = args.types) == null ? void 0 : _args$types[t.id]) || args.type;
+ const type = ((_args$types = args.types) == null ? void 0 : _args$types[t.id]) || args.type;
$$.setTargetType(t.id, type);
}.bind(this));
}
@@ -5487,7 +5568,7 @@ function callDone(fn, resizeAfter) {
// Update/Add data
data.targets.forEach(function (d) {
_newArrowCheck(this, _this);
- for (var i = 0; i < targets.length; i++) {
+ for (let i = 0; i < targets.length; i++) {
if (d.id === targets[i].id) {
d.values = append ? d.values.concat(targets[i].values) : targets[i].values;
targets.splice(i, 1);
@@ -5513,8 +5594,9 @@ function callDone(fn, resizeAfter) {
callDone.call($$, args.done, args.resizeAfter);
},
loadFromArgs: function loadFromArgs(args) {
- var _this2 = this,
- $$ = this;
+ var _this2 = this;
+ const $$ = this;
+
// prevent load when chart is already destroyed
if (!$$.config) {
return;
@@ -5524,18 +5606,18 @@ function callDone(fn, resizeAfter) {
$$.cache.reset();
$$.convertData(args, function (d) {
_newArrowCheck(this, _this2);
- var data = args.data || d;
+ const data = args.data || d;
args.append && (data.__append__ = !0);
data && $$.load($$.convertDataToTargets(data), args);
}.bind(this));
},
unload: function unload(rawTargetIds, customDoneCb) {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
state = $$.state,
$el = $$.$el,
- $T = $$.$T,
- done = customDoneCb,
+ $T = $$.$T;
+ let done = customDoneCb,
targetIds = rawTargetIds;
// reset internally cached data
$$.cache.reset();
@@ -5556,7 +5638,7 @@ function callDone(fn, resizeAfter) {
done();
return;
}
- var targets = $el.svg.selectAll(targetIds.map(function (id) {
+ const targets = $el.svg.selectAll(targetIds.map(function (id) {
_newArrowCheck(this, _this3);
return $$.selectorTarget(id);
}.bind(this)));
@@ -5600,54 +5682,6 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
/* harmony default export */ var interactions_interaction = ({
- selectRectForSingle: function selectRectForSingle(context, eventRect, index) {
- var _this = this,
- $$ = this,
- config = $$.config,
- _$$$$el = $$.$el,
- main = _$$$$el.main,
- circle = _$$$$el.circle,
- isSelectionEnabled = config.data_selection_enabled,
- isSelectionGrouped = config.data_selection_grouped,
- isSelectable = config.data_selection_isselectable,
- isTooltipGrouped = config.tooltip_grouped,
- selectedData = $$.getAllValuesOnIndex(index);
- if (isTooltipGrouped) {
- $$.showTooltip(selectedData, context);
- $$.showGridFocus == null ? void 0 : $$.showGridFocus(selectedData);
- if (!isSelectionEnabled || isSelectionGrouped) {
- return;
- }
- }
-
- // remove possible previous focused state
- circle || main.selectAll("." + $COMMON.EXPANDED + ":not(." + $SHAPE.shape + "-" + index + ")").classed($COMMON.EXPANDED, !1);
- var shapeAtIndex = main.selectAll("." + $SHAPE.shape + "-" + index).classed($COMMON.EXPANDED, !0).style("cursor", isSelectable ? "pointer" : null).filter(function (d) {
- return $$.isWithinShape(this, d);
- });
- if (shapeAtIndex.empty() && !isTooltipGrouped) {
- $$.hideGridFocus == null ? void 0 : $$.hideGridFocus();
- $$.hideTooltip();
- isSelectionGrouped || $$.setExpand(index);
- }
- shapeAtIndex.call(function (selected) {
- var _this2 = this;
- _newArrowCheck(this, _this);
- var d = selected.data();
- if (isSelectionEnabled && (isSelectionGrouped || isSelectable != null && isSelectable.bind($$.api)(d))) {
- eventRect.style("cursor", "pointer");
- }
- if (!isTooltipGrouped) {
- $$.showTooltip(d, context);
- $$.showGridFocus == null ? void 0 : $$.showGridFocus(d);
- $$.unexpandCircles == null ? void 0 : $$.unexpandCircles();
- selected.each(function (d) {
- _newArrowCheck(this, _this2);
- return $$.setExpand(index, d.id);
- }.bind(this));
- }
- }.bind(this));
- },
/**
* Expand data shape/point
* @param {number} index Index number
@@ -5656,7 +5690,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @private
*/
setExpand: function setExpand(index, id, reset) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
circle = $$.$el.circle;
circle && config.point_focus_expand_enabled && $$.expandCircles(index, id, reset);
@@ -5673,16 +5707,16 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @private
*/
expandBarTypeShapes: function expandBarTypeShapes(expand, i, id, reset) {
- var _this3 = this;
+ var _this = this;
if (expand === void 0) {
expand = !0;
}
- var $$ = this;
+ const $$ = this;
["bar", "candlestick"].filter(function (v) {
- _newArrowCheck(this, _this3);
+ _newArrowCheck(this, _this);
return $$.$el[v];
}.bind(this)).forEach(function (v) {
- _newArrowCheck(this, _this3);
+ _newArrowCheck(this, _this);
reset && $$.$el[v].classed($COMMON.EXPANDED, !1);
$$.getShapeByIndex(v, i, id).classed($COMMON.EXPANDED, expand);
}.bind(this));
@@ -5694,8 +5728,8 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @private
*/
setOverOut: function setOverOut(isOver, d) {
- var _this5 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
config = $$.config,
_$$$state = $$.state,
hasRadar = _$$$state.hasRadar,
@@ -5704,31 +5738,31 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
isArcTreemap = isObject(d);
// Call event handler
if (isArcTreemap || d !== -1) {
- var callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
+ const callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
config.color_onover && $$.setOverColor(isOver, d, isArcTreemap);
if (isArcTreemap && "id") {
- var selector = hasTreemap ? $TREEMAP.treemap : $ARC.arc;
+ const selector = hasTreemap ? $TREEMAP.treemap : $ARC.arc;
callback(d, main.select("." + selector + $$.getTargetSelectorSuffix(d.id)).node());
} else if (!config.tooltip_grouped) {
- var last = $$.cache.get(KEY.setOverOut) || [],
+ const last = $$.cache.get(KEY.setOverOut) || [],
shapesAtIndex = main.selectAll("." + $SHAPE.shape + "-" + d).filter(function (d) {
return $$.isWithinShape(this, d);
}),
shape = shapesAtIndex.filter(function () {
- var _this4 = this;
+ var _this2 = this;
return last.every(function (v) {
- _newArrowCheck(this, _this4);
+ _newArrowCheck(this, _this2);
return v !== this;
}.bind(this));
}); // select based on the index
// filter if has new selection
// call onout callback
if (!isOver || shapesAtIndex.empty() || last.length === shape.size() && shape.nodes().every(function (v, i) {
- _newArrowCheck(this, _this5);
+ _newArrowCheck(this, _this3);
return v !== last[i];
}.bind(this))) {
while (last.length) {
- var target = last.pop();
+ const target = last.pop();
config.data_onout.bind($$.api)((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum(), target);
}
}
@@ -5743,7 +5777,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
$$.cache.add(KEY.setOverOut, last);
} else {
if (isOver) {
- config.point_focus_only && hasRadar ? $$.showCircleFocus($$.getAllValuesOnIndex(d, !0)) : $$.setExpand(d, null, !0);
+ hasRadar && $$.isPointFocusOnly() ? $$.showCircleFocus($$.getAllValuesOnIndex(d, !0)) : $$.setExpand(d, null, !0);
}
$$.isMultipleX() || main.selectAll("." + $SHAPE.shape + "-" + d).each(function (d) {
callback(d, this);
@@ -5757,7 +5791,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @private
*/
callOverOutForTouch: function callOverOutForTouch(d) {
- var $$ = this,
+ const $$ = this,
last = $$.cache.get(KEY.callOverOutForTouch);
if (isObject(d) && last ? d.id !== last.id : d !== last) {
(last || isNumber(last)) && $$.setOverOut(!1, last);
@@ -5771,8 +5805,8 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @private
*/
getDraggableSelection: function getDraggableSelection() {
- var _this6 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
config = $$.config,
state = $$.state;
return config.interaction_enabled && config.data_selection_draggable && $$.drag ? (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().on("drag", function (event) {
@@ -5782,11 +5816,11 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
state.event = event;
$$.dragstart(getPointer(event, this));
}).on("end", function (event) {
- _newArrowCheck(this, _this6);
+ _newArrowCheck(this, _this4);
state.event = event;
$$.dragend();
}.bind(this)) : function () {
- _newArrowCheck(this, _this6);
+ _newArrowCheck(this, _this4);
}.bind(this);
},
/**
@@ -5797,38 +5831,40 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @param {Array} mouse x and y coordinate value
*/
dispatchEvent: function dispatchEvent(type, index, mouse) {
- var _ref,
- _this7 = this,
- $$ = this,
+ var _ref;
+ const $$ = this,
config = $$.config,
_$$$state2 = $$.state,
eventReceiver = _$$$state2.eventReceiver,
hasAxis = _$$$state2.hasAxis,
hasRadar = _$$$state2.hasRadar,
hasTreemap = _$$$state2.hasTreemap,
- _$$$$el2 = $$.$el,
- eventRect = _$$$$el2.eventRect,
- arcs = _$$$$el2.arcs,
- radar = _$$$$el2.radar,
- treemap = _$$$$el2.treemap,
- element = (_ref = hasTreemap && eventReceiver.rect || hasRadar && radar.axes.select("." + $AXIS.axis + "-" + index + " text") || eventRect || (arcs == null ? void 0 : arcs.selectAll("." + $COMMON.target + " path").filter(function (d, i) {
- _newArrowCheck(this, _this7);
- return i === index;
- }.bind(this)))) == null ? void 0 : _ref.node();
+ _$$$$el = $$.$el,
+ eventRect = _$$$$el.eventRect,
+ radar = _$$$$el.radar,
+ treemap = _$$$$el.treemap,
+ element = (_ref = hasTreemap && eventReceiver.rect || hasRadar && radar.axes.select("." + $AXIS.axis + "-" + index + " text") || eventRect || ($$.getArcElementByIdOrIndex == null ? void 0 : $$.getArcElementByIdOrIndex(index))) == null ? void 0 : _ref.node();
if (element) {
- var isMultipleX = $$.isMultipleX();
- var _element$getBoundingC = element.getBoundingClientRect(),
+ const isMultipleX = $$.isMultipleX(),
+ isRotated = config.axis_rotated;
+ let _element$getBoundingC = element.getBoundingClientRect(),
width = _element$getBoundingC.width,
left = _element$getBoundingC.left,
top = _element$getBoundingC.top;
if (hasAxis && !hasRadar && !isMultipleX) {
- var coords = eventReceiver.coords[index];
- width = coords.w;
- left += coords.x;
- top += coords.y;
+ const coords = eventReceiver.coords[index];
+ if (coords) {
+ width = coords.w;
+ left += coords.x;
+ top += coords.y;
+ } else {
+ width = 0;
+ left = 0;
+ top = 0;
+ }
}
- var x = left + (mouse ? mouse[0] : 0) + (isMultipleX || config.axis_rotated ? 0 : width / 2),
- y = top + (mouse ? mouse[1] : 0);
+ const x = left + (mouse ? mouse[0] : 0) + (isMultipleX || isRotated ? 0 : width / 2),
+ y = top + (mouse ? mouse[1] : 0) + (isRotated ? 4 : 0); // value 4, is to adjust coordinate value set from: scale.ts - updateScales(): $$.getResettedPadding(1)
emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](hasTreemap ? treemap.node() : element, type, {
screenX: x,
screenY: y,
@@ -5845,34 +5881,34 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @private
*/
unbindZoomEvent: function unbindZoomEvent() {
- var $$ = this,
- _$$$$el3 = $$.$el,
- eventRect = _$$$$el3.eventRect,
- zoomResetBtn = _$$$$el3.zoomResetBtn;
- eventRect == null ? void 0 : eventRect.on(".zoom wheel.zoom .drag", null);
- zoomResetBtn == null ? void 0 : zoomResetBtn.on("click", null).style("display", "none");
+ const $$ = this,
+ _$$$$el2 = $$.$el,
+ eventRect = _$$$$el2.eventRect,
+ zoomResetBtn = _$$$$el2.zoomResetBtn;
+ eventRect == null || eventRect.on(".zoom wheel.zoom .drag", null);
+ zoomResetBtn == null || zoomResetBtn.on("click", null).style("display", "none");
},
/**
* Unbind all attached events
* @private
*/
unbindAllEvents: function unbindAllEvents() {
- var _this8 = this,
- $$ = this,
- _$$$$el4 = $$.$el,
- arcs = _$$$$el4.arcs,
- eventRect = _$$$$el4.eventRect,
- legend = _$$$$el4.legend,
- region = _$$$$el4.region,
- svg = _$$$$el4.svg,
- treemap = _$$$$el4.treemap,
+ var _this5 = this;
+ const $$ = this,
+ _$$$$el3 = $$.$el,
+ arcs = _$$$$el3.arcs,
+ eventRect = _$$$$el3.eventRect,
+ legend = _$$$$el3.legend,
+ region = _$$$$el3.region,
+ svg = _$$$$el3.svg,
+ treemap = _$$$$el3.treemap,
brush = $$.brush;
// detach all possible event types
[svg, eventRect, region == null ? void 0 : region.list, brush == null ? void 0 : brush.getSelection(), arcs == null ? void 0 : arcs.selectAll("path"), legend == null ? void 0 : legend.selectAll("g"), treemap].forEach(function (v) {
- _newArrowCheck(this, _this8);
+ _newArrowCheck(this, _this5);
return v == null ? void 0 : v.on("wheel click mouseover mousemove mouseout touchstart touchmove touchend touchstart.eventRect touchmove.eventRect touchend.eventRect .brush .drag .zoom wheel.zoom dblclick.zoom", null);
}.bind(this));
- $$.unbindZoomEvent == null ? void 0 : $$.unbindZoomEvent();
+ $$.unbindZoomEvent == null || $$.unbindZoomEvent();
}
});
;// CONCATENATED MODULE: ./src/ChartInternal/internals/class.ts
@@ -5894,13 +5930,13 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @private
*/
getClass: function getClass(type, withShape) {
- var _this = this,
- isPlural = /s$/.test(type),
+ var _this = this;
+ const isPlural = /s$/.test(type),
useIdKey = /^(area|arc|line|treemap)s?$/.test(type),
key = isPlural ? "id" : "index";
return function (d) {
_newArrowCheck(this, _this);
- var data = d.data || d,
+ const data = d.data || d,
result = (withShape ? this.generateClass(classes[isPlural ? "shapes" : "shape"], data[key]) : "") + this.generateClass(classes[type], data[useIdKey ? "id" : key]);
return result.trim();
}.bind(this);
@@ -5919,12 +5955,12 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
}.bind(this);
},
generateExtraLineClass: function generateExtraLineClass() {
- var $$ = this,
+ const $$ = this,
classes = $$.config.line_classes || [],
ids = [];
return function (d) {
- var _d$data,
- id = d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d;
+ var _d$data;
+ const id = d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d;
if (ids.indexOf(id) < 0) {
ids.push(id);
}
@@ -5935,8 +5971,8 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
return this.generateClass(classes.region, i) + " " + ("class" in d ? d.class : "");
},
classTarget: function classTarget(id) {
- var additionalClassSuffix = this.config.data_classes[id];
- var additionalClass = "";
+ const additionalClassSuffix = this.config.data_classes[id];
+ let additionalClass = "";
if (additionalClassSuffix) {
additionalClass = " " + classes.target + "-" + additionalClassSuffix;
}
@@ -5952,7 +5988,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
return " " + (this.state.defocusedTargetIds.indexOf(d.id) >= 0 ? classes.defocused : "");
},
getTargetSelectorSuffix: function getTargetSelectorSuffix(targetId) {
- var targetStr = targetId || targetId === 0 ? "-" + targetId : "";
+ const targetStr = targetId || targetId === 0 ? "-" + targetId : "";
return targetStr.replace(/([\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\])/g, "-");
},
selectorTarget: function selectorTarget(id, prefix, postfix) {
@@ -5962,14 +5998,14 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
if (postfix === void 0) {
postfix = "";
}
- var target = this.getTargetSelectorSuffix(id);
+ const target = this.getTargetSelectorSuffix(id);
// select target & circle
return prefix + "." + (classes.target + target) + " " + postfix + ", " + prefix + "." + (classes.circles + target) + " " + postfix;
},
selectorTargets: function selectorTargets(idsValue, prefix) {
- var _this3 = this,
- ids = idsValue || [];
+ var _this3 = this;
+ const ids = idsValue || [];
return ids.length ? ids.map(function (id) {
_newArrowCheck(this, _this3);
return this.selectorTarget(id, prefix);
@@ -5999,8 +6035,9 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
* @private
*/
categoryName: function categoryName(i) {
- var categories = this.config.axis_x_categories;
- return i < (categories == null ? void 0 : categories.length) ? categories[i] : i;
+ var _axis_x_categories$i;
+ const axis_x_categories = this.config.axis_x_categories;
+ return (_axis_x_categories$i = axis_x_categories == null ? void 0 : axis_x_categories[i]) != null ? _axis_x_categories$i : i;
}
});
// EXTERNAL MODULE: external {"commonjs":"d3-scale","commonjs2":"d3-scale","amd":"d3-scale","root":"d3"}
@@ -6027,9 +6064,9 @@ var color_this = undefined;
* @returns {{id: string, node: SVGPatternElement}}
* @private
*/
-var colorizePattern = function (pattern, color, id) {
+const colorizePattern = function (pattern, color, id) {
_newArrowCheck(this, color_this);
- var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(!0));
+ const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(!0));
node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
return {
id: id,
@@ -6045,12 +6082,12 @@ var colorizePattern = function (pattern, color, id) {
* @private
*/
function getColorFromCss(element) {
- var _this2 = this,
- cacheKey = KEY.colorPattern,
- body = browser_doc.body,
- pattern = body[cacheKey];
+ var _this2 = this;
+ const cacheKey = KEY.colorPattern,
+ body = browser_doc.body;
+ let pattern = body[cacheKey];
if (!pattern) {
- var content = element.classed($COLOR.colorPattern, !0).style("background-image");
+ const content = element.classed($COLOR.colorPattern, !0).style("background-image");
element.classed($COLOR.colorPattern, !1);
if (content.indexOf(";") > -1) {
pattern = content.replace(/url[^#]*|["'()]|(\s|%20)/g, "").split(";").map(function (v) {
@@ -6065,23 +6102,23 @@ function getColorFromCss(element) {
// Replacement of d3.schemeCategory10.
// Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
-var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
+const schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
/* harmony default export */ var internals_color = ({
generateColor: function generateColor() {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
$el = $$.$el,
config = $$.config,
colors = config.data_colors,
callback = config.data_color,
- ids = [],
- pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(getColorFromCss($el.chart) || schemeCategory10).range(),
- originalColorPattern = pattern;
+ ids = [];
+ let pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(getColorFromCss($el.chart) || schemeCategory10).range();
+ const originalColorPattern = pattern;
if (isFunction(config.color_tiles)) {
- var tiles = config.color_tiles.bind($$.api)(),
+ const tiles = config.color_tiles.bind($$.api)(),
colorizedPatterns = pattern.map(function (p, index) {
_newArrowCheck(this, _this3);
- var color = p.replace(/[#\(\)\s,]/g, ""),
+ const color = p.replace(/[#\(\)\s,]/g, ""),
id = $$.state.datetimeId + "-pattern-" + color + "-" + index;
return colorizePattern(tiles[index % tiles.length], p, id);
}.bind(this)); // Add background color to patterns
@@ -6092,10 +6129,11 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
$$.patterns = colorizedPatterns;
}
return function (d) {
- var _data,
- id = d.id || ((_data = d.data) == null ? void 0 : _data.id) || d,
- isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id],
- color;
+ var _data;
+ const id = d.id || ((_data = d.data) == null ? void 0 : _data.id) || d,
+ isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id];
+ let color;
+
// if callback function is provided
if (isFunction(colors[id])) {
color = colors[id].bind($$.api)(d);
@@ -6116,7 +6154,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
};
},
generateLevelColor: function generateLevelColor() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
colors = config.color_pattern,
threshold = config.color_threshold,
@@ -6124,9 +6162,9 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
max = threshold.max || 100,
values = threshold.values && threshold.values.length ? threshold.values : [];
return notEmpty(threshold) ? function (value) {
- var v = asValue ? value : value * 100 / max;
- var color = colors[colors.length - 1];
- for (var i = 0, l = values.length; i < l; i++) {
+ const v = asValue ? value : value * 100 / max;
+ let color = colors[colors.length - 1];
+ for (let i = 0, l = values.length; i < l; i++) {
if (v <= values[i]) {
color = colors[i];
break;
@@ -6141,14 +6179,14 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
* @private
*/
generateDataLabelBackgroundColorFilter: function generateDataLabelBackgroundColorFilter(color) {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
$el = $$.$el,
config = $$.config,
state = $$.state,
backgroundColors = color || config.data_labels_backgroundColors;
if (backgroundColors) {
- var ids = [];
+ let ids = [];
if (isString(backgroundColors)) {
ids.push("");
} else if (isObject(backgroundColors)) {
@@ -6156,7 +6194,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
}
ids.forEach(function (v) {
_newArrowCheck(this, _this4);
- var id = state.datetimeId + "-labels-bg" + $$.getTargetSelectorSuffix(v) + (color ? $$.getTargetSelectorSuffix(color) : "");
+ const id = state.datetimeId + "-labels-bg" + $$.getTargetSelectorSuffix(v) + (color ? $$.getTargetSelectorSuffix(color) : "");
$el.defs.append("filter").attr("x", "0").attr("y", "0").attr("width", "1").attr("height", "1").attr("id", id).html("");
}.bind(this));
}
@@ -6171,12 +6209,14 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
return "url(#" + this.state.datetimeId + "-gradient" + this.getTargetSelectorSuffix(id) + ")";
},
/**
- * Update linear gradient definition (for area & bar only)
+ * Update linear/radial gradient definition
+ * - linear: area & bar only
+ * - radial: type which has data points only
* @private
*/
updateLinearGradient: function updateLinearGradient() {
- var _this5 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
config = $$.config,
targets = $$.data.targets,
datetimeId = $$.state.datetimeId,
@@ -6184,23 +6224,46 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
targets.forEach(function (d) {
var _this6 = this;
_newArrowCheck(this, _this5);
- var id = datetimeId + "-gradient" + $$.getTargetSelectorSuffix(d.id),
- supportedType = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar",
- isRotated = config.axis_rotated;
- if (supportedType && defs.select("#" + id).empty()) {
- var color = $$.color(d),
- _config = config[supportedType + "_linearGradient"],
- _config$x = _config.x,
- x = _config$x === void 0 ? isRotated ? [1, 0] : [0, 0] : _config$x,
- _config$y = _config.y,
- y = _config$y === void 0 ? isRotated ? [0, 0] : [0, 1] : _config$y,
- _config$stops = _config.stops,
- stops = _config$stops === void 0 ? [[0, color, 1], [1, color, 0]] : _config$stops,
- linearGradient = defs.append("linearGradient").attr("id", "" + id).attr("x1", x[0]).attr("x2", x[1]).attr("y1", y[0]).attr("y2", y[1]);
- stops.forEach(function (v) {
+ const id = datetimeId + "-gradient" + $$.getTargetSelectorSuffix(d.id),
+ radialGradient = $$.hasPointType() && config.point_radialGradient,
+ supportedType = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar";
+ if ((radialGradient || supportedType) && defs.select("#" + id).empty()) {
+ const color = $$.color(d),
+ gradient = {
+ defs: null,
+ stops: []
+ };
+ if (radialGradient) {
+ const _radialGradient = radialGradient,
+ _radialGradient$cx = _radialGradient.cx,
+ cx = _radialGradient$cx === void 0 ? .3 : _radialGradient$cx,
+ _radialGradient$cy = _radialGradient.cy,
+ cy = _radialGradient$cy === void 0 ? .3 : _radialGradient$cy,
+ _radialGradient$r = _radialGradient.r,
+ r = _radialGradient$r === void 0 ? .7 : _radialGradient$r,
+ _radialGradient$stops = _radialGradient.stops,
+ stops = _radialGradient$stops === void 0 ? [[.1, color, 0], [.9, color, 1]] : _radialGradient$stops;
+ gradient.stops = stops;
+ gradient.defs = defs.append("radialGradient").attr("id", "" + id).attr("cx", cx).attr("cy", cy).attr("r", r);
+ } else {
+ const isRotated = config.axis_rotated,
+ _config = config[supportedType + "_linearGradient"],
+ _config$x = _config.x,
+ x = _config$x === void 0 ? isRotated ? [1, 0] : [0, 0] : _config$x,
+ _config$y = _config.y,
+ y = _config$y === void 0 ? isRotated ? [0, 0] : [0, 1] : _config$y,
+ _config$stops = _config.stops,
+ stops = _config$stops === void 0 ? [[0, color, 1], [1, color, 0]] : _config$stops;
+ gradient.stops = stops;
+ gradient.defs = defs.append("linearGradient").attr("id", "" + id).attr("x1", x[0]).attr("x2", x[1]).attr("y1", y[0]).attr("y2", y[1]);
+ }
+ gradient.stops.forEach(function (v) {
_newArrowCheck(this, _this6);
- var stopColor = isFunction(v[1]) ? v[1].bind($$.api)(d.id) : v[1];
- linearGradient.append("stop").attr("offset", v[0]).attr("stop-color", stopColor || color).attr("stop-opacity", v[2]);
+ const offset = v[0],
+ stopColor = v[1],
+ stopOpacity = v[2],
+ colorValue = isFunction(stopColor) ? stopColor.bind($$.api)(d.id) : stopColor;
+ gradient.defs && gradient.defs.append("stop").attr("offset", offset).attr("stop-color", colorValue || color).attr("stop-opacity", stopOpacity);
}.bind(this));
}
}.bind(this));
@@ -6213,15 +6276,15 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
* @private
*/
setOverColor: function setOverColor(isOver, d) {
- var _this7 = this,
- $$ = this,
+ var _this7 = this;
+ const $$ = this,
config = $$.config,
main = $$.$el.main,
- onover = config.color_onover,
- color = isOver ? onover : $$.color;
+ onover = config.color_onover;
+ let color = isOver ? onover : $$.color;
if (isObject(color)) {
color = function (_ref) {
- var id = _ref.id;
+ let id = _ref.id;
_newArrowCheck(this, _this7);
return id in onover ? onover[id] : $$.color(id);
}.bind(this);
@@ -6247,8 +6310,8 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
/* harmony default export */ var domain = ({
getYDomainMinMax: function getYDomainMinMax(targets, type) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
axis = $$.axis,
config = $$.config,
isMin = type === "min",
@@ -6256,17 +6319,17 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
ids = $$.mapToIds(targets),
ys = $$.getValuesAsIdKeyed(targets);
if (dataGroups.length > 0) {
- var hasValue = $$["has" + (isMin ? "Negative" : "Positive") + "ValueInTargets"](targets);
+ const hasValue = $$["has" + (isMin ? "Negative" : "Positive") + "ValueInTargets"](targets);
dataGroups.forEach(function (groupIds) {
var _this2 = this;
_newArrowCheck(this, _this);
// Determine baseId
- var idsInGroup = groupIds.filter(function (v) {
+ const idsInGroup = groupIds.filter(function (v) {
_newArrowCheck(this, _this2);
return ids.indexOf(v) >= 0;
}.bind(this));
if (idsInGroup.length) {
- var baseId = idsInGroup[0],
+ const baseId = idsInGroup[0],
baseAxisId = axis.getId(baseId);
// Initialize base value. Set to 0 if not match with the condition
if (hasValue && ys[baseId]) {
@@ -6282,10 +6345,10 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
var _this3 = this;
_newArrowCheck(this, _this2);
if (ys[id]) {
- var axisId = axis.getId(id);
+ const axisId = axis.getId(id);
ys[id].forEach(function (v, i) {
_newArrowCheck(this, _this3);
- var val = +v,
+ const val = +v,
meetCondition = isMin ? val > 0 : val < 0;
if (axisId === baseAxisId && !(hasValue && meetCondition)) {
ys[baseId][i] += val;
@@ -6308,16 +6371,16 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
* @private
*/
isHiddenTargetWithYDomain: function isHiddenTargetWithYDomain(id) {
- var _this4 = this,
- $$ = this;
+ var _this4 = this;
+ const $$ = this;
return $$.state.hiddenTargetIds.some(function (v) {
_newArrowCheck(this, _this4);
return $$.axis.getId(v) === id;
}.bind(this));
},
getYDomain: function getYDomain(targets, axisId, xDomain) {
- var _this5 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
axis = $$.axis,
config = $$.config,
scale = $$.scale,
@@ -6325,7 +6388,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
if ($$.isStackNormalized()) {
return [0, 100];
}
- var isLog = (scale == null ? void 0 : scale[axisId]) && scale[axisId].type === "log",
+ const isLog = (scale == null ? void 0 : scale[axisId]) && scale[axisId].type === "log",
targetsByAxisId = targets.filter(function (t) {
_newArrowCheck(this, _this5);
return axis.getId(t.id) === axisId;
@@ -6342,17 +6405,17 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
$$.getYDomain(targets, "y2", xDomain);
}
}
- var yMin = config[pfx + "_min"],
+ const yMin = config[pfx + "_min"],
yMax = config[pfx + "_max"],
center = config[pfx + "_center"],
isInverted = config[pfx + "_inverted"],
showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated,
showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated;
- var yDomainMin = $$.getYDomainMinMax(yTargets, "min"),
+ let yDomainMin = $$.getYDomainMinMax(yTargets, "min"),
yDomainMax = $$.getYDomainMinMax(yTargets, "max"),
isZeroBased = [TYPE.BAR, TYPE.BUBBLE, TYPE.SCATTER].concat(TYPE_BY_CATEGORY.Line).some(function (v) {
_newArrowCheck(this, _this5);
- var type = v.indexOf("area") > -1 ? "area" : v;
+ const type = v.indexOf("area") > -1 ? "area" : v;
return $$.hasType(v, yTargets, !0) && config[type + "_zerobased"];
}.bind(this));
// MEMO: avoid inverting domain unexpectedly
@@ -6369,7 +6432,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
if (yDomainMin === yDomainMax) {
yDomainMin < 0 ? yDomainMax = 0 : yDomainMin = 0;
}
- var isAllPositive = yDomainMin >= 0 && yDomainMax >= 0,
+ const isAllPositive = yDomainMin >= 0 && yDomainMax >= 0,
isAllNegative = yDomainMin <= 0 && yDomainMax <= 0;
// Cancel zerobased if axis_*_min / axis_*_max specified
if (isValue(yMin) && isAllPositive || isValue(yMax) && isAllNegative) {
@@ -6381,20 +6444,20 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
isAllPositive && (yDomainMin = 0);
isAllNegative && (yDomainMax = 0);
}
- var domainLength = Math.abs(yDomainMax - yDomainMin);
- var padding = {
+ const domainLength = Math.abs(yDomainMax - yDomainMin);
+ let padding = {
top: domainLength * .1,
bottom: domainLength * .1
};
if (isDefined(center)) {
- var yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
+ const yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
yDomainMax = center + yDomainAbs;
yDomainMin = center - yDomainAbs;
}
// add padding for data label
if (showHorizontalDataLabel) {
- var diff = diffDomain(scale.y.range()),
+ const diff = diffDomain(scale.y.range()),
ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width").map(function (v) {
_newArrowCheck(this, _this5);
return v / diff;
@@ -6404,7 +6467,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
padding[v] += domainLength * (ratio[i] / (1 - ratio[0] - ratio[1]));
}.bind(this));
} else if (showVerticalDataLabel) {
- var lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, "height");
+ const lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, "height");
["bottom", "top"].forEach(function (v, i) {
_newArrowCheck(this, _this5);
padding[v] += $$.convertPixelToScale("y", lengths[i], domainLength);
@@ -6414,7 +6477,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
// if padding is set, the domain will be updated relative the current domain value
// ex) $$.height=300, padding.top=150, domainLength=4 --> domain=6
- var p = config[pfx + "_padding"];
+ const p = config[pfx + "_padding"];
if (notEmpty(p)) {
["bottom", "top"].forEach(function (v) {
_newArrowCheck(this, _this5);
@@ -6427,7 +6490,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
isAllPositive && (padding.bottom = yDomainMin);
isAllNegative && (padding.top = -yDomainMax);
}
- var domain = isLog ? [yDomainMin, yDomainMax].map(function (v) {
+ const domain = isLog ? [yDomainMin, yDomainMax].map(function (v) {
_newArrowCheck(this, _this5);
return v < 0 ? 0 : v;
}.bind(this)) : [yDomainMin - padding.bottom, yDomainMax + padding.top];
@@ -6435,7 +6498,8 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
},
getXDomainMinMax: function getXDomainMinMax(targets, type) {
var _this6 = this,
- $$ = this,
+ _$$$axis;
+ const $$ = this,
configValue = $$.config["axis_x_" + type],
dataValue = getMinMax(type, targets.map(function (t) {
var _this7 = this;
@@ -6444,9 +6508,8 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
_newArrowCheck(this, _this7);
return v.x;
}.bind(this)));
- }.bind(this))),
- _$$$axis,
- value = isObject(configValue) ? configValue.value : configValue;
+ }.bind(this)));
+ let value = isObject(configValue) ? configValue.value : configValue;
value = isDefined(value) && (_$$$axis = $$.axis) != null && _$$$axis.isTimeSeries() ? parseDate.bind(this)(value) : value;
if (isObject(configValue) && configValue.fit && (type === "min" && value < dataValue || type === "max" && value > dataValue)) {
value = undefined;
@@ -6461,24 +6524,24 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
* @private
*/
getXDomainPadding: function getXDomainPadding(domain, tickCount) {
- var $$ = this,
+ const $$ = this,
axis = $$.axis,
config = $$.config,
padding = config.axis_x_padding,
isTimeSeriesTickCount = axis.isTimeSeries() && tickCount,
diff = diffDomain(domain);
- var defaultValue;
+ let defaultValue;
// determine default padding value
if (axis.isCategorized() || isTimeSeriesTickCount) {
defaultValue = 0;
} else if ($$.hasType("bar")) {
- var maxDataCount = $$.getMaxDataCount();
+ const maxDataCount = $$.getMaxDataCount();
defaultValue = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : .5;
} else {
defaultValue = $$.getResettedPadding(diff * .01);
}
- var _ref = isNumber(padding) ? {
+ let _ref = isNumber(padding) ? {
left: padding,
right: padding
} : padding,
@@ -6489,13 +6552,13 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
// when the unit is pixel, convert pixels to axis scale value
if (padding.unit === "px") {
- var domainLength = Math.abs(diff + diff * .2);
+ const domainLength = Math.abs(diff + diff * .2);
left = axis.getPadding(padding, "left", defaultValue, domainLength);
right = axis.getPadding(padding, "right", defaultValue, domainLength);
} else {
- var range = diff + left + right;
+ const range = diff + left + right;
if (isTimeSeriesTickCount && range) {
- var relativeTickWidth = diff / tickCount / range;
+ const relativeTickWidth = diff / tickCount / range;
left = left / range / relativeTickWidth;
right = right / range / relativeTickWidth;
}
@@ -6512,21 +6575,21 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
* @private
*/
getXDomain: function getXDomain(targets) {
- var $$ = this,
+ const $$ = this,
axis = $$.axis,
config = $$.config,
x = $$.scale.x,
isInverted = config.axis_x_inverted,
domain = [$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")];
- var _domain$ = domain[0],
+ let _domain$ = domain[0],
min = _domain$ === void 0 ? 0 : _domain$,
_domain$2 = domain[1],
max = _domain$2 === void 0 ? 0 : _domain$2;
if (x.type !== "log") {
- var isCategorized = axis.isCategorized(),
+ const isCategorized = axis.isCategorized(),
isTimeSeries = axis.isTimeSeries(),
padding = $$.getXDomainPadding(domain);
- var firstX = domain[0],
+ let firstX = domain[0],
lastX = domain[1];
// show center of x domain if min and max are the same
@@ -6549,7 +6612,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
return isInverted ? [max, min] : [min, max];
},
updateXDomain: function updateXDomain(targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
org = $$.org,
_$$$scale = $$.scale,
@@ -6560,13 +6623,19 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
var _$$$brush;
x.domain(domain || sortValue($$.getXDomain(targets), !config.axis_x_inverted));
org.xDomain = x.domain();
- zoomEnabled && $$.zoom.updateScaleExtent();
+
+ // zoomEnabled && $$.zoom.updateScaleExtent();
+
subX.domain(x.domain());
- (_$$$brush = $$.brush) == null ? void 0 : _$$$brush.scale(subX);
+ (_$$$brush = $$.brush) == null || _$$$brush.scale(subX);
}
if (withUpdateXDomain) {
- var domainValue = domain || !$$.brush || brushEmpty($$) ? org.xDomain : getBrushSelection($$).map(subX.invert);
+ const domainValue = domain || !$$.brush || brushEmpty($$) ? org.xDomain : getBrushSelection($$).map(subX.invert);
x.domain(domainValue);
+ // zoomEnabled && $$.zoom.updateScaleExtent();
+ }
+
+ if (withUpdateOrgXDomain || withUpdateXDomain) {
zoomEnabled && $$.zoom.updateScaleExtent();
}
@@ -6581,15 +6650,15 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
* @private
*/
trimXDomain: function trimXDomain(domain) {
- var $$ = this,
+ const $$ = this,
isInverted = $$.config.axis_x_inverted,
zoomDomain = $$.getZoomDomain(),
_zoomDomain = zoomDomain,
min = _zoomDomain[0],
max = _zoomDomain[1];
if (isInverted ? domain[0] >= min : domain[0] <= min) {
- domain[0] = min;
domain[1] = +domain[1] + (min - domain[0]);
+ domain[0] = min;
}
if (isInverted ? domain[1] <= max : domain[1] >= max) {
domain[0] = +domain[0] - (domain[1] - max);
@@ -6598,22 +6667,33 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
return domain;
},
/**
- * Get zoom domain
+ * Get subchart/zoom domain
+ * @param {string} type "subX" or "zoom"
+ * @param {boolean} getCurrent Get current domain if true
* @returns {Array} zoom domain
* @private
*/
- getZoomDomain: function getZoomDomain() {
- var $$ = this,
- config = $$.config,
- org = $$.org;
- var _org$xDomain = org.xDomain,
- min = _org$xDomain[0],
- max = _org$xDomain[1];
- if (isDefined(config.zoom_x_min)) {
- min = getMinMax("min", [min, config.zoom_x_min]);
+ getZoomDomain: function getZoomDomain(type, getCurrent) {
+ if (type === void 0) {
+ type = "zoom";
}
- if (isDefined(config.zoom_x_max)) {
- max = getMinMax("max", [max, config.zoom_x_max]);
+ if (getCurrent === void 0) {
+ getCurrent = !1;
+ }
+ const $$ = this,
+ config = $$.config,
+ scale = $$.scale,
+ org = $$.org;
+ let _ref2 = getCurrent && scale[type] ? scale[type].domain() : org.xDomain,
+ min = _ref2[0],
+ max = _ref2[1];
+ if (type === "zoom") {
+ if (isDefined(config.zoom_x_min)) {
+ min = getMinMax("min", [min, config.zoom_x_min]);
+ }
+ if (isDefined(config.zoom_x_max)) {
+ max = getMinMax("max", [max, config.zoom_x_max]);
+ }
}
return [min, max];
},
@@ -6626,17 +6706,48 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
* @private
*/
convertPixelToScale: function convertPixelToScale(type, pixels, domainLength) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
isRotated = config.axis_rotated;
- var length;
+ let length;
if (type === "x") {
length = isRotated ? "height" : "width";
} else {
length = isRotated ? "width" : "height";
}
return domainLength * (pixels / state[length]);
+ },
+ /**
+ * Check if the given domain is within subchart/zoom range
+ * @param {Array} domain Target domain value
+ * @param {Array} current Current subchart/zoom domain value
+ * @param {Array} range subchart/zoom range value
+ * @returns {boolean}
+ * @private
+ */
+ withinRange: function withinRange(domain, current, range) {
+ var _this8 = this;
+ const $$ = this,
+ isInverted = $$.config.axis_x_inverted,
+ _ref3 = range,
+ min = _ref3[0],
+ max = _ref3[1];
+ if (Array.isArray(domain)) {
+ const target = [].concat(domain);
+ isInverted && target.reverse();
+ if (target[0] < target[1]) {
+ return domain.every(function (v, i) {
+ var _this9 = this;
+ _newArrowCheck(this, _this8);
+ return (i === 0 ? isInverted ? +v <= min : +v >= min : isInverted ? +v >= max : +v <= max) && !domain.every(function (v, i) {
+ _newArrowCheck(this, _this9);
+ return v === current[i];
+ }.bind(this));
+ }.bind(this));
+ }
+ }
+ return !1;
}
});
;// CONCATENATED MODULE: ./src/ChartInternal/internals/format.ts
@@ -6655,7 +6766,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
* @private
*/
function getFormat($$, typeValue, v) {
- var config = $$.config,
+ const config = $$.config,
type = "axis_" + typeValue + "_tick_format",
format = config[type] ? config[type] : $$.defaultValueFormat;
return format.call($$.api, v);
@@ -6673,18 +6784,18 @@ function getFormat($$, typeValue, v) {
* @private
*/
getDefaultValueFormat: function getDefaultValueFormat() {
- var $$ = this,
+ const $$ = this,
defaultArcValueFormat = $$.defaultArcValueFormat,
yFormat = $$.yFormat,
y2Format = $$.y2Format,
hasArc = $$.hasArcType(null, ["gauge", "polar", "radar"]);
return function (v, ratio, id) {
- var format = hasArc ? defaultArcValueFormat : $$.axis && $$.axis.getId(id) === "y2" ? y2Format : yFormat;
+ const format = hasArc ? defaultArcValueFormat : $$.axis && $$.axis.getId(id) === "y2" ? y2Format : yFormat;
return format.call($$, v, ratio);
};
},
defaultValueFormat: function defaultValueFormat(v) {
- return isValue(v) ? +v : "";
+ return isArray(v) ? v.join("~") : isValue(v) ? +v : "";
},
defaultArcValueFormat: function defaultArcValueFormat(v, ratio) {
return (ratio * 100).toFixed(1) + "%";
@@ -6693,14 +6804,22 @@ function getFormat($$, typeValue, v) {
return "" + v;
},
dataLabelFormat: function dataLabelFormat(targetId) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
dataLabels = $$.config.data_labels,
defaultFormat = function (v) {
_newArrowCheck(this, _this);
- return isValue(v) ? +v : "";
- }.bind(this),
- format = defaultFormat;
+ const delimiter = "~";
+ let res = v;
+ if (isArray(v)) {
+ res = v.join(delimiter);
+ } else if (isObject(v)) {
+ res = Object.values(v).join(delimiter);
+ }
+ return res;
+ }.bind(this);
+ let format = defaultFormat;
+
// find format according to axis id
if (isFunction(dataLabels.format)) {
format = dataLabels.format;
@@ -6736,7 +6855,7 @@ function getFormat($$, typeValue, v) {
* @private
*/
function getLegendColor(id) {
- var $$ = this,
+ const $$ = this,
data = $$.getDataById(id),
color = $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
return color;
@@ -6747,7 +6866,7 @@ function getLegendColor(id) {
* @private
*/
initLegend: function initLegend() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
$el = $$.$el;
$$.legendItemTextBox = {};
@@ -6772,8 +6891,8 @@ function getLegendColor(id) {
* @private
*/
updateLegend: function updateLegend(targetIds, options, transitions) {
- var _$el$legend,
- $$ = this,
+ var _$el$legend;
+ const $$ = this,
config = $$.config,
state = $$.state,
scale = $$.scale,
@@ -6792,8 +6911,8 @@ function getLegendColor(id) {
}
// toggle legend state
- (_$el$legend = $el.legend) == null ? void 0 : _$el$legend.selectAll("." + $LEGEND.legendItem).classed($LEGEND.legendItemHidden, function (id) {
- var hide = !$$.isTargetToShow(id);
+ (_$el$legend = $el.legend) == null || _$el$legend.selectAll("." + $LEGEND.legendItem).classed($LEGEND.legendItemHidden, function (id) {
+ const hide = !$$.isTargetToShow(id);
if (hide) {
this.style.opacity = null;
}
@@ -6813,19 +6932,19 @@ function getLegendColor(id) {
* @private
*/
updateLegendTemplate: function updateLegendTemplate() {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
$el = $$.$el,
wrapper = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.legend_contents_bindto),
template = config.legend_contents_template;
if (!wrapper.empty()) {
- var targets = $$.mapToIds($$.data.targets),
+ const targets = $$.mapToIds($$.data.targets),
ids = [];
- var html = "";
+ let html = "";
targets.forEach(function (v) {
_newArrowCheck(this, _this);
- var content = isFunction(template) ? template.bind($$.api)(v, $$.color(v), $$.api.data(v)[0].values) : tplProcess(template, {
+ const content = isFunction(template) ? template.bind($$.api)(v, $$.color(v), $$.api.data(v)[0].values) : tplProcess(template, {
COLOR: $$.color(v),
TITLE: v
});
@@ -6834,7 +6953,7 @@ function getLegendColor(id) {
html += content;
}
}.bind(this));
- var legendItem = wrapper.html(html).selectAll(function () {
+ const legendItem = wrapper.html(html).selectAll(function () {
return this.childNodes;
}).data(ids);
$$.setLegendItem(legendItem);
@@ -6847,7 +6966,7 @@ function getLegendColor(id) {
* @private
*/
updateSizeForLegend: function updateSizeForLegend(size) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
_$$$state = $$.state,
isLegendTop = _$$$state.isLegendTop,
@@ -6858,8 +6977,8 @@ function getLegendColor(id) {
width = size.width,
height = size.height,
insetLegendPosition = {
- top: isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : current.height - height - $$.getCurrentPaddingBottom() - config.legend_inset_y,
- left: isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + .5 : current.width - width - $$.getCurrentPaddingRight() - config.legend_inset_x + .5
+ top: isLegendTop ? $$.getCurrentPaddingByDirection("top") + config.legend_inset_y + 5.5 : current.height - height - $$.getCurrentPaddingByDirection("bottom") - config.legend_inset_y,
+ left: isLegendLeft ? $$.getCurrentPaddingByDirection("left") + config.legend_inset_x + .5 : current.width - width - $$.getCurrentPaddingByDirection("right") - config.legend_inset_x + .5
};
$$.state.margin3 = {
top: isLegendRight ? 0 : isLegendInset ? insetLegendPosition.top : current.height - height,
@@ -6874,7 +6993,7 @@ function getLegendColor(id) {
* @private
*/
transformLegend: function transformLegend(withTransition) {
- var $$ = this,
+ const $$ = this,
legend = $$.$el.legend,
$T = $$.$T;
$T(legend, withTransition).attr("transform", $$.getTranslate("legend"));
@@ -6910,7 +7029,7 @@ function getLegendColor(id) {
* @private
*/
updateLegendItemColor: function updateLegendItemColor(id, color) {
- var legend = this.$el.legend;
+ const legend = this.$el.legend;
if (legend) {
legend.select("." + $LEGEND.legendItem + "-" + id + " line").style("stroke", color);
}
@@ -6921,7 +7040,7 @@ function getLegendColor(id) {
* @private
*/
getLegendWidth: function getLegendWidth() {
- var $$ = this,
+ const $$ = this,
_$$$state2 = $$.state,
width = _$$$state2.current.width,
isLegendRight = _$$$state2.isLegendRight,
@@ -6936,8 +7055,8 @@ function getLegendColor(id) {
* @private
*/
getLegendHeight: function getLegendHeight() {
- var _$$$config$padding,
- $$ = this,
+ var _$$$config$padding;
+ const $$ = this,
_$$$state3 = $$.state,
current = _$$$state3.current,
isLegendRight = _$$$state3.isLegendRight,
@@ -6962,8 +7081,8 @@ function getLegendColor(id) {
* @private
*/
toggleFocusLegend: function toggleFocusLegend(targetIds, focus) {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
legend = $$.$el.legend,
$T = $$.$T,
targetIdz = $$.mapToTargetIds(targetIds);
@@ -6979,7 +7098,7 @@ function getLegendColor(id) {
* @private
*/
revertLegend: function revertLegend() {
- var $$ = this,
+ const $$ = this,
legend = $$.$el.legend,
$T = $$.$T;
legend && $T(legend.selectAll("." + $LEGEND.legendItem).classed($FOCUS.legendItemFocused, !1)).style("opacity", null);
@@ -6990,7 +7109,7 @@ function getLegendColor(id) {
* @private
*/
showLegend: function showLegend(targetIds) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
$el = $$.$el,
$T = $$.$T;
@@ -7008,7 +7127,7 @@ function getLegendColor(id) {
* @private
*/
hideLegend: function hideLegend(targetIds) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
legend = $$.$el.legend;
if (config.legend_show && isEmpty(targetIds)) {
@@ -7026,13 +7145,13 @@ function getLegendColor(id) {
* @private
*/
getLegendItemTextBox: function getLegendItemTextBox(id, textElement) {
- var $$ = this,
+ const $$ = this,
cache = $$.cache,
state = $$.state;
- var data;
+ let data;
// do not prefix w/'$', to not be resetted cache in .load() call
- var cacheKey = KEY.legendItemTextBox;
+ const cacheKey = KEY.legendItemTextBox;
if (id) {
data = !state.redrawing && cache.get(cacheKey) || {};
if (!data[id]) {
@@ -7049,8 +7168,8 @@ function getLegendColor(id) {
* @private
*/
setLegendItem: function setLegendItem(item) {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
$el = $$.$el,
api = $$.api,
config = $$.config,
@@ -7060,7 +7179,7 @@ function getLegendColor(id) {
useCssRule = config.boost_useCssRule,
interaction = config.legend_item_interaction;
item.attr("class", function (id) {
- var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
+ const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
itemClass = !node.empty() && node.attr("class") || "";
return itemClass + $$.generateClass($LEGEND.legendItem, id);
}).style("visibility", function (id) {
@@ -7071,14 +7190,14 @@ function getLegendColor(id) {
if (useCssRule) {
[["." + $LEGEND.legendItem, "cursor:pointer"], ["." + $LEGEND.legendItem + " text", "pointer-events:none"], ["." + $LEGEND.legendItemPoint + " text", "pointer-events:none"], ["." + $LEGEND.legendItemTile, "pointer-events:none"], ["." + $LEGEND.legendItemEvent, "fill-opacity:0"]].forEach(function (v) {
_newArrowCheck(this, _this3);
- var selector = v[0],
+ const selector = v[0],
props = v[1];
$$.setCssRule(!1, selector, [props])($el.legend);
}.bind(this));
}
item.on(interaction.dblclick ? "dblclick" : "click", interaction || isFunction(config.legend_item_onclick) ? function (event, id) {
if (!callFn(config.legend_item_onclick, api, id)) {
- var altKey = event.altKey,
+ const altKey = event.altKey,
target = event.target,
type = event.type;
if (type === "dblclick" || altKey) {
@@ -7127,8 +7246,8 @@ function getLegendColor(id) {
* @private
*/
updateLegendElement: function updateLegendElement(targetIds, options) {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
legend = $$.$el.legend,
@@ -7160,16 +7279,15 @@ function getLegendColor(id) {
heights: {},
margins: [0],
steps: {}
- },
- xForLegend,
- yForLegend,
- background,
- targetIdz = targetIds.filter(function (id) {
+ };
+ let xForLegend, yForLegend, background;
+ // Skip elements when their name is set to null
+ const targetIdz = targetIds.filter(function (id) {
_newArrowCheck(this, _this4);
return !isDefined(config.data_names[id]) || config.data_names[id] !== null;
}.bind(this)),
withTransition = options.withTransition,
- updatePositions = $$.getUpdateLegendPositions(targetIdz, dimension, sizes); // Skip elements when their name is set to null
+ updatePositions = $$.getUpdateLegendPositions(targetIdz, dimension, sizes);
if (state.isLegendInset) {
dimension.step = config.legend_inset_step ? config.legend_inset_step : targetIdz.length;
$$.updateLegendStep(dimension.step);
@@ -7202,7 +7320,7 @@ function getLegendColor(id) {
return dimension.max.height * sizes.steps[id];
}.bind(this);
}
- var posFn = {
+ const posFn = {
xText: function xText(id, i) {
_newArrowCheck(this, _this4);
return xForLegend(id, i) + 4 + itemTileSize.width;
@@ -7239,7 +7357,7 @@ function getLegendColor(id) {
if (state.isLegendInset && dimension.max.width > 0 && background.size() === 0) {
background = legend.insert("g", "." + $LEGEND.legendItem).attr("class", $LEGEND.legendBackground).append("rect");
}
- var texts = legend.selectAll("text").data(targetIdz).text(function (id) {
+ const texts = legend.selectAll("text").data(targetIdz).text(function (id) {
_newArrowCheck(this, _this4);
return isDefined(config.data_names[id]) ? config.data_names[id] : id;
}.bind(this)) // MEMO: needed for update
@@ -7247,7 +7365,7 @@ function getLegendColor(id) {
updatePositions(this, id, i);
});
$T(texts, withTransition).attr("x", posFn.xText).attr("y", posFn.yText);
- var rects = legend.selectAll("rect." + $LEGEND.legendItemEvent).data(targetIdz);
+ const rects = legend.selectAll("rect." + $LEGEND.legendItemEvent).data(targetIdz);
$T(rects, withTransition).attr("width", function (id) {
_newArrowCheck(this, _this4);
return sizes.widths[id];
@@ -7276,33 +7394,35 @@ function getLegendColor(id) {
* @private
*/
getUpdateLegendPositions: function getUpdateLegendPositions(targetIdz, dimension, sizes) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
isLegendRightOrInset = state.isLegendRight || state.isLegendInset;
return function (textElement, id, index) {
- var _this5 = this,
- isLast = index === targetIdz.length - 1,
+ var _this5 = this;
+ const isLast = index === targetIdz.length - 1,
box = $$.getLegendItemTextBox(id, textElement),
itemWidth = box.width + dimension.tileWidth + (isLast && !isLegendRightOrInset ? 0 : dimension.padding.right) + config.legend_padding,
itemHeight = box.height + dimension.padding.top,
itemLength = isLegendRightOrInset ? itemHeight : itemWidth,
- areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth(),
- margin,
- updateValues = function (id2, withoutStep) {
- if (!withoutStep) {
- margin = (areaLength - dimension.totalLength - itemLength) / 2;
- if (margin < dimension.posMin) {
- margin = (areaLength - itemLength) / 2;
- dimension.totalLength = 0;
- dimension.step++;
- }
+ areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth();
+ let margin;
+
+ // MEMO: care about condifion of step, totalLength
+ const updateValues = function (id2, withoutStep) {
+ if (!withoutStep) {
+ margin = (areaLength - dimension.totalLength - itemLength) / 2;
+ if (margin < dimension.posMin) {
+ margin = (areaLength - itemLength) / 2;
+ dimension.totalLength = 0;
+ dimension.step++;
}
- sizes.steps[id2] = dimension.step;
- sizes.margins[dimension.step] = state.isLegendInset ? 10 : margin;
- sizes.offsets[id2] = dimension.totalLength;
- dimension.totalLength += itemLength;
- }; // MEMO: care about condifion of step, totalLength
+ }
+ sizes.steps[id2] = dimension.step;
+ sizes.margins[dimension.step] = state.isLegendInset ? 10 : margin;
+ sizes.offsets[id2] = dimension.totalLength;
+ dimension.totalLength += itemLength;
+ };
if (index === 0) {
dimension.totalLength = 0;
dimension.step = 0;
@@ -7324,7 +7444,7 @@ function getLegendColor(id) {
if (!dimension.max.height || itemHeight >= dimension.max.height) {
dimension.max.height = itemHeight;
}
- var maxLength = isLegendRightOrInset ? dimension.max.height : dimension.max.width;
+ const maxLength = isLegendRightOrInset ? dimension.max.height : dimension.max.width;
if (config.legend_equally) {
Object.keys(sizes.widths).forEach(function (id2) {
_newArrowCheck(this, _this5);
@@ -7359,8 +7479,8 @@ function getLegendColor(id) {
* @private
*/
generateLegendItem: function generateLegendItem(targetIdz, itemTileSize, updatePositions, posFn) {
- var _this6 = this,
- $$ = this,
+ var _this6 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
legend = $$.$el.legend,
@@ -7369,7 +7489,9 @@ function getLegendColor(id) {
legendType = config.legend_item_tile_type,
isRectangle = legendType !== "circle",
isLegendRightOrInset = state.isLegendRight || state.isLegendInset,
+ pos = -200,
l = legend.selectAll("." + $LEGEND.legendItem).data(targetIdz).enter().append("g");
+
// Define g for legend area
$$.setLegendItem(l);
@@ -7381,19 +7503,19 @@ function getLegendColor(id) {
}).style("pointer-events", $$.getStylePropValue("none")).attr("x", isLegendRightOrInset ? posFn.xText : -200).attr("y", isLegendRightOrInset ? -200 : posFn.yText);
l.append("rect").attr("class", $LEGEND.legendItemEvent).style("fill-opacity", $$.getStylePropValue("0")).attr("x", isLegendRightOrInset ? posFn.xRect : -200).attr("y", isLegendRightOrInset ? -200 : posFn.yRect);
if (usePoint) {
- var _ids = [];
+ const ids = [];
l.append(function (d) {
_newArrowCheck(this, _this6);
- var pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
- _ids.indexOf(d) === -1 && _ids.push(d);
- var point = pattern[_ids.indexOf(d) % pattern.length];
+ const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
+ ids.indexOf(d) === -1 && ids.push(d);
+ let point = pattern[ids.indexOf(d) % pattern.length];
if (point === "rectangle") {
point = "rect";
}
return browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, "hasValidPointType" in $$ && $$.hasValidPointType(point) ? point : "use");
}.bind(this)).attr("class", $LEGEND.legendItemPoint).style("fill", getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).attr("href", function (data, idx, selection) {
_newArrowCheck(this, _this6);
- var node = selection[idx],
+ const node = selection[idx],
nodeName = node.nodeName.toLowerCase(),
id = $$.getTargetSelectorSuffix(data);
return nodeName === "use" ? "#" + state.datetimeId + "-point" + id : undefined;
@@ -7402,9 +7524,9 @@ function getLegendColor(id) {
l.append(isRectangle ? "line" : legendType).attr("class", $LEGEND.legendItemTile).style("stroke", getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).call(function (selection) {
_newArrowCheck(this, _this6);
if (legendType === "circle") {
- selection.attr("r", legendItemR).style("fill", getLegendColor.bind($$)).attr("cx", isLegendRightOrInset ? posFn.x2Tile : -200).attr("cy", isLegendRightOrInset ? -200 : posFn.yTile);
+ selection.attr("r", legendItemR).style("fill", getLegendColor.bind($$)).attr("cx", isLegendRightOrInset ? posFn.x2Tile : pos).attr("cy", isLegendRightOrInset ? pos : posFn.yTile);
} else if (isRectangle) {
- selection.attr("stroke-width", itemTileSize.height).attr("x1", isLegendRightOrInset ? posFn.x1Tile : -200).attr("y1", isLegendRightOrInset ? -200 : posFn.yTile).attr("x2", isLegendRightOrInset ? posFn.x2Tile : -200).attr("y2", isLegendRightOrInset ? -200 : posFn.yTile);
+ selection.attr("stroke-width", itemTileSize.height).attr("x1", isLegendRightOrInset ? posFn.x1Tile : pos).attr("y1", isLegendRightOrInset ? pos : posFn.yTile).attr("x2", isLegendRightOrInset ? posFn.x2Tile : pos).attr("y2", isLegendRightOrInset ? pos : posFn.yTile);
}
}.bind(this));
}
@@ -7417,20 +7539,20 @@ function getLegendColor(id) {
* @private
*/
updateLegendItemPos: function updateLegendItemPos(targetIdz, withTransition, posFn) {
- var _this8 = this,
- $$ = this,
+ var _this8 = this;
+ const $$ = this,
config = $$.config,
legend = $$.$el.legend,
$T = $$.$T,
usePoint = config.legend_usePoint,
legendType = config.legend_item_tile_type;
if (usePoint) {
- var tiles = legend.selectAll("." + $LEGEND.legendItemPoint).data(targetIdz);
+ const tiles = legend.selectAll("." + $LEGEND.legendItemPoint).data(targetIdz);
$T(tiles, withTransition).each(function () {
- var _this7 = this,
- nodeName = this.nodeName.toLowerCase(),
- pointR = config.point_r,
- x = "x",
+ var _this7 = this;
+ const nodeName = this.nodeName.toLowerCase(),
+ pointR = config.point_r;
+ let x = "x",
y = "y",
xOffset = 2,
yOffset = 2.5,
@@ -7438,16 +7560,16 @@ function getLegendColor(id) {
width = null,
height = null;
if (nodeName === "circle") {
- var size = pointR * .2;
+ const size = pointR * .2;
x = "cx";
y = "cy";
radius = pointR + size;
xOffset = pointR * 2;
yOffset = -size;
} else if (nodeName === "rect") {
- var _size = pointR * 2.5;
- width = _size;
- height = _size;
+ const size = pointR * 2.5;
+ width = size;
+ height = size;
yOffset = 3;
}
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).attr(x, function (d) {
@@ -7459,14 +7581,14 @@ function getLegendColor(id) {
}.bind(this)).attr("r", radius).attr("width", width).attr("height", height);
});
} else {
- var _tiles = legend.selectAll("." + $LEGEND.legendItemTile).data(targetIdz);
- $T(_tiles, withTransition).style("stroke", getLegendColor.bind($$)).call(function (selection) {
+ const tiles = legend.selectAll("." + $LEGEND.legendItemTile).data(targetIdz);
+ $T(tiles, withTransition).style("stroke", getLegendColor.bind($$)).call(function (selection) {
var _this9 = this;
_newArrowCheck(this, _this8);
if (legendType === "circle") {
selection.attr("cx", function (d) {
_newArrowCheck(this, _this9);
- var x2 = posFn.x2Tile(d);
+ const x2 = posFn.x2Tile(d);
return x2 - (x2 - posFn.x1Tile(d)) / 2;
}.bind(this)).attr("cy", posFn.yTile);
} else if (legendType !== "circle") {
@@ -7495,7 +7617,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
if (options === void 0) {
options = {};
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
$el = $$.$el,
@@ -7503,7 +7625,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
main = _$el.main,
treemap = _$el.treemap;
state.redrawing = !0;
- var targetsToShow = $$.filterTargetsToShow($$.data.targets),
+ const targetsToShow = $$.filterTargetsToShow($$.data.targets),
_options = options,
flow = _options.flow,
initializing = _options.initializing,
@@ -7524,11 +7646,6 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
$$.updateDimension(!0);
}
- // update circleY based on updated parameters
- if (!treemap && (!$$.hasArcType() || state.hasRadar)) {
- $$.updateCircleY && ($$.circleY = $$.updateCircleY());
- }
-
// Data empty label positioning and text.
config.data_empty_label_text && main.select("text." + $TEXT.text + "." + $COMMON.empty).attr("x", state.width / 2).attr("y", state.height / 2).text(config.data_empty_label_text).style("display", targetsToShow.length ? "none" : null);
@@ -7544,7 +7661,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
config.regions.length && $$.updateRegion();
["bar", "candlestick", "line", "area"].forEach(function (v) {
_newArrowCheck(this, _this);
- var name = capitalize(v);
+ const name = capitalize(v);
if (/^(line|area)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
$$["update" + name](wth.TransitionForExit);
}
@@ -7556,7 +7673,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
// event rects will redrawn when flow called
if (config.interaction_enabled && !flow && wth.EventRect) {
$$.redrawEventRect();
- $$.bindZoomEvent == null ? void 0 : $$.bindZoomEvent();
+ $$.bindZoomEvent == null || $$.bindZoomEvent();
}
} else {
// arc
@@ -7581,9 +7698,10 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
$$.hasDataLabel() && !$$.hasArcType(null, ["radar"]) && $$.updateText();
// title
- $$.redrawTitle == null ? void 0 : $$.redrawTitle();
+ $$.redrawTitle == null || $$.redrawTitle();
initializing && $$.updateTypesElements();
$$.generateRedrawList(targetsToShow, flow, duration, wth.Subchart);
+ $$.updateTooltipOnRedraw();
$$.callPluginHook("$redraw", options, duration);
},
/**
@@ -7595,8 +7713,8 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
* @private
*/
generateRedrawList: function generateRedrawList(targets, flow, duration, withSubchart) {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
shape = $$.getDrawShape();
@@ -7606,7 +7724,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
}
// generate flow
- var flowFn = flow && $$.generateFlow({
+ const flowFn = flow && $$.generateFlow({
targets: targets,
flow: flow,
duration: flow.duration,
@@ -7626,7 +7744,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
// Only use transition when current tab is visible.
if (withTransition && redrawList.length) {
// Wait for end of transitions for callback
- var waitForDraw = generateWait();
+ const waitForDraw = generateWait();
// transition should be derived from one transition
(0,external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_.transition)().duration(duration).each(function () {
@@ -7652,8 +7770,8 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
}.bind(this));
},
getRedrawList: function getRedrawList(shape, flow, flowFn, withTransition) {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
config = $$.config,
_$$$state = $$.state,
hasAxis = _$$$state.hasAxis,
@@ -7675,7 +7793,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
}
Object.keys(shape.type).forEach(function (v) {
_newArrowCheck(this, _this4);
- var name = capitalize(v),
+ const name = capitalize(v),
drawFn = shape.type[v];
if (/^(area|line)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
list.push($$["redraw" + name](drawFn, withTransition));
@@ -7686,7 +7804,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
if (!$$.hasArcType() || hasRadar) {
notEmpty(config.data_labels) && config.data_labels !== !1 && list.push($$.redrawText(xForText, yForText, flow, withTransition));
}
- if (($$.hasPointType() || hasRadar) && !config.point_focus_only) {
+ if (($$.hasPointType() || hasRadar) && !$$.isPointFocusOnly()) {
$$.redrawCircle && list.push($$.redrawCircle(cx, cy, withTransition, flowFn));
}
if (hasTreemap) {
@@ -7698,10 +7816,10 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
if (options === void 0) {
options = {};
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state;
- var transitions;
+ let transitions;
// same with redraw
options.withTransition = getOption(options, "withTransition", !0);
@@ -7758,7 +7876,7 @@ function getScale(type, min, max) {
if (max === void 0) {
max = 1;
}
- var scale = {
+ const scale = {
linear: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear,
log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSymlog,
_log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLog,
@@ -7780,7 +7898,7 @@ function getScale(type, min, max) {
* @private
*/
getXScale: function getXScale(min, max, domain, offset) {
- var $$ = this,
+ const $$ = this,
scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
return $$.getCustomizedXScale(domain ? scale.domain(domain) : scale, offset);
},
@@ -7794,7 +7912,7 @@ function getScale(type, min, max) {
* @private
*/
getYScale: function getYScale(id, min, max, domain) {
- var $$ = this,
+ const $$ = this,
scale = getScale($$.axis.getAxisType(id), min, max);
domain && scale.domain(domain);
return scale;
@@ -7811,7 +7929,7 @@ function getScale(type, min, max) {
if (isSub === void 0) {
isSub = !1;
}
- var isY2 = ((_this$axis = this.axis) == null ? void 0 : _this$axis.getId(id)) === "y2",
+ const isY2 = ((_this$axis = this.axis) == null ? void 0 : _this$axis.getId(id)) === "y2",
key = isSub ? isY2 ? "subY2" : "subY" : isY2 ? "y2" : "y";
return this.scale[key];
},
@@ -7823,19 +7941,19 @@ function getScale(type, min, max) {
* @private
*/
getCustomizedXScale: function getCustomizedXScale(scaleValue, offsetValue) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
offset = offsetValue || function () {
_newArrowCheck(this, _this);
return $$.axis.x.tickOffset();
}.bind(this),
isInverted = $$.config.axis_x_inverted,
scale = function (d, raw) {
- var v = scaleValue(d) + offset();
+ const v = scaleValue(d) + offset();
return raw ? v : Math.ceil(v);
};
// copy original scale methods
- for (var key in scaleValue) {
+ for (const key in scaleValue) {
scale[key] = scaleValue[key];
}
scale.orgDomain = function () {
@@ -7850,7 +7968,7 @@ function getScale(type, min, max) {
// define custom domain() for categorized axis
if ($$.axis.isCategorized()) {
scale.domain = function (domainValue) {
- var domain = domainValue;
+ let domain = domainValue;
if (!arguments.length) {
domain = this.orgDomain();
return isInverted ? [domain[0] + 1, domain[1]] : [domain[0], domain[1] + 1];
@@ -7872,7 +7990,7 @@ function getScale(type, min, max) {
if (updateXDomain === void 0) {
updateXDomain = !0;
}
- var $$ = this,
+ const $$ = this,
axis = $$.axis,
config = $$.config,
format = $$.format,
@@ -7887,8 +8005,8 @@ function getScale(type, min, max) {
hasAxis = _$$$state.hasAxis,
hasTreemap = _$$$state.hasTreemap;
if (hasAxis) {
- var _scale$x,
- isRotated = config.axis_rotated,
+ var _scale$x;
+ const isRotated = config.axis_rotated,
resettedPadding = $$.getResettedPadding(1),
min = {
x: isRotated ? resettedPadding : 0,
@@ -7903,12 +8021,9 @@ function getScale(type, min, max) {
subY: isRotated ? width2 : 1
},
xDomain = updateXDomain && ((_scale$x = scale.x) == null ? void 0 : _scale$x.orgDomain()),
- xSubDomain = updateXDomain && org.xDomain;
- // update edges
-
+ xSubDomain = updateXDomain && org.xDomain; // update edges
// update scales
// x Axis
-
scale.x = $$.getXScale(min.x, max.x, xDomain, function () {
_newArrowCheck(this, _this2);
return axis.x.tickOffset();
@@ -7937,12 +8052,12 @@ function getScale(type, min, max) {
axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
}
} else if (hasTreemap) {
- var padding = $$.getCurrentPadding();
+ const padding = $$.getCurrentPadding();
scale.x = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear)().rangeRound([padding.left, current.width - padding.right]);
scale.y = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear)().rangeRound([padding.top, current.height - padding.bottom]);
} else {
// update for arc
- $$.updateArc == null ? void 0 : $$.updateArc();
+ $$.updateArc == null || $$.updateArc();
}
},
/**
@@ -7952,7 +8067,7 @@ function getScale(type, min, max) {
* @private
*/
xx: function xx(d) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
_$$$scale = $$.scale,
x = _$$$scale.x,
@@ -7961,14 +8076,14 @@ function getScale(type, min, max) {
return d ? fn(isValue(d.x) ? d.x : d) : null;
},
xv: function xv(d) {
- var $$ = this,
+ const $$ = this,
axis = $$.axis,
config = $$.config,
_$$$scale2 = $$.scale,
x = _$$$scale2.x,
zoom = _$$$scale2.zoom,
fn = config.zoom_enabled && zoom ? zoom : x;
- var value = $$.getBaseValue(d);
+ let value = $$.getBaseValue(d);
if (axis.isTimeSeries()) {
value = parseDate.call($$, value);
} else if (axis.isCategorized() && isString(value)) {
@@ -7977,7 +8092,7 @@ function getScale(type, min, max) {
return Math.ceil(fn(value));
},
yv: function yv(d) {
- var $$ = this,
+ const $$ = this,
_$$$scale3 = $$.scale,
y = _$$$scale3.y,
y2 = _$$$scale3.y2,
@@ -8000,6 +8115,23 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
+/**
+ * Get grouped data point function for y coordinate
+ * - Note: Grouped(stacking) works only for line and bar types
+ * @param {object} d data vlaue
+ * @returns {Function|undefined}
+ * @private
+ */
+function getGroupedDataPointsFn(d) {
+ const $$ = this;
+ let fn;
+ if ($$.isLineType(d)) {
+ fn = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType));
+ } else if ($$.isBarType(d)) {
+ fn = $$.generateGetBarPoints($$.getShapeIndices($$.isBarType));
+ }
+ return fn;
+}
/* harmony default export */ var shape = ({
/**
* Get the shape draw function
@@ -8007,8 +8139,8 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
getDrawShape: function getDrawShape() {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
isRotated = $$.config.axis_rotated,
_$$$state = $$.state,
hasRadar = _$$$state.hasRadar,
@@ -8020,16 +8152,16 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
};
hasTreemap || ["bar", "candlestick", "line", "area"].forEach(function (v) {
_newArrowCheck(this, _this);
- var name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
+ const name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
if ($$.hasType(v) || $$.hasTypeOf(name) || v === "line" && ($$.hasType("bubble") || $$.hasType("scatter"))) {
- var indices = $$.getShapeIndices($$["is" + name + "Type"]),
+ const indices = $$.getShapeIndices($$["is" + name + "Type"]),
drawFn = $$["generateDraw" + name];
shape.indices[v] = indices;
shape.type[v] = drawFn ? drawFn.bind($$)(indices, !1) : undefined;
}
}.bind(this));
if (!$$.hasArcType() || hasRadar || hasTreemap) {
- var cx, cy;
+ let cx, cy;
// generate circle x/y functions depending on updated params
if (!hasTreemap) {
cx = hasRadar ? $$.radarCircleX : isRotated ? $$.circleY : $$.circleX;
@@ -8045,7 +8177,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
return shape;
},
/**
- * Get shape's indices according it's position
+ * Get shape's indices according it's position within each axis tick.
*
* From the below example, indices will be:
* ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
@@ -8058,13 +8190,13 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @returns {object} Indices object with its position
*/
getShapeIndices: function getShapeIndices(typeFilter) {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
xs = config.data_xs,
hasXs = notEmpty(xs),
- indices = {},
- i = hasXs ? {} : 0;
+ indices = {};
+ let i = hasXs ? {} : 0;
if (hasXs) {
getUnique(Object.keys(xs).map(function (v) {
_newArrowCheck(this, _this2);
@@ -8077,17 +8209,23 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
}
$$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) {
_newArrowCheck(this, _this2);
- var xKey = d.id in xs ? xs[d.id] : "",
+ const xKey = d.id in xs ? xs[d.id] : "",
ind = xKey ? indices[xKey] : indices;
- for (var j = 0, groups; groups = config.data_groups[j]; j++) {
+ for (let j = 0, groups; groups = config.data_groups[j]; j++) {
if (groups.indexOf(d.id) < 0) {
continue;
}
- for (var k = 0, row; row = groups[k]; k++) {
- if (row in ind) {
- ind[d.id] = ind[row];
+ for (let k = 0, key; key = groups[k]; k++) {
+ if (key in ind) {
+ ind[d.id] = ind[key];
break;
}
+
+ // for same grouped data, add other data to same indices
+ if (d.id !== key && xKey) {
+ var _ind$d$id;
+ ind[key] = (_ind$d$id = ind[d.id]) != null ? _ind$d$id : i[xKey];
+ }
}
}
if (isUndefined(ind[d.id])) {
@@ -8106,15 +8244,16 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
getIndices: function getIndices(indices, d) {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ // eslint-disable-line
+ const $$ = this,
_$$$config = $$.config,
xs = _$$$config.data_xs,
removeNull = _$$$config.bar_indices_removeNull,
id = d.id,
- index = d.index; // eslint-disable-line
+ index = d.index;
if ($$.isBarType(id) && removeNull) {
- var ind = {};
+ const ind = {};
// redefine bar indices order
$$.getAllValuesOnIndex(index, !0).forEach(function (v, i) {
@@ -8145,8 +8284,8 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
}.bind(this)) : indices.__max__;
},
getShapeX: function getShapeX(offset, indices, isSub) {
- var _this5 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
config = $$.config,
scale = $$.scale,
currScale = isSub ? scale.subX : scale.zoom || scale.x,
@@ -8157,18 +8296,19 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
return p + c;
}.bind(this),
halfWidth = isObjectType(offset) && (offset._$total.length ? offset._$total.reduce(sum) / 2 : 0);
+
// total shapes half width
return function (d) {
_newArrowCheck(this, _this5);
- var ind = $$.getIndices(indices, d, "getShapeX"),
+ const ind = $$.getIndices(indices, d, "getShapeX"),
index = d.id in ind ? ind[d.id] : 0,
targetsNum = (ind.__max__ || 0) + 1;
- var x = 0;
+ let x = 0;
if (notEmpty(d.x)) {
- var xPos = currScale(d.x, !0);
+ const xPos = currScale(d.x, !0);
if (halfWidth) {
- var offsetWidth = offset[d.id] || offset._$width;
+ const offsetWidth = offset[d.id] || offset._$width;
x = barOverlap ? xPos - offsetWidth / 2 : xPos - offsetWidth + offset._$total.slice(0, index + 1).reduce(sum) - halfWidth;
} else {
x = xPos - (isNumber(offset) ? offset : offset._$width) * (targetsNum / 2 - (barOverlap ? 1 : index));
@@ -8190,14 +8330,16 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
}.bind(this);
},
getShapeY: function getShapeY(isSub) {
- var _this6 = this,
- $$ = this,
+ var _this6 = this;
+ const $$ = this,
isStackNormalized = $$.isStackNormalized();
return function (d) {
_newArrowCheck(this, _this6);
- var value = d.value;
+ let value = d.value;
if (isNumber(d)) {
value = d;
+ } else if ($$.isAreaRangeType(d)) {
+ value = $$.getBaseValue(d, "mid");
} else if (isStackNormalized) {
value = $$.getRatio("index", d, !0);
} else if ($$.isBubbleZType(d)) {
@@ -8216,7 +8358,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
getShapeYMin: function getShapeYMin(id) {
- var $$ = this,
+ const $$ = this,
axisId = $$.axis.getId(id),
scale = $$.scale[axisId],
_scale$domain = scale.domain(),
@@ -8231,21 +8373,21 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
getShapeOffsetData: function getShapeOffsetData(typeFilter) {
- var _this7 = this,
- $$ = this,
+ var _this7 = this;
+ const $$ = this,
targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))),
isStackNormalized = $$.isStackNormalized(),
shapeOffsetTargets = targets.map(function (target) {
var _this8 = this;
_newArrowCheck(this, _this7);
- var rowValues = target.values,
- values = {};
+ let rowValues = target.values;
+ const values = {};
if ($$.isStepType(target)) {
rowValues = $$.convertValuesToStep(rowValues);
}
- var rowValueMapByXValue = rowValues.reduce(function (out, d) {
+ const rowValueMapByXValue = rowValues.reduce(function (out, d) {
_newArrowCheck(this, _this8);
- var key = +d.x;
+ const key = +d.x;
out[key] = d;
values[key] = isStackNormalized ? $$.getRatio("index", d, !0) : d.value;
return out;
@@ -8258,7 +8400,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
};
}.bind(this)),
indexMapByTargetId = targets.reduce(function (out, _ref, index) {
- var id = _ref.id;
+ let id = _ref.id;
_newArrowCheck(this, _this7);
out[id] = index;
return out;
@@ -8269,8 +8411,8 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
};
},
getShapeOffset: function getShapeOffset(typeFilter, indices, isSub) {
- var _this9 = this,
- $$ = this,
+ var _this9 = this;
+ const $$ = this,
_$$$getShapeOffsetDat = $$.getShapeOffsetData(typeFilter),
shapeOffsetTargets = _$$$getShapeOffsetDat.shapeOffsetTargets,
indexMapByTargetId = _$$$getShapeOffsetDat.indexMapByTargetId,
@@ -8278,7 +8420,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
return function (d, idx) {
var _this10 = this;
_newArrowCheck(this, _this9);
- var id = d.id,
+ const id = d.id,
value = d.value,
x = d.x,
ind = $$.getIndices(indices, d),
@@ -8287,30 +8429,31 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
// TODO use range.getStart()
return scale(value[0]);
}
- var dataXAsNumber = +x,
+ const dataXAsNumber = +x,
y0 = scale(groupsZeroAs === "zero" ? 0 : $$.getShapeYMin(id));
- var offset = y0;
+ let offset = y0;
shapeOffsetTargets.filter(function (t) {
_newArrowCheck(this, _this10);
return t.id !== id && ind[t.id] === ind[id];
}.bind(this)).forEach(function (t) {
_newArrowCheck(this, _this10);
- var tid = t.id,
+ const tid = t.id,
rowValueMapByXValue = t.rowValueMapByXValue,
rowValues = t.rowValues,
tvalues = t.values;
// for same stacked group (ind[tid] === ind[id])
if (indexMapByTargetId[tid] < indexMapByTargetId[id]) {
- var _row,
- rValue = tvalues[dataXAsNumber],
- row = rowValues[idx];
+ var _row;
+ const rValue = tvalues[dataXAsNumber];
+ let row = rowValues[idx];
+
// check if the x values line up
if (!row || +row.x !== dataXAsNumber) {
row = rowValueMapByXValue[dataXAsNumber];
}
if (((_row = row) == null ? void 0 : _row.value) * value >= 0 && isNumber(rValue)) {
- var addOffset = value === 0 ? groupsZeroAs === "positive" && rValue > 0 || groupsZeroAs === "negative" && rValue < 0 : !0;
+ const addOffset = value === 0 ? groupsZeroAs === "positive" && rValue > 0 || groupsZeroAs === "negative" && rValue < 0 : !0;
if (addOffset) {
offset += scale(rValue) - y0;
}
@@ -8320,9 +8463,25 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
return offset;
}.bind(this);
},
+ /**
+ * Get data's y coordinate
+ * @param {object} d Target data
+ * @param {number} i Index number
+ * @returns {number} y coordinate
+ * @private
+ */
+ circleY: function circleY(d, i) {
+ const $$ = this,
+ id = d.id;
+ let points;
+ if ($$.isGrouped(id)) {
+ points = getGroupedDataPointsFn.bind($$)(d);
+ }
+ return points ? points(d, i)[0][1] : $$.getYScaleById(id)($$.getBaseValue(d));
+ },
getBarW: function getBarW(type, axis, targetsNum) {
- var _this11 = this,
- $$ = this,
+ var _this11 = this;
+ const $$ = this,
config = $$.config,
org = $$.org,
scale = $$.scale,
@@ -8338,13 +8497,13 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
}.bind(this)) / maxDataCount : axis.tickInterval(maxDataCount),
getWidth = function (id) {
_newArrowCheck(this, _this11);
- var width = id ? config[configName][id] : config[configName],
+ const width = id ? config[configName][id] : config[configName],
ratio = id ? width.ratio : config[configName + "_ratio"],
max = id ? width.max : config[configName + "_max"],
w = isNumber(width) ? width : targetsNum ? tickInterval * ratio / targetsNum : 0;
return max && w > max ? max : w;
- }.bind(this),
- result = getWidth();
+ }.bind(this);
+ let result = getWidth();
if (!isGrouped && isObjectType(config[configName])) {
result = {
_$width: result,
@@ -8369,11 +8528,12 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
getShapeByIndex: function getShapeByIndex(shapeName, i, id) {
- var _this12 = this,
- $$ = this,
+ var _this12 = this;
+ const $$ = this,
$el = $$.$el,
- suffix = isValue(i) ? "-" + i : "",
- shape = $el[shapeName];
+ suffix = isValue(i) ? "-" + i : "";
+ let shape = $el[shapeName];
+
// filter from shape reference if has
if (shape && !shape.empty()) {
shape = shape.filter(function (d) {
@@ -8389,9 +8549,9 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
return shape;
},
isWithinShape: function isWithinShape(that, d) {
- var $$ = this,
+ const $$ = this,
shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that);
- var isWithin;
+ let isWithin;
if (!$$.isTargetToShow(d.id)) {
isWithin = !1;
} else if ($$.hasValidPointType != null && $$.hasValidPointType(that.nodeName)) {
@@ -8402,7 +8562,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
return isWithin;
},
getInterpolate: function getInterpolate(d) {
- var $$ = this,
+ const $$ = this,
interpolation = $$.getInterpolateType(d);
return {
"basis": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasis,
@@ -8426,14 +8586,14 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
}[interpolation];
},
getInterpolateType: function getInterpolateType(d) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
type = config.spline_interpolation_type,
interpolation = $$.isInterpolationType(type) ? type : "cardinal";
return $$.isSplineType(d) ? interpolation : $$.isStepType(d) ? config.line_step_type : "linear";
},
isWithinBar: function isWithinBar(that) {
- var mouse = getPointer(this.state.event, that),
+ const mouse = getPointer(this.state.event, that),
list = getRectSegList(that),
_list = list,
seg0 = _list[0],
@@ -8463,103 +8623,21 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
setContainerSize: function setContainerSize() {
- var $$ = this,
+ const $$ = this,
state = $$.state;
state.current.width = $$.getCurrentWidth();
state.current.height = $$.getCurrentHeight();
},
getCurrentWidth: function getCurrentWidth() {
- var $$ = this;
+ const $$ = this;
return $$.config.size_width || $$.getParentWidth();
},
getCurrentHeight: function getCurrentHeight() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
h = config.size_height || $$.getParentHeight();
return h > 0 ? h : 320 / ($$.hasType("gauge") && !config.gauge_fullCircle ? 2 : 1);
},
- getCurrentPaddingTop: function getCurrentPaddingTop() {
- var $$ = this,
- config = $$.config,
- hasAxis = $$.state.hasAxis,
- $el = $$.$el,
- axesLen = hasAxis ? config.axis_y2_axes.length : 0;
- var padding = isValue(config.padding_top) ? config.padding_top : 0;
- if ($el.title && $el.title.node()) {
- padding += $$.getTitlePadding();
- }
- if (axesLen && config.axis_rotated) {
- padding += $$.getHorizontalAxisHeight("y2") * axesLen;
- }
- return padding;
- },
- getCurrentPaddingBottom: function getCurrentPaddingBottom() {
- var $$ = this,
- config = $$.config,
- hasAxis = $$.state.hasAxis,
- axisId = config.axis_rotated ? "y" : "x",
- axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
- padding = isValue(config.padding_bottom) ? config.padding_bottom : 0;
- return padding + (axesLen ? $$.getHorizontalAxisHeight(axisId) * axesLen : 0);
- },
- getCurrentPaddingLeft: function getCurrentPaddingLeft(withoutRecompute) {
- var _config$padding,
- $$ = this,
- config = $$.config,
- hasAxis = $$.state.hasAxis,
- isRotated = config.axis_rotated,
- isFitPadding = ((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit",
- axisId = isRotated ? "x" : "y",
- axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
- axisWidth = hasAxis ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : 0;
- if (!isFitPadding) {
- axisWidth = ceil10(axisWidth);
- }
- var padding = config["axis_" + axisId + "_inner"] || !config["axis_" + axisId + "_show"] ? 0 : axisWidth;
- if (isValue(config.padding_left)) {
- padding = config.padding_left + (isFitPadding && isRotated ? axisWidth : 0);
- } else if (hasAxis && isRotated) {
- padding = !config.axis_x_show ? 1 : isFitPadding ? axisWidth : Math.max(axisWidth, 40);
- }
- if (hasAxis && (isFitPadding || config["axis_" + axisId + "_inner"]) && config["axis_" + axisId + "_label"].text) {
- padding += $$.axis.getAxisLabelPosition("y").isOuter ? 20 : 0;
- }
- return padding + axisWidth * axesLen;
- },
- getCurrentPaddingRight: function getCurrentPaddingRight(withXAxisTickTextOverflow) {
- var _config$padding2, _$$$axis;
- if (withXAxisTickTextOverflow === void 0) {
- withXAxisTickTextOverflow = !1;
- }
- var $$ = this,
- config = $$.config,
- hasAxis = $$.state.hasAxis,
- isRotated = config.axis_rotated,
- isFitPadding = ((_config$padding2 = config.padding) == null ? void 0 : _config$padding2.mode) === "fit",
- defaultPadding = isFitPadding ? 2 : 10,
- legendWidthOnRight = $$.state.isLegendRight ? $$.getLegendWidth() + 20 : 0,
- axesLen = hasAxis ? config.axis_y2_axes.length : 0,
- axisLabelWidth = (_$$$axis = $$.axis) != null && _$$$axis.getAxisLabelPosition("y2").isOuter ? 20 : 0,
- xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
- var axisWidth = hasAxis && !config.axis_y2_inner ? $$.getAxisWidthByAxisId("y2") : 1;
- if (!isFitPadding) {
- axisWidth = ceil10(axisWidth);
- }
- var padding = isRotated ? 0 : Math.max(axisWidth + legendWidthOnRight, xAxisTickTextOverflow);
- if (isValue(config.padding_right)) {
- // padding = config.padding_right + (hasAxis ? 1 : 0); // 1 is needed not to hide tick line
-
- padding = config.padding_right + (isFitPadding && (isRotated || !config.axis_y2_show ? defaultPadding : padding)) + (hasAxis && !isFitPadding ? 1 : 0); // 1 is needed not to hide tick line
- } else if ($$.axis && isRotated) {
- padding = defaultPadding + legendWidthOnRight;
- } else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) {
- padding = Math.max((isFitPadding && !config.axis_y2_show ? 2 : 1) + legendWidthOnRight + axisLabelWidth, xAxisTickTextOverflow);
- }
- if (hasAxis && !isRotated && isFitPadding && config.axis_y2_show && !config.axis_y2_inner && config.axis_y2_label.text) {
- padding += axisLabelWidth;
- }
- return padding + axisWidth * axesLen;
- },
/**
* Get the parent rect element's size
* @param {string} key property/attribute name
@@ -8567,8 +8645,8 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
getParentRectValue: function getParentRectValue(key) {
- var offsetName = "offset" + capitalize(key);
- var parent = this.$el.chart.node(),
+ const offsetName = "offset" + capitalize(key);
+ let parent = this.$el.chart.node(),
v = 0;
while (v < 30 && parent && parent.tagName !== "BODY") {
try {
@@ -8585,7 +8663,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
// Sometimes element's dimension value is incorrect(ex. flex container)
// In this case, use body's offset instead.
- var bodySize = browser_doc.body[offsetName];
+ const bodySize = browser_doc.body[offsetName];
v > bodySize && (v = bodySize);
return v;
},
@@ -8593,36 +8671,48 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
return this.getParentRectValue("width");
},
getParentHeight: function getParentHeight() {
- var h = this.$el.chart.style("height");
- var height = 0;
+ const h = this.$el.chart.style("height");
+ let height = 0;
if (h) {
height = /px$/.test(h) ? parseInt(h, 10) : this.getParentRectValue("height");
}
return height;
},
getSvgLeft: function getSvgLeft(withoutRecompute) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
+ hasAxis = $$.state.hasAxis,
$el = $$.$el,
- hasLeftAxisRect = config.axis_rotated || !config.axis_rotated && !config.axis_y_inner,
- leftAxisClass = config.axis_rotated ? $AXIS.axisX : $AXIS.axisY,
+ isRotated = config.axis_rotated,
+ hasLeftAxisRect = isRotated || !isRotated && !config.axis_y_inner,
+ leftAxisClass = isRotated ? $AXIS.axisX : $AXIS.axisY,
leftAxis = $el.main.select("." + leftAxisClass).node(),
- svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : {
+ leftLabel = hasAxis && config["axis_" + (isRotated ? "x" : "y") + "_label"];
+ let labelWidth = 0;
+
+ // if axis label position set to inner, exclude from the value
+ if (hasAxis && (isString(leftLabel) || isString(leftLabel.text) || /^inner-/.test(leftLabel == null ? void 0 : leftLabel.position))) {
+ const label = $el.main.select("." + leftAxisClass + "-label");
+ if (!label.empty()) {
+ labelWidth = label.node().getBoundingClientRect().left;
+ }
+ }
+ const svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : {
right: 0
},
- chartRect = $el.chart.node().getBoundingClientRect(),
+ chartRectLeft = $el.chart.node().getBoundingClientRect().left + labelWidth,
hasArc = $$.hasArcType(),
- svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute));
+ svgLeft = svgRect.right - chartRectLeft - (hasArc ? 0 : $$.getCurrentPaddingByDirection("left", withoutRecompute));
return svgLeft > 0 ? svgLeft : 0;
},
updateDimension: function updateDimension(withoutAxis) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
hasAxis = $$.state.hasAxis,
$el = $$.$el;
if (hasAxis && !withoutAxis && $$.axis.x && config.axis_rotated) {
var _$$$axis$subX;
- (_$$$axis$subX = $$.axis.subX) == null ? void 0 : _$$$axis$subX.create($el.axis.subX);
+ (_$$$axis$subX = $$.axis.subX) == null || _$$$axis$subX.create($el.axis.subX);
}
// pass 'withoutAxis' param to not animate at the init rendering
@@ -8631,7 +8721,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
$$.transformAll(!1);
},
updateSvgSize: function updateSvgSize() {
- var $$ = this,
+ const $$ = this,
_$$$state = $$.state,
clip = _$$$state.clip,
current = _$$$state.current,
@@ -8641,7 +8731,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
svg = $$.$el.svg;
svg.attr("width", current.width).attr("height", current.height);
if (hasAxis) {
- var brush = svg.select("." + $SUBCHART.brush + " .overlay"),
+ const brush = svg.select("." + $SUBCHART.brush + " .overlay"),
brushSize = {
width: 0,
height: 0
@@ -8656,13 +8746,87 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
clip.idSubchart && svg.select("#" + clip.idSubchart).select("rect").attr("width", width).attr("height", brushSize.height);
}
},
- getCurrentPadding: function getCurrentPadding() {
- var $$ = this;
+ /**
+ * Get padding by the direction.
+ * @param {string} type "top" | "bottom" | "left" | "right"
+ * @param {boolean} [withoutRecompute=false] If set true, do not recompute the padding value.
+ * @param {boolean} [withXAxisTickTextOverflow=false] If set true, calculate x axis tick text overflow.
+ * @returns {number} padding value
+ * @private
+ */
+ getCurrentPaddingByDirection: function getCurrentPaddingByDirection(type, withoutRecompute, withXAxisTickTextOverflow) {
+ var _config$padding;
+ if (withoutRecompute === void 0) {
+ withoutRecompute = !1;
+ }
+ if (withXAxisTickTextOverflow === void 0) {
+ withXAxisTickTextOverflow = !1;
+ }
+ const $$ = this,
+ config = $$.config,
+ $el = $$.$el,
+ hasAxis = $$.state.hasAxis,
+ isRotated = config.axis_rotated,
+ isFitPadding = ((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit",
+ paddingOption = isNumber(config["padding_" + type]) ? config["padding_" + type] : undefined,
+ axisId = hasAxis ? {
+ top: isRotated ? "y2" : null,
+ bottom: isRotated ? "y" : "x",
+ left: isRotated ? "x" : "y",
+ right: isRotated ? null : "y2"
+ }[type] : null,
+ isLeftRight = /^(left|right)$/.test(type),
+ isAxisInner = axisId && config["axis_" + axisId + "_inner"],
+ isAxisShow = axisId && config["axis_" + axisId + "_show"],
+ axesLen = axisId ? config["axis_" + axisId + "_axes"].length : 0;
+ let axisSize = axisId ? isLeftRight ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : $$.getHorizontalAxisHeight(axisId) : 0;
+ const defaultPadding = 20;
+ let gap = 0;
+ if (!isFitPadding && isLeftRight) {
+ axisSize = ceil10(axisSize);
+ }
+ let padding = hasAxis && isLeftRight && (isAxisInner || isUndefined(paddingOption) && !isAxisShow) ? 0 : isFitPadding ? (isAxisShow ? axisSize : 0) + (paddingOption != null ? paddingOption : 0) : isUndefined(paddingOption) ? axisSize : paddingOption;
+ if (isLeftRight && hasAxis) {
+ if (axisId && (isFitPadding || isAxisInner) && config["axis_" + axisId + "_label"].text) {
+ padding += $$.axis.getAxisLabelPosition(axisId).isOuter ? defaultPadding : 0;
+ }
+ if (type === "right") {
+ padding += isRotated ? !isFitPadding && isUndefined(paddingOption) ? 10 : 2 : !isAxisShow || isAxisInner ? isFitPadding ? 2 : 1 : 0;
+ padding += withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
+ } else if (type === "left" && isRotated && isUndefined(paddingOption)) {
+ padding = !config.axis_x_show ? 1 : isFitPadding ? axisSize : Math.max(axisSize, 40);
+ }
+ } else {
+ if (type === "top") {
+ if ($el.title && $el.title.node()) {
+ padding += $$.getTitlePadding();
+ }
+ gap = isRotated && !isAxisInner ? axesLen : 0;
+ } else if (type === "bottom" && hasAxis && isRotated && !isAxisShow) {
+ padding += 1;
+ }
+ }
+ return padding + axisSize * axesLen - gap;
+ },
+ getCurrentPadding: function getCurrentPadding(withXAxisTickTextOverflow) {
+ var _this = this;
+ if (withXAxisTickTextOverflow === void 0) {
+ withXAxisTickTextOverflow = !1;
+ }
+ const $$ = this,
+ _map = ["top", "bottom", "left", "right"].map(function (v) {
+ _newArrowCheck(this, _this);
+ return $$.getCurrentPaddingByDirection(v, null, withXAxisTickTextOverflow);
+ }.bind(this)),
+ top = _map[0],
+ bottom = _map[1],
+ left = _map[2],
+ right = _map[3];
return {
- top: $$.getCurrentPaddingTop(),
- bottom: $$.getCurrentPaddingBottom(),
- left: $$.getCurrentPaddingLeft(),
- right: $$.getCurrentPaddingRight()
+ top: top,
+ bottom: bottom,
+ left: left,
+ right: right
};
},
/**
@@ -8673,14 +8837,14 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
getResettedPadding: function getResettedPadding(v) {
- var _this = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
- isNum = isNumber(v),
- p = isNum ? 0 : {};
+ isNum = isNumber(v);
+ let p = isNum ? 0 : {};
if (config.padding === !1) {
isNum || Object.keys(v).forEach(function (key) {
- _newArrowCheck(this, _this);
+ _newArrowCheck(this, _this2);
// when data.lables=true, do not reset top padding
p[key] = !isEmpty(config.data_labels) && config.data_labels !== !1 && key === "top" ? v[key] : 0;
}.bind(this));
@@ -8695,39 +8859,42 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
updateSizes: function updateSizes(isInit) {
- var _config$padding3,
- $$ = this,
+ var _config$padding2;
+ const $$ = this,
config = $$.config,
state = $$.state,
legend = $$.$el.legend,
isRotated = config.axis_rotated,
isNonAxis = $$.hasArcType() || state.hasTreemap,
- isFitPadding = ((_config$padding3 = config.padding) == null ? void 0 : _config$padding3.mode) === "fit";
+ isFitPadding = ((_config$padding2 = config.padding) == null ? void 0 : _config$padding2.mode) === "fit";
isInit || $$.setContainerSize();
- var currLegend = {
+ const currLegend = {
width: legend ? $$.getLegendWidth() : 0,
height: legend ? $$.getLegendHeight() : 0
};
if (!isNonAxis && config.axis_x_show && config.axis_x_tick_autorotate) {
$$.updateXAxisTickClip();
}
- var legendHeightForBottom = state.isLegendRight || state.isLegendInset ? 0 : currLegend.height,
+ const legendSize = {
+ right: config.legend_show && state.isLegendRight ? $$.getLegendWidth() + (isFitPadding ? 0 : 20) : 0,
+ bottom: !config.legend_show || state.isLegendRight || state.isLegendInset ? 0 : currLegend.height
+ },
xAxisHeight = isRotated || isNonAxis ? 0 : $$.getHorizontalAxisHeight("x"),
subchartXAxisHeight = config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ? xAxisHeight : 30,
subchartHeight = config.subchart_show && !isNonAxis ? config.subchart_size_height + subchartXAxisHeight : 0,
gaugeHeight = $$.hasType("gauge") && config.arc_needle_show && !config.gauge_fullCircle && !config.gauge_label_show ? 10 : 0,
- padding = $$.getCurrentPadding(); // when needle is shown with legend, it need some bottom space to not overlap with legend text
+ padding = $$.getCurrentPadding(!0); // when needle is shown with legend, it need some bottom space to not overlap with legend text
// for main
state.margin = !isNonAxis && isRotated ? {
- top: $$.getHorizontalAxisHeight("y2") + padding.top,
- right: isNonAxis ? 0 : $$.getCurrentPaddingRight(!0),
- bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + padding.bottom,
+ top: padding.top,
+ right: isNonAxis ? 0 : padding.right + legendSize.right,
+ bottom: legendSize.bottom + padding.bottom,
left: subchartHeight + (isNonAxis ? 0 : padding.left)
} : {
top: (isFitPadding ? 0 : 4) + padding.top,
// for top tick text
- right: isNonAxis ? 0 : $$.getCurrentPaddingRight(!0),
- bottom: gaugeHeight + xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
+ right: isNonAxis ? 0 : padding.right + legendSize.right,
+ bottom: gaugeHeight + subchartHeight + legendSize.bottom + padding.bottom,
left: isNonAxis ? 0 : padding.left
};
state.margin = $$.getResettedPadding(state.margin);
@@ -8736,12 +8903,12 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
state.margin2 = isRotated ? {
top: state.margin.top,
right: NaN,
- bottom: 20 + legendHeightForBottom,
+ bottom: 20 + legendSize.bottom,
left: $$.state.rotatedPadding.left
} : {
- top: state.current.height - subchartHeight - legendHeightForBottom,
+ top: state.current.height - subchartHeight - legendSize.bottom,
right: NaN,
- bottom: subchartXAxisHeight + legendHeightForBottom,
+ bottom: subchartXAxisHeight + legendSize.bottom,
left: state.margin.left
};
@@ -8752,7 +8919,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
bottom: 0,
left: 0
};
- $$.updateSizeForLegend == null ? void 0 : $$.updateSizeForLegend(currLegend);
+ $$.updateSizeForLegend == null || $$.updateSizeForLegend(currLegend);
state.width = state.current.width - state.margin.left - state.margin.right;
state.height = state.current.height - state.margin.top - state.margin.bottom;
if (state.width < 0) {
@@ -8772,14 +8939,14 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
// for arc
if ($$.hasArcType()) {
- var hasGauge = $$.hasType("gauge"),
+ const hasGauge = $$.hasType("gauge"),
isLegendRight = config.legend_show && state.isLegendRight;
state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0);
state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10);
if (hasGauge && !config.gauge_fullCircle) {
state.arcHeight += state.height - $$.getPaddingBottomForGauge();
}
- $$.updateRadius == null ? void 0 : $$.updateRadius();
+ $$.updateRadius == null || $$.updateRadius();
}
if (state.isLegendRight && isNonAxis) {
state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1;
@@ -8805,8 +8972,8 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
setCssRule: function setCssRule(withShape, selector, props, propsFn) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
_$$$state = $$.state,
cssRule = _$$$state.cssRule,
@@ -8817,7 +8984,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
selection.each(function (d) {
var _this3 = this;
_newArrowCheck(this, _this2);
- var res = propsFn && (propsFn == null ? void 0 : propsFn.call($$, d)),
+ const res = propsFn && (propsFn == null ? void 0 : propsFn.call($$, d)),
shapeSelector = "" + (withShape ? "." + ($SHAPE.shapes + $$.getTargetSelectorSuffix(d.id)) : "") + selector;
selector in cssRule && style.sheet.deleteRule(cssRule[shapeSelector]);
$$.state.cssRule[shapeSelector] = addCssRules(style, shapeSelector, props.filter(Boolean).map(function (v) {
@@ -8836,7 +9003,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
getStylePropValue: function getStylePropValue(v) {
- var useCssRule = this.config.boost_useCssRule;
+ const useCssRule = this.config.boost_useCssRule;
return useCssRule ? null : isFunction(v) ? v.bind(this) : v;
}
});
@@ -8857,7 +9024,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
* @private
*/
function getRotateAnchor(angle) {
- var anchor = "middle";
+ let anchor = "middle";
if (angle > 0 && angle <= 170) {
anchor = "end";
} else if (angle > 190 && angle <= 360) {
@@ -8879,33 +9046,34 @@ function getRotateAnchor(angle) {
* @private
*/
function setRotatePos(d, pos, anchor, isRotated, isInverted) {
- var _$$$getCandlestickDat,
- $$ = this,
+ var _$$$getCandlestickDat;
+ const $$ = this,
value = d.value,
isCandlestickType = $$.isCandlestickType(d),
- isNegative = isNumber(value) && value < 0 || isCandlestickType && !((_$$$getCandlestickDat = $$.getCandlestickData(d)) != null && _$$$getCandlestickDat._isUp),
- x = pos.x,
- y = pos.y,
+ isNegative = isNumber(value) && value < 0 || isCandlestickType && !((_$$$getCandlestickDat = $$.getCandlestickData(d)) != null && _$$$getCandlestickDat._isUp);
+ let x = pos.x,
+ y = pos.y;
+ const gap = 4,
doubleGap = 8;
if (isRotated) {
if (anchor === "start") {
x += isNegative ? 0 : doubleGap;
- y += 4;
+ y += gap;
} else if (anchor === "middle") {
x += doubleGap;
y -= doubleGap;
} else if (anchor === "end") {
isNegative && (x -= doubleGap);
- y += 4;
+ y += gap;
}
} else {
if (anchor === "start") {
- x += 4;
+ x += gap;
isNegative && (y += doubleGap * 2);
} else if (anchor === "middle") {
y -= doubleGap;
} else if (anchor === "end") {
- x -= 4;
+ x -= gap;
isNegative && (y += doubleGap * 2);
}
if (isInverted) {
@@ -8926,8 +9094,8 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
* @private
*/
function getTextPos(d, type) {
- var _ref,
- position = this.config.data_labels_position,
+ var _ref;
+ const position = this.config.data_labels_position,
id = d.id,
index = d.index,
value = d.value;
@@ -8935,7 +9103,7 @@ function getTextPos(d, type) {
}
/* harmony default export */ var internals_text = ({
opacityForText: function opacityForText(d) {
- var $$ = this;
+ const $$ = this;
return $$.isBarType(d) && !$$.meetsLabelThreshold(Math.abs($$.getRatio("bar", d)), "bar") ? "0" : $$.hasDataLabel ? null : "0";
},
/**
@@ -8943,7 +9111,7 @@ function getTextPos(d, type) {
* @private
*/
initText: function initText() {
- var $el = this.$el;
+ const $el = this.$el;
$el.main.select("." + $COMMON.chart).append("g").attr("class", $TEXT.chartTexts).style("pointer-events", $el.treemap ? "none" : null);
},
/**
@@ -8952,8 +9120,8 @@ function getTextPos(d, type) {
* @private
*/
updateTargetsForText: function updateTargetsForText(targets) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
classChartText = $$.getChartClass("Text"),
classTexts = $$.getClass("texts", "id"),
classFocus = $$.classFocus.bind($$),
@@ -8969,8 +9137,8 @@ function getTextPos(d, type) {
* @private
*/
updateText: function updateText() {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
$el = $$.$el,
$T = $$.$T,
config = $$.config,
@@ -8981,29 +9149,29 @@ function getTextPos(d, type) {
$T(text.exit()).style("fill-opacity", "0").remove();
$el.text = text.enter().append("text").merge(text).attr("class", classText).attr("text-anchor", function (d) {
_newArrowCheck(this, _this2);
- var isInverted = config["axis_" + (axis == null ? void 0 : axis.getId(d.id)) + "_inverted"];
+ const isInverted = config["axis_" + (axis == null ? void 0 : axis.getId(d.id)) + "_inverted"];
// when value is negative or
- var isEndAnchor = isInverted ? d.value > 0 : d.value < 0;
+ let isEndAnchor = isInverted ? d.value > 0 : d.value < 0;
if ($$.isCandlestickType(d)) {
- var data = $$.getCandlestickData(d);
+ const data = $$.getCandlestickData(d);
isEndAnchor = !(data != null && data._isUp);
} else if ($$.isTreemapType(d)) {
return labelsCentered ? "middle" : "start";
}
return config.axis_rotated ? isEndAnchor ? "end" : "start" : "middle";
}.bind(this)).style("fill", $$.getStylePropValue($$.updateTextColor)).style("fill-opacity", "0").each(function (d, i, texts) {
- var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
- var value = d.value;
+ const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
+ let value = d.value;
if ($$.isBubbleZType(d)) {
value = $$.getBubbleZData(value, "z");
} else if ($$.isCandlestickType(d)) {
- var data = $$.getCandlestickData(d);
+ const data = $$.getCandlestickData(d);
if (data) {
value = data.close;
}
}
- value = $$.isTreemapType(d) ? $$.treemapDataLabelFormat(d)(node) : $$.dataLabelFormat(d.id)(value, d.id, i, texts);
+ value = $$.isTreemapType(d) ? $$.treemapDataLabelFormat(d)(node) : $$.dataLabelFormat(d.id)(value, d.id, d.index, texts);
if (isNumber(value)) {
this.textContent = value;
} else {
@@ -9012,24 +9180,24 @@ function getTextPos(d, type) {
});
},
updateTextColor: function updateTextColor(d) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
labelColors = config.data_labels_colors,
defaultColor = $$.isArcType(d) && !$$.isRadarType(d) || $$.isTreemapType(d) ? null : $$.color(d);
- var color;
+ let color;
if (isString(labelColors)) {
color = labelColors;
} else if (isObject(labelColors)) {
- var _ref2 = d.data || d,
+ const _ref2 = d.data || d,
id = _ref2.id;
color = labelColors[id];
} else if (isFunction(labelColors)) {
color = labelColors.bind($$.api)(defaultColor, d);
}
if ($$.isCandlestickType(d) && !isFunction(labelColors)) {
- var value = $$.getCandlestickData(d);
+ const value = $$.getCandlestickData(d);
if (!(value != null && value._isUp)) {
- var downColor = config.candlestick_color_down;
+ const downColor = config.candlestick_color_down;
color = isObject(downColor) ? downColor[d.id] : downColor;
}
}
@@ -9041,14 +9209,14 @@ function getTextPos(d, type) {
* @returns {string|null}
* @private
*/
- updateTextBacgroundColor: function updateTextBacgroundColor(d) {
- var $$ = this,
+ updateTextBackgroundColor: function updateTextBackgroundColor(d) {
+ const $$ = this,
$el = $$.$el,
config = $$.config,
backgroundColor = config.data_labels_backgroundColors;
- var color = "";
+ let color = "";
if (isString(backgroundColor) || isObject(backgroundColor)) {
- var id = isString(backgroundColor) ? "" : $$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id),
+ const id = isString(backgroundColor) ? "" : $$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id),
filter = $el.defs.select(["filter[id*='labels-bg", "']"].join(id));
if (filter.size()) {
color = "url(#" + filter.attr("id") + ")";
@@ -9066,7 +9234,7 @@ function getTextPos(d, type) {
* @private
*/
redrawText: function redrawText(getX, getY, forFlow, withTransition) {
- var $$ = this,
+ const $$ = this,
$T = $$.$T,
axis = $$.axis,
config = $$.config,
@@ -9076,13 +9244,11 @@ function getTextPos(d, type) {
angle = config.data_labels.rotate,
anchorString = getRotateAnchor(angle),
rotateString = angle ? "rotate(" + angle + ")" : "";
- // $$.meetsLabelThreshold(ratio,
-
- $$.$el.text.style("fill", $$.getStylePropValue($$.updateTextColor)).attr("filter", $$.updateTextBacgroundColor.bind($$)).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function (d, i) {
+ $$.$el.text.style("fill", $$.getStylePropValue($$.updateTextColor)).attr("filter", $$.updateTextBackgroundColor.bind($$)).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function (d, i) {
// do not apply transition for newly added text elements
- var node = $T(hasTreemap && this.childElementCount ? this.parentNode : this, !!(withTransition && this.getAttribute("x")), t),
+ const node = $T(hasTreemap && this.childElementCount ? this.parentNode : this, !!(withTransition && this.getAttribute("x")), t),
isInverted = config["axis_" + (axis == null ? void 0 : axis.getId(d.id)) + "_inverted"];
- var pos = {
+ let pos = {
x: getX.bind(this)(d, i),
y: getY.bind(this)(d, i)
};
@@ -9111,15 +9277,15 @@ function getTextPos(d, type) {
* @private
*/
getTextRect: function getTextRect(element, className) {
- var _this3 = this,
- $$ = this,
- base = element.node ? element.node() : element;
+ var _this3 = this;
+ const $$ = this;
+ let base = element.node ? element.node() : element;
if (!/text/i.test(base.tagName)) {
base = base.querySelector("text");
}
- var text = base.textContent,
+ const text = base.textContent,
cacheKey = KEY.textRect + "-" + text.replace(/\W/g, "_");
- var rect = $$.cache.get(cacheKey);
+ let rect = $$.cache.get(cacheKey);
if (!rect) {
$$.$el.svg.append("text").style("visibility", "hidden").style("font", (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(base).style("font")).classed(className, !0).text(text).call(function (v) {
_newArrowCheck(this, _this3);
@@ -9137,8 +9303,8 @@ function getTextPos(d, type) {
* @private
*/
generateXYForText: function generateXYForText(indices, forX) {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
_$$$state = $$.state,
hasRadar = _$$$state.hasRadar,
hasTreemap = _$$$state.hasTreemap,
@@ -9152,7 +9318,7 @@ function getTextPos(d, type) {
points[v] = $$["generateGet" + capitalize(v) + "Points"](indices[v], !1);
}.bind(this));
return function (d, i) {
- var type = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar" || $$.isCandlestickType(d) && "candlestick" || $$.isRadarType(d) && "radar" || $$.isTreemapType(d) && "treemap" || "line";
+ const type = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar" || $$.isCandlestickType(d) && "candlestick" || $$.isRadarType(d) && "radar" || $$.isTreemapType(d) && "treemap" || "line";
return getter.call($$, points[type](d, i), d, this);
};
},
@@ -9166,20 +9332,20 @@ function getTextPos(d, type) {
* @private
*/
getCenteredTextPos: function getCenteredTextPos(d, points, textElement, type) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
isRotated = config.axis_rotated,
isBarType = $$.isBarType(d),
isTreemapType = $$.isTreemapType(d);
if (config.data_labels.centered && (isBarType || isTreemapType)) {
- var rect = getBoundingRect(textElement);
+ const rect = getBoundingRect(textElement);
if (isBarType) {
- var isPositive = d.value >= 0;
+ const isPositive = $$.getRangedData(d, null, "bar") >= 0;
if (isRotated) {
- var w = (isPositive ? points[1][1] - points[0][1] : points[0][1] - points[1][1]) / 2 + rect.width / 2;
+ const w = (isPositive ? points[1][1] - points[0][1] : points[0][1] - points[1][1]) / 2 + rect.width / 2;
return isPositive ? -w - 3 : w + 2;
} else {
- var h = (isPositive ? points[0][1] - points[1][1] : points[1][1] - points[0][1]) / 2 + rect.height / 2;
+ const h = (isPositive ? points[0][1] - points[1][1] : points[1][1] - points[0][1]) / 2 + rect.height / 2;
return isPositive ? h : -h - 2;
}
} else if (isTreemapType) {
@@ -9197,12 +9363,11 @@ function getTextPos(d, type) {
* @private
*/
getXForText: function getXForText(points, d, textElement) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
- state = $$.state,
isRotated = config.axis_rotated,
isTreemapType = $$.isTreemapType(d);
- var xPos = points[0][0];
+ let xPos = points[0][0];
if ($$.isCandlestickType(d)) {
if (isRotated) {
var _$$$getCandlestickDat2;
@@ -9214,7 +9379,7 @@ function getTextPos(d, type) {
xPos += config.data_labels.centered ? 0 : 5;
} else {
if (isRotated) {
- var isInverted = config["axis_" + $$.axis.getId(d.id) + "_inverted"],
+ const isInverted = config["axis_" + $$.axis.getId(d.id) + "_inverted"],
padding = $$.isBarType(d) ? 4 : 6,
value = d.value;
xPos = points[2][1];
@@ -9227,17 +9392,6 @@ function getTextPos(d, type) {
xPos = $$.hasType("bar") ? (points[2][0] + points[0][0]) / 2 : xPos;
}
}
-
- // show labels regardless of the domain if value is null
- if (d.value === null) {
- if (xPos > state.width) {
- var _getBoundingRect = getBoundingRect(textElement),
- width = _getBoundingRect.width;
- xPos = state.width - width;
- } else if (xPos < 0) {
- xPos = 4;
- }
- }
if (isRotated || isTreemapType) {
xPos += $$.getCenteredTextPos(d, points, textElement, "x");
}
@@ -9252,7 +9406,7 @@ function getTextPos(d, type) {
* @private
*/
getYForText: function getYForText(points, d, textElement) {
- var $$ = this,
+ const $$ = this,
axis = $$.axis,
config = $$.config,
state = $$.state,
@@ -9262,7 +9416,7 @@ function getTextPos(d, type) {
isTreemapType = $$.isTreemapType(d),
r = config.point_r,
rect = getBoundingRect(textElement);
- var value = d.value,
+ let value = d.value,
baseY = 3,
yPos;
if ($$.isCandlestickType(d)) {
@@ -9289,7 +9443,7 @@ function getTextPos(d, type) {
if (value < 0 || value === 0 && !state.hasPositiveValue && state.hasNegativeValue) {
yPos += isInverted ? isBarType ? -3 : -5 : rect.height + (isBarType ? -baseY : baseY);
} else {
- var diff = -baseY * 2;
+ let diff = -baseY * 2;
if (isBarType) {
diff = -baseY;
} else if ($$.isBubbleType(d)) {
@@ -9302,16 +9456,6 @@ function getTextPos(d, type) {
}
}
}
-
- // show labels regardless of the domain if value is null
- if (d.value === null && !isRotated) {
- var boxHeight = rect.height;
- if (yPos < boxHeight) {
- yPos = boxHeight;
- } else if (yPos > state.height) {
- yPos = state.height - 4;
- }
- }
if (!isRotated || isTreemapType) {
yPos += $$.getCenteredTextPos(d, points, textElement, "y");
}
@@ -9326,8 +9470,8 @@ function getTextPos(d, type) {
* @private
*/
markOverlapped: function markOverlapped(id, $$, selector) {
- var _this5 = this,
- textNodes = $$.$el.arcs.selectAll(selector),
+ var _this5 = this;
+ const textNodes = $$.$el.arcs.selectAll(selector),
filteredTextNodes = textNodes.filter(function (node) {
_newArrowCheck(this, _this5);
return node.data.id !== id;
@@ -9340,11 +9484,9 @@ function getTextPos(d, type) {
calcHypo = function (x, y) {
_newArrowCheck(this, _this5);
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
- }.bind(this);
- // Calculates the length of the hypotenuse
-
+ }.bind(this); // Calculates the length of the hypotenuse
textNode.node() && filteredTextNodes.each(function () {
- var coordinate = getTranslation(this),
+ const coordinate = getTranslation(this),
filteredTextNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : filteredTextNode,
overlapsX = Math.ceil(Math.abs(translate.e - coordinate.e)) < Math.ceil(nodeForWidth.node().getComputedTextLength()),
@@ -9375,7 +9517,7 @@ function getTextPos(d, type) {
if (ratio === void 0) {
ratio = 0;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
threshold = config[type + "_label_threshold"] || 0;
return ratio >= threshold;
@@ -9396,12 +9538,12 @@ function getTextPos(d, type) {
* @returns {string|number} text-anchor value or position in pixel
* @private
*/
-function title_getTextPos(pos, width) {
+function getTextXPos(pos, width) {
if (pos === void 0) {
pos = "left";
}
- var isNum = isNumber(width);
- var position;
+ const isNum = isNumber(width);
+ let position;
if (pos.indexOf("center") > -1) {
position = isNum ? width / 2 : "middle";
} else if (pos.indexOf("right") > -1) {
@@ -9417,12 +9559,12 @@ function title_getTextPos(pos, width) {
* @private
*/
initTitle: function initTitle() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
$el = $$.$el;
if (config.title_text) {
$el.title = $el.svg.append("g");
- var text = $el.title.append("text").style("text-anchor", title_getTextPos(config.title_position)).attr("class", $TEXT.title);
+ const text = $el.title.append("text").style("text-anchor", getTextXPos(config.title_position)).attr("class", $TEXT.title);
setTextValue(text, config.title_text, [.3, 1.5]);
}
},
@@ -9431,61 +9573,26 @@ function title_getTextPos(pos, width) {
* @private
*/
redrawTitle: function redrawTitle() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
current = $$.state.current,
title = $$.$el.title;
if (title) {
- var y = $$.yForTitle.call($$);
- if (/g/i.test(title.node().tagName)) {
- title.attr("transform", "translate(" + title_getTextPos(config.title_position, current.width) + ", " + y + ")");
- } else {
- title.attr("x", $$.xForTitle.call($$)).attr("y", y);
- }
+ const x = getTextXPos(config.title_position, current.width),
+ y = (config.title_padding.top || 0) + $$.getTextRect($$.$el.title, $TEXT.title).height;
+ title.attr("transform", "translate(" + x + ", " + y + ")");
}
},
- /**
- * Returns the x attribute value of the title
- * @returns {number} x attribute value
- * @private
- */
- xForTitle: function xForTitle() {
- var $$ = this,
- config = $$.config,
- current = $$.state.current,
- position = config.title_position || "left",
- textRectWidth = $$.getTextRect($$.$el.title, $TEXT.title).width;
- var x;
- if (/(right|center)/.test(position)) {
- x = current.width - textRectWidth;
- if (position.indexOf("right") >= 0) {
- x = current.width - textRectWidth - config.title_padding.right;
- } else if (position.indexOf("center") >= 0) {
- x = (current.width - textRectWidth) / 2;
- }
- } else {
- // left
- x = config.title_padding.left || 0;
- }
- return x;
- },
- /**
- * Returns the y attribute value of the title
- * @returns {number} y attribute value
- * @private
- */
- yForTitle: function yForTitle() {
- var $$ = this;
- return ($$.config.title_padding.top || 0) + $$.getTextRect($$.$el.title, $TEXT.title).height;
- },
/**
* Get title padding
* @returns {number} padding value
* @private
*/
getTitlePadding: function getTitlePadding() {
- var $$ = this;
- return $$.yForTitle() + ($$.config.title_padding.bottom || 0);
+ const $$ = this,
+ $el = $$.$el,
+ config = $$.config;
+ return (config.title_padding.top || 0) + $$.getTextRect($el.title, $TEXT.title).height + (config.title_padding.bottom || 0);
}
});
;// CONCATENATED MODULE: ./src/ChartInternal/internals/tooltip.ts
@@ -9504,7 +9611,7 @@ function title_getTextPos(pos, width) {
* @private
*/
initTooltip: function initTooltip() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
$el = $$.$el;
$el.tooltip = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.tooltip_contents.bindto);
@@ -9513,9 +9620,13 @@ function title_getTextPos(pos, width) {
}
$$.bindTooltipResizePos();
},
+ /**
+ * Show tooltip at initialization.
+ * Is called only when tooltip.init.show=true option is set
+ * @private
+ */
initShowTooltip: function initShowTooltip() {
- var _this = this,
- $$ = this,
+ const $$ = this,
config = $$.config,
$el = $$.$el,
_$$$state = $$.state,
@@ -9523,31 +9634,20 @@ function title_getTextPos(pos, width) {
hasRadar = _$$$state.hasRadar;
// Show tooltip if needed
if (config.tooltip_init_show) {
- var _$$$axis,
- _$$$axis2,
- isArc = !(hasAxis && hasRadar);
+ var _$$$axis, _data;
if ((_$$$axis = $$.axis) != null && _$$$axis.isTimeSeries() && isString(config.tooltip_init_x)) {
- var targets = $$.data.targets[0];
- var i, val;
config.tooltip_init_x = parseDate.call($$, config.tooltip_init_x);
- for (i = 0; val = targets.values[i]; i++) {
- if (val.x - config.tooltip_init_x === 0) {
- break;
- }
- }
- config.tooltip_init_x = i;
}
- var data = $$.data.targets.map(function (d) {
- _newArrowCheck(this, _this);
- var x = isArc ? 0 : config.tooltip_init_x;
- return $$.addName(d.values[x]);
- }.bind(this));
- if (isArc) {
- data = [data[config.tooltip_init_x]];
- }
- $el.tooltip.html($$.getTooltipHTML(data, (_$$$axis2 = $$.axis) == null ? void 0 : _$$$axis2.getXAxisTickFormat(), $$.getDefaultValueFormat(), $$.color));
- if (!config.tooltip_contents.bindto) {
- $el.tooltip.style("top", config.tooltip_init_position.top).style("left", config.tooltip_init_position.left).style("display", null);
+ $$.api.tooltip.show({
+ data: (_data = {}, _data[!(hasAxis || hasRadar) ? "index" : "x"] = config.tooltip_init_x, _data)
+ });
+ const position = config.tooltip_init_position;
+ if (!config.tooltip_contents.bindto && !isEmpty(position)) {
+ const _position$top = position.top,
+ top = _position$top === void 0 ? 0 : _position$top,
+ _position$left = position.left,
+ left = _position$left === void 0 ? 50 : _position$left;
+ $el.tooltip.style("top", isString(top) ? top : top + "px").style("left", isString(left) ? left : left + "px").style("display", null);
}
}
},
@@ -9558,7 +9658,7 @@ function title_getTextPos(pos, width) {
* @private
*/
getTooltipHTML: function getTooltipHTML() {
- var $$ = this,
+ const $$ = this,
api = $$.api,
config = $$.config;
return isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api).apply(void 0, arguments) : $$.getTooltipContent.apply($$, arguments);
@@ -9572,54 +9672,71 @@ function title_getTextPos(pos, width) {
* @returns {string} html
* @private
*/
- getTooltipContent: function getTooltipContent(d, defaultTitleFormat, defaultValueFormat, _color) {
- var _this2 = this,
- $$ = this,
+ getTooltipContent: function getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) {
+ var _this = this;
+ const $$ = this,
api = $$.api,
config = $$.config,
state = $$.state,
$el = $$.$el,
_map = ["title", "name", "value"].map(function (v) {
- _newArrowCheck(this, _this2);
- var fn = config["tooltip_format_" + v];
+ _newArrowCheck(this, _this);
+ const fn = config["tooltip_format_" + v];
return isFunction(fn) ? fn.bind(api) : fn;
}.bind(this)),
- titleFormat = _map[0],
- nameFormat = _map[1],
- valueFormat = _map[2];
- titleFormat = titleFormat || defaultTitleFormat;
- nameFormat = nameFormat || function (name) {
- _newArrowCheck(this, _this2);
- return name;
- }.bind(this);
- valueFormat = valueFormat || (state.hasTreemap || $$.isStackNormalized() ? function (v, ratio) {
- _newArrowCheck(this, _this2);
- return (ratio * 100).toFixed(2) + "%";
- }.bind(this) : defaultValueFormat);
- var order = config.tooltip_order,
+ titleFn = _map[0],
+ nameFn = _map[1],
+ valueFn = _map[2],
+ titleFormat = function () {
+ _newArrowCheck(this, _this);
+ return sanitize((titleFn || defaultTitleFormat).apply(void 0, arguments));
+ }.bind(this),
+ nameFormat = function () {
+ var _this2 = this;
+ _newArrowCheck(this, _this);
+ return sanitize((nameFn || function (name) {
+ _newArrowCheck(this, _this2);
+ return name;
+ }.bind(this)).apply(void 0, arguments));
+ }.bind(this),
+ valueFormat = function () {
+ var _this3 = this;
+ _newArrowCheck(this, _this);
+ const fn = valueFn || (state.hasTreemap || $$.isStackNormalized() ? function (v, ratio) {
+ _newArrowCheck(this, _this3);
+ return (ratio * 100).toFixed(2) + "%";
+ }.bind(this) : defaultValueFormat);
+ return sanitize(fn.apply(void 0, arguments));
+ }.bind(this),
+ order = config.tooltip_order,
getRowValue = function (row) {
- _newArrowCheck(this, _this2);
+ _newArrowCheck(this, _this);
return $$.axis && $$.isBubbleZType(row) ? $$.getBubbleZData(row.value, "z") : $$.getBaseValue(row);
}.bind(this),
getBgColor = $$.levelColor ? function (row) {
- _newArrowCheck(this, _this2);
+ _newArrowCheck(this, _this);
return $$.levelColor(row.value);
}.bind(this) : function (row) {
- _newArrowCheck(this, _this2);
- return _color(row);
+ _newArrowCheck(this, _this);
+ return color(row);
}.bind(this),
contents = config.tooltip_contents,
tplStr = contents.template,
targetIds = $$.mapToTargetIds();
+
+ // get formatter function
+
+ // determine fotmatter function with sanitization
+
if (order === null && config.data_groups.length) {
// for stacked data, order should aligned with the visually displayed data
- var ids = $$.orderTargets($$.data.targets).map(function (i2) {
- _newArrowCheck(this, _this2);
+ const ids = $$.orderTargets($$.data.targets).map(function (i2) {
+ _newArrowCheck(this, _this);
return i2.id;
}.bind(this)).reverse();
d.sort(function (a, b) {
- _newArrowCheck(this, _this2);
- var v1 = a ? a.value : null,
+ _newArrowCheck(this, _this);
+ let v1 = a ? a.value : null,
v2 = b ? b.value : null;
if (v1 > 0 && v2 > 0) {
v1 = a.id ? ids.indexOf(a.id) : null;
@@ -9629,25 +9746,24 @@ function title_getTextPos(pos, width) {
}.bind(this));
} else if (/^(asc|desc)$/.test(order)) {
d.sort(function (a, b) {
- _newArrowCheck(this, _this2);
- var v1 = a ? getRowValue(a) : null,
+ _newArrowCheck(this, _this);
+ const v1 = a ? getRowValue(a) : null,
v2 = b ? getRowValue(b) : null;
return order === "asc" ? v1 - v2 : v2 - v1;
}.bind(this));
} else if (isFunction(order)) {
d.sort(order.bind(api));
}
- var tpl = $$.getTooltipContentTemplate(tplStr),
+ const tpl = $$.getTooltipContentTemplate(tplStr),
len = d.length;
- var text, row, param, value, i;
- var _loop = function () {
- var _this3 = this;
+ let text, row, param, value, i;
+ for (i = 0; i < len; i++) {
row = d[i];
if (!row || !(getRowValue(row) || getRowValue(row) === 0)) {
- return "continue";
+ continue;
}
if (isUndefined(text)) {
- var title = (state.hasAxis || state.hasRadar) && sanitise(titleFormat ? titleFormat(row.x) : row.x);
+ const title = (state.hasAxis || state.hasRadar) && titleFormat(row.x);
text = tplProcess(tpl[0], {
CLASS_TOOLTIP: $TOOLTIP.tooltip,
TITLE: isValue(title) ? tplStr ? title : "
" + title + "
" : ""
@@ -9657,59 +9773,61 @@ function title_getTextPos(pos, width) {
param = ["arc", $$.$el.arcs.select("path." + $ARC.arc + "-" + row.id).data()[0]];
row.ratio = $$.getRatio.apply($$, param);
}
- param = [row.ratio, row.id, row.index, d];
- value = sanitise(valueFormat.apply(void 0, [getRowValue(row)].concat(param)));
+
+ // arrange param to be passed to formatter
+ param = [row.ratio, row.id, row.index];
if ($$.isAreaRangeType(row)) {
- var _map2 = ["high", "low"].map(function (v) {
- _newArrowCheck(this, _this3);
- return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v)].concat(param)));
+ const _map2 = ["high", "low"].map(function (v) {
+ _newArrowCheck(this, _this);
+ return valueFormat.apply(void 0, [$$.getRangedData(row, v)].concat(param));
}.bind(this)),
high = _map2[0],
- low = _map2[1];
- value = "Mid: " + value + " High: " + high + " Low: " + low;
+ low = _map2[1],
+ mid = valueFormat.apply(void 0, [getRowValue(row)].concat(param));
+ value = "Mid: " + mid + " High: " + high + " Low: " + low;
} else if ($$.isCandlestickType(row)) {
- var _map3 = ["open", "high", "low", "close", "volume"].map(function (v) {
- _newArrowCheck(this, _this3);
- return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v, "candlestick")].concat(param)));
+ const _map3 = ["open", "high", "low", "close", "volume"].map(function (v) {
+ _newArrowCheck(this, _this);
+ const value = $$.getRangedData(row, v, "candlestick");
+ return value ? valueFormat.apply(void 0, [$$.getRangedData(row, v, "candlestick")].concat(param)) : undefined;
}.bind(this)),
open = _map3[0],
- _high = _map3[1],
- _low = _map3[2],
+ high = _map3[1],
+ low = _map3[2],
close = _map3[3],
volume = _map3[4];
- value = "Open: " + open + " High: " + _high + " Low: " + _low + " Close: " + close + (volume ? " Volume: " + volume : "");
+ value = "Open: " + open + " High: " + high + " Low: " + low + " Close: " + close + (volume ? " Volume: " + volume : "");
} else if ($$.isBarRangeType(row)) {
- var _row$value = row.value,
- start = _row$value[0],
- end = _row$value[1];
- value = valueFormat(start) + " ~ " + valueFormat(end);
+ const _row = row,
+ rangeValue = _row.value,
+ id = _row.id,
+ index = _row.index;
+ value = "" + valueFormat(rangeValue, undefined, id, index);
+ } else {
+ value = valueFormat.apply(void 0, [getRowValue(row)].concat(param));
}
if (value !== undefined) {
// Skip elements when their name is set to null
if (row.name === null) {
- return "continue";
+ continue;
}
- var name = sanitise(nameFormat.apply(void 0, [row.name].concat(param))),
- _color = getBgColor(row),
+ const name = nameFormat.apply(void 0, [row.name].concat(param)),
+ color = getBgColor(row),
contentValue = {
CLASS_TOOLTIP_NAME: $TOOLTIP.tooltipName + $$.getTargetSelectorSuffix(row.id),
- COLOR: tplStr || !$$.patterns ? _color : "",
+ COLOR: tplStr || !$$.patterns ? color : "",
NAME: name,
VALUE: value
};
if (tplStr && isObject(contents.text)) {
- var index = targetIds.indexOf(row.id);
+ const index = targetIds.indexOf(row.id);
Object.keys(contents.text).forEach(function (key) {
- _newArrowCheck(this, _this3);
+ _newArrowCheck(this, _this);
contentValue[key] = contents.text[key][index];
}.bind(this));
}
text += tplProcess(tpl[1], contentValue);
}
- };
- for (i = 0; i < len; i++) {
- var _ret = _loop();
- if (_ret === "continue") continue;
}
return text + "";
},
@@ -9722,18 +9840,86 @@ function title_getTextPos(pos, width) {
getTooltipContentTemplate: function getTooltipContentTemplate(tplStr) {
return (tplStr || "
\n\t\t\t\t{=TITLE}\n\t\t\t\t{{
\n\t\t\t\t\t
" + (this.patterns ? "{=COLOR}" : "") + "{=NAME}
\n\t\t\t\t\t
{=VALUE}
\n\t\t\t\t
}}\n\t\t\t
").replace(/(\r?\n|\t)/g, "").split(/{{(.*)}}/);
},
+ /**
+ * Update tooltip position coordinate
+ * @param {object} dataToShow Data object
+ * @param {SVGElement} eventTarget Event element
+ * @private
+ */
+ setTooltipPosition: function setTooltipPosition(dataToShow, eventTarget) {
+ var _this4 = this;
+ const $$ = this,
+ config = $$.config,
+ scale = $$.scale,
+ state = $$.state,
+ _$$$$el = $$.$el,
+ eventRect = _$$$$el.eventRect,
+ tooltip = _$$$$el.tooltip,
+ bindto = config.tooltip_contents.bindto,
+ isRotated = config.axis_rotated,
+ datum = tooltip == null ? void 0 : tooltip.datum();
+ if (!bindto && datum) {
+ var _config$tooltip_posit, _config$tooltip_posit2;
+ const data = dataToShow != null ? dataToShow : JSON.parse(datum.current),
+ _getPointer = getPointer(state.event, eventTarget != null ? eventTarget : eventRect == null ? void 0 : eventRect.node()),
+ x = _getPointer[0],
+ y = _getPointer[1],
+ currPos = {
+ x: x,
+ y: y
+ };
+ // get mouse event position
+
+ if (state.hasAxis && scale.x && datum && "x" in datum) {
+ const getYPos = function (value, id, axisId) {
+ var _$$$axis2;
+ if (value === void 0) {
+ value = 0;
+ }
+ if (axisId === void 0) {
+ axisId = "y";
+ }
+ _newArrowCheck(this, _this4);
+ const scaleFn = scale[id ? (_$$$axis2 = $$.axis) == null ? void 0 : _$$$axis2.getId(id) : axisId];
+ return scaleFn ? scaleFn(value) + (isRotated ? state.margin.left : state.margin.top) : 0;
+ }.bind(this);
+ currPos.xAxis = scale.x(datum.x) + (
+ // add margin only when user specified tooltip.position function
+ config.tooltip_position ? isRotated ? state.margin.top : state.margin.left : 0);
+ if (data.length === 1) {
+ currPos.yAxis = getYPos(data[0].value, data[0].id);
+ } else {
+ currPos.yAxis = getYPos;
+ }
+ }
+ const _datum$width = datum.width,
+ width = _datum$width === void 0 ? 0 : _datum$width,
+ _datum$height = datum.height,
+ height = _datum$height === void 0 ? 0 : _datum$height,
+ pos = (_config$tooltip_posit = (_config$tooltip_posit2 = config.tooltip_position) == null ? void 0 : _config$tooltip_posit2.bind($$.api)(data, width, height, eventRect == null ? void 0 : eventRect.node(), currPos)) != null ? _config$tooltip_posit : $$.getTooltipPosition.bind($$)(width, height, currPos); // Get tooltip position
+ ["top", "left"].forEach(function (v) {
+ _newArrowCheck(this, _this4);
+ const value = pos[v];
+ tooltip.style(v, value + "px");
+
+ // Remember left pos in percentage to be used on resize call
+ if (v === "left" && !datum.xPosInPercent) {
+ datum.xPosInPercent = value / state.current.width * 100;
+ }
+ }.bind(this));
+ }
+ },
/**
* Returns the position of the tooltip
- * @param {object} dataToShow data
* @param {string} tWidth Width value of tooltip element
* @param {string} tHeight Height value of tooltip element
- * @param {HTMLElement} element Tooltip element
+ * @param {object} currPos Current mouse position
* @returns {object} top, left value
* @private
*/
- tooltipPosition: function tooltipPosition(dataToShow, tWidth, tHeight, element) {
- var _this4 = this,
- $$ = this,
+ getTooltipPosition: function getTooltipPosition(tWidth, tHeight, currPos) {
+ var _this5 = this;
+ const $$ = this,
config = $$.config,
scale = $$.scale,
state = $$.state,
@@ -9743,51 +9929,54 @@ function title_getTextPos(pos, width) {
current = _state.current,
isLegendRight = _state.isLegendRight,
inputType = _state.inputType,
- event = _state.event,
hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle,
hasTreemap = state.hasTreemap,
isRotated = config.axis_rotated,
- svgLeft = $$.getSvgLeft(!0),
- chartRight = svgLeft + current.width - $$.getCurrentPaddingRight(),
- chartLeft = $$.getCurrentPaddingLeft(!0),
- _getPointer = getPointer(event, element),
- x = _getPointer[0],
- y = _getPointer[1];
+ hasArcType = $$.hasArcType(),
+ svgLeft = $$.getSvgLeft(!0);
+ let chartRight = svgLeft + current.width - $$.getCurrentPaddingByDirection("right");
+ const size = 20;
+ let x = currPos.x,
+ y = currPos.y;
+
// Determine tooltip position
- if ($$.hasArcType()) {
- var raw = inputType === "touch" || $$.hasType("radar");
+ if (hasArcType) {
+ const raw = inputType === "touch" || $$.hasType("radar");
if (!raw) {
- y += hasGauge ? height : height / 2;
x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
+ y += hasGauge ? height : height / 2;
}
} else if (!hasTreemap) {
- var dataScale = scale.x(dataToShow[0].x);
+ const padding = {
+ top: $$.getCurrentPaddingByDirection("top", !0),
+ left: $$.getCurrentPaddingByDirection("left", !0)
+ };
if (isRotated) {
- y = dataScale + 20;
- x += svgLeft;
+ x += svgLeft + padding.left + size;
+ y = padding.top + currPos.xAxis + size;
chartRight -= svgLeft;
} else {
- y -= 5;
- x = svgLeft + chartLeft + 20 + (scale.zoom ? x : dataScale);
+ x = svgLeft + padding.left + size + (scale.zoom ? x : currPos.xAxis);
+ y += padding.top - 5;
}
}
// when tooltip left + tWidth > chart's width
if (x + tWidth + 15 > chartRight) {
- x -= isRotated ? tWidth - chartLeft : tWidth + (hasTreemap ? 0 : chartLeft);
+ x -= tWidth + (hasTreemap || hasArcType ? 0 : isRotated ? 40 : 38);
}
if (y + tHeight > current.height) {
- var gap = hasTreemap ? 0 : 30;
+ const gap = hasTreemap ? 0 : 30;
y -= hasGauge ? tHeight * 3 : tHeight + gap;
}
- var pos = {
+ const pos = {
top: y,
left: x
};
// make sure to not be positioned out of viewport
Object.keys(pos).forEach(function (v) {
- _newArrowCheck(this, _this4);
+ _newArrowCheck(this, _this5);
if (pos[v] < 0) {
pos[v] = 0;
}
@@ -9797,33 +9986,27 @@ function title_getTextPos(pos, width) {
/**
* Show the tooltip
* @param {object} selectedData Data object
- * @param {SVGElement} eventRect Event element
+ * @param {SVGElement} eventTarget Event element
* @private
*/
- showTooltip: function showTooltip(selectedData, eventRect) {
- var _this5 = this,
- $$ = this,
+ showTooltip: function showTooltip(selectedData, eventTarget) {
+ var _this6 = this;
+ const $$ = this,
config = $$.config,
- scale = $$.scale,
- state = $$.state,
tooltip = $$.$el.tooltip,
- bindto = config.tooltip_contents.bindto,
dataToShow = selectedData.filter(function (d) {
- _newArrowCheck(this, _this5);
+ _newArrowCheck(this, _this6);
return d && isValue($$.getBaseValue(d));
}.bind(this));
if (!tooltip || dataToShow.length === 0 || !config.tooltip_show) {
return;
}
- var datum = tooltip.datum(),
- _ref = datum || {},
- _ref$width = _ref.width,
- width = _ref$width === void 0 ? 0 : _ref$width,
- _ref$height = _ref.height,
- height = _ref$height === void 0 ? 0 : _ref$height;
- var dataStr = JSON.stringify(selectedData);
+ let datum = tooltip.datum();
+ const dataStr = JSON.stringify(selectedData);
if (!datum || datum.current !== dataStr) {
- var index = selectedData.concat().sort()[0].index;
+ const _selectedData$concat$ = selectedData.concat().sort()[0],
+ index = _selectedData$concat$.index,
+ x = _selectedData$concat$.x;
callFn(config.tooltip_onshow, $$.api, selectedData);
// set tooltip content
@@ -9837,70 +10020,41 @@ function title_getTextPos(pos, width) {
)).style("display", null).style("visibility", null) // for IE9
.datum(datum = {
index: index,
+ x: x,
current: dataStr,
- width: width = tooltip.property("offsetWidth"),
- height: height = tooltip.property("offsetHeight")
+ width: tooltip.property("offsetWidth"),
+ height: tooltip.property("offsetHeight")
});
callFn(config.tooltip_onshown, $$.api, selectedData);
$$._handleLinkedCharts(!0, index);
}
- if (!bindto) {
- var _config$tooltip_posit,
- _selectedData$filter,
- fnPos = ((_config$tooltip_posit = config.tooltip_position) == null ? void 0 : _config$tooltip_posit.bind($$.api)) || $$.tooltipPosition.bind($$),
- _getPointer2 = getPointer(state.event, eventRect),
- x = _getPointer2[0],
- y = _getPointer2[1],
- currPos = {
- x: x,
- y: y
- },
- data = (_selectedData$filter = selectedData.filter(Boolean)) == null ? void 0 : _selectedData$filter.shift();
- // get mouse event position
-
- if (scale.x && data && "x" in data) {
- currPos.xAxis = scale.x(data.x);
- }
-
- // Get tooltip dimensions
- var pos = fnPos(dataToShow, width, height, eventRect, currPos);
- ["top", "left"].forEach(function (v) {
- _newArrowCheck(this, _this5);
- var value = pos[v];
- tooltip.style(v, value + "px");
-
- // Remember left pos in percentage to be used on resize call
- if (v === "left" && !datum.xPosInPercent) {
- datum.xPosInPercent = value / state.current.width * 100;
- }
- }.bind(this));
- }
+ $$.setTooltipPosition(dataToShow, eventTarget);
},
/**
* Adjust tooltip position on resize event
* @private
*/
bindTooltipResizePos: function bindTooltipResizePos() {
- var _this6 = this,
- $$ = this,
+ var _this7 = this;
+ const $$ = this,
resizeFunction = $$.resizeFunction,
state = $$.state,
tooltip = $$.$el.tooltip;
resizeFunction.add(function () {
- _newArrowCheck(this, _this6);
+ _newArrowCheck(this, _this7);
if (tooltip.style("display") === "block") {
- var current = state.current,
+ const current = state.current,
_tooltip$datum = tooltip.datum(),
width = _tooltip$datum.width,
xPosInPercent = _tooltip$datum.xPosInPercent;
- var _value = current.width / 100 * xPosInPercent;
- var diff = current.width - (_value + width);
+ let value = current.width / 100 * xPosInPercent;
+ const diff = current.width - (value + width);
// if tooltip size overs current viewport size
if (diff < 0) {
- _value += diff;
+ value += diff;
}
- tooltip.style("left", _value + "px");
+ tooltip.style("left", value + "px");
}
}.bind(this));
},
@@ -9910,12 +10064,13 @@ function title_getTextPos(pos, width) {
* @private
*/
hideTooltip: function hideTooltip(force) {
- var $$ = this,
+ const $$ = this,
api = $$.api,
config = $$.config,
tooltip = $$.$el.tooltip;
if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
- var selectedData = JSON.parse(tooltip.datum().current);
+ var _tooltip$datum$curren;
+ const selectedData = JSON.parse((_tooltip$datum$curren = tooltip.datum().current) != null ? _tooltip$datum$curren : {});
callFn(config.tooltip_onhide, api, selectedData);
// hide tooltip
@@ -9931,28 +10086,28 @@ function title_getTextPos(pos, width) {
* @private
*/
_handleLinkedCharts: function _handleLinkedCharts(show, index) {
- var _this7 = this,
- $$ = this,
+ var _this8 = this;
+ const $$ = this,
charts = $$.charts,
config = $$.config,
event = $$.state.event;
// Prevent propagation among instances if isn't instantiated from the user's event
// https://github.com/naver/billboard.js/issues/1979
if (event != null && event.isTrusted && config.tooltip_linked && charts.length > 1) {
- var linkedName = config.tooltip_linked_name;
+ const linkedName = config.tooltip_linked_name;
charts.filter(function (c) {
- _newArrowCheck(this, _this7);
+ _newArrowCheck(this, _this8);
return c !== $$.api;
}.bind(this)).forEach(function (c) {
- _newArrowCheck(this, _this7);
- var _c$internal = c.internal,
+ _newArrowCheck(this, _this8);
+ const _c$internal = c.internal,
config = _c$internal.config,
$el = _c$internal.$el,
isLinked = config.tooltip_linked,
name = config.tooltip_linked_name,
isInDom = browser_doc.body.contains($el.chart.node());
if (isLinked && linkedName === name && isInDom) {
- var data = $el.tooltip.data()[0],
+ const data = $el.tooltip.data()[0],
isNotSameIndex = index !== (data == null ? void 0 : data.index);
try {
c.tooltip[show && isNotSameIndex ? "show" : "hide"]({
@@ -9962,6 +10117,64 @@ function title_getTextPos(pos, width) {
}
}.bind(this));
}
+ },
+ /**
+ * Update tooltip content on redraw
+ * - In a situation where tooltip is displayed and data load happens, it should reflect loaded data to tooltip
+ * @param {d3Selection} context Event rect element
+ * @param {number} index Data index
+ * @private
+ */
+ updateTooltipOnRedraw: function updateTooltipOnRedraw(context, index) {
+ var _this9 = this;
+ const $$ = this,
+ config = $$.config,
+ _$$$$el2 = $$.$el,
+ eventRect = _$$$$el2.eventRect,
+ svg = _$$$$el2.svg,
+ tooltip = _$$$$el2.tooltip,
+ _$$$state2 = $$.state,
+ event = _$$$state2.event,
+ hasAxis = _$$$state2.hasAxis,
+ hasRadar = _$$$state2.hasRadar,
+ hasTreemap = _$$$state2.hasTreemap;
+ // Update tooltip, when tooltip is in shown state
+ if ((tooltip == null ? void 0 : tooltip.style("display")) === "block" && event) {
+ var _ref;
+ const rect = context != null ? context : (_ref = hasRadar ? svg : eventRect) == null ? void 0 : _ref.node();
+
+ // for Axis based & Radar
+ if (hasAxis || hasRadar) {
+ if ($$.isMultipleX()) {
+ $$.selectRectForMultipleXs(rect, !1);
+ } else {
+ const idx = index != null ? index : $$.getDataIndexFromEvent(event);
+ if (index === -1) {
+ $$.api.tooltip.hide();
+ } else {
+ $$.selectRectForSingle(rect, idx);
+ $$.setExpand(idx, null, !0);
+ }
+ }
+
+ // for Arc & Treemap
+ } else {
+ const clientX = event.clientX,
+ clientY = event.clientY;
+ setTimeout(function () {
+ _newArrowCheck(this, _this9);
+ let target = browser_doc.elementFromPoint(clientX, clientY);
+ const data = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
+ if (data) {
+ const d = $$.hasArcType() ? $$.convertToArcData($$.updateAngle(data)) : data == null ? void 0 : data.data;
+ hasTreemap && (target = svg.node());
+ d && $$.showTooltip([d], target);
+ } else {
+ $$.api.tooltip.hide();
+ }
+ }.bind(this), config.transition_duration);
+ }
+ }
}
});
;// CONCATENATED MODULE: ./src/ChartInternal/internals/transform.ts
@@ -9976,11 +10189,11 @@ function title_getTextPos(pos, width) {
if (index === void 0) {
index = 0;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
isRotated = config.axis_rotated;
- var padding = 0,
+ let padding = 0,
x,
y;
if (index && /^(x|y2?)$/.test(target)) {
@@ -10003,7 +10216,7 @@ function title_getTextPos(pos, width) {
y = isRotated ? state.height + padding : 0;
} else if (target === "y2") {
x = isRotated ? 0 : state.width + padding;
- y = isRotated && padding ? 1 - padding : 0;
+ y = isRotated ? -padding - 1 : 0;
} else if (target === "subX") {
x = 0;
y = isRotated ? 0 : state.height2;
@@ -10014,7 +10227,7 @@ function title_getTextPos(pos, width) {
x = state.arcWidth / 2;
y = state.arcHeight / 2;
} else if (target === "radar") {
- var _$$$getRadarSize = $$.getRadarSize(),
+ const _$$$getRadarSize = $$.getRadarSize(),
width = _$$$getRadarSize[0];
x = state.width / 2 - width;
y = asHalfPixel(state.margin.top);
@@ -10022,7 +10235,7 @@ function title_getTextPos(pos, width) {
return "translate(" + x + ", " + y + ")";
},
transformMain: function transformMain(withTransition, transitions) {
- var $$ = this,
+ const $$ = this,
main = $$.$el.main,
$T = $$.$T,
xAxis = transitions != null && transitions.axisX ? transitions.axisX : $T(main.select("." + $AXIS.axisX), withTransition),
@@ -10035,7 +10248,7 @@ function title_getTextPos(pos, width) {
main.select("." + $ARC.chartArcs).attr("transform", $$.getTranslate("arc"));
},
transformAll: function transformAll(withTransition, transitions) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
_$$$state = $$.state,
hasAxis = _$$$state.hasAxis,
@@ -10065,8 +10278,8 @@ function title_getTextPos(pos, width) {
return !!(type && Object.values(TYPE).indexOf(type) > -1);
},
setTargetType: function setTargetType(targetIds, type) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
withoutFadeIn = $$.state.withoutFadeIn;
$$.mapToTargetIds(targetIds).forEach(function (id) {
@@ -10083,12 +10296,12 @@ function title_getTextPos(pos, width) {
* @private
*/
updateTypesElements: function updateTypesElements() {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
current = $$.state.current;
Object.keys(TYPE).forEach(function (v) {
_newArrowCheck(this, _this2);
- var t = TYPE[v],
+ const t = TYPE[v],
has = $$.hasType(t, null, !0),
idx = current.types.indexOf(t);
if (idx === -1 && has) {
@@ -10115,18 +10328,18 @@ function title_getTextPos(pos, width) {
if (checkFromData === void 0) {
checkFromData = !1;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
current = $$.state.current,
types = config.data_types,
targets = targetsValue || $$.data.targets;
- var has = !1;
+ let has = !1;
if (!checkFromData && ((_current$types = current.types) == null ? void 0 : _current$types.indexOf(type)) > -1) {
has = !0;
} else if (targets != null && targets.length) {
targets.forEach(function (target) {
_newArrowCheck(this, _this3);
- var t = types[target.id];
+ const t = types[target.id];
if (t === type || !t && type === "line") {
has = !0;
}
@@ -10175,12 +10388,12 @@ function title_getTextPos(pos, width) {
* @private
*/
isTypeOf: function isTypeOf(d, type) {
- var id = isString(d) ? d : d.id,
+ const id = isString(d) ? d : d.id,
dataType = this.config.data_types[id] || this.config.data_type;
return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
},
hasPointType: function hasPointType() {
- var $$ = this;
+ const $$ = this;
return $$.hasTypeOf("Line") || $$.hasType("bubble") || $$.hasType("scatter");
},
/**
@@ -10197,7 +10410,7 @@ function title_getTextPos(pos, width) {
return this.hasType("gauge") && this.config.gauge_type === "multi";
},
isLineType: function isLineType(d) {
- var id = isString(d) ? d : d.id;
+ const id = isString(d) ? d : d.id;
return !this.config.data_types[id] || this.isTypeOf(id, TYPE_BY_CATEGORY.Line);
},
isStepType: function isStepType(d) {
@@ -10247,9 +10460,9 @@ function title_getTextPos(pos, width) {
},
// determine if is 'circle' data point
isCirclePoint: function isCirclePoint(node) {
- var config = this.config,
+ const config = this.config,
pattern = config.point_pattern;
- var isCircle = !1;
+ let isCircle = !1;
if ((node == null ? void 0 : node.tagName) === "circle") {
isCircle = !0;
} else {
@@ -10335,7 +10548,7 @@ function title_getTextPos(pos, width) {
* @ignore
* @private
*/
-var ChartInternal = /*#__PURE__*/function () {
+let ChartInternal = /*#__PURE__*/function () {
function ChartInternal(api) {
this.api = void 0;
// API interface
@@ -10389,11 +10602,11 @@ var ChartInternal = /*#__PURE__*/function () {
axisTime: null // axisTimeFormat
};
- var $$ = this;
+ const $$ = this;
$$.api = api; // Chart class instance alias
$$.config = new Options();
$$.cache = new Cache();
- var store = new Store();
+ const store = new Store();
$$.$el = store.getStore("element");
$$.state = store.getStore("state");
$$.$T = $$.$T.bind($$);
@@ -10409,11 +10622,11 @@ var ChartInternal = /*#__PURE__*/function () {
*/
var _proto = ChartInternal.prototype;
_proto.$T = function $T(selection, force, name) {
- var config = this.config,
+ const config = this.config,
state = this.state,
duration = config.transition_duration,
subchart = config.subchart_show;
- var t = selection;
+ let t = selection;
if (t) {
// in case of non d3 selection, wrap with d3 selection
if ("tagName" in t) {
@@ -10425,27 +10638,27 @@ var ChartInternal = /*#__PURE__*/function () {
// - when has no subchart
// - initialization
// - resizing
- var transit = (force !== !1 && duration || force) && (!state.zooming || state.dragging) && !state.resizing && state.rendered && !subchart;
+ const transit = (force !== !1 && duration || force) && (!state.zooming || state.dragging) && !state.resizing && state.rendered && !subchart;
t = transit ? t.transition(name).duration(duration) : t;
}
return t;
};
_proto.beforeInit = function beforeInit() {
- var $$ = this;
+ const $$ = this;
$$.callPluginHook("$beforeInit");
// can do something
callFn($$.config.onbeforeinit, $$.api);
};
_proto.afterInit = function afterInit() {
- var $$ = this;
+ const $$ = this;
$$.callPluginHook("$afterInit");
// can do something
callFn($$.config.onafterinit, $$.api);
};
_proto.init = function init() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
$el = $$.$el,
@@ -10459,7 +10672,7 @@ var ChartInternal = /*#__PURE__*/function () {
state.datetimeId = "bb-" + +new Date() * getRandom();
if (useCssRule) {
// append style element
- var styleEl = browser_doc.createElement("style");
+ const styleEl = browser_doc.createElement("style");
// styleEl.id = styleId;
styleEl.type = "text/css";
@@ -10472,7 +10685,7 @@ var ChartInternal = /*#__PURE__*/function () {
// used on .destroy()
$el.style = styleEl;
}
- var bindto = {
+ const bindto = {
element: config.bindto,
classname: "bb"
};
@@ -10497,8 +10710,8 @@ var ChartInternal = /*#__PURE__*/function () {
* @private
*/;
_proto.initToRender = function initToRender(forced) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
chart = $$.$el.chart,
@@ -10529,8 +10742,8 @@ var ChartInternal = /*#__PURE__*/function () {
}
};
_proto.initParams = function initParams() {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
format = $$.format,
state = $$.state,
@@ -10554,10 +10767,10 @@ var ChartInternal = /*#__PURE__*/function () {
format.extraLineClasses = $$.generateExtraLineClass();
format.dataTime = config.data_xLocaltime ? external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.timeParse : external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.utcParse;
format.axisTime = config.axis_x_localtime ? external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.timeFormat : external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.utcFormat;
- var isDragZoom = $$.config.zoom_enabled && $$.config.zoom_type === "drag";
+ const isDragZoom = $$.config.zoom_enabled && $$.config.zoom_type === "drag";
format.defaultAxisTime = function (d) {
_newArrowCheck(this, _this2);
- var _$$$scale = $$.scale,
+ const _$$$scale = $$.scale,
x = _$$$scale.x,
zoom = _$$$scale.zoom,
isZoomed = isDragZoom ? zoom : zoom && x.orgDomain().toString() !== zoom.domain().toString(),
@@ -10574,8 +10787,8 @@ var ChartInternal = /*#__PURE__*/function () {
state.inputType = convertInputType(config.interaction_inputType_mouse, config.interaction_inputType_touch);
};
_proto.initWithData = function initWithData(data) {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
config = $$.config,
scale = $$.scale,
state = $$.state,
@@ -10614,7 +10827,7 @@ var ChartInternal = /*#__PURE__*/function () {
// retrieve scale after the 'updateScales()' is called
if (hasAxis) {
- var x = scale.x,
+ const x = scale.x,
y = scale.y,
y2 = scale.y2,
subX = scale.subX,
@@ -10642,7 +10855,7 @@ var ChartInternal = /*#__PURE__*/function () {
// -- Basic Elements --
$el.svg = $el.chart.append("svg").style("overflow", "hidden").style("display", "block");
if (hasInteraction && state.inputType) {
- var isTouch = state.inputType === "touch",
+ const isTouch = state.inputType === "touch",
onclick = config.onclick,
onover = config.onover,
onout = config.onout;
@@ -10651,7 +10864,7 @@ var ChartInternal = /*#__PURE__*/function () {
config.svg_classname && $el.svg.attr("class", config.svg_classname);
// Define defs
- var hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
+ const hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || config.data_labels_backgroundColors) {
$el.defs = $el.svg.append("defs");
if (hasAxis) {
@@ -10682,7 +10895,7 @@ var ChartInternal = /*#__PURE__*/function () {
$$.bindResize();
// Define regions
- var main = $el.svg.append("g").classed($COMMON.main, !0).attr("transform", hasTreemap ? null : $$.getTranslate("main"));
+ const main = $el.svg.append("g").classed($COMMON.main, !0).attr("transform", hasTreemap ? null : $$.getTranslate("main"));
$el.main = main;
// initialize subchart when subchart show option is set
@@ -10745,7 +10958,7 @@ var ChartInternal = /*#__PURE__*/function () {
// data.onmin/max callback
if (config.data_onmin || config.data_onmax) {
- var minMax = $$.getMinMaxData();
+ const minMax = $$.getMinMaxData();
callFn(config.data_onmin, $$.api, minMax.min);
callFn(config.data_onmax, $$.api, minMax.max);
}
@@ -10758,21 +10971,21 @@ var ChartInternal = /*#__PURE__*/function () {
* @private
*/;
_proto.initChartElements = function initChartElements() {
- var _this5 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
_$$$state = $$.state,
hasAxis = _$$$state.hasAxis,
hasRadar = _$$$state.hasRadar,
hasTreemap = _$$$state.hasTreemap,
types = [];
if (hasAxis) {
- var shapes = ["bar", "bubble", "candlestick", "line"];
+ const shapes = ["bar", "bubble", "candlestick", "line"];
if ($$.config.bar_front) {
shapes.push(shapes.shift());
}
shapes.forEach(function (v) {
_newArrowCheck(this, _this5);
- var name = capitalize(v);
+ const name = capitalize(v);
if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
types.push(name);
}
@@ -10780,7 +10993,7 @@ var ChartInternal = /*#__PURE__*/function () {
} else if (hasTreemap) {
types.push("Treemap");
} else {
- var hasPolar = $$.hasType("polar");
+ const hasPolar = $$.hasType("polar");
if (!hasRadar) {
types.push("Arc", "Pie");
}
@@ -10804,7 +11017,7 @@ var ChartInternal = /*#__PURE__*/function () {
* @private
*/;
_proto.setChartElements = function setChartElements() {
- var $$ = this,
+ const $$ = this,
_$$$$el = $$.$el,
chart = _$$$$el.chart,
svg = _$$$$el.svg,
@@ -10854,12 +11067,12 @@ var ChartInternal = /*#__PURE__*/function () {
* @private
*/;
_proto.setBackground = function setBackground() {
- var $$ = this,
+ const $$ = this,
bg = $$.config.background,
state = $$.state,
svg = $$.$el.svg;
if (notEmpty(bg)) {
- var element = svg.select("g").insert(bg.imgUrl ? "image" : "rect", ":first-child");
+ const element = svg.select("g").insert(bg.imgUrl ? "image" : "rect", ":first-child");
if (bg.imgUrl) {
element.attr("href", bg.imgUrl);
} else if (bg.color) {
@@ -10875,8 +11088,8 @@ var ChartInternal = /*#__PURE__*/function () {
* @private
*/;
_proto.updateTargets = function updateTargets(targets) {
- var _this6 = this,
- $$ = this,
+ var _this6 = this;
+ const $$ = this,
_$$$state2 = $$.state,
hasAxis = _$$$state2.hasAxis,
hasRadar = _$$$state2.hasRadar,
@@ -10890,7 +11103,7 @@ var ChartInternal = /*#__PURE__*/function () {
if (hasAxis) {
["bar", "candlestick", "line"].forEach(function (v) {
_newArrowCheck(this, _this6);
- var name = capitalize(v);
+ const name = capitalize(v);
if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
helper(name);
}
@@ -10901,7 +11114,7 @@ var ChartInternal = /*#__PURE__*/function () {
// Arc, Polar, Radar
} else if ($$.hasArcType(targets)) {
- var type = "Arc";
+ let type = "Arc";
if (hasRadar) {
type = "Radar";
} else if ($$.hasType("polar")) {
@@ -10914,9 +11127,9 @@ var ChartInternal = /*#__PURE__*/function () {
}
// Point types
- var hasPointType = $$.hasType("bubble") || $$.hasType("scatter");
+ const hasPointType = $$.hasType("bubble") || $$.hasType("scatter");
if (hasPointType) {
- $$.updateTargetForCircle == null ? void 0 : $$.updateTargetForCircle();
+ $$.updateTargetForCircle == null || $$.updateTargetForCircle();
}
// Fade-in each chart
@@ -10933,10 +11146,10 @@ var ChartInternal = /*#__PURE__*/function () {
if (hasPointType === void 0) {
hasPointType = !1;
}
- var $$ = this,
+ const $$ = this,
svg = $$.$el.svg,
$T = $$.$T;
- var selector = "." + $COMMON.target;
+ let selector = "." + $COMMON.target;
if (hasPointType) {
selector += ", ." + $CIRCLE.chartCircles + " > ." + $CIRCLE.circles;
}
@@ -10946,25 +11159,25 @@ var ChartInternal = /*#__PURE__*/function () {
}.bind(this))).style("opacity", null);
};
_proto.getWithOption = function getWithOption(options) {
- var _this8 = this,
- withOptions = {
- Dimension: !0,
- EventRect: !0,
- Legend: !1,
- Subchart: !0,
- Transform: !1,
- Transition: !0,
- TrimXDomain: !0,
- UpdateXAxis: "UpdateXDomain",
- UpdateXDomain: !1,
- UpdateOrgXDomain: !1,
- TransitionForExit: "Transition",
- TransitionForAxis: "Transition",
- Y: !0
- };
+ var _this8 = this;
+ const withOptions = {
+ Dimension: !0,
+ EventRect: !0,
+ Legend: !1,
+ Subchart: !0,
+ Transform: !1,
+ Transition: !0,
+ TrimXDomain: !0,
+ UpdateXAxis: "UpdateXDomain",
+ UpdateXDomain: !1,
+ UpdateOrgXDomain: !1,
+ TransitionForExit: "Transition",
+ TransitionForAxis: "Transition",
+ Y: !0
+ };
Object.keys(withOptions).forEach(function (key) {
_newArrowCheck(this, _this8);
- var defVal = withOptions[key];
+ let defVal = withOptions[key];
if (isString(defVal)) {
defVal = withOptions[defVal];
}
@@ -10973,14 +11186,14 @@ var ChartInternal = /*#__PURE__*/function () {
return withOptions;
};
_proto.initialOpacity = function initialOpacity(d) {
- var $$ = this,
+ const $$ = this,
withoutFadeIn = $$.state.withoutFadeIn,
r = $$.getBaseValue(d) !== null && withoutFadeIn[d.id] ? null : "0";
return r;
};
_proto.bindResize = function bindResize() {
- var _this9 = this,
- $$ = this,
+ var _this9 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
resizeFunction = generateResize(config.resize_timer),
@@ -11057,22 +11270,20 @@ convert, data_data, load, category, internals_class, internals_color, domain, in
* @private
*/
function loadConfig(config) {
- var _this = this,
- thisConfig = this.config,
- target,
- keys,
- read,
- _find = function find() {
- _newArrowCheck(this, _this);
- var key = keys.shift();
- if (key && target && isObjectType(target) && key in target) {
- target = target[key];
- return _find();
- } else if (!key) {
- return target;
- }
- return undefined;
- }.bind(this);
+ var _this = this;
+ const thisConfig = this.config;
+ let target, keys, read;
+ const _find = function find() {
+ _newArrowCheck(this, _this);
+ const key = keys.shift();
+ if (key && target && isObjectType(target) && key in target) {
+ target = target[key];
+ return _find();
+ } else if (!key) {
+ return target;
+ }
+ return undefined;
+ }.bind(this);
Object.keys(thisConfig).forEach(function (key) {
_newArrowCheck(this, _this);
target = config;
@@ -11113,7 +11324,7 @@ function loadConfig(config) {
* });
*/
resize: function resize(size) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config,
state = $$.state;
if (state.rendered) {
@@ -11138,7 +11349,7 @@ function loadConfig(config) {
* chart.flush(true);
*/
flush: function flush(soft) {
- var $$ = this.internal,
+ const $$ = this.internal,
state = $$.state,
zoomResetBtn = $$.$el.zoomResetBtn;
if (state.rendered) {
@@ -11147,16 +11358,16 @@ function loadConfig(config) {
if (state.resizing) {
var _$$$brush;
// arguments[1] is given when is called from resize
- (_$$$brush = $$.brush) == null ? void 0 : _$$$brush.updateResize();
+ (_$$$brush = $$.brush) == null || _$$$brush.updateResize();
} else {
var _$$$axis;
// re-update config info
- (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.setOrient();
+ (_$$$axis = $$.axis) == null || _$$$axis.setOrient();
}
// hide possible reset zoom button
// https://github.com/naver/billboard.js/issues/2201
- zoomResetBtn == null ? void 0 : zoomResetBtn.style("display", "none");
+ zoomResetBtn == null || zoomResetBtn.style("display", "none");
$$.scale.zoom = null;
soft ? $$.redraw({
withTransform: !0,
@@ -11188,8 +11399,8 @@ function loadConfig(config) {
* chart.destroy();
*/
destroy: function destroy() {
- var _this = this,
- $$ = this.internal,
+ var _this = this;
+ const $$ = this.internal,
_$$$$el = $$.$el,
chart = _$$$$el.chart,
style = _$$$$el.style,
@@ -11223,7 +11434,7 @@ function loadConfig(config) {
}.bind(this));
// release prototype chains
- for (var key in this) {
+ for (const key in this) {
this[key] = function () {
_newArrowCheck(this, _this);
}.bind(this);
@@ -11267,11 +11478,11 @@ function loadConfig(config) {
* chart.config("gauge.max", 100, true);
*/
config: function (name, value, redraw) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config,
state = $$.state,
key = name == null ? void 0 : name.replace(/\./g, "_");
- var res;
+ let res;
if (name && key in config) {
if (isDefined(value)) {
config[key] = value;
@@ -11332,11 +11543,11 @@ function loadConfig(config) {
* // Get all data
* chart.data();
*/
-var api_data_data = function (targetIds) {
- var _this = this,
- targets = this.internal.data.targets;
+const api_data_data = function (targetIds) {
+ var _this = this;
+ const targets = this.internal.data.targets;
if (!isUndefined(targetIds)) {
- var ids = isArray(targetIds) ? targetIds : [targetIds];
+ const ids = isArray(targetIds) ? targetIds : [targetIds];
return targets.filter(function (t) {
var _this2 = this;
_newArrowCheck(this, _this);
@@ -11388,15 +11599,15 @@ extend(api_data_data, {
if (flat === void 0) {
flat = !0;
}
- var values = null;
+ let values = null;
if (targetIds) {
- var targets = this.data(targetIds);
+ const targets = this.data(targetIds);
if (isArray(targets)) {
values = [];
targets.forEach(function (v) {
var _this4 = this;
_newArrowCheck(this, _this3);
- var dataValue = v.values.map(function (d) {
+ const dataValue = v.values.map(function (d) {
_newArrowCheck(this, _this4);
return d.value;
}.bind(this));
@@ -11425,7 +11636,7 @@ extend(api_data_data, {
*});
*/
names: function names(_names) {
- var $$ = this.internal;
+ const $$ = this.internal;
return $$.updateDataAttributes("names", _names);
},
/**
@@ -11520,7 +11731,7 @@ var export_this = undefined;
* @private
* @see https://developer.mozilla.org/ko/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
*/
-var b64EncodeUnicode = function (str) {
+const b64EncodeUnicode = function (str) {
var _this2 = this;
_newArrowCheck(this, export_this);
return win.btoa == null ? void 0 : win.btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p) {
@@ -11538,8 +11749,8 @@ var b64EncodeUnicode = function (str) {
* @private
*/
function nodeToSvgDataUrl(node, option, orgSize) {
- var _this3 = this,
- _ref = option || orgSize,
+ var _this3 = this;
+ const _ref = option || orgSize,
width = _ref.width,
height = _ref.height,
serializer = new XMLSerializer(),
@@ -11564,11 +11775,11 @@ function nodeToSvgDataUrl(node, option, orgSize) {
t.innerHTML = "";
}.bind(this));
}
- var nodeXml = serializer.serializeToString(clone),
+ const nodeXml = serializer.serializeToString(clone),
style = browser_doc.createElement("style"); // escape css for XML
style.appendChild(browser_doc.createTextNode(cssText.join("\n")));
- var styleXml = serializer.serializeToString(style),
- dataStr = ("").replace("/\n/g", "%0A"); // foreignObject not supported in IE11 and below
+ const styleXml = serializer.serializeToString(style),
+ dataStr = ""; // foreignObject not supported in IE11 and below
// https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx
return "data:image/svg+xml;base64," + b64EncodeUnicode(dataStr);
}
@@ -11581,7 +11792,7 @@ function nodeToSvgDataUrl(node, option, orgSize) {
* @private
*/
function getCoords(elem, svgOffset) {
- var top = svgOffset.top,
+ const top = svgOffset.top,
left = svgOffset.left,
_elem$getBBox = elem.getBBox(),
x = _elem$getBBox.x,
@@ -11611,8 +11822,8 @@ function getCoords(elem, svgOffset) {
* @private
*/
function getGlyph(svg) {
- var _this4 = this,
- _svg$getBoundingClien = svg.getBoundingClientRect(),
+ var _this4 = this;
+ const _svg$getBoundingClien = svg.getBoundingClientRect(),
left = _svg$getBoundingClien.left,
top = _svg$getBoundingClien.top,
filterFn = function (t) {
@@ -11624,10 +11835,10 @@ function getGlyph(svg) {
var _this5 = this;
_newArrowCheck(this, _this4);
// eslint-disable-line
- var getStyleFn = function (ts) {
+ const getStyleFn = function (ts) {
var _ref2;
_newArrowCheck(this, _this5);
- var _window$getComputedSt = win.getComputedStyle(ts),
+ const _window$getComputedSt = win.getComputedStyle(ts),
fill = _window$getComputedSt.fill,
fontFamily = _window$getComputedSt.fontFamily,
fontSize = _window$getComputedSt.fontSize,
@@ -11681,7 +11892,7 @@ function renderText(ctx, glyph) {
Object.keys(g).forEach(function (key) {
var _this8 = this;
_newArrowCheck(this, _this7);
- var _g$key = g[key],
+ const _g$key = g[key],
x = _g$key.x,
y = _g$key.y,
width = _g$key.width,
@@ -11696,7 +11907,7 @@ function renderText(ctx, glyph) {
if (transform === "none") {
ctx.fillText(key, x, y);
} else {
- var args = transform.replace(/(matrix|\(|\))/g, "").split(",");
+ const args = transform.replace(/(matrix|\(|\))/g, "").split(",");
if (args.splice(4).every(function (v) {
_newArrowCheck(this, _this8);
return +v === 0;
@@ -11764,8 +11975,8 @@ function renderText(ctx, glyph) {
* );
*/
export: function _export(option, callback) {
- var _this9 = this,
- $$ = this.internal,
+ var _this9 = this;
+ const $$ = this.internal,
state = $$.state,
_$$$$el = $$.$el,
chart = _$$$$el.chart,
@@ -11786,11 +11997,11 @@ function renderText(ctx, glyph) {
}),
glyph = opt.preserveFontStyle ? getGlyph(svg.node()) : [];
if (callback && isFunction(callback)) {
- var img = new Image();
+ const img = new Image();
img.crossOrigin = "Anonymous";
img.onload = function () {
_newArrowCheck(this, _this9);
- var canvas = browser_doc.createElement("canvas"),
+ const canvas = browser_doc.createElement("canvas"),
ctx = canvas.getContext("2d");
canvas.width = opt.width || width;
canvas.height = opt.height || height;
@@ -11835,8 +12046,8 @@ function renderText(ctx, glyph) {
* chart.focus();
*/
focus: function focus(targetIdsValue) {
- var _this = this,
- $$ = this.internal,
+ var _this = this;
+ const $$ = this.internal,
state = $$.state,
targetIds = $$.mapToTargetIds(targetIdsValue),
candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
@@ -11872,8 +12083,8 @@ function renderText(ctx, glyph) {
* chart.defocus();
*/
defocus: function defocus(targetIdsValue) {
- var _this2 = this,
- $$ = this.internal,
+ var _this2 = this;
+ const $$ = this.internal,
state = $$.state,
targetIds = $$.mapToTargetIds(targetIdsValue),
candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
@@ -11907,7 +12118,7 @@ function renderText(ctx, glyph) {
* chart.revert();
*/
revert: function revert(targetIdsValue) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config,
state = $$.state,
$el = $$.$el,
@@ -11936,7 +12147,7 @@ function renderText(ctx, glyph) {
* Define legend
* @ignore
*/
-var legend_legend = {
+const legend_legend = {
/**
* Show legend for each target.
* - **NOTE:** Legend APIs aren't supported for `treemap` type.
@@ -11958,7 +12169,7 @@ var legend_legend = {
* chart.legend.show();
*/
show: function show(targetIds) {
- var $$ = this.internal;
+ const $$ = this.internal;
$$.showLegend($$.mapToTargetIds(targetIds));
$$.updateAndRedraw({
withLegend: !0
@@ -11984,7 +12195,7 @@ var legend_legend = {
* chart.legend.hide();
*/
hide: function hide(targetIds) {
- var $$ = this.internal;
+ const $$ = this.internal;
$$.hideLegend($$.mapToTargetIds(targetIds));
$$.updateAndRedraw({
withLegend: !0
@@ -12141,8 +12352,8 @@ var legend_legend = {
* });
*/
load: function load(args) {
- var _this = this,
- $$ = this.internal,
+ var _this = this;
+ const $$ = this.internal,
config = $$.config;
// update xs if specified
args.xs && $$.addXs(args.xs);
@@ -12187,7 +12398,6 @@ var legend_legend = {
}.bind(this));
}.bind(this));
} else {
- $$.api.tooltip.hide();
$$.loadFromArgs(args);
}
},
@@ -12217,9 +12427,12 @@ var legend_legend = {
* });
*/
unload: function unload(argsValue) {
- var _this3 = this,
- $$ = this.internal,
- args = argsValue || {};
+ var _this3 = this;
+ const $$ = this.internal;
+ let args = argsValue || {};
+
+ // hide possible tooltip display when data is completely unloaded
+ isEmpty(args) && this.tooltip.hide();
if (isArray(args)) {
args = {
ids: args
@@ -12229,7 +12442,7 @@ var legend_legend = {
ids: [args]
};
}
- var ids = $$.mapToTargetIds(args.ids);
+ const ids = $$.mapToTargetIds(args.ids);
$$.unload(ids, function () {
_newArrowCheck(this, _this3);
$$.redraw({
@@ -12258,8 +12471,8 @@ var legend_legend = {
* @private
*/
function showHide(show, targetIdsValue, options) {
- var _this = this,
- $$ = this.internal,
+ var _this = this;
+ const $$ = this.internal,
targetIds = $$.mapToTargetIds(targetIdsValue),
hiddenIds = $$.state.hiddenTargetIds.map(function (v) {
_newArrowCheck(this, _this);
@@ -12267,7 +12480,7 @@ function showHide(show, targetIdsValue, options) {
}.bind(this)).filter(Boolean);
$$.state.toggling = !0;
$$[(show ? "remove" : "add") + "HiddenTargetIds"](targetIds);
- var targets = $$.$el.svg.selectAll($$.selectorTargets(targetIds)),
+ const targets = $$.$el.svg.selectAll($$.selectorTargets(targetIds)),
opacity = show ? null : "0";
if (show && hiddenIds.length) {
targets.style("display", null);
@@ -12365,7 +12578,7 @@ function showHide(show, targetIdsValue, options) {
if (options === void 0) {
options = {};
}
- var $$ = this.internal,
+ const $$ = this.internal,
targets = {
show: [],
hide: []
@@ -12397,7 +12610,7 @@ function showHide(show, targetIdsValue, options) {
* Define tooltip
* @ignore
*/
-var tooltip_tooltip = {
+const tooltip_tooltip = {
/**
* Show tooltip
* @function tooltip․show
@@ -12437,6 +12650,10 @@ var tooltip_tooltip = {
* }
* });
*
+ * // for Arc types, specify 'id' or 'index'
+ * chart.tooltip.show({ data: { id: "data2" }});
+ * chart.tooltip.show({ data: { index: 2 }});
+ *
* // when data.xs is used
* chart.tooltip.show({
* data: {
@@ -12456,16 +12673,15 @@ var tooltip_tooltip = {
* });
*/
show: function show(args) {
- var _this = this,
- $$ = this.internal,
+ var _this = this;
+ const $$ = this.internal,
$el = $$.$el,
config = $$.config,
_$$$state = $$.state,
eventReceiver = _$$$state.eventReceiver,
hasTreemap = _$$$state.hasTreemap,
- inputType = _$$$state.inputType,
- index,
- mouse;
+ inputType = _$$$state.inputType;
+ let index, mouse;
// determine mouse position on the chart
if (args.mouse) {
mouse = args.mouse;
@@ -12473,18 +12689,20 @@ var tooltip_tooltip = {
// determine focus data
if (args.data) {
- var data = args.data,
- y = $$.getYScaleById(data.id)(data.value);
+ var _$$$getYScaleById;
+ const data = args.data,
+ y = (_$$$getYScaleById = $$.getYScaleById(data.id)) == null ? void 0 : _$$$getYScaleById(data.value);
if (hasTreemap && data.id) {
eventReceiver.rect = $el.main.select("" + $$.selectorTarget(data.id, undefined, "rect"));
} else if ($$.isMultipleX()) {
// if multiple xs, target point will be determined by mouse
mouse = [$$.xx(data), y];
} else {
+ var _data$index, _$$$getArcElementById;
if (!config.tooltip_grouped) {
mouse = [0, y];
}
- index = isValue(data.index) ? data.index : $$.getIndexByX(data.x);
+ index = (_data$index = data.index) != null ? _data$index : $$.hasArcType() && data.id ? (_$$$getArcElementById = $$.getArcElementByIdOrIndex(data.id)) == null ? void 0 : _$$$getArcElementById.datum().index : $$.getIndexByX(data.x);
}
} else if (isDefined(args.x)) {
index = $$.getIndexByX(args.x);
@@ -12503,13 +12721,13 @@ var tooltip_tooltip = {
* @memberof Chart
*/
hide: function hide() {
- var _this2 = this,
- $$ = this.internal,
+ var _this2 = this;
+ const $$ = this.internal,
inputType = $$.state.inputType,
tooltip = $$.$el.tooltip,
data = tooltip == null ? void 0 : tooltip.datum();
if (data) {
- var index = JSON.parse(data.current)[0].index;
+ const index = JSON.parse(data.current)[0].index;
// make to finalize, possible pending event flow set from '.tooltip.show()' call
(inputType === "mouse" ? ["mouseout"] : ["touchend"]).forEach(function (eventName) {
@@ -12521,9 +12739,9 @@ var tooltip_tooltip = {
// reset last touch point index
inputType === "touch" && $$.callOverOutForTouch();
$$.hideTooltip(!0);
- $$.hideGridFocus == null ? void 0 : $$.hideGridFocus();
- $$.unexpandCircles == null ? void 0 : $$.unexpandCircles();
- $$.expandBarTypeShapes == null ? void 0 : $$.expandBarTypeShapes(!1);
+ $$.hideGridFocus == null || $$.hideGridFocus();
+ $$.unexpandCircles == null || $$.unexpandCircles();
+ $$.expandBarTypeShapes == null || $$.expandBarTypeShapes(!1);
}
};
/* harmony default export */ var api_tooltip = ({
@@ -12636,10 +12854,10 @@ var tooltip_tooltip = {
*
* chart.plugins; // [Stanford, PluginA] - instance array
*/
-var Chart = function Chart(options) {
+let Chart = function Chart(options) {
this.plugins = [];
this.internal = void 0;
- var $$ = new ChartInternal(this);
+ const $$ = new ChartInternal(this);
this.internal = $$;
// bind to namespaced APIs
@@ -12647,7 +12865,7 @@ var Chart = function Chart(options) {
var _this = this;
Object.keys(fn).forEach(function (key) {
_newArrowCheck(this, _this);
- var isFunc = isFunction(fn[key]),
+ const isFunc = isFunction(fn[key]),
isChild = target !== argThis,
isNotNil = notEmpty(fn[key]),
hasChild = isNotNil && Object.keys(fn[key]).length > 0;
@@ -12682,11 +12900,11 @@ extend(Chart.prototype, [chart, api_color, api_data, api_export, api_focus, api_
* @private
*/
function setMinMax($$, type, value) {
- var _this = this,
- config = $$.config,
+ var _this = this;
+ const config = $$.config,
helper = function (key, value) {
_newArrowCheck(this, _this);
- var v = isNumber(value) ? value : value === !1 ? undefined : null;
+ const v = isNumber(value) ? value : value === !1 ? undefined : null;
if (v !== null) {
config["axis_" + key + "_" + type] = v;
}
@@ -12719,7 +12937,7 @@ function setMinMax($$, type, value) {
* @private
*/
function axis_getMinMax($$, type) {
- var config = $$.config;
+ const config = $$.config;
return {
x: config["axis_x_" + type],
y: config["axis_y_" + type],
@@ -12731,9 +12949,10 @@ function axis_getMinMax($$, type) {
* Define axis
* @ignore
*/
-var axis = {
+const axis = {
/**
* Get and set axis labels.
+ * - **NOTE:** Only applicable for chart types which has x and y axes.
* @function axis․labels
* @instance
* @memberof Chart
@@ -12758,9 +12977,9 @@ var axis = {
* // }
*/
labels: function labels(_labels) {
- var _this2 = this,
- $$ = this.internal,
- labelText;
+ var _this2 = this;
+ const $$ = this.internal;
+ let labelText;
if (_labels) {
Object.keys(_labels).forEach(function (axisId) {
_newArrowCheck(this, _this2);
@@ -12770,7 +12989,7 @@ var axis = {
}
["x", "y", "y2"].forEach(function (v) {
_newArrowCheck(this, _this2);
- var text = $$.axis.getLabelText(v);
+ const text = $$.axis.getLabelText(v);
if (text) {
labelText || (labelText = {});
labelText[v] = text;
@@ -12780,6 +12999,7 @@ var axis = {
},
/**
* Get and set axis min value.
+ * - **NOTE:** Only applicable for chart types which has x and y axes.
* @function axis․min
* @instance
* @memberof Chart
@@ -12808,11 +13028,12 @@ var axis = {
* chart.axis.min(false);
*/
min: function min(_min) {
- var $$ = this.internal;
+ const $$ = this.internal;
return isValue(_min) || _min === !1 ? setMinMax($$, "min", _min) : axis_getMinMax($$, "min");
},
/**
* Get and set axis max value.
+ * - **NOTE:** Only applicable for chart types which has x and y axes.
* @function axis․max
* @instance
* @memberof Chart
@@ -12841,11 +13062,12 @@ var axis = {
* chart.axis.max(false);
*/
max: function max(_max) {
- var $$ = this.internal;
+ const $$ = this.internal;
return isValue(_max) || _max === !1 ? setMinMax($$, "max", _max) : axis_getMinMax($$, "max");
},
/**
* Get and set axis min and max value.
+ * - **NOTE:** Only applicable for chart types which has x and y axes.
* @function axis․range
* @instance
* @memberof Chart
@@ -12887,9 +13109,9 @@ var axis = {
* chart.axis.range({ min: false, max: false });
*/
range: function range(_range) {
- var axis = this.axis;
+ const axis = this.axis;
if (arguments.length) {
- var min = _range.min,
+ const min = _range.min,
max = _range.max;
isDefined(max) && axis.max(max);
isDefined(min) && axis.min(min);
@@ -12910,6 +13132,7 @@ var axis = {
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
+
/* harmony default export */ var api_category = ({
/**
* Set specified category name on category axis.
@@ -12923,7 +13146,7 @@ var axis = {
* chart.category(2, "Category 3");
*/
category: function category(i, _category) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config;
if (arguments.length > 1) {
config.axis_x_categories[i] = _category;
@@ -12932,7 +13155,7 @@ var axis = {
return config.axis_x_categories[i];
},
/**
- * Set category names on category axis.
+ * Set or get category names on category axis.
* @function categories
* @instance
* @memberof Chart
@@ -12944,10 +13167,11 @@ var axis = {
* ]);
*/
categories: function categories(_categories) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config;
- if (!arguments.length) {
- return config.axis_x_categories;
+ if (!_categories || !Array.isArray(_categories)) {
+ const cat = config.axis_x_categories;
+ return isEmpty(cat) ? Object.values($$.data.xs)[0] : cat;
}
config.axis_x_categories = _categories;
$$.redraw();
@@ -12968,7 +13192,7 @@ var axis = {
* @private
*/
function grid(grids, axisId) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config,
withTransition = config.transition_duration && isTabVisible(),
gridPropLines = "grid_" + axisId + "_lines";
@@ -13017,7 +13241,7 @@ function _remove(grids, isXAxis) {
* ]);
* // --> Returns: [{value: 1, text: "Label 1"}, {value: 4, text: "Label 4"}]
*/
-var xgrids = function (grids) {
+const xgrids = function (grids) {
return grid.bind(this)(grids, "x");
};
extend(xgrids, {
@@ -13087,7 +13311,7 @@ extend(xgrids, {
* ]);
* // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}]
*/
-var ygrids = function (grids) {
+const ygrids = function (grids) {
return grid.bind(this)(grids, "y");
};
extend(ygrids, {
@@ -13166,7 +13390,7 @@ extend(ygrids, {
* ]);
*/
groups: function groups(_groups) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config;
if (isUndefined(_groups)) {
return config.data_groups;
@@ -13195,7 +13419,7 @@ function regionsFn(regions, isAdd) {
if (isAdd === void 0) {
isAdd = !1;
}
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config,
withTransition = config.transition_duration && isTabVisible();
if (!regions) {
@@ -13221,7 +13445,7 @@ function regionsFn(regions, isAdd) {
* {axis: "y", end: 50, class: "regionY"}
* ]);
*/
-var regions = function (_regions) {
+const regions = function (_regions) {
return regionsFn.bind(this)(_regions);
};
extend(regions, {
@@ -13268,23 +13492,23 @@ extend(regions, {
* chart.regions.remove();
*/
remove: function remove(optionsValue) {
- var _this = this,
- $$ = this.internal,
+ var _this = this;
+ const $$ = this.internal,
config = $$.config,
$T = $$.$T,
options = optionsValue || {},
- classes = getOption(options, "classes", [$REGION.region]),
- regions = $$.$el.main.select("." + $REGION.regions).selectAll(classes.map(function (c) {
- _newArrowCheck(this, _this);
- return "." + c;
- }.bind(this)));
+ classes = getOption(options, "classes", [$REGION.region]);
+ let regions = $$.$el.main.select("." + $REGION.regions).selectAll(classes.map(function (c) {
+ _newArrowCheck(this, _this);
+ return "." + c;
+ }.bind(this)));
$T(regions).style("opacity", "0").remove();
regions = config.regions;
if (Object.keys(options).length) {
regions = regions.filter(function (region) {
var _this2 = this;
_newArrowCheck(this, _this);
- var found = !1;
+ let found = !1;
if (!region.class) {
return !0;
}
@@ -13328,7 +13552,7 @@ extend(regions, {
* chart.x([100, 200, 300, 400, ...]);
*/
x: function x(_x) {
- var $$ = this.internal,
+ const $$ = this.internal,
axis = $$.axis,
data = $$.data,
isCategorized = axis.isCustomX() && axis.isCategorized();
@@ -13363,7 +13587,7 @@ extend(regions, {
* });
*/
xs: function xs(_xs) {
- var $$ = this.internal;
+ const $$ = this.internal;
if (isObject(_xs)) {
$$.updateTargetXs($$.data.targets, _xs);
$$.redraw({
@@ -13432,9 +13656,9 @@ extend(regions, {
* });
*/
flow: function flow(args) {
- var _this = this,
- $$ = this.internal,
- data;
+ var _this = this;
+ const $$ = this.internal;
+ let data;
if (args.json || args.rows || args.columns) {
$$.convertData(args, function (res) {
_newArrowCheck(this, _this);
@@ -13448,8 +13672,8 @@ extend(regions, {
* @private
*/
function _() {
- var _this2 = this,
- domain,
+ var _this2 = this;
+ let domain,
length = 0,
tail = 0,
diff,
@@ -13457,22 +13681,22 @@ extend(regions, {
if ($$.state.redrawing || !data || !isTabVisible()) {
return;
}
- var notfoundIds = [],
+ const notfoundIds = [],
orgDataCount = $$.getMaxDataCount(),
targets = $$.convertDataToTargets(data, !0),
isTimeSeries = $$.axis.isTimeSeries();
// Update/Add data
$$.data.targets.forEach(function (t) {
_newArrowCheck(this, _this2);
- var found = !1;
- for (var i = 0; i < targets.length; i++) {
+ let found = !1;
+ for (let i = 0; i < targets.length; i++) {
if (t.id === targets[i].id) {
found = !0;
if (t.values[t.values.length - 1]) {
tail = t.values[t.values.length - 1].index + 1;
}
length = targets[i].values.length;
- for (var j = 0; j < length; j++) {
+ for (let j = 0; j < length; j++) {
targets[i].values[j].index = tail + j;
if (!isTimeSeries) {
targets[i].values[j].x = tail + j;
@@ -13489,10 +13713,10 @@ extend(regions, {
// Append null for not found targets
$$.data.targets.forEach(function (t) {
_newArrowCheck(this, _this2);
- for (var i = 0; i < notfoundIds.length; i++) {
+ for (let i = 0; i < notfoundIds.length; i++) {
if (t.id === notfoundIds[i]) {
tail = t.values[t.values.length - 1].index + 1;
- for (var j = 0; j < length; j++) {
+ for (let j = 0; j < length; j++) {
t.values.push({
id: t.id,
index: tail + j,
@@ -13509,8 +13733,8 @@ extend(regions, {
targets.forEach(function (t) {
var _this3 = this;
_newArrowCheck(this, _this2);
- var missing = [];
- for (var i = $$.data.targets[0].values[0].index; i < tail; i++) {
+ const missing = [];
+ for (let i = $$.data.targets[0].values[0].index; i < tail; i++) {
missing.push({
id: t.id,
index: i,
@@ -13532,7 +13756,7 @@ extend(regions, {
// check data count because behavior needs to change when it"s only one
// const dataCount = $$.getMaxDataCount();
- var baseTarget = $$.data.targets[0],
+ const baseTarget = $$.data.targets[0],
baseValue = baseTarget.values[0];
// Update length to flow if needed
if (isDefined(args.to)) {
@@ -13591,12 +13815,12 @@ var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack
*/
-var AxisRendererHelper = /*#__PURE__*/function () {
+let AxisRendererHelper = /*#__PURE__*/function () {
function AxisRendererHelper(owner) {
this.owner = void 0;
this.config = void 0;
this.scale = void 0;
- var scale = getScale(),
+ const scale = getScale(),
config = owner.config,
params = owner.params;
this.owner = owner;
@@ -13617,15 +13841,16 @@ var AxisRendererHelper = /*#__PURE__*/function () {
* @private
*/
AxisRendererHelper.getSizeFor1Char = function getSizeFor1Char(node) {
- var _this = this,
- size = {
- w: 5.5,
- h: 11.5
- }; // default size for one character
+ var _this = this;
+ // default size for one character
+ const size = {
+ w: 5.5,
+ h: 11.5
+ };
node.empty() || node.select("text").text("0").call(function (el) {
_newArrowCheck(this, _this);
try {
- var _el$node$getBBox = el.node().getBBox(),
+ const _el$node$getBBox = el.node().getBBox(),
width = _el$node$getBBox.width,
height = _el$node$getBBox.height;
if (width && height) {
@@ -13651,8 +13876,8 @@ var AxisRendererHelper = /*#__PURE__*/function () {
*/;
var _proto = AxisRendererHelper.prototype;
_proto.getTickTransformSetter = function getTickTransformSetter(id) {
- var _this2 = this,
- config = this.config,
+ var _this2 = this;
+ const config = this.config,
fn = id === "x" ? function (value) {
_newArrowCheck(this, _this2);
return "translate(" + (value + config.tickOffset) + ",0)";
@@ -13670,34 +13895,35 @@ var AxisRendererHelper = /*#__PURE__*/function () {
}.bind(this);
};
_proto.scaleExtent = function scaleExtent(domain) {
- var start = domain[0],
+ const start = domain[0],
stop = domain[domain.length - 1];
return start < stop ? [start, stop] : [stop, start];
};
_proto.generateTicks = function generateTicks(scale, isYAxes) {
- var _this4 = this,
- tickStepSize = this.owner.params.tickStepSize,
+ var _this4 = this;
+ const tickStepSize = this.owner.params.tickStepSize,
_scale$domain = scale.domain(),
start = _scale$domain[0],
- end = _scale$domain[1],
- ticks = [];
+ end = _scale$domain[1];
+ let ticks = [];
+
// When 'axis[y|y2].tick.stepSize' option is set
if (isYAxes && tickStepSize) {
- var interval = Math.round(start);
+ let interval = Math.round(start);
while (interval <= end) {
ticks.push(interval);
interval += tickStepSize;
}
} else if (scale.ticks) {
- var tickArguments = this.config.tickArguments;
+ const tickArguments = this.config.tickArguments;
// adjust excessive tick count show
if (scale.type === "log" && !tickArguments) {
// nicer symlog ticks didn't implemented yet: https://github.com/d3/d3-scale/issues/162
// get ticks values from logScale
- var s = getScale("_log").domain([start > 0 ? start : 1, end]).range(scale.range());
+ const s = getScale("_log").domain([start > 0 ? start : 1, end]).range(scale.range());
ticks = s.ticks();
- for (var cnt = end.toFixed().length; ticks.length > 15; cnt--) {
+ for (let cnt = end.toFixed().length; ticks.length > 15; cnt--) {
ticks = s.ticks(cnt);
}
ticks.splice(0, 1, start);
@@ -13708,21 +13934,14 @@ var AxisRendererHelper = /*#__PURE__*/function () {
ticks = ticks.map(function (v) {
_newArrowCheck(this, _this4);
// round the tick value if is number
- var r = isString(v) && isNumber(v) && !isNaN(v) && Math.round(v * 10) / 10 || v;
+ const r = isString(v) && isNumber(v) && !isNaN(v) && Math.round(v * 10) / 10 || v;
return r;
}.bind(this));
- } else {
- for (var i = Math.ceil(start); i < end; i++) {
- ticks.push(i);
- }
- if (ticks.length > 0 && ticks[0] > 0) {
- ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
- }
}
return ticks;
};
_proto.copyScale = function copyScale() {
- var newScale = this.scale.copy();
+ const newScale = this.scale.copy();
if (!newScale.domain().length) {
newScale.domain(this.scale.domain());
}
@@ -13730,7 +13949,7 @@ var AxisRendererHelper = /*#__PURE__*/function () {
return newScale;
};
_proto.textFormatted = function textFormatted(v) {
- var tickFormat = this.config.tickFormat,
+ const tickFormat = this.config.tickFormat,
value = /\d+\.\d+0{5,}\d$/.test(v) ? +(v + "").replace(/0+\d$/, "") : v,
formatted = tickFormat ? tickFormat(value) : value; // to round float numbers from 'binary floating point'
// https://en.wikipedia.org/wiki/Double-precision_floating-point_format
@@ -13738,8 +13957,8 @@ var AxisRendererHelper = /*#__PURE__*/function () {
return isDefined(formatted) ? formatted : "";
};
_proto.transitionise = function transitionise(selection) {
- var config = this.config;
- var transitionSelection = selection;
+ const config = this.config;
+ let transitionSelection = selection;
if (config.withoutTransition) {
transitionSelection = selection.interrupt();
} else if (config.transition || !this.owner.params.noTransition) {
@@ -13764,7 +13983,7 @@ var AxisRendererHelper = /*#__PURE__*/function () {
-var AxisRenderer = /*#__PURE__*/function () {
+let AxisRenderer = /*#__PURE__*/function () {
function AxisRenderer(params) {
if (params === void 0) {
params = {};
@@ -13774,7 +13993,7 @@ var AxisRenderer = /*#__PURE__*/function () {
this.params = void 0;
this.g = void 0;
this.generatedTicks = void 0;
- var config = {
+ const config = {
innerTickSize: 6,
outerTickSize: params.outerTick ? 6 : 0,
orient: "bottom",
@@ -13803,7 +14022,7 @@ var AxisRenderer = /*#__PURE__*/function () {
*/
var _proto = AxisRenderer.prototype;
_proto.create = function create(g) {
- var ctx = this,
+ const ctx = this,
config = ctx.config,
helper = ctx.helper,
params = ctx.params,
@@ -13822,7 +14041,7 @@ var AxisRenderer = /*#__PURE__*/function () {
// tick text helpers
this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
- var innerTickSize = config.innerTickSize,
+ const innerTickSize = config.innerTickSize,
tickLength = config.tickLength,
range = config.range,
id = params.id,
@@ -13837,50 +14056,50 @@ var AxisRenderer = /*#__PURE__*/function () {
text: axisShow ? params.config[prefix + "_tick_text_show"] : !1
}; // // get the axis' tick position configuration
// tick visiblity
- var $g;
+ let $g;
g.each(function () {
- var _this = this,
- g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
- scale0 = this.__chart__ || scale,
+ var _this = this;
+ const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
+ let scale0 = this.__chart__ || scale,
scale1 = helper.copyScale();
$g = g;
this.__chart__ = scale1;
config.tickOffset = params.isCategory ? Math.ceil((scale1(1) - scale1(0)) / 2) : 0;
// update selection - data join
- var path = g.selectAll(".domain").data([0]);
+ const path = g.selectAll(".domain").data([0]);
// enter + update selection
path.enter().append("path").attr("class", "domain")
// https://observablehq.com/@d3/d3-selection-2-0
.merge(path).attr("d", function () {
_newArrowCheck(this, _this);
- var outerTickSized = config.outerTickSize * sign;
+ const outerTickSized = config.outerTickSize * sign;
return isTopBottom ? "M" + range[0] + "," + outerTickSized + "V0H" + range[1] + "V" + outerTickSized : "M" + outerTickSized + "," + range[0] + "H0V" + range[1] + "H" + outerTickSized;
}.bind(this));
if (tickShow.tick || tickShow.text) {
// count of tick data in array
- var ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight);
+ const ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight);
// set generated ticks
ctx.generatedTicks = ticks;
// update selection
- var tick = g.selectAll(".tick").data(ticks, scale1);
+ let tick = g.selectAll(".tick").data(ticks, scale1);
// enter selection
- var tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick"),
+ const tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick"),
tickExit = tick.exit().remove(); // MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks.
// enter + update selection
tick = tickEnter.merge(tick);
tickShow.tick && tickEnter.append("line");
tickShow.text && tickEnter.append("text");
- var sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tick),
+ const sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tick),
counts = [];
- var tspan = tick.select("text").selectAll("tspan").data(function (d, index) {
+ let tspan = tick.select("text").selectAll("tspan").data(function (d, index) {
var _this2 = this;
_newArrowCheck(this, _this);
- var split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
+ const split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
counts[index] = split.length;
return split.map(function (splitted) {
_newArrowCheck(this, _this2);
@@ -13899,14 +14118,14 @@ var AxisRenderer = /*#__PURE__*/function () {
// set 's position
tspan.attr("x", isTopBottom ? 0 : tickLength * sign).attr("dx", function () {
_newArrowCheck(this, _this);
- var dx = 0;
+ let dx = 0;
if (/(top|bottom)/.test(orient) && rotate) {
dx = 8 * Math.sin(Math.PI * (rotate / 180)) * (orient === "top" ? -1 : 1);
}
return dx + (tickTextPos.x || 0);
}.bind(this)()).attr("dy", function (d, i) {
_newArrowCheck(this, _this);
- var dy = 0;
+ let dy = 0;
if (orient !== "top") {
dy = sizeFor1Char.h;
if (i === 0) {
@@ -13915,7 +14134,7 @@ var AxisRenderer = /*#__PURE__*/function () {
}
return isNumber(dy) && tickTextPos.y ? dy + tickTextPos.y : dy || ".71em";
}.bind(this));
- var lineUpdate = tick.select("line"),
+ const lineUpdate = tick.select("line"),
textUpdate = tick.select("text");
tickEnter.select("line").attr(axisPx + "2", innerTickSize * sign);
tickEnter.select("text").attr(axisPx, tickLength * sign);
@@ -13923,14 +14142,14 @@ var AxisRenderer = /*#__PURE__*/function () {
// Append for tooltip display
if (params.tickTitle) {
- var title = textUpdate.select("title");
+ const title = textUpdate.select("title");
(title.empty() ? textUpdate.append("title") : title).text(function (index) {
_newArrowCheck(this, _this);
return params.tickTitle[index];
}.bind(this));
}
if (scale1.bandwidth) {
- var x = scale1,
+ const x = scale1,
dx = x.bandwidth() / 2;
scale0 = function (d) {
_newArrowCheck(this, _this);
@@ -13961,11 +14180,11 @@ var AxisRenderer = /*#__PURE__*/function () {
*/;
_proto.getGeneratedTicks = function getGeneratedTicks(count) {
var _this$generatedTicks,
- _this3 = this,
- len = ((_this$generatedTicks = this.generatedTicks) == null ? void 0 : _this$generatedTicks.length) - 1,
- res = this.generatedTicks;
+ _this3 = this;
+ const len = ((_this$generatedTicks = this.generatedTicks) == null ? void 0 : _this$generatedTicks.length) - 1;
+ let res = this.generatedTicks;
if (len > count) {
- var interval = Math.round(len / count + .1);
+ const interval = Math.round(len / count + .1);
res = this.generatedTicks.map(function (v, i) {
_newArrowCheck(this, _this3);
return i % interval === 0 ? v : null;
@@ -13983,7 +14202,7 @@ var AxisRenderer = /*#__PURE__*/function () {
* @private
*/;
_proto.getTickXY = function getTickXY() {
- var config = this.config,
+ const config = this.config,
pos = {
x: 0,
y: 0
@@ -14002,7 +14221,7 @@ var AxisRenderer = /*#__PURE__*/function () {
* @private
*/;
_proto.getTickSize = function getTickSize(d) {
- var scale = this.helper.scale,
+ const scale = this.helper.scale,
config = this.config,
_config2 = config,
innerTickSize = _config2.innerTickSize,
@@ -14018,8 +14237,8 @@ var AxisRenderer = /*#__PURE__*/function () {
* @private
*/;
_proto.setTickLineTextPosition = function setTickLineTextPosition(lineUpdate, textUpdate) {
- var _this4 = this,
- tickPos = this.getTickXY(),
+ var _this4 = this;
+ const tickPos = this.getTickXY(),
_this$config = this.config,
innerTickSize = _this$config.innerTickSize,
orient = _this$config.orient,
@@ -14028,7 +14247,7 @@ var AxisRenderer = /*#__PURE__*/function () {
rotate = this.params.tickTextRotate,
textAnchorForText = function (r) {
_newArrowCheck(this, _this4);
- var value = ["start", "end"];
+ const value = ["start", "end"];
orient === "top" && value.reverse();
return !r ? "middle" : value[r > 0 ? 0 : 1];
}.bind(this),
@@ -14038,7 +14257,7 @@ var AxisRenderer = /*#__PURE__*/function () {
}.bind(this),
yForText = function (r) {
_newArrowCheck(this, _this4);
- var r2 = r / (orient === "bottom" ? 15 : 23);
+ const r2 = r / (orient === "bottom" ? 15 : 23);
return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
}.bind(this);
switch (orient) {
@@ -14063,7 +14282,7 @@ var AxisRenderer = /*#__PURE__*/function () {
// this should be called only when category axis
;
_proto.splitTickText = function splitTickText(d, scale, ticks, isLeftRight, charWidth) {
- var params = this.params,
+ const params = this.params,
tickText = this.helper.textFormatted(d),
splitted = isString(tickText) && tickText.indexOf("\n") > -1 ? tickText.split("\n") : [];
if (splitted.length) {
@@ -14072,7 +14291,7 @@ var AxisRenderer = /*#__PURE__*/function () {
if (isArray(tickText)) {
return tickText;
}
- var tickWidth = params.tickWidth;
+ let tickWidth = params.tickWidth;
if (!tickWidth || tickWidth <= 0) {
tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(params.isInverted ? scale(ticks[0]) - scale(ticks[1]) : scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
}
@@ -14080,8 +14299,8 @@ var AxisRenderer = /*#__PURE__*/function () {
// split given text by tick width size
// eslint-disable-next-line
function split(splitted, text) {
- var subtext, spaceIndex, textWidth;
- for (var i = 1; i < text.length; i++) {
+ let subtext, spaceIndex, textWidth;
+ for (let i = 1; i < text.length; i++) {
if (text.charAt(i) === " ") {
spaceIndex = i;
}
@@ -14117,7 +14336,7 @@ var AxisRenderer = /*#__PURE__*/function () {
return this;
};
_proto.tickFormat = function tickFormat(format) {
- var config = this.config;
+ const config = this.config;
if (!arguments.length) {
return config.tickFormat;
}
@@ -14125,7 +14344,7 @@ var AxisRenderer = /*#__PURE__*/function () {
return this;
};
_proto.tickCentered = function tickCentered(isCentered) {
- var config = this.config;
+ const config = this.config;
if (!arguments.length) {
return config.tickCentered;
}
@@ -14150,22 +14369,22 @@ var AxisRenderer = /*#__PURE__*/function () {
* @returns {number}
*/;
_proto.tickInterval = function tickInterval(size) {
- var _this5 = this,
- _this$config2 = this.config,
+ var _this5 = this;
+ const _this$config2 = this.config,
outerTickSize = _this$config2.outerTickSize,
tickOffset = _this$config2.tickOffset,
- tickValues = _this$config2.tickValues,
- interval;
+ tickValues = _this$config2.tickValues;
+ let interval;
if (this.params.isCategory) {
interval = tickOffset * 2;
} else {
- var length = this.g.select("path.domain").node().getTotalLength() - outerTickSize * 2;
+ const length = this.g.select("path.domain").node().getTotalLength() - outerTickSize * 2;
interval = length / (size || this.g.selectAll("line").size());
// get the interval by its values
- var intervalByValue = tickValues ? tickValues.map(function (v, i, arr) {
+ const intervalByValue = tickValues ? tickValues.map(function (v, i, arr) {
_newArrowCheck(this, _this5);
- var next = i + 1;
+ const next = i + 1;
return next < arr.length ? this.helper.scale(arr[next]) - this.helper.scale(v) : null;
}.bind(this)).filter(Boolean) : [];
interval = Math.min.apply(Math, intervalByValue.concat([interval]));
@@ -14173,7 +14392,7 @@ var AxisRenderer = /*#__PURE__*/function () {
return interval === Infinity ? 0 : interval;
};
_proto.ticks = function ticks() {
- var config = this.config;
+ const config = this.config;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
@@ -14184,7 +14403,7 @@ var AxisRenderer = /*#__PURE__*/function () {
return this;
};
_proto.tickCulling = function tickCulling(culling) {
- var config = this.config;
+ const config = this.config;
if (!arguments.length) {
return config.tickCulling;
}
@@ -14192,8 +14411,8 @@ var AxisRenderer = /*#__PURE__*/function () {
return this;
};
_proto.tickValues = function tickValues(x) {
- var _this6 = this,
- config = this.config;
+ var _this6 = this;
+ const config = this.config;
if (isFunction(x)) {
config.tickValues = function () {
_newArrowCheck(this, _this6);
@@ -14230,7 +14449,7 @@ var AxisRenderer = /*#__PURE__*/function () {
return this.axis || new Axis_Axis(this);
}
});
-var Axis_Axis = /*#__PURE__*/function () {
+let Axis_Axis = /*#__PURE__*/function () {
function Axis(owner) {
this.owner = void 0;
this.x = void 0;
@@ -14258,17 +14477,17 @@ var Axis_Axis = /*#__PURE__*/function () {
return $AXIS.axis + " " + $AXIS["axis" + capitalize(id)];
};
_proto.isHorizontal = function isHorizontal($$, forHorizontal) {
- var isRotated = $$.config.axis_rotated;
+ const isRotated = $$.config.axis_rotated;
return forHorizontal ? isRotated : !isRotated;
};
_proto.isCategorized = function isCategorized() {
- var _this$owner = this.owner,
+ const _this$owner = this.owner,
config = _this$owner.config,
state = _this$owner.state;
return config.axis_x_type.indexOf("category") >= 0 || state.hasRadar;
};
_proto.isCustomX = function isCustomX() {
- var config = this.owner.config;
+ const config = this.owner.config;
return !this.isTimeSeries() && (config.data_x || notEmpty(config.data_xs));
};
_proto.isTimeSeries = function isTimeSeries(id) {
@@ -14290,7 +14509,7 @@ var Axis_Axis = /*#__PURE__*/function () {
if (id === void 0) {
id = "x";
}
- var type = "linear";
+ let type = "linear";
if (this.isTimeSeries(id)) {
type = this.owner.config.axis_x_localtime ? "time" : "utc";
} else if (this.isLog(id)) {
@@ -14299,8 +14518,8 @@ var Axis_Axis = /*#__PURE__*/function () {
return type;
};
_proto.init = function init() {
- var _this = this,
- $$ = this.owner,
+ var _this = this;
+ const $$ = this.owner,
config = $$.config,
_$$$$el = $$.$el,
main = _$$$$el.main,
@@ -14312,15 +14531,15 @@ var Axis_Axis = /*#__PURE__*/function () {
target.forEach(function (v) {
var _this2 = this;
_newArrowCheck(this, _this);
- var classAxis = this.getAxisClassName(v),
+ const classAxis = this.getAxisClassName(v),
classLabel = $AXIS["axis" + v.toUpperCase() + "Label"];
axis[v] = main.append("g").attr("class", classAxis).attr("clip-path", function () {
_newArrowCheck(this, _this2);
- var res = null;
+ let res = null;
if (v === "x") {
res = clip.pathXAxis;
} else if (v === "y") {
- // && config.axis_y_inner) {
+ // || v === "y2") {
res = clip.pathYAxis;
}
return res;
@@ -14338,7 +14557,7 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/;
_proto.setOrient = function setOrient() {
- var $$ = this.owner,
+ const $$ = this.owner,
_$$$config = $$.config,
isRotated = _$$$config.axis_rotated,
yInner = _$$$config.axis_y_inner,
@@ -14358,13 +14577,13 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/;
_proto.generateAxes = function generateAxes(id) {
- var _this3 = this,
- $$ = this.owner,
+ var _this3 = this;
+ const $$ = this.owner,
config = $$.config,
axes = [],
axesConfig = config["axis_" + id + "_axes"],
- isRotated = config.axis_rotated,
- d3Axis;
+ isRotated = config.axis_rotated;
+ let d3Axis;
if (id === "x") {
d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisLeft : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisBottom;
} else if (id === "y") {
@@ -14376,7 +14595,7 @@ var Axis_Axis = /*#__PURE__*/function () {
axesConfig.forEach(function (v) {
var _this4 = this;
_newArrowCheck(this, _this3);
- var tick = v.tick || {},
+ const tick = v.tick || {},
scale = $$.scale[id].copy();
v.domain && scale.domain(v.domain);
axes.push(d3Axis(scale).ticks(tick.count).tickFormat(isFunction(tick.format) ? tick.format.bind($$.api) : function (x) {
@@ -14393,21 +14612,21 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/;
_proto.updateAxes = function updateAxes() {
- var _this5 = this,
- $$ = this.owner,
+ var _this5 = this;
+ const $$ = this.owner,
config = $$.config,
main = $$.$el.main,
$T = $$.$T;
Object.keys(this.axesList).forEach(function (id) {
var _this6 = this;
_newArrowCheck(this, _this5);
- var axesConfig = config["axis_" + id + "_axes"],
+ const axesConfig = config["axis_" + id + "_axes"],
scale = $$.scale[id].copy(),
range = scale.range();
this.axesList[id].forEach(function (v, i) {
var _this7 = this;
_newArrowCheck(this, _this6);
- var axisRange = v.scale().range();
+ const axisRange = v.scale().range();
// adjust range value with the current
// https://github.com/naver/billboard.js/issues/859
@@ -14417,8 +14636,8 @@ var Axis_Axis = /*#__PURE__*/function () {
}.bind(this))) {
v.scale().range(range);
}
- var className = this.getAxisClassName(id) + "-" + (i + 1);
- var g = main.select("." + className.replace(/\s/, "."));
+ const className = this.getAxisClassName(id) + "-" + (i + 1);
+ let g = main.select("." + className.replace(/\s/, "."));
if (g.empty()) {
g = main.append("g").attr("class", className).style("visibility", config["axis_" + id + "_show"] ? null : "hidden").call(v);
} else {
@@ -14440,7 +14659,7 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/;
_proto.setAxis = function setAxis(id, scale, outerTick, noTransition) {
- var $$ = this.owner;
+ const $$ = this.owner;
if (id !== "subX") {
this.tick[id] = this.getTickValues(id);
}
@@ -14452,28 +14671,28 @@ var Axis_Axis = /*#__PURE__*/function () {
id === "x" && ($$.scale.zoom || $$.config.subchart_show || $$.state.resizing) ? !0 : noTransition);
}
- // called from : getMaxTickWidth()
+ // called from : getMaxTickSize()
;
_proto.getAxis = function getAxis(id, scale, outerTick, noTransition, noTickTextRotate) {
- var _this8 = this,
- $$ = this.owner,
+ var _this8 = this;
+ const $$ = this.owner,
config = $$.config,
isX = /^(x|subX)$/.test(id),
type = isX ? "x" : id,
isCategory = isX && this.isCategorized(),
orient = this.orient[id],
- tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type),
- tickFormat;
+ tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type);
+ let tickFormat;
if (isX) {
tickFormat = id === "subX" ? $$.format.subXAxisTick : $$.format.xAxisTick;
} else {
- var fn = config["axis_" + id + "_tick_format"];
+ const fn = config["axis_" + id + "_tick_format"];
if (isFunction(fn)) {
tickFormat = fn.bind($$.api);
}
}
- var tickValues = this.tick[type];
- var axisParams = mergeObj({
+ let tickValues = this.tick[type];
+ const axisParams = mergeObj({
outerTick: outerTick,
noTransition: noTransition,
config: config,
@@ -14491,12 +14710,12 @@ var Axis_Axis = /*#__PURE__*/function () {
if (!isX) {
axisParams.tickStepSize = config["axis_" + type + "_tick_stepSize"];
}
- var axis = new AxisRenderer(axisParams).scale(isX && $$.scale.zoom || scale).orient(orient);
+ const axis = new AxisRenderer(axisParams).scale(isX && $$.scale.zoom || scale).orient(orient);
if (isX && this.isTimeSeries() && tickValues && !isFunction(tickValues)) {
- var _fn = parseDate.bind($$);
+ const fn = parseDate.bind($$);
tickValues = tickValues.map(function (v) {
_newArrowCheck(this, _this8);
- return _fn(v);
+ return fn(v);
}.bind(this));
} else if (!isX && this.isTimeSeriesY()) {
// https://github.com/d3/d3/blob/master/CHANGES.md#time-intervals-d3-time
@@ -14516,15 +14735,15 @@ var Axis_Axis = /*#__PURE__*/function () {
config.axis_x_tick_culling = !1;
}
}
- var tickCount = config["axis_" + type + "_tick_count"];
+ const tickCount = config["axis_" + type + "_tick_count"];
tickCount && axis.ticks(tickCount);
return axis;
};
_proto.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) {
- var $$ = this.owner,
+ const $$ = this.owner,
config = $$.config,
fit = config.axis_x_tick_fit;
- var count = config.axis_x_tick_count,
+ let count = config.axis_x_tick_count,
values;
if (fit || count && fit) {
values = $$.mapTargetsToUniqueXs(targets);
@@ -14540,15 +14759,15 @@ var Axis_Axis = /*#__PURE__*/function () {
} else if (this.x) {
var _this$subX;
this.x.tickValues(values);
- (_this$subX = this.subX) == null ? void 0 : _this$subX.tickValues(values);
+ (_this$subX = this.subX) == null || _this$subX.tickValues(values);
}
return values;
};
_proto.getId = function getId(id) {
- var _this$owner2 = this.owner,
+ const _this$owner2 = this.owner,
config = _this$owner2.config,
scale = _this$owner2.scale;
- var axis = config.data_axes[id];
+ let axis = config.data_axes[id];
// when data.axes option has 'y2', but 'axis.y2.show=true' isn't set will return 'y'
if (!axis || !scale[axis]) {
@@ -14557,14 +14776,17 @@ var Axis_Axis = /*#__PURE__*/function () {
return axis;
};
_proto.getXAxisTickFormat = function getXAxisTickFormat(forSubchart) {
- var _this9 = this,
- $$ = this.owner,
+ var _this9 = this;
+ const $$ = this.owner,
config = $$.config,
format = $$.format,
tickFormat = forSubchart ? config.subchart_axis_x_tick_format || config.axis_x_tick_format : config.axis_x_tick_format,
isTimeSeries = this.isTimeSeries(),
- isCategorized = this.isCategorized(),
- currFormat; // enable different tick format for x and subX - subX format defaults to x format if not defined
+ isCategorized = this.isCategorized();
+
+ // enable different tick format for x and subX - subX format defaults to x format if not defined
+
+ let currFormat;
if (tickFormat) {
if (isFunction(tickFormat)) {
currFormat = tickFormat.bind($$.api);
@@ -14586,7 +14808,7 @@ var Axis_Axis = /*#__PURE__*/function () {
}.bind(this) : currFormat;
};
_proto.getTickValues = function getTickValues(id) {
- var $$ = this.owner,
+ const $$ = this.owner,
tickValues = $$.config["axis_" + id + "_tick_values"],
axis = $$[id + "Axis"];
return (isFunction(tickValues) ? tickValues.call($$.api) : tickValues) || (axis ? axis.tickValues() : undefined);
@@ -14595,11 +14817,11 @@ var Axis_Axis = /*#__PURE__*/function () {
return this.owner.config["axis_" + id + "_label"];
};
_proto.getLabelText = function getLabelText(id) {
- var option = this.getLabelOptionByAxisId(id);
+ const option = this.getLabelOptionByAxisId(id);
return isString(option) ? option : option ? option.text : null;
};
_proto.setLabelText = function setLabelText(id, text) {
- var $$ = this.owner,
+ const $$ = this.owner,
config = $$.config,
option = this.getLabelOptionByAxisId(id);
if (isString(option)) {
@@ -14609,8 +14831,8 @@ var Axis_Axis = /*#__PURE__*/function () {
}
};
_proto.getLabelPosition = function getLabelPosition(id, defaultPosition) {
- var _this10 = this,
- isRotated = this.owner.config.axis_rotated,
+ var _this10 = this;
+ const isRotated = this.owner.config.axis_rotated,
option = this.getLabelOptionByAxisId(id),
position = isObjectType(option) && option.position ? option.position : defaultPosition[+!isRotated],
has = function (v) {
@@ -14635,12 +14857,12 @@ var Axis_Axis = /*#__PURE__*/function () {
return this.getAxisLabelPosition(id);
};
_proto.xForAxisLabel = function xForAxisLabel(id) {
- var $$ = this.owner,
+ const $$ = this.owner,
_$$$state = $$.state,
width = _$$$state.width,
height = _$$$state.height,
position = this.getAxisLabelPosition(id);
- var x = position.isMiddle ? -height / 2 : 0;
+ let x = position.isMiddle ? -height / 2 : 0;
if (this.isHorizontal($$, id !== "x")) {
x = position.isLeft ? 0 : position.isCenter ? width / 2 : width;
} else if (position.isBottom) {
@@ -14649,9 +14871,9 @@ var Axis_Axis = /*#__PURE__*/function () {
return x;
};
_proto.dxForAxisLabel = function dxForAxisLabel(id) {
- var $$ = this.owner,
+ const $$ = this.owner,
position = this.getAxisLabelPosition(id);
- var dx = position.isBottom ? "0.5em" : "0";
+ let dx = position.isBottom ? "0.5em" : "0";
if (this.isHorizontal($$, id !== "x")) {
dx = position.isLeft ? "0.5em" : position.isRight ? "-0.5em" : "0";
} else if (position.isTop) {
@@ -14660,9 +14882,9 @@ var Axis_Axis = /*#__PURE__*/function () {
return dx;
};
_proto.textAnchorForAxisLabel = function textAnchorForAxisLabel(id) {
- var $$ = this.owner,
+ const $$ = this.owner,
position = this.getAxisLabelPosition(id);
- var anchor = position.isMiddle ? "middle" : "end";
+ let anchor = position.isMiddle ? "middle" : "end";
if (this.isHorizontal($$, id !== "x")) {
anchor = position.isLeft ? "start" : position.isCenter ? "middle" : "end";
} else if (position.isBottom) {
@@ -14671,15 +14893,16 @@ var Axis_Axis = /*#__PURE__*/function () {
return anchor;
};
_proto.dyForAxisLabel = function dyForAxisLabel(id) {
- var $$ = this.owner,
+ const $$ = this.owner,
config = $$.config,
isRotated = config.axis_rotated,
isInner = this.getAxisLabelPosition(id).isInner,
tickRotate = config["axis_" + id + "_tick_rotate"] ? $$.getHorizontalAxisHeight(id) : 0,
- maxTickWidth = this.getMaxTickWidth(id);
- var dy;
+ _this$getMaxTickSize = this.getMaxTickSize(id),
+ maxTickWidth = _this$getMaxTickSize.width;
+ let dy;
if (id === "x") {
- var xHeight = config.axis_x_height;
+ const xHeight = config.axis_x_height;
if (isRotated) {
dy = isInner ? "1.2em" : -25 - maxTickWidth;
} else if (isInner) {
@@ -14709,22 +14932,34 @@ var Axis_Axis = /*#__PURE__*/function () {
}
}
return dy;
- };
- _proto.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) {
- var _this11 = this,
- $$ = this.owner,
+ }
+
+ /**
+ * Get max tick size
+ * @param {string} id axis id string
+ * @param {boolean} withoutRecompute wheather or not to recompute
+ * @returns {object} {width, height}
+ * @private
+ */;
+ _proto.getMaxTickSize = function getMaxTickSize(id, withoutRecompute) {
+ var _this11 = this;
+ const $$ = this.owner,
config = $$.config,
current = $$.state.current,
_$$$$el2 = $$.$el,
svg = _$$$$el2.svg,
chart = _$$$$el2.chart,
- currentTickMax = current.maxTickWidths[id],
- maxWidth = 0;
- if (withoutRecompute || !config["axis_" + id + "_show"] || currentTickMax.size > 0 && $$.filterTargetsToShow().length === 0) {
- return currentTickMax.size;
+ currentTickMax = current.maxTickSize[id],
+ configPrefix = "axis_" + id,
+ max = {
+ width: 0,
+ height: 0
+ };
+ if (withoutRecompute || !config[configPrefix + "_show"] || currentTickMax.width > 0 && $$.filterTargetsToShow().length === 0) {
+ return currentTickMax;
}
if (svg) {
- var isYAxis = /^y2?$/.test(id),
+ const isYAxis = /^y2?$/.test(id),
targetsToShow = $$.filterTargetsToShow($$.data.targets),
scale = $$.scale[id].copy().domain($$["get" + (isYAxis ? "Y" : "X") + "Domain"](targetsToShow, id)),
domain = scale.domain(),
@@ -14747,9 +14982,10 @@ var Axis_Axis = /*#__PURE__*/function () {
if (!isYAxis) {
currentTickMax.ticks.splice(0);
}
- var axis = this.getAxis(id, scale, !1, !1, !0),
- tickCount = config["axis_" + id + "_tick_count"],
- tickValues = config["axis_" + id + "_tick_values"];
+ const axis = this.getAxis(id, scale, !1, !1, !0),
+ tickRotate = config[configPrefix + "_tick_rotate"],
+ tickCount = config[configPrefix + "_tick_count"],
+ tickValues = config[configPrefix + "_tick_values"];
// Make to generate the final tick text to be rendered
// https://github.com/naver/billboard.js/issues/920
// Do not generate if 'tick values' option is given
@@ -14758,31 +14994,38 @@ var Axis_Axis = /*#__PURE__*/function () {
axis.tickValues(this.generateTickValues(domain, tickCount, isYAxis ? this.isTimeSeriesY() : this.isTimeSeries()));
}
isYAxis || this.updateXAxisTickValues(targetsToShow, axis);
- var dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0").style("left", "0");
+ const dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0").style("left", "0");
axis.create(dummy);
- dummy.selectAll("text").each(function (d, i) {
- var currentTextWidth = this.getBoundingClientRect().width;
- maxWidth = Math.max(maxWidth, currentTextWidth);
+ dummy.selectAll("text").attr("transform", isNumber(tickRotate) ? "rotate(" + tickRotate + ")" : null).each(function (d, i) {
+ const _this$getBoundingClie = this.getBoundingClientRect(),
+ width = _this$getBoundingClie.width,
+ height = _this$getBoundingClie.height;
+ max.width = Math.max(max.width, width);
+ max.height = Math.max(max.height, height);
+
// cache tick text width for getXAxisTickTextY2Overflow()
if (!isYAxis) {
- currentTickMax.ticks[i] = currentTextWidth;
+ currentTickMax.ticks[i] = width;
}
});
dummy.remove();
}
- if (maxWidth > 0) {
- currentTickMax.size = maxWidth;
- }
- return currentTickMax.size;
+ Object.keys(max).forEach(function (key) {
+ _newArrowCheck(this, _this11);
+ if (max[key] > 0) {
+ currentTickMax[key] = max[key];
+ }
+ }.bind(this));
+ return currentTickMax;
};
_proto.getXAxisTickTextY2Overflow = function getXAxisTickTextY2Overflow(defaultPadding) {
- var $$ = this.owner,
+ const $$ = this.owner,
axis = $$.axis,
config = $$.config,
state = $$.state,
xAxisTickRotate = $$.getAxisTickRotate("x");
- if ((axis.isCategorized() || axis.isTimeSeries()) && config.axis_x_tick_fit && !config.axis_x_tick_culling && !config.axis_x_tick_multiline && xAxisTickRotate > 0 && xAxisTickRotate < 90) {
- var widthWithoutCurrentPaddingLeft = state.current.width - $$.getCurrentPaddingLeft(),
+ if ((axis.isCategorized() || axis.isTimeSeries()) && config.axis_x_tick_fit && (!config.axis_x_tick_culling || isEmpty(config.axis_x_tick_culling)) && !config.axis_x_tick_multiline && xAxisTickRotate > 0 && xAxisTickRotate < 90) {
+ const widthWithoutCurrentPaddingLeft = state.current.width - $$.getCurrentPaddingByDirection("left"),
maxOverflow = this.getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft - defaultPadding),
xAxisTickTextY2Overflow = Math.max(0, maxOverflow) + defaultPadding;
// for display inconsistencies between browsers
@@ -14792,45 +15035,40 @@ var Axis_Axis = /*#__PURE__*/function () {
return 0;
};
_proto.getXAxisTickMaxOverflow = function getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft) {
- var $$ = this.owner,
+ const $$ = this.owner,
axis = $$.axis,
config = $$.config,
state = $$.state,
isTimeSeries = axis.isTimeSeries(),
- tickTextWidths = state.current.maxTickWidths.x.ticks,
+ tickTextWidths = state.current.maxTickSize.x.ticks,
tickCount = tickTextWidths.length,
_state$axis$x$padding = state.axis.x.padding,
left = _state$axis$x$padding.left,
right = _state$axis$x$padding.right;
- var maxOverflow = 0;
- var remaining = tickCount - (isTimeSeries && config.axis_x_tick_fit ? .5 : 0);
- for (var i = 0; i < tickCount; i++) {
- var tickIndex = i + 1,
+ let maxOverflow = 0;
+ const remaining = tickCount - (isTimeSeries && config.axis_x_tick_fit ? .5 : 0);
+ for (let i = 0; i < tickCount; i++) {
+ const tickIndex = i + 1,
rotatedTickTextWidth = Math.cos(Math.PI * xAxisTickRotate / 180) * tickTextWidths[i],
ticksBeforeTickText = tickIndex - (isTimeSeries ? 1 : .5) + left;
// Skip ticks if there are no ticks before them
if (ticksBeforeTickText <= 0) {
continue;
}
- var xAxisLengthWithoutTickTextWidth = widthWithoutCurrentPaddingLeft - rotatedTickTextWidth,
- tickLength = xAxisLengthWithoutTickTextWidth / ticksBeforeTickText,
- remainingTicks = remaining - tickIndex,
- paddingRightLength = right * tickLength,
- remainingTickWidth = remainingTicks * tickLength + paddingRightLength,
- overflow = rotatedTickTextWidth - tickLength / 2 - remainingTickWidth;
- maxOverflow = Math.max(maxOverflow, overflow);
+ const tickLength = (widthWithoutCurrentPaddingLeft - rotatedTickTextWidth) / ticksBeforeTickText;
+ maxOverflow = Math.max(maxOverflow, rotatedTickTextWidth - tickLength / 2 - ((remaining - tickIndex) * tickLength + right * tickLength));
}
- var filteredTargets = $$.filterTargetsToShow($$.data.targets);
- var tickOffset = 0;
+ const filteredTargets = $$.filterTargetsToShow($$.data.targets);
+ let tickOffset = 0;
if (!isTimeSeries && config.axis_x_tick_count <= filteredTargets.length && filteredTargets[0].values.length) {
- var _scale2 = getScale($$.axis.getAxisType("x"), 0, widthWithoutCurrentPaddingLeft - maxOverflow).domain([left * -1, $$.getXDomainMax($$.data.targets) + 1 + right]);
- tickOffset = Math.ceil((_scale2(1) - _scale2(0)) / 2);
+ const scale = getScale($$.axis.getAxisType("x"), 0, widthWithoutCurrentPaddingLeft - maxOverflow).domain([left * -1, $$.getXDomainMax($$.data.targets) + 1 + right]);
+ tickOffset = Math.ceil((scale(1) - scale(0)) / 2);
}
return maxOverflow + tickOffset;
};
_proto.updateLabels = function updateLabels(withTransition) {
- var _this12 = this,
- $$ = this.owner,
+ var _this12 = this;
+ const $$ = this.owner,
main = $$.$el.main,
$T = $$.$T,
labels = {
@@ -14844,7 +15082,7 @@ var Axis_Axis = /*#__PURE__*/function () {
}.bind(this)).forEach(function (v) {
var _this13 = this;
_newArrowCheck(this, _this12);
- var node = labels[v];
+ const node = labels[v];
// @check $$.$T(node, withTransition)
$T(node, withTransition).attr("x", function () {
@@ -14873,17 +15111,17 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/;
_proto.getPadding = function getPadding(padding, key, defaultValue, domainLength) {
- var p = isNumber(padding) ? padding : padding[key];
+ const p = isNumber(padding) ? padding : padding[key];
if (!isValue(p)) {
return defaultValue;
}
return this.owner.convertPixelToScale(/(bottom|top)/.test(key) ? "y" : "x", p, domainLength);
};
_proto.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) {
- var _this14 = this,
- tickValues = values;
+ var _this14 = this;
+ let tickValues = values;
if (tickCount) {
- var targetCount = isFunction(tickCount) ? tickCount() : tickCount;
+ const targetCount = isFunction(tickCount) ? tickCount() : tickCount;
// compute ticks according to tickCount
if (targetCount === 1) {
@@ -14891,15 +15129,15 @@ var Axis_Axis = /*#__PURE__*/function () {
} else if (targetCount === 2) {
tickValues = [values[0], values[values.length - 1]];
} else if (targetCount > 2) {
- var isCategorized = this.isCategorized(),
+ const isCategorized = this.isCategorized(),
count = targetCount - 2,
start = values[0],
end = values[values.length - 1];
- var tickValue;
+ let tickValue;
// re-construct unique values
tickValues = [start];
- for (var i = 0; i < count; i++) {
+ for (let i = 0; i < count; i++) {
tickValue = +start + (end - start) / (count + 1) * (i + 1);
tickValues.push(forTimeSeries ? new Date(tickValue) : isCategorized ? Math.round(tickValue) : tickValue);
}
@@ -14915,8 +15153,8 @@ var Axis_Axis = /*#__PURE__*/function () {
return tickValues;
};
_proto.generateTransitions = function generateTransitions(withTransition) {
- var _this15 = this,
- $$ = this.owner,
+ var _this15 = this;
+ const $$ = this.owner,
axis = $$.$el.axis,
$T = $$.$T,
_map = ["x", "y", "y2", "subX"].map(function (v) {
@@ -14935,14 +15173,14 @@ var Axis_Axis = /*#__PURE__*/function () {
};
};
_proto.redraw = function redraw(transitions, isHidden, isInit) {
- var _this16 = this,
- $$ = this.owner,
+ var _this16 = this;
+ const $$ = this.owner,
config = $$.config,
$el = $$.$el,
opacity = isHidden ? "0" : null;
["x", "y", "y2", "subX"].forEach(function (id) {
_newArrowCheck(this, _this16);
- var axis = this[id],
+ const axis = this[id],
$axis = $el.axis[id];
if (axis && $axis) {
if (!isInit && !config.transition_duration) {
@@ -14965,13 +15203,13 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/;
_proto.redrawAxis = function redrawAxis(targetsToShow, wth, transitions, flow, isInit) {
- var _this17 = this,
- $$ = this.owner,
+ var _this17 = this;
+ const $$ = this.owner,
config = $$.config,
scale = $$.scale,
$el = $$.$el,
- hasZoom = !!scale.zoom,
- xDomainForZoom;
+ hasZoom = !!scale.zoom;
+ let xDomainForZoom;
if (!hasZoom && this.isCategorized() && targetsToShow.length === 0) {
scale.x.domain([0, $el.axis.x.selectAll(".tick").size()]);
}
@@ -14983,7 +15221,7 @@ var Axis_Axis = /*#__PURE__*/function () {
} else if (this.x) {
var _this$subX2;
this.x.tickValues([]);
- (_this$subX2 = this.subX) == null ? void 0 : _this$subX2.tickValues([]);
+ (_this$subX2 = this.subX) == null || _this$subX2.tickValues([]);
}
if (config.zoom_rescale && !flow) {
xDomainForZoom = scale.x.orgDomain();
@@ -14991,14 +15229,14 @@ var Axis_Axis = /*#__PURE__*/function () {
["y", "y2"].forEach(function (key) {
var _this18 = this;
_newArrowCheck(this, _this17);
- var prefix = "axis_" + key + "_",
+ const prefix = "axis_" + key + "_",
axisScale = scale[key];
if (axisScale) {
- var tickValues = config[prefix + "tick_values"],
+ const tickValues = config[prefix + "tick_values"],
tickCount = config[prefix + "tick_count"];
axisScale.domain($$.getYDomain(targetsToShow, key, xDomainForZoom));
if (!tickValues && tickCount) {
- var axis = $$.axis[key],
+ const axis = $$.axis[key],
domain = axisScale.domain();
axis.tickValues(this.generateTickValues(domain, domain.every(function (v) {
_newArrowCheck(this, _this18);
@@ -15022,8 +15260,8 @@ var Axis_Axis = /*#__PURE__*/function () {
// Update sub domain
if (wth.Y) {
var _scale$subY, _scale$subY2;
- (_scale$subY = scale.subY) == null ? void 0 : _scale$subY.domain($$.getYDomain(targetsToShow, "y"));
- (_scale$subY2 = scale.subY2) == null ? void 0 : _scale$subY2.domain($$.getYDomain(targetsToShow, "y2"));
+ (_scale$subY = scale.subY) == null || _scale$subY.domain($$.getYDomain(targetsToShow, "y"));
+ (_scale$subY2 = scale.subY2) == null || _scale$subY2.domain($$.getYDomain(targetsToShow, "y2"));
}
}
@@ -15032,8 +15270,8 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/;
_proto.setCulling = function setCulling() {
- var _this19 = this,
- $$ = this.owner,
+ var _this19 = this;
+ const $$ = this.owner,
config = $$.config,
_$$$state2 = $$.state,
clip = _$$$state2.clip,
@@ -15041,26 +15279,26 @@ var Axis_Axis = /*#__PURE__*/function () {
$el = $$.$el;
["subX", "x", "y", "y2"].forEach(function (type) {
_newArrowCheck(this, _this19);
- var axis = $el.axis[type],
+ const axis = $el.axis[type],
id = type === "subX" ? "x" : type,
cullingOptionPrefix = "axis_" + id + "_tick_culling",
toCull = config[cullingOptionPrefix]; // subchart x axis should be aligned with x axis culling
if (axis && toCull) {
- var tickNodes = axis.selectAll(".tick"),
+ const tickNodes = axis.selectAll(".tick"),
tickValues = sortValue(tickNodes.data()),
tickSize = tickValues.length,
cullingMax = config[cullingOptionPrefix + "_max"],
lines = config[cullingOptionPrefix + "_lines"];
- var intervalForCulling;
+ let intervalForCulling;
if (tickSize) {
- for (var i = 1; i < tickSize; i++) {
+ for (let i = 1; i < tickSize; i++) {
if (tickSize / i < cullingMax) {
intervalForCulling = i;
break;
}
}
tickNodes.each(function (d) {
- var node = lines ? this.querySelector("text") : this;
+ const node = lines ? this.querySelector("text") : this;
if (node) {
node.style.display = tickValues.indexOf(d) % intervalForCulling ? "none" : null;
}
@@ -15071,7 +15309,7 @@ var Axis_Axis = /*#__PURE__*/function () {
// set/unset x_axis_tick_clippath
if (type === "x") {
- var clipPath = current.maxTickWidths.x.clipPath ? clip.pathXAxisTickTexts : null;
+ const clipPath = current.maxTickSize.x.clipPath ? clip.pathXAxisTickTexts : null;
$el.svg.selectAll("." + $AXIS.axisX + " .tick text").attr("clip-path", clipPath);
}
}
@@ -15094,7 +15332,7 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/
initEventRect: function initEventRect() {
- var $$ = this;
+ const $$ = this;
$$.$el.main.select("." + $COMMON.chart).append("g").attr("class", $EVENT.eventRects).style("fill-opacity", "0");
},
/**
@@ -15102,8 +15340,8 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/
redrawEventRect: function redrawEventRect() {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
$el = $$.$el,
@@ -15114,7 +15352,7 @@ var Axis_Axis = /*#__PURE__*/function () {
// do not initialize eventRect when data is empty
} else if ($$.data.targets.length) {
- var eventRects = $$.$el.main.select("." + $EVENT.eventRects).style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ? config.axis_rotated ? "ns-resize" : "ew-resize" : null).classed($EVENT.eventRectsMultiple, isMultipleX).classed($EVENT.eventRectsSingle, !isMultipleX),
+ const eventRects = $$.$el.main.select("." + $EVENT.eventRects).style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ? config.axis_rotated ? "ns-resize" : "ew-resize" : null).classed($EVENT.eventRectsMultiple, isMultipleX).classed($EVENT.eventRectsSingle, !isMultipleX),
eventRectUpdate = eventRects.selectAll("." + $EVENT.eventRect).data([0]).enter().append("rect"); // append event
$$.updateEventRect(eventRectUpdate);
@@ -15125,7 +15363,7 @@ var Axis_Axis = /*#__PURE__*/function () {
eventRectUpdate.call($$.getDraggableSelection());
$el.eventRect = eventRectUpdate;
if ($$.state.inputType === "touch" && !$el.svg.on("touchstart.eventRect") && !$$.hasArcType()) {
- $$.bindTouchOnEventRect(isMultipleX);
+ $$.bindTouchOnEventRect();
}
// when initilazed with empty data and data loaded later, need to update eventRect
@@ -15133,7 +15371,7 @@ var Axis_Axis = /*#__PURE__*/function () {
}
if (!isMultipleX) {
// Set data and update eventReceiver.data
- var xAxisTickValues = $$.getMaxDataCountTarget();
+ const xAxisTickValues = $$.getMaxDataCountTarget();
if (!config.data_xSort || isInverted) {
xAxisTickValues.sort(function (a, b) {
_newArrowCheck(this, _this);
@@ -15144,14 +15382,14 @@ var Axis_Axis = /*#__PURE__*/function () {
// update data's index value to be alinged with the x Axis
$$.updateDataIndexByX(xAxisTickValues);
$$.updateXs(xAxisTickValues);
- $$.updatePointClass == null ? void 0 : $$.updatePointClass(!0);
+ $$.updatePointClass == null || $$.updatePointClass(!0);
state.eventReceiver.data = xAxisTickValues;
}
$$.updateEventRectData();
},
- bindTouchOnEventRect: function bindTouchOnEventRect(isMultipleX) {
- var _this2 = this,
- $$ = this,
+ bindTouchOnEventRect: function bindTouchOnEventRect() {
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
_$$$$el = $$.$el,
@@ -15159,12 +15397,12 @@ var Axis_Axis = /*#__PURE__*/function () {
svg = _$$$$el.svg,
selectRect = function (context) {
_newArrowCheck(this, _this2);
- if (isMultipleX) {
+ if ($$.isMultipleX()) {
$$.selectRectForMultipleXs(context);
} else {
- var index = $$.getDataIndexFromEvent(state.event);
+ const index = $$.getDataIndexFromEvent(state.event);
$$.callOverOutForTouch(index);
- index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, eventRect, index);
+ index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, index);
}
}.bind(this),
unselectRect = function () {
@@ -15174,29 +15412,33 @@ var Axis_Axis = /*#__PURE__*/function () {
}.bind(this),
preventDefault = config.interaction_inputType_touch.preventDefault,
isPrevented = isboolean(preventDefault) && preventDefault || !1,
- preventThreshold = !isNaN(preventDefault) && preventDefault || null,
- startPx,
- preventEvent = function (event) {
- _newArrowCheck(this, _this2);
- var eventType = event.type,
- touch = event.changedTouches[0],
- currentXY = touch["client" + (config.axis_rotated ? "Y" : "X")];
- // prevent document scrolling
- if (eventType === "touchstart") {
- if (isPrevented) {
- event.preventDefault();
- } else if (preventThreshold !== null) {
- startPx = currentXY;
- }
- } else if (eventType === "touchmove") {
- if (isPrevented || startPx === !0 || preventThreshold !== null && Math.abs(startPx - currentXY) >= preventThreshold) {
- // once prevented, keep prevented during whole 'touchmove' context
- startPx = !0;
- event.preventDefault();
- }
- }
- }.bind(this); // call event.preventDefault()
+ preventThreshold = !isNaN(preventDefault) && preventDefault || null;
+
+ // call event.preventDefault()
// according 'interaction.inputType.touch.preventDefault' option
+
+ let startPx;
+ const preventEvent = function (event) {
+ _newArrowCheck(this, _this2);
+ const eventType = event.type,
+ touch = event.changedTouches[0],
+ currentXY = touch["client" + (config.axis_rotated ? "Y" : "X")];
+ // prevent document scrolling
+ if (eventType === "touchstart") {
+ if (isPrevented) {
+ event.preventDefault();
+ } else if (preventThreshold !== null) {
+ startPx = currentXY;
+ }
+ } else if (eventType === "touchmove") {
+ if (isPrevented || startPx === !0 || preventThreshold !== null && Math.abs(startPx - currentXY) >= preventThreshold) {
+ // once prevented, keep prevented during whole 'touchmove' context
+ startPx = !0;
+ event.preventDefault();
+ }
+ }
+ }.bind(this);
+
// bind touch events
eventRect.on("touchstart", function (event) {
_newArrowCheck(this, _this2);
@@ -15227,7 +15469,7 @@ var Axis_Axis = /*#__PURE__*/function () {
svg.on("touchstart", function (event) {
_newArrowCheck(this, _this2);
state.event = event;
- var target = event.target;
+ const target = event.target;
if (target && target !== eventRect.node()) {
unselectRect();
}
@@ -15244,7 +15486,7 @@ var Axis_Axis = /*#__PURE__*/function () {
if (force === void 0) {
force = !1;
}
- var $$ = this,
+ const $$ = this,
state = $$.state,
$el = $$.$el,
_state = state,
@@ -15273,17 +15515,14 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/
updateEventRectData: function updateEventRectData() {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
config = $$.config,
scale = $$.scale,
state = $$.state,
xScale = scale.zoom || scale.x,
- isRotated = config.axis_rotated,
- x,
- y,
- w,
- h;
+ isRotated = config.axis_rotated;
+ let x, y, w, h;
if ($$.isMultipleX()) {
// TODO: rotated not supported yet
x = 0;
@@ -15291,7 +15530,7 @@ var Axis_Axis = /*#__PURE__*/function () {
w = state.width;
h = state.height;
} else {
- var rectW, rectX;
+ let rectW, rectX;
if ($$.axis.isCategorized()) {
rectW = $$.getEventRectWidth();
rectX = function (d) {
@@ -15299,8 +15538,8 @@ var Axis_Axis = /*#__PURE__*/function () {
return xScale(d.x) - rectW / 2;
}.bind(this);
} else {
- var getPrevNextX = function (_ref) {
- var index = _ref.index;
+ const getPrevNextX = function (_ref) {
+ let index = _ref.index;
_newArrowCheck(this, _this4);
return {
prev: $$.getPrevX(index),
@@ -15310,9 +15549,9 @@ var Axis_Axis = /*#__PURE__*/function () {
rectW = function (d) {
var _this5 = this;
_newArrowCheck(this, _this4);
- var x = getPrevNextX(d),
+ const x = getPrevNextX(d),
xDomain = xScale.domain();
- var val;
+ let val;
// if there this is a single data point make the eventRect full width (or height)
if (x.prev === null && x.next === null) {
@@ -15333,8 +15572,8 @@ var Axis_Axis = /*#__PURE__*/function () {
}.bind(this);
rectX = function (d) {
_newArrowCheck(this, _this4);
- var x = getPrevNextX(d);
- var val;
+ const x = getPrevNextX(d);
+ let val;
// if there this is a single data point position the eventRect at 0
if (x.prev === null && x.next === null) {
@@ -15352,7 +15591,7 @@ var Axis_Axis = /*#__PURE__*/function () {
w = isRotated ? state.width : rectW;
h = isRotated ? rectW : state.height;
}
- var eventReceiver = state.eventReceiver,
+ const eventReceiver = state.eventReceiver,
call = function (fn, v) {
_newArrowCheck(this, _this4);
return isFunction(fn) ? fn(v) : fn;
@@ -15369,9 +15608,72 @@ var Axis_Axis = /*#__PURE__*/function () {
};
}.bind(this));
},
- selectRectForMultipleXs: function selectRectForMultipleXs(context) {
- var _this6 = this,
- $$ = this,
+ /**
+ * Seletct rect for single x value
+ * @param {d3Selection} context Event rect element
+ * @param {number} index x Axis index
+ * @private
+ */
+ selectRectForSingle: function selectRectForSingle(context, index) {
+ var _this6 = this;
+ const $$ = this,
+ config = $$.config,
+ _$$$$el2 = $$.$el,
+ main = _$$$$el2.main,
+ circle = _$$$$el2.circle,
+ isSelectionEnabled = config.data_selection_enabled,
+ isSelectionGrouped = config.data_selection_grouped,
+ isSelectable = config.data_selection_isselectable,
+ isTooltipGrouped = config.tooltip_grouped,
+ selectedData = $$.getAllValuesOnIndex(index);
+ if (isTooltipGrouped) {
+ $$.showTooltip(selectedData, context);
+ $$.showGridFocus == null || $$.showGridFocus(selectedData);
+ if (!isSelectionEnabled || isSelectionGrouped) {
+ return;
+ }
+ }
+
+ // remove possible previous focused state
+ circle || main.selectAll("." + $COMMON.EXPANDED + ":not(." + $SHAPE.shape + "-" + index + ")").classed($COMMON.EXPANDED, !1);
+ const shapeAtIndex = main.selectAll("." + $SHAPE.shape + "-" + index).classed($COMMON.EXPANDED, !0).style("cursor", isSelectable ? "pointer" : null).filter(function (d) {
+ return $$.isWithinShape(this, d);
+ });
+ if (shapeAtIndex.empty() && !isTooltipGrouped) {
+ $$.hideGridFocus == null || $$.hideGridFocus();
+ $$.hideTooltip();
+ isSelectionGrouped || $$.setExpand(index);
+ }
+ shapeAtIndex.call(function (selected) {
+ var _this7 = this;
+ _newArrowCheck(this, _this6);
+ const d = selected.data();
+ if (isSelectionEnabled && (isSelectionGrouped || isSelectable != null && isSelectable.bind($$.api)(d))) {
+ context.style.cursor = "pointer";
+ }
+ if (!isTooltipGrouped) {
+ $$.showTooltip(d, context);
+ $$.showGridFocus == null || $$.showGridFocus(d);
+ $$.unexpandCircles == null || $$.unexpandCircles();
+ selected.each(function (d) {
+ _newArrowCheck(this, _this7);
+ return $$.setExpand(index, d.id);
+ }.bind(this));
+ }
+ }.bind(this));
+ },
+ /**
+ * Select rect for multiple x values
+ * @param {d3Selection} context Event rect element
+ * @param {boolean} [triggerEvent=true] Whether trigger event or not
+ * @private
+ */
+ selectRectForMultipleXs: function selectRectForMultipleXs(context, triggerEvent) {
+ var _this8 = this;
+ if (triggerEvent === void 0) {
+ triggerEvent = !0;
+ }
+ const $$ = this,
config = $$.config,
state = $$.state,
targetsToShow = $$.filterTargetsToShow($$.data.targets);
@@ -15379,9 +15681,9 @@ var Axis_Axis = /*#__PURE__*/function () {
if (state.dragging || $$.hasArcType(targetsToShow)) {
return;
}
- var mouse = getPointer(state.event, context),
+ const mouse = getPointer(state.event, context),
closest = $$.findClosestFromTargets(targetsToShow, mouse);
- if (state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
+ if (triggerEvent && state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
config.data_onout.call($$.api, state.mouseover);
state.mouseover = undefined;
}
@@ -15389,9 +15691,9 @@ var Axis_Axis = /*#__PURE__*/function () {
$$.unselectRect();
return;
}
- var sameXData = $$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x),
+ const sameXData = $$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x),
selectedData = sameXData.map(function (d) {
- _newArrowCheck(this, _this6);
+ _newArrowCheck(this, _this8);
return $$.addName(d);
}.bind(this)); // show tooltip when cursor is close to some point
$$.showTooltip(selectedData, context);
@@ -15401,11 +15703,12 @@ var Axis_Axis = /*#__PURE__*/function () {
// Show xgrid focus line
$$.showGridFocus(selectedData);
+ const dist = $$.dist(closest, mouse);
// Show cursor as pointer if point is close to mouse position
- if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
+ if ($$.isBarType(closest.id) || dist < $$.getPointSensitivity(closest)) {
$$.$el.svg.select("." + $EVENT.eventRect).style("cursor", "pointer");
- if (!state.mouseover) {
+ if (triggerEvent && !state.mouseover) {
config.data_onover.call($$.api, closest);
state.mouseover = closest;
}
@@ -15416,18 +15719,17 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/
unselectRect: function unselectRect() {
- var $$ = this,
- config = $$.config,
- _$$$$el2 = $$.$el,
- circle = _$$$$el2.circle,
- tooltip = _$$$$el2.tooltip;
+ const $$ = this,
+ _$$$$el3 = $$.$el,
+ circle = _$$$$el3.circle,
+ tooltip = _$$$$el3.tooltip;
$$.$el.svg.select("." + $EVENT.eventRect).style("cursor", null);
$$.hideGridFocus();
if (tooltip) {
$$.hideTooltip();
$$._handleLinkedCharts(!1);
}
- circle && !config.point_focus_only && $$.unexpandCircles();
+ circle && !$$.isPointFocusOnly() && $$.unexpandCircles();
$$.expandBarTypeShapes(!1);
},
/**
@@ -15438,40 +15740,40 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/
generateEventRectsForSingleX: function generateEventRectsForSingleX(eventRectEnter) {
- var _this7 = this,
- $$ = this,
+ var _this9 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
eventReceiver = state.eventReceiver,
rect = eventRectEnter.style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null).on("click", function (event) {
state.event = event;
- var currentIdx = eventReceiver.currentIdx,
+ const currentIdx = eventReceiver.currentIdx,
data = eventReceiver.data,
d = data[currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx];
$$.clickHandlerForSingleX.bind(this)(d, $$);
});
if (state.inputType === "mouse") {
- var getData = function (event) {
- _newArrowCheck(this, _this7);
- var index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
+ const getData = function (event) {
+ _newArrowCheck(this, _this9);
+ const index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
return index > -1 ? eventReceiver.data[index] : null;
}.bind(this);
rect.on("mouseover", function (event) {
- _newArrowCheck(this, _this7);
+ _newArrowCheck(this, _this9);
state.event = event;
$$.updateEventRect();
}.bind(this)).on("mousemove", function (event) {
- var d = getData(event);
+ const d = getData(event);
state.event = event;
if (!d) {
return;
}
- var index = d.index;
- var stepType = config.line_step_type;
+ let index = d.index;
+ const stepType = config.line_step_type;
// tooltip position match for step-before & step-after
if (config.line_step_tooltipMatch && $$.hasType("step") && /^step\-(before|after)$/.test(stepType)) {
- var scale = $$.scale.zoom || $$.scale.x,
+ const scale = $$.scale.zoom || $$.scale.x,
xs = $$.axis.xs[index],
inverted = scale.invert(getPointer(event, this)[0]);
if (stepType === "step-after" && inverted < xs) {
@@ -15480,22 +15782,24 @@ var Axis_Axis = /*#__PURE__*/function () {
index += 1;
}
}
+ const eventOnSameIdx = config.tooltip_grouped && index === eventReceiver.currentIdx;
// do nothing while dragging/flowing
- if (state.dragging || state.flowing || $$.hasArcType() || config.tooltip_grouped && index === eventReceiver.currentIdx) {
+ if (state.dragging || state.flowing || $$.hasArcType() || eventOnSameIdx) {
+ config.tooltip_show && eventOnSameIdx && $$.setTooltipPosition();
return;
}
if (index !== eventReceiver.currentIdx) {
$$.setOverOut(!1, eventReceiver.currentIdx);
eventReceiver.currentIdx = index;
}
- index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, rect, index);
+ index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, index);
// As of individual data point(or ) element can't bind mouseover/out event
// to determine current interacting element, so use 'mousemove' event instead.
$$.setOverOut(index !== -1, index);
}).on("mouseout", function (event) {
- _newArrowCheck(this, _this7);
+ _newArrowCheck(this, _this9);
state.event = event;
// chart is destroyed
@@ -15512,7 +15816,7 @@ var Axis_Axis = /*#__PURE__*/function () {
return rect;
},
clickHandlerForSingleX: function clickHandlerForSingleX(d, ctx) {
- var $$ = ctx,
+ const $$ = ctx,
config = $$.config,
state = $$.state,
main = $$.$el.main;
@@ -15520,10 +15824,10 @@ var Axis_Axis = /*#__PURE__*/function () {
state.cancelClick && (state.cancelClick = !1);
return;
}
- var index = d.index;
+ const index = d.index;
main.selectAll("." + $SHAPE.shape + "-" + index).each(function (d2) {
if (config.data_selection_grouped || $$.isWithinShape(this, d2)) {
- $$.toggleShape == null ? void 0 : $$.toggleShape(this, d2, index);
+ $$.toggleShape == null || $$.toggleShape(this, d2, index);
config.data_onclick.bind($$.api)(d2, this);
}
});
@@ -15535,8 +15839,8 @@ var Axis_Axis = /*#__PURE__*/function () {
* @private
*/
generateEventRectsForMultipleXs: function generateEventRectsForMultipleXs(eventRectEnter) {
- var _this8 = this,
- $$ = this,
+ var _this10 = this;
+ const $$ = this,
state = $$.state;
eventRectEnter.on("click", function (event) {
state.event = event;
@@ -15547,7 +15851,7 @@ var Axis_Axis = /*#__PURE__*/function () {
state.event = event;
$$.selectRectForMultipleXs(this);
}).on("mouseout", function (event) {
- _newArrowCheck(this, _this8);
+ _newArrowCheck(this, _this10);
state.event = event;
// chart is destroyed
@@ -15559,24 +15863,25 @@ var Axis_Axis = /*#__PURE__*/function () {
}
},
clickHandlerForMultipleXS: function clickHandlerForMultipleXS(ctx) {
- var $$ = ctx,
+ const $$ = ctx,
config = $$.config,
state = $$.state,
targetsToShow = $$.filterTargetsToShow($$.data.targets);
if ($$.hasArcType(targetsToShow)) {
return;
}
- var mouse = getPointer(state.event, this),
- closest = $$.findClosestFromTargets(targetsToShow, mouse);
+ const mouse = getPointer(state.event, this),
+ closest = $$.findClosestFromTargets(targetsToShow, mouse),
+ sensitivity = config.point_sensitivity === "radius" ? closest.r : config.point_sensitivity;
if (!closest) {
return;
}
// select if selection enabled
- if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
+ if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < sensitivity) {
$$.$el.main.selectAll("." + $SHAPE.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll("." + $SHAPE.shape + "-" + closest.index).each(function () {
if (config.data_selection_grouped || $$.isWithinShape(this, closest)) {
- $$.toggleShape == null ? void 0 : $$.toggleShape(this, closest, closest.index);
+ $$.toggleShape == null || $$.toggleShape(this, closest, closest.index);
config.data_onclick.bind($$.api)(closest, this);
}
});
@@ -15603,13 +15908,14 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
* @private
*/
generateFlow: function generateFlow(args) {
- var $$ = this,
+ const $$ = this,
data = $$.data,
state = $$.state,
$el = $$.$el;
return function () {
- var _this = this,
- flowLength = args.flow.length;
+ var _this = this;
+ const flowLength = args.flow.length;
+
// set flag
state.flowing = !0;
@@ -15625,12 +15931,12 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
}
// target elements
- var elements = {};
+ const elements = {};
["axis.x", "grid.x", "gridLines.x", "region.list", "text", "bar", "line", "area", "circle"].forEach(function (v) {
var _node;
_newArrowCheck(this, _this);
- var name = v.split(".");
- var node = $el[name[0]];
+ const name = v.split(".");
+ let node = $el[name[0]];
if (node && name.length > 1) {
node = node[name[1]];
}
@@ -15649,8 +15955,8 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
* @private
*/
setFlowList: function setFlowList(elements, args) {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
flow = args.flow,
targets = args.targets,
_flow = flow,
@@ -15660,8 +15966,8 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
flowLength = _flow.length,
orgDataCount = _flow.orgDataCount,
transform = $$.getFlowTransform(targets, orgDataCount, flowIndex, flowLength),
- wait = generateWait(),
- n;
+ wait = generateWait();
+ let n;
wait.add(Object.keys(elements).map(function (v) {
var _this3 = this;
_newArrowCheck(this, _this2);
@@ -15690,8 +15996,8 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
* @private
*/
cleanUpFlow: function cleanUpFlow(elements, args) {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
svg = $$.$el.svg,
@@ -15714,8 +16020,8 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
if (flowLength) {
["circle", "text", "shape", "eventRect"].forEach(function (v) {
_newArrowCheck(this, _this4);
- var target = [];
- for (var i = 0; i < flowLength; i++) {
+ const target = [];
+ for (let i = 0; i < flowLength; i++) {
target.push("." + classes[v] + "-" + i);
}
svg.selectAll("." + classes[v + "s"]) // circles, shapes, texts, eventRects
@@ -15728,7 +16034,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
Object.keys(elements).forEach(function (v) {
var _this5 = this;
_newArrowCheck(this, _this4);
- var n = elements[v];
+ const n = elements[v];
if (v !== "axis.x") {
n.attr("transform", null);
}
@@ -15736,8 +16042,6 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
n.attr(state.xgridAttr);
} else if (v === "gridLines.x") {
n.attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
- } else if (v === "gridLines.x") {
- n.select("line").attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
n.select("text").attr("x", isRotated ? state.width : 0).attr("y", xv);
} else if (/^(area|bar|line)$/.test(v)) {
n.attr("d", shape.type[v]);
@@ -15747,7 +16051,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
if ($$.isCirclePoint()) {
n.attr("cx", cx).attr("cy", cy);
} else {
- var xFunc = function (d) {
+ const xFunc = function (d) {
_newArrowCheck(this, _this5);
return cx(d) - config.point_r;
}.bind(this),
@@ -15755,8 +16059,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
_newArrowCheck(this, _this5);
return cy(d) - config.point_r;
}.bind(this);
- n.attr("x", xFunc).attr("y", yFunc).attr("cx", cx) // when pattern is used, it possibly contain 'circle' also.
- .attr("cy", cy);
+ n.attr("x", xFunc).attr("y", yFunc);
}
} else if (v === "region.list") {
n.select("rect").filter($$.isRegionOnX).attr("x", $$.regionX.bind($$)).attr("width", $$.regionWidth.bind($$));
@@ -15778,17 +16081,17 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
* @private
*/
getFlowTransform: function getFlowTransform(targets, orgDataCount, flowIndex, flowLength) {
- var _flowStart,
- _flowEnd,
- $$ = this,
+ var _flowStart, _flowEnd;
+ const $$ = this,
data = $$.data,
x = $$.scale.x,
- dataValues = data.targets[0].values,
- flowStart = $$.getValueOnIndex(dataValues, flowIndex),
+ dataValues = data.targets[0].values;
+ let flowStart = $$.getValueOnIndex(dataValues, flowIndex),
flowEnd = $$.getValueOnIndex(dataValues, flowIndex + flowLength),
- translateX,
- orgDomain = x.domain(),
- domain = $$.updateXDomain(targets, !0, !0); // update x domain to generate axis elements for flow
+ translateX;
+ // update x domain to generate axis elements for flow
+ const orgDomain = x.domain(),
+ domain = $$.updateXDomain(targets, !0, !0);
// generate transform to flow
if (!orgDataCount) {
// if empty
@@ -15809,7 +16112,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
var _flowStart2;
translateX = $$.axis.isTimeSeries() ? x(orgDomain[0]) - x(domain[0]) : x(((_flowStart2 = flowStart) == null ? void 0 : _flowStart2.x) || 0) - x(flowEnd.x);
}
- var scaleX = diffDomain(orgDomain) / diffDomain(domain);
+ const scaleX = diffDomain(orgDomain) / diffDomain(domain);
return "translate(" + translateX + ",0) scale(" + scaleX + ",1)";
}
});
@@ -15821,7 +16124,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
/* harmony default export */ var clip = ({
initClip: function initClip() {
- var $$ = this,
+ const $$ = this,
_$$$state = $$.state,
clip = _$$$state.clip,
datetimeId = _$$$state.datetimeId;
@@ -15838,12 +16141,12 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
clip.pathGrid = $$.getClipPath(clip.idGrid);
},
getClipPath: function getClipPath(id) {
- var $$ = this,
+ const $$ = this,
config = $$.config;
if (!config.clipPath && /-clip$/.test(id) || !config.axis_x_clipPath && /-clip-xaxis$/.test(id) || !config.axis_y_clipPath && /-clip-yaxis$/.test(id)) {
return null;
}
- var isIE9 = win.navigator ? win.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0 : !1;
+ const isIE9 = win.navigator ? win.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0 : !1;
return "url(" + (isIE9 ? "" : browser_doc.URL.split("#")[0]) + "#" + id + ")";
},
appendClip: function appendClip(parent, id) {
@@ -15855,7 +16158,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
* @private
*/
setXAxisClipPath: function setXAxisClipPath(node) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
_$$$state2 = $$.state,
margin = _$$$state2.margin,
@@ -15863,23 +16166,23 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
height = _$$$state2.height,
isRotated = config.axis_rotated,
left = Math.max(30, margin.left) - (isRotated ? 0 : 20),
+ h = (isRotated ? margin.top + height + 10 : margin.bottom) + 20,
x = isRotated ? -(1 + left) : -(left - 1),
- y = -Math.max(15, margin.top),
- w = isRotated ? margin.left + 20 : width + 10 + left,
- h = (isRotated ? margin.top + height + 10 : margin.bottom) + 20;
+ w = isRotated ? margin.left + 20 : width + 10 + left;
// less than 20 is not enough to show the axis label 'outer' without legend
- node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
+ // -Math.max(15, margin.top);
+
+ node.attr("x", x).attr("y", -15).attr("width", w).attr("height", h);
},
/**
* Set y Axis clipPath dimension
- * @param {d3Selecton} node clipPath selection
+ * @param {d3Selection} node clipPath selection
* @private
*/
setYAxisClipPath: function setYAxisClipPath(node) {
- var _config$padding,
- $$ = this,
+ const $$ = this,
config = $$.config,
_$$$state3 = $$.state,
margin = _$$$state3.margin,
@@ -15891,11 +16194,11 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
x = isInner && !isRotated ? config.axis_y_label.text ? -20 : -1 : isRotated ? -(1 + left) : -(left - 1),
y = -(isRotated ? 20 : margin.top),
w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0),
- h = (isRotated ? margin.bottom + (((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit" ? 10 : 0) : margin.top + height) + 10;
+ h = (isRotated ? margin.bottom + 10 : margin.top + height) + 10;
node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
},
updateXAxisTickClip: function updateXAxisTickClip() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
_$$$state4 = $$.state,
clip = _$$$state4.clip,
@@ -15903,7 +16206,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
defs = $$.$el.defs,
newXAxisHeight = $$.getHorizontalAxisHeight("x");
if (defs && !clip.idXAxisTickTexts) {
- var clipId = clip.id + "-xaxisticktexts";
+ const clipId = clip.id + "-xaxisticktexts";
$$.appendClip(defs, clipId);
clip.pathXAxisTickTexts = $$.getClipPath(clip.idXAxisTickTexts);
clip.idXAxisTickTexts = clipId;
@@ -15915,25 +16218,25 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
$$.state.xAxisHeight = newXAxisHeight;
},
setXAxisTickClipWidth: function setXAxisTickClipWidth() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
- maxTickWidths = $$.state.current.maxTickWidths,
+ maxTickSize = $$.state.current.maxTickSize,
xAxisTickRotate = $$.getAxisTickRotate("x");
if (!config.axis_x_tick_multiline && xAxisTickRotate) {
- var sinRotation = Math.sin(Math.PI / 180 * Math.abs(xAxisTickRotate));
- maxTickWidths.x.clipPath = ($$.getHorizontalAxisHeight("x") - 20) / sinRotation;
+ const sinRotation = Math.sin(Math.PI / 180 * Math.abs(xAxisTickRotate));
+ maxTickSize.x.clipPath = ($$.getHorizontalAxisHeight("x") - 20) / sinRotation;
} else {
- maxTickWidths.x.clipPath = null;
+ maxTickSize.x.clipPath = null;
}
},
setXAxisTickTextClipPathWidth: function setXAxisTickTextClipPathWidth() {
- var $$ = this,
+ const $$ = this,
_$$$state5 = $$.state,
clip = _$$$state5.clip,
current = _$$$state5.current,
svg = $$.$el.svg;
if (svg) {
- svg.select("#" + clip.idXAxisTickTexts + " rect").attr("width", current.maxTickWidths.x.clipPath).attr("height", 30);
+ svg.select("#" + clip.idXAxisTickTexts + " rect").attr("width", current.maxTickSize.x.clipPath).attr("height", 30);
}
}
});
@@ -15949,7 +16252,7 @@ var grid_this = undefined;
// Grid position and text anchor helpers
-var getGridTextAnchor = function (d) {
+const getGridTextAnchor = function (d) {
_newArrowCheck(this, grid_this);
return isValue(d.position) || "end";
}.bind(undefined),
@@ -15969,7 +16272,7 @@ function getGridTextX(isX, width, height) {
var _this2 = this;
return function (d) {
_newArrowCheck(this, _this2);
- var x = isX ? 0 : width;
+ let x = isX ? 0 : width;
if (d.position === "start") {
x = isX ? -height : 0;
} else if (d.position === "middle") {
@@ -15988,8 +16291,8 @@ function getGridTextX(isX, width, height) {
function smoothLines(el, type) {
if (type === "grid") {
el.each(function () {
- var _this3 = this,
- g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
+ var _this3 = this;
+ const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
["x1", "x2", "y1", "y2"].forEach(function (v) {
_newArrowCheck(this, _this3);
return g.attr(v, Math.ceil(+g.attr(v)));
@@ -15999,20 +16302,20 @@ function smoothLines(el, type) {
}
/* harmony default export */ var internals_grid = ({
hasGrid: function hasGrid() {
- var _this4 = this,
- config = this.config;
+ var _this4 = this;
+ const config = this.config;
return ["x", "y"].some(function (v) {
_newArrowCheck(this, _this4);
return config["grid_" + v + "_show"] || config["grid_" + v + "_lines"].length;
}.bind(this));
},
initGrid: function initGrid() {
- var $$ = this;
+ const $$ = this;
$$.hasGrid() && $$.initGridLines();
$$.initFocusGrid();
},
initGridLines: function initGridLines() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
clip = $$.state.clip,
$el = $$.$el;
@@ -16024,8 +16327,8 @@ function smoothLines(el, type) {
}
},
updateXGrid: function updateXGrid(withoutUpdate) {
- var _this5 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
config = $$.config,
scale = $$.scale,
state = $$.state,
@@ -16055,8 +16358,8 @@ function smoothLines(el, type) {
grid.x = grid.x.enter().append("line").attr("class", $GRID.xgrid).merge(grid.x);
if (!withoutUpdate) {
grid.x.each(function () {
- var _this6 = this,
- grid = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
+ var _this6 = this;
+ const grid = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
Object.keys(state.xgridAttr).forEach(function (id) {
var _this7 = this;
_newArrowCheck(this, _this6);
@@ -16069,8 +16372,8 @@ function smoothLines(el, type) {
}
},
updateYGrid: function updateYGrid() {
- var _this8 = this,
- $$ = this,
+ var _this8 = this;
+ const $$ = this,
axis = $$.axis,
config = $$.config,
scale = $$.scale,
@@ -16091,7 +16394,7 @@ function smoothLines(el, type) {
smoothLines(grid.y, "grid");
},
updateGrid: function updateGrid() {
- var $$ = this,
+ const $$ = this,
_$$$$el3 = $$.$el,
grid = _$$$$el3.grid,
gridLines = _$$$$el3.gridLines;
@@ -16100,101 +16403,73 @@ function smoothLines(el, type) {
// hide if arc type
grid.main.style("visibility", $$.hasArcType() ? "hidden" : null);
$$.hideGridFocus();
- $$.updateXGridLines();
- $$.updateYGridLines();
+ $$.updateGridLines("x");
+ $$.updateGridLines("y");
},
/**
- * Update X Grid lines
+ * Update Grid lines
+ * @param {string} type x | y
* @private
*/
- updateXGridLines: function updateXGridLines() {
- var _this9 = this,
- $$ = this,
+ updateGridLines: function updateGridLines(type) {
+ var _this9 = this;
+ const $$ = this,
config = $$.config,
_$$$$el4 = $$.$el,
gridLines = _$$$$el4.gridLines,
main = _$$$$el4.main,
$T = $$.$T,
isRotated = config.axis_rotated;
- config.grid_x_show && $$.updateXGrid();
- var xLines = main.select("." + $GRID.xgridLines).selectAll("." + $GRID.xgridLine).data(config.grid_x_lines);
+ config["grid_" + type + "_show"] && $$["update" + type.toUpperCase() + "Grid"]();
+ let lines = main.select("." + $GRID[type + "gridLines"]).selectAll("." + $GRID[type + "gridLine"]).data(config["grid_" + type + "_lines"]);
// exit
- $T(xLines.exit()).style("opacity", "0").remove();
+ $T(lines.exit()).style("opacity", "0").remove();
// enter
- var xgridLine = xLines.enter().append("g");
- xgridLine.append("line").style("opacity", "0");
- xgridLine.append("text").attr("transform", isRotated ? null : "rotate(-90)").attr("dy", -5).style("opacity", "0");
- xLines = xgridLine.merge(xLines);
- $T(xLines.attr("class", function (d) {
+ const gridLine = lines.enter().append("g");
+ gridLine.append("line").style("opacity", "0");
+ lines = gridLine.merge(lines);
+ lines.each(function (d) {
+ const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
+ if (g.select("text").empty() && d.text) {
+ g.append("text").style("opacity", "0");
+ }
+ });
+ $T(lines.attr("class", function (d) {
_newArrowCheck(this, _this9);
- return ($GRID.xgridLine + " " + (d.class || "")).trim();
- }.bind(this)).select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx)).text(function (d) {
+ return ($GRID[type + "gridLine"] + " " + (d.class || "")).trim();
+ }.bind(this)).select("text").attr("text-anchor", getGridTextAnchor).attr("transform", function () {
_newArrowCheck(this, _this9);
- return d.text;
- }.bind(this)).style("opacity", null);
- gridLines.x = xLines;
+ return type === "x" ? isRotated ? null : "rotate(-90)" : isRotated ? "rotate(-90)" : null;
+ }.bind(this)).attr("dx", getGridTextDx).attr("dy", -5)).text(function (d) {
+ var _d$text;
+ return (_d$text = d.text) != null ? _d$text : this.remove();
+ });
+ gridLines[type] = lines;
},
- /**
- * Update Y Grid lines
- * @private
- */
- updateYGridLines: function updateYGridLines() {
- var _this10 = this,
- $$ = this,
- config = $$.config,
+ redrawGrid: function redrawGrid(withTransition) {
+ const $$ = this,
+ isRotated = $$.config.axis_rotated,
_$$$state = $$.state,
width = _$$$state.width,
height = _$$$state.height,
- $el = $$.$el,
- $T = $$.$T,
- isRotated = config.axis_rotated;
- config.grid_y_show && $$.updateYGrid();
- var ygridLines = $el.main.select("." + $GRID.ygridLines).selectAll("." + $GRID.ygridLine).data(config.grid_y_lines);
-
- // exit
- $T(ygridLines.exit()).style("opacity", "0").remove();
-
- // enter
- var ygridLine = ygridLines.enter().append("g");
- ygridLine.append("line").style("opacity", "0");
- ygridLine.append("text").attr("transform", isRotated ? "rotate(-90)" : "").style("opacity", "0");
- ygridLines = ygridLine.merge(ygridLines);
-
- // update
- var yv = $$.yv.bind($$);
- $T(ygridLines.attr("class", function (d) {
- _newArrowCheck(this, _this10);
- return ($GRID.ygridLine + " " + (d.class || "")).trim();
- }.bind(this)).select("line")).attr("x1", isRotated ? yv : 0).attr("x2", isRotated ? yv : width).attr("y1", isRotated ? 0 : yv).attr("y2", isRotated ? height : yv).style("opacity", null);
- $T(ygridLines.select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx)).attr("dy", -5).attr("x", getGridTextX(isRotated, width, height)).attr("y", yv).text(function (d) {
- _newArrowCheck(this, _this10);
- return d.text;
- }.bind(this)).style("opacity", null);
- $el.gridLines.y = ygridLines;
- },
- redrawGrid: function redrawGrid(withTransition) {
- var _this11 = this,
- $$ = this,
- isRotated = $$.config.axis_rotated,
- _$$$state2 = $$.state,
- width = _$$$state2.width,
- height = _$$$state2.height,
gridLines = $$.$el.gridLines,
$T = $$.$T,
xv = $$.xv.bind($$),
- lines = gridLines.x.select("line"),
- texts = gridLines.x.select("text");
- lines = $T(lines, withTransition).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height);
- texts = $T(texts, withTransition).attr("x", getGridTextX(!isRotated, width, height)).attr("y", xv).text(function (d) {
- _newArrowCheck(this, _this11);
- return d.text;
- }.bind(this));
- return [lines.style("opacity", null), texts.style("opacity", null)];
+ yv = $$.yv.bind($$);
+ let xLines = gridLines.x.select("line"),
+ xTexts = gridLines.x.select("text"),
+ yLines = gridLines.y.select("line"),
+ yTexts = gridLines.y.select("text");
+ xLines = $T(xLines, withTransition).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height);
+ xTexts = $T(xTexts, withTransition).attr("x", getGridTextX(!isRotated, width, height)).attr("y", xv);
+ yLines = $T(yLines, withTransition).attr("x1", isRotated ? yv : 0).attr("x2", isRotated ? yv : width).attr("y1", isRotated ? 0 : yv).attr("y2", isRotated ? height : yv);
+ yTexts = $T(yTexts, withTransition).attr("x", getGridTextX(isRotated, width, height)).attr("y", yv);
+ return [xLines.style("opacity", null), xTexts.style("opacity", null), yLines.style("opacity", null), yTexts.style("opacity", null)];
},
initFocusGrid: function initFocusGrid() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
clip = $$.state.clip,
$el = $$.$el,
@@ -16219,32 +16494,32 @@ function smoothLines(el, type) {
* @private
*/
showGridFocus: function showGridFocus(data) {
- var _this12 = this,
- $$ = this,
+ var _this10 = this;
+ const $$ = this,
config = $$.config,
- _$$$state3 = $$.state,
- width = _$$$state3.width,
- height = _$$$state3.height,
+ _$$$state2 = $$.state,
+ width = _$$$state2.width,
+ height = _$$$state2.height,
isRotated = config.axis_rotated,
focusEl = $$.$el.main.selectAll("line." + $FOCUS.xgridFocus + ", line." + $FOCUS.ygridFocus),
dataToShow = (data || [focusEl.datum()]).filter(function (d) {
- _newArrowCheck(this, _this12);
+ _newArrowCheck(this, _this10);
return d && isValue($$.getBaseValue(d));
}.bind(this));
// Hide when bubble/scatter/stanford plot exists
if (!config.tooltip_show || dataToShow.length === 0 || $$.hasType("bubble") || $$.hasArcType()) {
return;
}
- var isEdge = config.grid_focus_edge && !config.tooltip_grouped,
+ const isEdge = config.grid_focus_edge && !config.tooltip_grouped,
xx = $$.xx.bind($$);
focusEl.style("visibility", null).data(dataToShow.concat(dataToShow)).each(function (d) {
- var _this13 = this,
- el = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
+ var _this11 = this;
+ const el = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
pos = {
x: xx(d),
y: $$.getYScaleById(d.id)(d.value)
- },
- xy;
+ };
+ let xy;
if (el.classed($FOCUS.xgridFocus)) {
// will contain 'x1, y1, x2, y2' order
xy = isRotated ? [null,
@@ -16256,7 +16531,7 @@ function smoothLines(el, type) {
pos.x // y2
] : [pos.x, isEdge ? pos.y : null, pos.x, height];
} else {
- var isY2 = $$.axis.getId(d.id) === "y2";
+ const isY2 = $$.axis.getId(d.id) === "y2";
xy = isRotated ? [pos.y,
// x1
isEdge && !isY2 ? pos.x : null,
@@ -16267,31 +16542,31 @@ function smoothLines(el, type) {
] : [isEdge && isY2 ? pos.x : null, pos.y, isEdge && !isY2 ? pos.x : width, pos.y];
}
["x1", "y1", "x2", "y2"].forEach(function (v, i) {
- _newArrowCheck(this, _this13);
+ _newArrowCheck(this, _this11);
return el.attr(v, xy[i]);
}.bind(this));
});
smoothLines(focusEl, "grid");
- $$.showCircleFocus == null ? void 0 : $$.showCircleFocus(data);
+ $$.showCircleFocus == null || $$.showCircleFocus(data);
},
hideGridFocus: function hideGridFocus() {
- var $$ = this,
- _$$$state4 = $$.state,
- inputType = _$$$state4.inputType,
- resizing = _$$$state4.resizing,
+ const $$ = this,
+ _$$$state3 = $$.state,
+ inputType = _$$$state3.inputType,
+ resizing = _$$$state3.resizing,
main = $$.$el.main;
if (inputType === "mouse" || !resizing) {
main.selectAll("line." + $FOCUS.xgridFocus + ", line." + $FOCUS.ygridFocus).style("visibility", "hidden");
- $$.hideCircleFocus == null ? void 0 : $$.hideCircleFocus();
+ $$.hideCircleFocus == null || $$.hideCircleFocus();
}
},
updateGridFocus: function updateGridFocus() {
- var $$ = this,
- _$$$state5 = $$.state,
- inputType = _$$$state5.inputType,
- width = _$$$state5.width,
- height = _$$$state5.height,
- resizing = _$$$state5.resizing,
+ const $$ = this,
+ _$$$state4 = $$.state,
+ inputType = _$$$state4.inputType,
+ width = _$$$state4.width,
+ height = _$$$state4.height,
+ resizing = _$$$state4.resizing,
grid = $$.$el.grid,
xgridFocus = grid.main.select("line." + $FOCUS.xgridFocus);
if (inputType === "touch") {
@@ -16301,8 +16576,8 @@ function smoothLines(el, type) {
$$.showGridFocus();
}
} else {
- var _isRotated = $$.config.axis_rotated;
- xgridFocus.attr("x1", _isRotated ? 0 : -10).attr("x2", _isRotated ? width : -10).attr("y1", _isRotated ? -10 : 0).attr("y2", _isRotated ? -10 : height);
+ const isRotated = $$.config.axis_rotated;
+ xgridFocus.attr("x1", isRotated ? 0 : -10).attr("x2", isRotated ? width : -10).attr("y1", isRotated ? -10 : 0).attr("y2", isRotated ? -10 : height);
}
// need to return 'true' as of being pushed to the redraw list
@@ -16310,19 +16585,19 @@ function smoothLines(el, type) {
return !0;
},
generateGridData: function generateGridData(type, scale) {
- var _this14 = this,
- $$ = this,
- tickNum = $$.$el.main.select("." + $AXIS.axisX).selectAll(".tick").size(),
- gridData = [];
+ var _this12 = this;
+ const $$ = this,
+ tickNum = $$.$el.main.select("." + $AXIS.axisX).selectAll(".tick").size();
+ let gridData = [];
if (type === "year") {
- var xDomain = $$.getXDomain(),
+ const xDomain = $$.getXDomain(),
_xDomain$map = xDomain.map(function (v) {
- _newArrowCheck(this, _this14);
+ _newArrowCheck(this, _this12);
return v.getFullYear();
}.bind(this)),
firstYear = _xDomain$map[0],
lastYear = _xDomain$map[1];
- for (var i = firstYear; i <= lastYear; i++) {
+ for (let i = firstYear; i <= lastYear; i++) {
gridData.push(new Date(i + "-01-01 00:00:00"));
}
} else {
@@ -16330,7 +16605,7 @@ function smoothLines(el, type) {
if (gridData.length > tickNum) {
// use only int
gridData = gridData.filter(function (d) {
- _newArrowCheck(this, _this14);
+ _newArrowCheck(this, _this12);
return (d + "").indexOf(".") < 0;
}.bind(this));
}
@@ -16338,37 +16613,37 @@ function smoothLines(el, type) {
return gridData;
},
getGridFilterToRemove: function getGridFilterToRemove(params) {
- var _this15 = this;
+ var _this13 = this;
return params ? function (line) {
- var _this16 = this;
- _newArrowCheck(this, _this15);
- var found = !1;
+ var _this14 = this;
+ _newArrowCheck(this, _this13);
+ let found = !1;
(isArray(params) ? params.concat() : [params]).forEach(function (param) {
- _newArrowCheck(this, _this16);
+ _newArrowCheck(this, _this14);
if ("value" in param && line.value === param.value || "class" in param && line.class === param.class) {
found = !0;
}
}.bind(this));
return found;
}.bind(this) : function () {
- _newArrowCheck(this, _this15);
+ _newArrowCheck(this, _this13);
return !0;
}.bind(this);
},
removeGridLines: function removeGridLines(params, forX) {
- var _this17 = this,
- $$ = this,
+ var _this15 = this;
+ const $$ = this,
config = $$.config,
$T = $$.$T,
toRemove = $$.getGridFilterToRemove(params),
toShow = function (line) {
- _newArrowCheck(this, _this17);
+ _newArrowCheck(this, _this15);
return !toRemove(line);
}.bind(this),
classLines = forX ? $GRID.xgridLines : $GRID.ygridLines,
classLine = forX ? $GRID.xgridLine : $GRID.ygridLine;
$T($$.$el.main.select("." + classLines).selectAll("." + classLine).filter(toRemove)).style("opacity", "0").remove();
- var gridLines = "grid_" + (forX ? "x" : "y") + "_lines";
+ const gridLines = "grid_" + (forX ? "x" : "y") + "_lines";
config[gridLines] = config[gridLines].filter(toShow);
}
});
@@ -16383,12 +16658,12 @@ function smoothLines(el, type) {
/* harmony default export */ var region = ({
initRegion: function initRegion() {
- var $$ = this,
+ const $$ = this,
$el = $$.$el;
$el.region.main = $el.main.insert("g", ":first-child").attr("clip-path", $$.state.clip.path).attr("class", $REGION.regions);
},
updateRegion: function updateRegion() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
region = $$.$el.region,
$T = $$.$T;
@@ -16400,34 +16675,66 @@ function smoothLines(el, type) {
region.main.style("visibility", $$.hasArcType() ? "hidden" : null);
// select element
- var regions = region.main.selectAll("." + $REGION.region).data(config.regions);
+ const regions = region.main.selectAll("." + $REGION.region).data(config.regions);
$T(regions.exit()).style("opacity", "0").remove();
- var regionsEnter = regions.enter().append("g");
+ const regionsEnter = regions.enter().append("g");
regionsEnter.append("rect").style("fill-opacity", "0");
region.list = regionsEnter.merge(regions).attr("class", $$.classRegion.bind($$));
+ region.list.each(function (d) {
+ var _d$label;
+ const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
+ if (g.select("text").empty() && (_d$label = d.label) != null && _d$label.text) {
+ (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).append("text").style("opacity", "0");
+ }
+ });
},
redrawRegion: function redrawRegion(withTransition) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
region = $$.$el.region,
- $T = $$.$T,
- regions = region.list.select("rect");
+ $T = $$.$T;
+ let regions = region.list.select("rect"),
+ label = region.list.selectAll("text");
regions = $T(regions, withTransition).attr("x", $$.regionX.bind($$)).attr("y", $$.regionY.bind($$)).attr("width", $$.regionWidth.bind($$)).attr("height", $$.regionHeight.bind($$));
+ label = $T(label, withTransition).attr("transform", function (d) {
+ var _d$label2;
+ _newArrowCheck(this, _this);
+ const _ref = (_d$label2 = d.label) != null ? _d$label2 : {},
+ _ref$x = _ref.x,
+ x = _ref$x === void 0 ? 0 : _ref$x,
+ _ref$y = _ref.y,
+ y = _ref$y === void 0 ? 0 : _ref$y,
+ _ref$rotated = _ref.rotated,
+ rotated = _ref$rotated === void 0 ? !1 : _ref$rotated;
+ return "translate(" + ($$.regionX.bind($$)(d) + x) + ", " + ($$.regionY.bind($$)(d) + y) + ")" + (rotated ? " rotate(-90)" : "");
+ }.bind(this)).attr("text-anchor", function (d) {
+ var _d$label3;
+ _newArrowCheck(this, _this);
+ return (_d$label3 = d.label) != null && _d$label3.rotated ? "end" : null;
+ }.bind(this)).attr("dy", "1em").style("fill", function (d) {
+ var _d$label$color, _d$label4;
+ _newArrowCheck(this, _this);
+ return (_d$label$color = (_d$label4 = d.label) == null ? void 0 : _d$label4.color) != null ? _d$label$color : null;
+ }.bind(this)).text(function (d) {
+ var _d$label5;
+ _newArrowCheck(this, _this);
+ return (_d$label5 = d.label) == null ? void 0 : _d$label5.text;
+ }.bind(this));
return [regions.style("fill-opacity", function (d) {
_newArrowCheck(this, _this);
return isValue(d.opacity) ? d.opacity : null;
}.bind(this)).on("end", function () {
// remove unnecessary rect after transition
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode).selectAll("rect:not([x])").remove();
- })];
+ }), label.style("opacity", null)];
},
getRegionXY: function getRegionXY(type, d) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
scale = $$.scale,
isRotated = config.axis_rotated,
isX = type === "x";
- var key = "start",
+ let key = "start",
currScale,
pos = 0;
if (d.axis === "y" || d.axis === "y2") {
@@ -16451,14 +16758,14 @@ function smoothLines(el, type) {
return this.getRegionXY("y", d);
},
getRegionSize: function getRegionSize(type, d) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
scale = $$.scale,
state = $$.state,
isRotated = config.axis_rotated,
isWidth = type === "width",
start = $$[isWidth ? "regionX" : "regionY"](d);
- var currScale,
+ let currScale,
key = "end",
end = state[type];
if (d.axis === "y" || d.axis === "y2") {
@@ -16499,43 +16806,41 @@ function smoothLines(el, type) {
* @private
*/
getAxisSize: function getAxisSize(id) {
- var $$ = this,
+ const $$ = this,
isRotated = $$.config.axis_rotated;
return isRotated && id === "x" || !isRotated && /y2?/.test(id) ? $$.getAxisWidthByAxisId(id, !0) : $$.getHorizontalAxisHeight(id);
},
getAxisWidthByAxisId: function getAxisWidthByAxisId(id, withoutRecompute) {
- var $$ = this;
+ const $$ = this;
if ($$.axis) {
- var _$$$axis,
- position = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.getLabelPositionById(id),
- width = $$.axis.getMaxTickWidth(id, withoutRecompute),
- gap = width === 0 ? .5 : 0,
- _$$$config$padding;
+ var _$$$axis, _$$$config$padding;
+ const position = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.getLabelPositionById(id),
+ _$$$axis$getMaxTickSi = $$.axis.getMaxTickSize(id, withoutRecompute),
+ width = _$$$axis$getMaxTickSi.width,
+ gap = width === 0 ? .5 : 0;
return width + (((_$$$config$padding = $$.config.padding) == null ? void 0 : _$$$config$padding.mode) === "fit" ? position.isInner ? 10 + gap : 10 : position.isInner ? 20 + gap : 40);
} else {
return 40;
}
},
getHorizontalAxisHeight: function getHorizontalAxisHeight(id) {
- var _config$padding,
- $$ = this,
+ var _config$padding, _config$padding2;
+ const $$ = this,
config = $$.config,
state = $$.state,
_state = state,
- current = _state.current,
rotatedPadding = _state.rotatedPadding,
isLegendRight = _state.isLegendRight,
isLegendInset = _state.isLegendInset,
isRotated = config.axis_rotated,
isFitPadding = ((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit",
isInner = config["axis_" + id + "_inner"],
- hasLabelText = config["axis_" + id + "_label"].text,
- _config$padding2,
- h = ((_config$padding2 = config.padding) == null ? void 0 : _config$padding2.mode) === "fit" ? isInner && !hasLabelText ? id === "y" ? 1 : 0 : 20 : 30;
+ hasLabelText = config["axis_" + id + "_label"].text;
+ let h = ((_config$padding2 = config.padding) == null ? void 0 : _config$padding2.mode) === "fit" ? isInner && !hasLabelText ? id === "y" ? 1 : 0 : 20 : 30;
if (id === "x" && !config.axis_x_show) {
return 8;
}
- if (id === "x" && config.axis_x_height) {
+ if (id === "x" && isNumber(config.axis_x_height)) {
return config.axis_x_height;
}
if (id === "y" && !config.axis_y_show) {
@@ -16544,21 +16849,14 @@ function smoothLines(el, type) {
if (id === "y2" && !config.axis_y2_show) {
return isFitPadding ? 0 : rotatedPadding.top;
}
- var rotate = $$.getAxisTickRotate(id);
-
- // Calculate x/y axis height when tick rotated
- if ((id === "x" && !isRotated || /y2?/.test(id) && isRotated) && rotate) {
- h = 30 + $$.axis.getMaxTickWidth(id) * Math.cos(Math.PI * (90 - Math.abs(rotate)) / 180);
- if (!config.axis_x_tick_multiline && current.height) {
- if (h > current.height / 2) {
- h = current.height / 2;
- }
- }
+ const maxtickSize = $$.axis.getMaxTickSize(id);
+ if (maxtickSize.height > 13) {
+ h += maxtickSize.height - 13;
}
return h + ($$.axis.getLabelPositionById(id).isInner ? 0 : 10) + (id === "y2" && !isRotated ? -10 : 0);
},
getEventRectWidth: function getEventRectWidth() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
axis = $$.axis,
isInverted = config.axis_x_inverted,
@@ -16572,30 +16870,30 @@ function smoothLines(el, type) {
* @private
*/
getAxisTickRotate: function getAxisTickRotate(id) {
- var $$ = this,
+ const $$ = this,
axis = $$.axis,
config = $$.config,
state = $$.state,
$el = $$.$el;
- var rotate = config["axis_" + id + "_tick_rotate"];
+ let rotate = config["axis_" + id + "_tick_rotate"];
if (id === "x") {
- var allowedXAxisTypes = axis.isCategorized() || axis.isTimeSeries();
+ const allowedXAxisTypes = axis.isCategorized() || axis.isTimeSeries();
if (config.axis_x_tick_fit && allowedXAxisTypes) {
- var xTickCount = config.axis_x_tick_count,
- currentXTicksLength = state.current.maxTickWidths.x.ticks.length;
- var tickCount = 0;
+ const xTickCount = config.axis_x_tick_count,
+ currentXTicksLength = state.current.maxTickSize.x.ticks.length;
+ let tickCount = 0;
if (xTickCount) {
tickCount = xTickCount > currentXTicksLength ? currentXTicksLength : xTickCount;
} else if (currentXTicksLength) {
tickCount = currentXTicksLength;
}
if (tickCount !== state.axis.x.tickCount) {
- var targets = $$.data.targets;
+ const targets = $$.data.targets;
state.axis.x.padding = $$.getXDomainPadding([$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")], tickCount);
}
state.axis.x.tickCount = tickCount;
}
- if ($el.svg && config.axis_x_tick_fit && !config.axis_x_tick_multiline && !config.axis_x_tick_culling && config.axis_x_tick_autorotate && allowedXAxisTypes) {
+ if ($el.svg && config.axis_x_tick_autorotate && config.axis_x_tick_fit && !config.axis_x_tick_multiline && !config.axis_x_tick_culling && allowedXAxisTypes) {
rotate = $$.needToRotateXAxisTickTexts() ? config.axis_x_tick_rotate : 0;
}
}
@@ -16607,15 +16905,16 @@ function smoothLines(el, type) {
* @private
*/
needToRotateXAxisTickTexts: function needToRotateXAxisTickTexts() {
- var $$ = this,
+ const $$ = this,
_$$$state = $$.state,
axis = _$$$state.axis,
current = _$$$state.current,
- xAxisLength = current.width - $$.getCurrentPaddingLeft(!1) - $$.getCurrentPaddingRight(),
+ xAxisLength = current.width - $$.getCurrentPaddingByDirection("left") - $$.getCurrentPaddingByDirection("right"),
tickCountWithPadding = axis.x.tickCount + axis.x.padding.left + axis.x.padding.right,
- maxTickWidth = $$.axis.getMaxTickWidth("x"),
+ _$$$axis$getMaxTickSi2 = $$.axis.getMaxTickSize("x"),
+ width = _$$$axis$getMaxTickSi2.width,
tickLength = tickCountWithPadding ? xAxisLength / tickCountWithPadding : 0;
- return maxTickWidth > tickLength;
+ return width > tickLength;
}
});
;// CONCATENATED MODULE: ./src/config/Options/data/axis.ts
@@ -16623,6 +16922,7 @@ function smoothLines(el, type) {
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
+
/**
* Axis based chart data config options
*/
@@ -16664,7 +16964,7 @@ function smoothLines(el, type) {
* type: "timeseries"
* }
* }
- * @see [D3's time specifier](https://github.com/d3/d3-time-format#locale_format)
+ * @see [D3's time specifier](https://d3js.org/d3-time-format#locale_format)
*/
data_xFormat: "%Y-%m-%d",
/**
@@ -16812,6 +17112,7 @@ function smoothLines(el, type) {
* - **log** type:
* - the x values specified by [`data.x`](#.data%25E2%2580%25A4x)(or by any equivalent option), must be exclusively-positive.
* - x axis min value should be >= 0.
+ * - for 'category' type, `data.xs` option isn't supported.
*
* @name axis․x․type
* @memberof Options
@@ -16881,7 +17182,7 @@ function smoothLines(el, type) {
* @memberof Options
* @type {Function|string}
* @default undefined
- * @see [D3's time specifier](https://github.com/d3/d3-time-format#locale_format)
+ * @see [D3's time specifier](https://d3js.org/d3-time-format#locale_format)
* @example
* axis: {
* x: {
@@ -18386,8 +18687,8 @@ function smoothLines(el, type) {
});
;// CONCATENATED MODULE: ./src/config/Options/axis/axis.ts
-function axis_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
-function axis_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? axis_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : axis_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+function axis_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
+function axis_objectSpread(e) { for (var r = 1, t; r < arguments.length; r++) { t = null != arguments[r] ? arguments[r] : {}; r % 2 ? axis_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : axis_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
@@ -18523,13 +18824,16 @@ function axis_objectSpread(target) { for (var i = 1, source; i < arguments.lengt
-var api = [api_axis, api_category, flow, api_grid, group, api_regions, x];
-var internal = [Axis, clip, eventrect, interactions_flow, internals_grid, region, size_axis];
-var options = [data_axis, axis_axis, common_grid];
+const api = [api_axis, api_category, flow, api_grid, group, api_regions, x];
+const internal = [Axis, clip, eventrect, interactions_flow, internals_grid, region, size_axis];
+const options = [data_axis, axis_axis, common_grid];
// EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(12);
;// CONCATENATED MODULE: ./src/ChartInternal/shape/arc.ts
+
+function arc_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
+function arc_objectSpread(e) { for (var r = 1, t; r < arguments.length; r++) { t = null != arguments[r] ? arguments[r] : {}; r % 2 ? arc_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : arc_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
@@ -18552,7 +18856,7 @@ function getRadiusFn(expandRate) {
if (expandRate === void 0) {
expandRate = 0;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
hasMultiArcGauge = $$.hasMultiArcGauge(),
@@ -18566,7 +18870,7 @@ function getRadiusFn(expandRate) {
* @private
*/
inner: function inner(d) {
- var _$$$getRadius = $$.getRadius(d),
+ const _$$$getRadius = $$.getRadius(d),
innerRadius = _$$$getRadius.innerRadius;
return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : isNumber(innerRadius) ? innerRadius : 0;
},
@@ -18577,9 +18881,9 @@ function getRadiusFn(expandRate) {
* @private
*/
outer: function outer(d) {
- var _$$$getRadius2 = $$.getRadius(d),
+ const _$$$getRadius2 = $$.getRadius(d),
outerRadius = _$$$getRadius2.outerRadius;
- var radius;
+ let radius;
if (hasMultiArcGauge) {
radius = state.radius - singleArcWidth * d.index + expandWidth;
} else if ($$.hasType("polar") && !expandRate) {
@@ -18587,7 +18891,7 @@ function getRadiusFn(expandRate) {
} else {
radius = outerRadius;
if (expandRate) {
- var radiusExpanded = state.radiusExpanded;
+ let radiusExpanded = state.radiusExpanded;
if (state.radius !== outerRadius) {
radiusExpanded -= Math.abs(state.radius - outerRadius);
}
@@ -18604,13 +18908,13 @@ function getRadiusFn(expandRate) {
* @private
*/
corner: function (d, outerRadius) {
- var _config$arc_cornerRad = config.arc_cornerRadius_ratio,
+ const _config$arc_cornerRad = config.arc_cornerRadius_ratio,
ratio = _config$arc_cornerRad === void 0 ? 0 : _config$arc_cornerRad,
_config$arc_cornerRad2 = config.arc_cornerRadius,
cornerRadius = _config$arc_cornerRad2 === void 0 ? 0 : _config$arc_cornerRad2,
id = d.data.id,
value = d.value;
- var corner = 0;
+ let corner = 0;
if (ratio) {
corner = ratio * outerRadius;
} else {
@@ -18629,34 +18933,58 @@ function getRadiusFn(expandRate) {
*/
function getAttrTweenFn(fn) {
return function (d) {
- var interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, d);
+ var _this2 = this;
+ const getAngleKeyValue = function (_ref) {
+ let _ref$startAngle = _ref.startAngle,
+ startAngle = _ref$startAngle === void 0 ? 0 : _ref$startAngle,
+ _ref$endAngle = _ref.endAngle,
+ endAngle = _ref$endAngle === void 0 ? 0 : _ref$endAngle,
+ _ref$padAngle = _ref.padAngle,
+ padAngle = _ref$padAngle === void 0 ? 0 : _ref$padAngle;
+ _newArrowCheck(this, _this2);
+ return {
+ startAngle: startAngle,
+ endAngle: endAngle,
+ padAngle: padAngle
+ };
+ }.bind(this),
+ interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(getAngleKeyValue(this._current), getAngleKeyValue(d)); // d3.interpolate interpolates id value, if id is given as color string(ex. gold, silver, etc)
+ // to avoid unexpected behavior, interpolate only angle values
+ // https://github.com/naver/billboard.js/issues/3321
this._current = d;
return function (t) {
- var interpolated = interpolate(t);
- return fn(interpolated);
+ const interpolated = interpolate(t),
+ data = d.data,
+ index = d.index,
+ value = d.value;
+ return fn(arc_objectSpread(arc_objectSpread({}, interpolated), {}, {
+ data: data,
+ index: index,
+ value: value
+ }));
};
};
}
/* harmony default export */ var arc = ({
initPie: function initPie() {
- var _this2 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
config = $$.config,
dataType = config.data_type,
padding = config[dataType + "_padding"],
startingAngle = config[dataType + "_startingAngle"] || 0,
padAngle = (padding ? padding * .01 : config[dataType + "_padAngle"]) || 0;
$$.pie = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.pie)().startAngle(startingAngle).endAngle(startingAngle + 2 * Math.PI).padAngle(padAngle).value(function (d) {
- var _this3 = this;
- _newArrowCheck(this, _this2);
+ var _this4 = this;
+ _newArrowCheck(this, _this3);
return d.values.reduce(function (a, b) {
- _newArrowCheck(this, _this3);
+ _newArrowCheck(this, _this4);
return a + b.value;
}.bind(this), 0);
}.bind(this)).sort($$.getSortCompareFn.bind($$)(!0));
},
updateRadius: function updateRadius() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
dataType = config.data_type,
@@ -18668,7 +18996,7 @@ function getAttrTweenFn(fn) {
state.radius = state.radiusExpanded * .95;
state.innerRadiusRatio = w ? (state.radius - w) / state.radius : .6;
state.gaugeArcWidth = w || (gaugeArcWidth <= state.radius - state.innerRadius ? state.radius - state.innerRadius : gaugeArcWidth <= state.radius ? gaugeArcWidth : state.radius);
- var innerRadius = config.pie_innerRadius || (padding ? padding * (state.innerRadiusRatio + .1) : 0);
+ const innerRadius = config.pie_innerRadius || (padding ? padding * (state.innerRadiusRatio + .1) : 0);
// NOTE: inner/outerRadius can be an object by user setting, only for 'pie' type
state.outerRadius = config.pie_outerRadius;
@@ -18681,9 +19009,9 @@ function getAttrTweenFn(fn) {
* @private
*/
getRadius: function getRadius(d) {
- var $$ = this,
+ const $$ = this,
data = d == null ? void 0 : d.data;
- var _$$$state = $$.state,
+ let _$$$state = $$.state,
innerRadius = _$$$state.innerRadius,
outerRadius = _$$$state.outerRadius;
if (!isNumber(innerRadius) && data) {
@@ -18700,16 +19028,16 @@ function getAttrTweenFn(fn) {
};
},
updateArc: function updateArc() {
- var $$ = this;
+ const $$ = this;
$$.updateRadius();
$$.svgArc = $$.getSvgArc();
$$.svgArcExpanded = $$.getSvgArcExpanded();
},
getArcLength: function getArcLength() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
arcLengthInPercent = config.gauge_arcLength * 3.6;
- var len = 2 * (arcLengthInPercent / 360);
+ let len = 2 * (arcLengthInPercent / 360);
if (arcLengthInPercent < -360) {
len = -2;
} else if (arcLengthInPercent > 360) {
@@ -18718,12 +19046,12 @@ function getAttrTweenFn(fn) {
return len * Math.PI;
},
getGaugeStartAngle: function getGaugeStartAngle() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
isFullCircle = config.gauge_fullCircle,
defaultStartAngle = -1 * Math.PI / 2,
defaultEndAngle = Math.PI / 2;
- var startAngle = config.gauge_startingAngle;
+ let startAngle = config.gauge_startingAngle;
if (!isFullCircle && startAngle <= defaultStartAngle) {
startAngle = defaultStartAngle;
} else if (!isFullCircle && startAngle >= defaultEndAngle) {
@@ -18734,20 +19062,20 @@ function getAttrTweenFn(fn) {
return startAngle;
},
updateAngle: function updateAngle(dValue) {
- var _this4 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
config = $$.config,
- state = $$.state,
- pie = $$.pie,
+ state = $$.state;
+ let pie = $$.pie,
d = dValue,
found = !1;
if (!config) {
return null;
}
- var gStart = $$.getGaugeStartAngle(),
+ const gStart = $$.getGaugeStartAngle(),
radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
- var min = config.gauge_min,
+ const min = config.gauge_min,
max = config.gauge_max,
totalSum = $$.getTotalDataSum(state.rendered); // to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
// https://github.com/naver/billboard.js/issues/2123
@@ -18755,7 +19083,7 @@ function getAttrTweenFn(fn) {
}
pie($$.filterTargetsToShow()).forEach(function (t, i) {
var _d$data;
- _newArrowCheck(this, _this4);
+ _newArrowCheck(this, _this5);
if (!found && t.data.id === ((_d$data = d.data) == null ? void 0 : _d$data.id)) {
found = !0;
d = t;
@@ -18769,7 +19097,7 @@ function getAttrTweenFn(fn) {
d.endAngle = d.startAngle;
}
if (d.data && $$.hasMultiArcGauge()) {
- var gMin = config.gauge_min,
+ const gMin = config.gauge_min,
gMax = config.gauge_max,
gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin;
d.startAngle = gStart;
@@ -18778,17 +19106,17 @@ function getAttrTweenFn(fn) {
return found ? d : null;
},
getSvgArc: function getSvgArc() {
- var $$ = this,
+ const $$ = this,
_getRadiusFn$call = getRadiusFn.call($$),
inner = _getRadiusFn$call.inner,
outer = _getRadiusFn$call.outer,
corner = _getRadiusFn$call.corner,
arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer),
newArc = function (d, withoutUpdate) {
- var path = "M 0 0";
+ let path = "M 0 0";
if (d.value || d.data) {
- var _$$$updateAngle,
- data = withoutUpdate ? d : (_$$$updateAngle = $$.updateAngle(d)) != null ? _$$$updateAngle : null;
+ var _$$$updateAngle;
+ const data = withoutUpdate ? d : (_$$$updateAngle = $$.updateAngle(d)) != null ? _$$$updateAngle : null;
if (data) {
path = arc.cornerRadius(corner(data, outer(data)))(data);
}
@@ -18806,21 +19134,21 @@ function getAttrTweenFn(fn) {
* @private
*/
getSvgArcExpanded: function getSvgArcExpanded(rate) {
- var _this5 = this;
+ var _this6 = this;
if (rate === void 0) {
rate = 1;
}
- var $$ = this,
+ const $$ = this,
_getRadiusFn$call2 = getRadiusFn.call($$, rate),
inner = _getRadiusFn$call2.inner,
outer = _getRadiusFn$call2.outer,
corner = _getRadiusFn$call2.corner,
arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer);
return function (d) {
- _newArrowCheck(this, _this5);
- var updated = $$.updateAngle(d),
+ _newArrowCheck(this, _this6);
+ const updated = $$.updateAngle(d),
outerR = outer(updated);
- var cornerR = 0;
+ let cornerR = 0;
if (updated) {
cornerR = corner(updated, outerR);
}
@@ -18837,35 +19165,35 @@ function getAttrTweenFn(fn) {
* @private
*/
transformForArcLabel: function transformForArcLabel(d) {
- var _this6 = this,
- $$ = this,
+ var _this7 = this;
+ const $$ = this,
config = $$.config,
radiusExpanded = $$.state.radiusExpanded,
- updated = $$.updateAngle(d),
- translate = "";
+ updated = $$.updateAngle(d);
+ let translate = "";
if (updated) {
if ($$.hasMultiArcGauge()) {
- var y1 = Math.sin(updated.endAngle - Math.PI / 2),
+ const y1 = Math.sin(updated.endAngle - Math.PI / 2),
x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + 25),
y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
translate = "translate(" + x + "," + y + ")";
} else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
- var _filter$map,
- _$$$getRadius3 = $$.getRadius(d),
+ var _filter$map;
+ let _$$$getRadius3 = $$.getRadius(d),
outerRadius = _$$$getRadius3.outerRadius;
if ($$.hasType("polar")) {
outerRadius = $$.getPolarOuterRadius(d, outerRadius);
}
- var c = this.svgArc.centroid(updated),
+ const c = this.svgArc.centroid(updated),
_c$map = c.map(function (v) {
- _newArrowCheck(this, _this6);
+ _newArrowCheck(this, _this7);
return isNaN(v) ? 0 : v;
}.bind(this)),
x = _c$map[0],
y = _c$map[1],
h = Math.sqrt(x * x + y * y);
- var ratio = (_filter$map = ["donut", "pie", "polar"].filter($$.hasType.bind($$)).map(function (v) {
- _newArrowCheck(this, _this6);
+ let ratio = (_filter$map = ["donut", "pie", "polar"].filter($$.hasType.bind($$)).map(function (v) {
+ _newArrowCheck(this, _this7);
return config[v + "_label_ratio"];
}.bind(this))) == null ? void 0 : _filter$map[0];
if (ratio) {
@@ -18887,17 +19215,17 @@ function getAttrTweenFn(fn) {
});
},
textForArcLabel: function textForArcLabel(selection) {
- var $$ = this,
+ const $$ = this,
hasGauge = $$.hasType("gauge");
if ($$.shouldShowArcLabel()) {
- selection.style("fill", $$.updateTextColor.bind($$)).attr("filter", $$.updateTextBacgroundColor.bind($$)).each(function (d) {
- var _filter,
- node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
+ selection.style("fill", $$.updateTextColor.bind($$)).attr("filter", $$.updateTextBackgroundColor.bind($$)).each(function (d) {
+ var _filter;
+ const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
updated = $$.updateAngle(d),
ratio = $$.getRatio("arc", updated),
isUnderThreshold = $$.meetsLabelThreshold(ratio, (_filter = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) == null ? void 0 : _filter[0]);
if (isUnderThreshold) {
- var value = (updated || d).value,
+ const value = (updated || d).value,
text = ($$.getArcLabelFormat() || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
setTextValue(node, text, [-1, 1], hasGauge);
} else {
@@ -18907,14 +19235,14 @@ function getAttrTweenFn(fn) {
}
},
expandArc: function expandArc(targetIds) {
- var _this7 = this,
- $$ = this,
+ var _this8 = this;
+ const $$ = this,
transiting = $$.state.transiting,
$el = $$.$el;
// MEMO: avoid to cancel transition
if (transiting) {
- var interval = setInterval(function () {
- _newArrowCheck(this, _this7);
+ const interval = setInterval(function () {
+ _newArrowCheck(this, _this8);
if (!transiting) {
clearInterval(interval);
$el.legend.selectAll("." + $FOCUS.legendItemFocused).size() > 0 && $$.expandArc(targetIds);
@@ -18922,27 +19250,27 @@ function getAttrTweenFn(fn) {
}.bind(this), 10);
return;
}
- var newTargetIds = $$.mapToTargetIds(targetIds);
+ const newTargetIds = $$.mapToTargetIds(targetIds);
$el.svg.selectAll($$.selectorTargets(newTargetIds, "." + $ARC.chartArc)).each(function (d) {
if (!$$.shouldExpand(d.data.id)) {
return;
}
- var expandDuration = $$.getExpandConfig(d.data.id, "duration"),
+ const expandDuration = $$.getExpandConfig(d.data.id, "duration"),
svgArcExpandedSub = $$.getSvgArcExpanded($$.getExpandConfig(d.data.id, "rate"));
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attrTween("d", getAttrTweenFn($$.svgArcExpanded.bind($$))).transition().duration(expandDuration * 2).attrTween("d", getAttrTweenFn(svgArcExpandedSub.bind($$)));
});
},
unexpandArc: function unexpandArc(targetIds) {
- var _this8 = this,
- $$ = this,
+ var _this9 = this;
+ const $$ = this,
transiting = $$.state.transiting,
svg = $$.$el.svg;
if (transiting) {
return;
}
- var newTargetIds = $$.mapToTargetIds(targetIds);
+ const newTargetIds = $$.mapToTargetIds(targetIds);
svg.selectAll($$.selectorTargets(newTargetIds, "." + $ARC.chartArc)).selectAll("path").transition().duration(function (d) {
- _newArrowCheck(this, _this8);
+ _newArrowCheck(this, _this9);
return $$.getExpandConfig(d.data.id, "duration");
}.bind(this)).attrTween("d", getAttrTweenFn($$.svgArc.bind($$)));
svg.selectAll("" + $ARC.arc).style("opacity", null);
@@ -18955,9 +19283,9 @@ function getAttrTweenFn(fn) {
* @private
*/
getExpandConfig: function getExpandConfig(id, key) {
- var $$ = this,
+ const $$ = this,
config = $$.config;
- var type;
+ let type;
if ($$.isDonutType(id)) {
type = "donut";
} else if ($$.isGaugeType(id)) {
@@ -18971,36 +19299,36 @@ function getAttrTweenFn(fn) {
}[key];
},
shouldExpand: function shouldExpand(id) {
- var $$ = this,
+ const $$ = this,
config = $$.config;
return $$.isDonutType(id) && config.donut_expand || $$.isGaugeType(id) && config.gauge_expand || $$.isPieType(id) && config.pie_expand;
},
shouldShowArcLabel: function shouldShowArcLabel() {
- var _this9 = this,
- $$ = this,
+ var _this10 = this;
+ const $$ = this,
config = $$.config;
return ["donut", "gauge", "pie", "polar"].some(function (v) {
- _newArrowCheck(this, _this9);
+ _newArrowCheck(this, _this10);
return $$.hasType(v) && config[v + "_label_show"];
}.bind(this));
},
getArcLabelFormat: function getArcLabelFormat() {
- var _this10 = this,
- $$ = this,
- config = $$.config,
- format = function (v) {
- _newArrowCheck(this, _this10);
- return v;
- }.bind(this);
+ var _this11 = this;
+ const $$ = this,
+ config = $$.config;
+ let format = function (v) {
+ _newArrowCheck(this, _this11);
+ return v;
+ }.bind(this);
["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).forEach(function (v) {
- _newArrowCheck(this, _this10);
+ _newArrowCheck(this, _this11);
format = config[v + "_label_format"];
}.bind(this));
return isFunction(format) ? format.bind($$.api) : format;
},
updateTargetsForArc: function updateTargetsForArc(targets) {
- var _this11 = this,
- $$ = this,
+ var _this12 = this;
+ const $$ = this,
$el = $$.$el,
hasGauge = $$.hasType("gauge"),
classChartArc = $$.getChartClass("Arc"),
@@ -19008,7 +19336,7 @@ function getAttrTweenFn(fn) {
classFocus = $$.classFocus.bind($$),
chartArcs = $el.main.select("." + $ARC.chartArcs),
mainPieUpdate = chartArcs.selectAll("." + $ARC.chartArc).data($$.pie(targets)).attr("class", function (d) {
- _newArrowCheck(this, _this11);
+ _newArrowCheck(this, _this12);
return classChartArc(d) + classFocus(d.data);
}.bind(this)),
mainPieEnter = mainPieUpdate.enter().append("g").attr("class", classChartArc).call(this.setCssRule(!1, "." + $ARC.chartArcs + " text", ["pointer-events:none", "text-anchor:middle"]));
@@ -19019,7 +19347,7 @@ function getAttrTweenFn(fn) {
// mainPieUpdate.exit().remove();
},
initArc: function initArc() {
- var $$ = this,
+ const $$ = this,
$el = $$.$el;
$el.arcs = $el.main.select("." + $COMMON.chart).append("g").attr("class", $ARC.chartArcs).attr("transform", $$.getTranslate("arc"));
$$.setArcTitle();
@@ -19030,12 +19358,12 @@ function getAttrTweenFn(fn) {
* @private
*/
setArcTitle: function setArcTitle(str) {
- var $$ = this,
+ const $$ = this,
title = str || $$.getArcTitle(),
hasGauge = $$.hasType("gauge");
if (title) {
- var className = hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle;
- var text = $$.$el.arcs.select("." + className);
+ const className = hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle;
+ let text = $$.$el.arcs.select("." + className);
if (text.empty()) {
text = $$.$el.arcs.append("text").attr("class", className).style("text-anchor", "middle");
}
@@ -19049,7 +19377,7 @@ function getAttrTweenFn(fn) {
* @private
*/
getArcTitle: function getArcTitle() {
- var $$ = this,
+ const $$ = this,
type = $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge";
return type ? $$.config[type + "_title"] : "";
},
@@ -19059,12 +19387,12 @@ function getAttrTweenFn(fn) {
* @private
*/
getArcTitleWithNeedleValue: function getArcTitleWithNeedleValue() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
title = $$.getArcTitle();
if (title && $$.config.arc_needle_show && /{=[A-Z_]+}/.test(title)) {
- var value = state.current.needle;
+ let value = state.current.needle;
if (!isNumber(value)) {
value = config.arc_needle_value;
}
@@ -19075,20 +19403,20 @@ function getAttrTweenFn(fn) {
return !1;
},
redrawArc: function redrawArc(duration, durationForExit, withTransform) {
- var _this12 = this,
- $$ = this,
+ var _this13 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
main = $$.$el.main,
hasInteraction = config.interaction_enabled,
- isSelectable = hasInteraction && config.data_selection_isselectable,
- mainArc = main.selectAll("." + $ARC.arcs).selectAll("." + $ARC.arc).data($$.arcData.bind($$));
+ isSelectable = hasInteraction && config.data_selection_isselectable;
+ let mainArc = main.selectAll("." + $ARC.arcs).selectAll("." + $ARC.arc).data($$.arcData.bind($$));
mainArc.exit().transition().duration(durationForExit).style("opacity", "0").remove();
mainArc = mainArc.enter().append("path").attr("class", $$.getClass("arc", !0)).style("fill", function (d) {
- _newArrowCheck(this, _this12);
+ _newArrowCheck(this, _this13);
return $$.color(d.data);
}.bind(this)).style("cursor", function (d) {
- _newArrowCheck(this, _this12);
+ _newArrowCheck(this, _this13);
return isSelectable != null && isSelectable.bind != null && isSelectable.bind($$.api)(d) ? "pointer" : null;
}.bind(this)).style("opacity", "0").each(function (d) {
if ($$.isGaugeType(d.data)) {
@@ -19102,19 +19430,19 @@ function getAttrTweenFn(fn) {
$$.hasMultiArcGauge() && $$.redrawMultiArcGauge();
}
mainArc.attr("transform", function (d) {
- _newArrowCheck(this, _this12);
+ _newArrowCheck(this, _this13);
return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : "";
}.bind(this)).style("opacity", function (d) {
return d === this._current ? "0" : null;
}).each(function () {
- _newArrowCheck(this, _this12);
+ _newArrowCheck(this, _this13);
state.transiting = !0;
}.bind(this)).transition().duration(duration).attrTween("d", function (d) {
- var _this13 = this,
- updated = $$.updateAngle(d);
+ var _this14 = this;
+ const updated = $$.updateAngle(d);
if (!updated) {
return function () {
- _newArrowCheck(this, _this13);
+ _newArrowCheck(this, _this14);
return "M 0 0";
}.bind(this);
}
@@ -19124,17 +19452,17 @@ function getAttrTweenFn(fn) {
if (isNaN(this._current.endAngle)) {
this._current.endAngle = this._current.startAngle;
}
- var interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, updated);
+ const interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, updated);
this._current = interpolate(0);
return function (t) {
- var interpolated = interpolate(t);
+ const interpolated = interpolate(t);
interpolated.data = d.data; // data.id will be updated by interporator
return $$.getArc(interpolated, !0);
};
}).attr("transform", withTransform ? "scale(1)" : "").style("fill", function (d) {
- _newArrowCheck(this, _this12);
- var color;
+ _newArrowCheck(this, _this13);
+ let color;
if ($$.levelColor) {
color = $$.levelColor(d.data.values[0].value);
@@ -19148,8 +19476,8 @@ function getAttrTweenFn(fn) {
// Where gauge reading color would receive customization.
.style("opacity", null).call(endall, function () {
if ($$.levelColor) {
- var path = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
- d = path.datum();
+ const path = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
+ d = path.datum(this._current);
$$.updateLegendItemColor(d.data.id, path.style("fill"));
}
state.transiting = !1;
@@ -19168,17 +19496,19 @@ function getAttrTweenFn(fn) {
* @private
*/
redrawNeedle: function redrawNeedle() {
- var _this14 = this,
- $$ = this,
+ var _this15 = this;
+ const $$ = this,
$el = $$.$el,
config = $$.config,
_$$$state2 = $$.state,
hiddenTargetIds = _$$$state2.hiddenTargetIds,
radius = _$$$state2.radius,
length = (radius - 1) / 100 * config.arc_needle_length,
- hasDataToShow = hiddenTargetIds.length !== $$.data.targets.length,
- needle = $$.$el.arcs.select("." + $ARC.needle),
- pathFn = config.arc_needle_path,
+ hasDataToShow = hiddenTargetIds.length !== $$.data.targets.length;
+ let needle = $$.$el.arcs.select("." + $ARC.needle);
+
+ // needle options
+ const pathFn = config.arc_needle_path,
baseWidth = config.arc_needle_bottom_width / 2,
topWidth = config.arc_needle_top_width / 2,
topRx = config.arc_needle_top_rx,
@@ -19188,10 +19518,10 @@ function getAttrTweenFn(fn) {
bottomRy = config.arc_needle_bottom_ry,
needleAngle = $$.getNeedleAngle(),
updateNeedleValue = function () {
- _newArrowCheck(this, _this14);
- var title = $$.getArcTitleWithNeedleValue();
+ _newArrowCheck(this, _this15);
+ const title = $$.getArcTitleWithNeedleValue();
title && $$.setArcTitle(title);
- }.bind(this); // needle options
+ }.bind(this);
updateNeedleValue();
if (needle.empty()) {
needle = $el.arcs.append("path").classed($ARC.needle, !0);
@@ -19204,14 +19534,14 @@ function getAttrTweenFn(fn) {
* @private
*/
$el.needle.updateHelper = function (v, updateConfig) {
- var _this15 = this;
+ var _this16 = this;
if (updateConfig === void 0) {
updateConfig = !1;
}
- _newArrowCheck(this, _this14);
+ _newArrowCheck(this, _this15);
if ($el.needle.style("display") !== "none") {
$$.$T($el.needle).style("transform", "rotate(" + $$.getNeedleAngle(v) + "deg)").call(endall, function () {
- _newArrowCheck(this, _this15);
+ _newArrowCheck(this, _this16);
updateConfig && (config.arc_needle_value = v);
updateNeedleValue();
}.bind(this));
@@ -19219,7 +19549,7 @@ function getAttrTweenFn(fn) {
}.bind(this);
}
if (hasDataToShow) {
- var path = isFunction(pathFn) ? pathFn.call($$, length) : "M-" + baseWidth + " " + bottomLen + " A" + bottomRx + " " + bottomRy + " 0 0 0 " + baseWidth + " " + bottomLen + " L" + topWidth + " -" + length + " A" + topRx + " " + topRy + " 0 0 0 -" + topWidth + " -" + length + " L-" + baseWidth + " " + bottomLen + " Z";
+ const path = isFunction(pathFn) ? pathFn.call($$, length) : "M-" + baseWidth + " " + bottomLen + " A" + bottomRx + " " + bottomRy + " 0 0 0 " + baseWidth + " " + bottomLen + " L" + topWidth + " -" + length + " A" + topRx + " " + topRy + " 0 0 0 -" + topWidth + " -" + length + " L-" + baseWidth + " " + bottomLen + " Z";
$$.$T(needle).attr("d", path).style("fill", config.arc_needle_color).style("display", null).style("transform", "rotate(" + needleAngle + "deg)");
} else {
needle.style("display", "none");
@@ -19232,13 +19562,13 @@ function getAttrTweenFn(fn) {
* @private
*/
getNeedleAngle: function getNeedleAngle(v) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
arcLength = $$.getArcLength(),
hasGauge = $$.hasType("gauge"),
total = $$.getTotalDataSum(!0);
- var value = isDefined(v) ? v : config.arc_needle_value,
+ let value = isDefined(v) ? v : config.arc_needle_value,
startingAngle = config[config.data_type + "_startingAngle"] || 0,
radian = 0;
if (!isNumber(value)) {
@@ -19247,39 +19577,39 @@ function getAttrTweenFn(fn) {
state.current.needle = value;
if (hasGauge) {
startingAngle = $$.getGaugeStartAngle();
- var _radius = config.gauge_fullCircle ? arcLength : startingAngle * -2,
+ const radius = config.gauge_fullCircle ? arcLength : startingAngle * -2,
min = config.gauge_min,
max = config.gauge_max;
- radian = _radius * ((value - min) / (max - min));
+ radian = radius * ((value - min) / (max - min));
} else {
radian = arcLength * (value / total);
}
return (startingAngle + radian) * (180 / Math.PI);
},
redrawBackgroundArcs: function redrawBackgroundArcs() {
- var _this16 = this,
- $$ = this,
+ var _this17 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
hasMultiArcGauge = $$.hasMultiArcGauge(),
isFullCircle = config.gauge_fullCircle,
showEmptyTextLabel = $$.filterTargetsToShow($$.data.targets).length === 0 && !!config.data_empty_label_text,
startAngle = $$.getGaugeStartAngle(),
- endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1,
- backgroundArc = $$.$el.arcs.select((hasMultiArcGauge ? "g" : "") + "." + $ARC.chartArcsBackground);
+ endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1;
+ let backgroundArc = $$.$el.arcs.select((hasMultiArcGauge ? "g" : "") + "." + $ARC.chartArcsBackground);
if (hasMultiArcGauge) {
- var index = 0;
+ let index = 0;
backgroundArc = backgroundArc.selectAll("path." + $ARC.chartArcsBackground).data($$.data.targets);
backgroundArc.enter().append("path").attr("class", function (d, i) {
- _newArrowCheck(this, _this16);
+ _newArrowCheck(this, _this17);
return $ARC.chartArcsBackground + " " + $ARC.chartArcsBackground + "-" + i;
- }.bind(this)).merge(backgroundArc).style("fill", config.gauge_background || null).attr("d", function (_ref2) {
- var id = _ref2.id;
- _newArrowCheck(this, _this16);
+ }.bind(this)).merge(backgroundArc).style("fill", config.gauge_background || null).attr("d", function (_ref3) {
+ let id = _ref3.id;
+ _newArrowCheck(this, _this17);
if (showEmptyTextLabel || state.hiddenTargetIds.indexOf(id) >= 0) {
return "M 0 0";
}
- var d = {
+ const d = {
data: [{
value: config.gauge_max
}],
@@ -19292,8 +19622,8 @@ function getAttrTweenFn(fn) {
backgroundArc.exit().remove();
} else {
backgroundArc.attr("d", showEmptyTextLabel ? "M 0 0" : function () {
- _newArrowCheck(this, _this16);
- var d = {
+ _newArrowCheck(this, _this17);
+ const d = {
data: [{
value: config.gauge_max
}],
@@ -19305,8 +19635,8 @@ function getAttrTweenFn(fn) {
}
},
bindArcEvent: function bindArcEvent(arc) {
- var _this17 = this,
- $$ = this,
+ var _this18 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
isTouch = state.inputType === "touch",
@@ -19322,18 +19652,18 @@ function getAttrTweenFn(fn) {
// eslint-disable-next-line
function unselectArc(arcData) {
- var id = (arcData == null ? void 0 : arcData.id) || undefined;
+ const id = (arcData == null ? void 0 : arcData.id) || undefined;
$$.unexpandArc(id);
$$.api.revert();
$$.revertLegend();
$$.hideTooltip();
}
arc.on("click", function (event, d, i) {
- var updated = $$.updateAngle(d);
- var arcData;
+ const updated = $$.updateAngle(d);
+ let arcData;
if (updated) {
arcData = $$.convertToArcData(updated);
- $$.toggleShape == null ? void 0 : $$.toggleShape(this, arcData, i);
+ $$.toggleShape == null || $$.toggleShape(this, arcData, i);
config.data_onclick.bind($$.api)(arcData, this);
}
});
@@ -19347,24 +19677,24 @@ function getAttrTweenFn(fn) {
return;
}
state.event = event;
- var updated = $$.updateAngle(d),
+ const updated = $$.updateAngle(d),
arcData = updated ? $$.convertToArcData(updated) : null,
id = ((_arcData = arcData) == null ? void 0 : _arcData.id) || undefined;
selectArc(this, arcData, id);
$$.setOverOut(!0, arcData);
}).on("mouseout", function (event, d) {
- _newArrowCheck(this, _this17);
+ _newArrowCheck(this, _this18);
if (state.transiting) {
// skip while transiting
return;
}
state.event = event;
- var updated = $$.updateAngle(d),
+ const updated = $$.updateAngle(d),
arcData = updated ? $$.convertToArcData(updated) : null;
unselectArc();
$$.setOverOut(!1, arcData);
}.bind(this)).on("mousemove", function (event, d) {
- var updated = $$.updateAngle(d),
+ const updated = $$.updateAngle(d),
arcData = updated ? $$.convertToArcData(updated) : null;
state.event = event;
$$.showTooltip([arcData], this);
@@ -19373,10 +19703,16 @@ function getAttrTweenFn(fn) {
// touch events
if (isTouch && $$.hasArcType() && !$$.radars) {
- var getEventArc = function (event) {
- _newArrowCheck(this, _this17);
- var touch = event.changedTouches[0],
- eventArc = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.elementFromPoint(touch.clientX, touch.clientY));
+ const getEventArc = function (event) {
+ var _event$changedTouches, _event$changedTouches2;
+ _newArrowCheck(this, _this18);
+ const _ref4 = (_event$changedTouches = (_event$changedTouches2 = event.changedTouches) == null ? void 0 : _event$changedTouches2[0]) != null ? _event$changedTouches : {
+ clientX: 0,
+ clientY: 0
+ },
+ clientX = _ref4.clientX,
+ clientY = _ref4.clientY,
+ eventArc = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.elementFromPoint(clientX, clientY));
return eventArc;
}.bind(this);
$$.$el.svg.on("touchstart touchmove", function (event) {
@@ -19386,7 +19722,7 @@ function getAttrTweenFn(fn) {
return;
}
state.event = event;
- var eventArc = getEventArc(event),
+ const eventArc = getEventArc(event),
datum = eventArc.datum(),
updated = (_datum = datum) != null && _datum.data && datum.data.id ? $$.updateAngle(datum) : null,
arcData = updated ? $$.convertToArcData(updated) : null,
@@ -19397,34 +19733,35 @@ function getAttrTweenFn(fn) {
}
},
redrawArcText: function redrawArcText(duration) {
- var _this18 = this,
- $$ = this,
+ var _this19 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
_$$$$el = $$.$el,
main = _$$$$el.main,
arcs = _$$$$el.arcs,
hasGauge = $$.hasType("gauge"),
- hasMultiArcGauge = $$.hasMultiArcGauge(),
- text;
+ hasMultiArcGauge = $$.hasMultiArcGauge();
+ let text;
+
// for gauge type, update text when has no title & multi data
if (!(hasGauge && $$.data.targets.length === 1 && config.gauge_title)) {
text = main.selectAll("." + $ARC.chartArc).select("text").style("opacity", "0").attr("class", function (d) {
- _newArrowCheck(this, _this18);
+ _newArrowCheck(this, _this19);
return $$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null;
}.bind(this)).call($$.textForArcLabel.bind($$)).attr("transform", $$.transformForArcLabel.bind($$)).style("font-size", function (d) {
- _newArrowCheck(this, _this18);
+ _newArrowCheck(this, _this19);
return $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? Math.round(state.radius / 5) + "px" : null;
}.bind(this)).transition().duration(duration).style("opacity", function (d) {
- _newArrowCheck(this, _this18);
+ _newArrowCheck(this, _this19);
return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0";
}.bind(this));
hasMultiArcGauge && text.attr("dy", "-.1em");
}
main.select("." + $ARC.chartArcsTitle).style("opacity", $$.hasType("donut") || hasGauge ? null : "0");
if (hasGauge) {
- var _text,
- isFullCircle = config.gauge_fullCircle;
+ var _text;
+ const isFullCircle = config.gauge_fullCircle;
isFullCircle && ((_text = text) == null ? void 0 : _text.attr("dy", "" + (hasMultiArcGauge ? 0 : Math.round(state.radius / 14))));
if (config.gauge_label_show) {
arcs.select("." + $GAUGE.chartArcsGaugeUnit).attr("dy", (isFullCircle ? 1.5 : .75) + "em").text(config.gauge_units);
@@ -19434,6 +19771,25 @@ function getAttrTweenFn(fn) {
isFullCircle || arcs.select("." + $GAUGE.chartArcsGaugeMax).attr("dx", state.innerRadius + (state.radius - state.innerRadius) / 2 + "px").attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_max, !0));
}
}
+ },
+ /**
+ * Get Arc element by id or index
+ * @param {string|number} value id or index of Arc
+ * @returns {d3Selection} Arc path element
+ * @private
+ */
+ getArcElementByIdOrIndex: function getArcElementByIdOrIndex(value) {
+ var _this20 = this;
+ const $$ = this,
+ arcs = $$.$el.arcs,
+ filterFn = isNumber(value) ? function (d) {
+ _newArrowCheck(this, _this20);
+ return d.index === value;
+ }.bind(this) : function (d) {
+ _newArrowCheck(this, _this20);
+ return d.data.id === value;
+ }.bind(this);
+ return arcs == null ? void 0 : arcs.selectAll("." + $COMMON.target + " path").filter(filterFn);
}
});
;// CONCATENATED MODULE: ./src/ChartInternal/shape/area.ts
@@ -19448,7 +19804,7 @@ function getAttrTweenFn(fn) {
/* harmony default export */ var shape_area = ({
initArea: function initArea(mainLine) {
- var $$ = this,
+ const $$ = this,
config = $$.config;
mainLine.insert("g", "." + (config.area_front ? $CIRCLE.circles : $LINE.lines)).attr("class", $$.getClass("areas", !0));
},
@@ -19459,7 +19815,7 @@ function getAttrTweenFn(fn) {
* @private
*/
updateAreaColor: function updateAreaColor(d) {
- var $$ = this;
+ const $$ = this;
return $$.config.area_linearGradient ? $$.getGradienColortUrl(d.id) : $$.color(d);
},
/**
@@ -19472,14 +19828,14 @@ function getAttrTweenFn(fn) {
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
$el = $$.$el,
$T = $$.$T,
$root = isSub ? $el.subchart : $el;
config.area_linearGradient && $$.updateLinearGradient();
- var area = $root.main.selectAll("." + $AREA.areas).selectAll("." + $AREA.area).data($$.lineData.bind($$));
+ const area = $root.main.selectAll("." + $AREA.areas).selectAll("." + $AREA.area).data($$.lineData.bind($$));
$T(area.exit(), withTransition).style("opacity", "0").remove();
$root.area = area.enter().append("path").attr("class", $$.getClass("area", !0)).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function () {
state.orgAreaOpacity = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).style("opacity");
@@ -19502,7 +19858,7 @@ function getAttrTweenFn(fn) {
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
_ref = isSub ? this.$el.subchart : this.$el,
area = _ref.area,
orgAreaOpacity = $$.state.orgAreaOpacity;
@@ -19519,8 +19875,8 @@ function getAttrTweenFn(fn) {
* @private
*/
generateDrawArea: function generateDrawArea(areaIndices, isSub) {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
lineConnectNull = config.line_connectNull,
isRotated = config.axis_rotated,
@@ -19541,12 +19897,12 @@ function getAttrTweenFn(fn) {
return function (d) {
var _this3 = this;
_newArrowCheck(this, _this2);
- var values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
+ let values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
x0 = 0,
y0 = 0,
path;
if ($$.isAreaType(d)) {
- var area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
+ let area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue).y0(config.area_above ? 0 : config.area_below ? $$.state.height : value0).y1(value1);
if (!lineConnectNull) {
area = area.defined(function (d) {
@@ -19570,18 +19926,18 @@ function getAttrTweenFn(fn) {
},
generateGetAreaPoints: function generateGetAreaPoints(areaIndices, isSub) {
// partial duplication of generateGetBarPoints
- var $$ = this,
+ const $$ = this,
config = $$.config,
x = $$.getShapeX(0, areaIndices, isSub),
y = $$.getShapeY(!!isSub),
areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub),
yScale = $$.getYScaleById.bind($$);
return function (d, i) {
- var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
+ const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
offset = areaOffset(d, i) || y0,
posX = x(d),
value = d.value; // offset is for stacked area chart
- var posY = y(d);
+ let posY = y(d);
// fix posY not to overflow opposite quadrant
if (config.axis_rotated && (value > 0 && posY < y0 || value < 0 && y0 < posY)) {
@@ -19607,7 +19963,7 @@ function getAttrTweenFn(fn) {
/* harmony default export */ var bar = ({
initBar: function initBar() {
- var $el = this.$el,
+ const $el = this.$el,
config = this.config,
clip = this.state.clip;
$el.bar = $el.main.select("." + $COMMON.chart);
@@ -19621,8 +19977,8 @@ function getAttrTweenFn(fn) {
}
},
updateTargetsForBar: function updateTargetsForBar(targets) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
$el = $$.$el,
classChartBar = $$.getChartClass("Bar"),
@@ -19632,7 +19988,7 @@ function getAttrTweenFn(fn) {
if (!$el.bar) {
$$.initBar();
}
- var mainBarUpdate = $el.main.select("." + $BAR.chartBars).selectAll("." + $BAR.chartBar).data(
+ const mainBarUpdate = $el.main.select("." + $BAR.chartBars).selectAll("." + $BAR.chartBar).data(
// remove
targets.filter(function (v) {
var _this2 = this;
@@ -19662,7 +20018,7 @@ function getAttrTweenFn(fn) {
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
$el = $$.$el,
$T = $$.$T,
@@ -19670,7 +20026,7 @@ function getAttrTweenFn(fn) {
classBar = $$.getClass("bar", !0),
initialOpacity = $$.initialOpacity.bind($$);
config.bar_linearGradient && $$.updateLinearGradient();
- var bar = $root.main.selectAll("." + $BAR.bars).selectAll("." + $BAR.bar).data($$.labelishData.bind($$));
+ const bar = $root.main.selectAll("." + $BAR.bars).selectAll("." + $BAR.bar).data($$.labelishData.bind($$));
$T(bar.exit(), withTransition).style("opacity", "0").remove();
$root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.updateBarColor.bind($$)).merge(bar).style("opacity", initialOpacity);
@@ -19684,7 +20040,7 @@ function getAttrTweenFn(fn) {
* @private
*/
updateBarColor: function updateBarColor(d) {
- var $$ = this,
+ const $$ = this,
fn = $$.getStylePropValue($$.color);
return $$.config.bar_linearGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
},
@@ -19701,7 +20057,7 @@ function getAttrTweenFn(fn) {
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
_ref = isSub ? $$.$el.subchart : $$.$el,
bar = _ref.bar;
return [$$.$T(bar, withTransition, getRandom()).attr("d", function (d) {
@@ -19730,8 +20086,8 @@ function getAttrTweenFn(fn) {
* @private
*/
generateDrawBar: function generateDrawBar(barIndices, isSub) {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
config = $$.config,
getPoints = $$.generateGetBarPoints(barIndices, isSub),
isRotated = config.axis_rotated,
@@ -19744,26 +20100,27 @@ function getAttrTweenFn(fn) {
_newArrowCheck(this, _this4);
return w * barRadiusRatio;
}.bind(this) : null;
+
// get the bar radius
return function (d, i) {
_newArrowCheck(this, _this4);
// 4 points that make a bar
- var points = getPoints(d, i),
+ const points = getPoints(d, i),
indexX = +isRotated,
indexY = +!indexX,
isUnderZero = d.value < 0,
isInverted = config["axis_" + $$.axis.getId(d.id) + "_inverted"],
isNegative = !isInverted && isUnderZero || isInverted && !isUnderZero,
pathRadius = ["", ""]; // switch points if axis is rotated, not applicable for sub chart
- var radius = 0;
- var isGrouped = $$.isGrouped(d.id),
+ let radius = 0;
+ const isGrouped = $$.isGrouped(d.id),
isRadiusData = getRadius && isGrouped ? $$.isStackingRadiusData(d) : !1;
if (getRadius) {
- var index = isRotated ? indexY : indexX,
+ const index = isRotated ? indexY : indexX,
barW = points[2][index] - points[0][index];
radius = !isGrouped || isRadiusData ? getRadius(barW) : 0;
- var arc = "a" + radius + "," + radius + " " + (isNegative ? "1 0 0" : "0 0 1") + " ";
+ const arc = "a" + radius + "," + radius + " " + (isNegative ? "1 0 0" : "0 0 1") + " ";
pathRadius[+!isRotated] = "" + arc + radius + "," + radius;
pathRadius[+isRotated] = "" + arc + [-radius, radius][isRotated ? "sort" : "reverse"]();
isNegative && pathRadius.reverse();
@@ -19771,7 +20128,7 @@ function getAttrTweenFn(fn) {
// path string data shouldn't be containing new line chars
// https://github.com/naver/billboard.js/issues/530
- var path = isRotated ? "H" + (points[1][indexX] + (isNegative ? radius : -radius)) + " " + pathRadius[0] + "V" + (points[2][indexY] - radius) + " " + pathRadius[1] + "H" + points[3][indexX] : "V" + (points[1][indexY] + (isNegative ? -radius : radius)) + " " + pathRadius[0] + "H" + (points[2][indexX] - radius) + " " + pathRadius[1] + "V" + points[3][indexY];
+ const path = isRotated ? "H" + (points[1][indexX] + (isNegative ? radius : -radius)) + " " + pathRadius[0] + "V" + (points[2][indexY] - radius) + " " + pathRadius[1] + "H" + points[3][indexX] : "V" + (points[1][indexY] + (isNegative ? -radius : radius)) + " " + pathRadius[0] + "H" + (points[2][indexX] - radius) + " " + pathRadius[1] + "V" + points[3][indexY];
return "M" + points[0][indexX] + "," + points[0][indexY] + path + "z";
}.bind(this);
},
@@ -19781,8 +20138,8 @@ function getAttrTweenFn(fn) {
* @returns {boolean}
*/
isStackingRadiusData: function isStackingRadiusData(d) {
- var _this5 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
$el = $$.$el,
config = $$.config,
data = $$.data,
@@ -19792,7 +20149,7 @@ function getAttrTweenFn(fn) {
value = d.value;
// when the data is hidden, check if has rounded edges
if (state.hiddenTargetIds.indexOf(id) > -1) {
- var target = $el.bar.filter(function (d) {
+ const target = $el.bar.filter(function (d) {
_newArrowCheck(this, _this5);
return d.id === id && d.value === value;
}.bind(this));
@@ -19800,7 +20157,7 @@ function getAttrTweenFn(fn) {
}
// Find same grouped ids
- var keys = config.data_groups.find(function (v) {
+ const keys = config.data_groups.find(function (v) {
_newArrowCheck(this, _this5);
return v.indexOf(id) > -1;
}.bind(this)),
@@ -19831,8 +20188,8 @@ function getAttrTweenFn(fn) {
* @private
*/
generateGetBarPoints: function generateGetBarPoints(barIndices, isSub) {
- var _this7 = this,
- $$ = this,
+ var _this7 = this;
+ const $$ = this,
config = $$.config,
axis = isSub ? $$.axis.subX : $$.axis.x,
barTargetsNum = $$.getIndicesMax(barIndices) + 1,
@@ -19843,7 +20200,7 @@ function getAttrTweenFn(fn) {
yScale = $$.getYScaleById.bind($$);
return function (d, i) {
_newArrowCheck(this, _this7);
- var id = d.id,
+ const id = d.id,
y0 = yScale.call($$, id, isSub)($$.getShapeYMin(id)),
offset = barOffset(d, i) || y0,
width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
@@ -19853,7 +20210,7 @@ function getAttrTweenFn(fn) {
// offset is for stacked bar chart
- var posY = barY(d);
+ let posY = barY(d);
// fix posY not to overflow opposite quadrant
if (config.axis_rotated && !isInverted && (value > 0 && posY < y0 || value < 0 && y0 < posY)) {
@@ -19862,7 +20219,7 @@ function getAttrTweenFn(fn) {
if (!$$.isBarRangeType(d)) {
posY -= y0 - offset;
}
- var startPosX = posX + width;
+ const startPosX = posX + width;
// 4 points that make a bar
return [[posX, offset], [posX, posY], [startPosX, posY], [startPosX, offset]];
@@ -19872,8 +20229,8 @@ function getAttrTweenFn(fn) {
;// CONCATENATED MODULE: ./src/ChartInternal/shape/candlestick.ts
-function candlestick_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
-function candlestick_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? candlestick_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : candlestick_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+function candlestick_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
+function candlestick_objectSpread(e) { for (var r = 1, t; r < arguments.length; r++) { t = null != arguments[r] ? arguments[r] : {}; r % 2 ? candlestick_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : candlestick_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
@@ -19883,7 +20240,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
/* harmony default export */ var candlestick = ({
initCandlestick: function initCandlestick() {
- var $el = this.$el;
+ const $el = this.$el;
$el.candlestick = $el.main.select("." + $COMMON.chart)
// should positioned at the beginning of the shape node to not overlap others
.append("g").attr("class", $CANDLESTICK.chartCandlesticks);
@@ -19895,18 +20252,13 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @private
*/
updateTargetsForCandlestick: function updateTargetsForCandlestick(targets) {
- var _this = this,
- $$ = this,
+ const $$ = this,
$el = $$.$el,
- classChart = $$.getChartClass("Candlestick"),
- classFocus = $$.classFocus.bind($$);
+ classChart = $$.getChartClass("Candlestick");
if (!$el.candlestick) {
$$.initCandlestick();
}
- var mainUpdate = $$.$el.main.select("." + $CANDLESTICK.chartCandlesticks).selectAll("." + $CANDLESTICK.chartCandlestick).data(targets).attr("class", function (d) {
- _newArrowCheck(this, _this);
- return classChart(d) + classFocus(d);
- }.bind(this));
+ const mainUpdate = $$.$el.main.select("." + $CANDLESTICK.chartCandlesticks).selectAll("." + $CANDLESTICK.chartCandlestick).data(targets);
mainUpdate.enter().append("g").attr("class", classChart).style("pointer-events", "none");
},
/**
@@ -19916,11 +20268,11 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @private
*/
updateCandlestick: function updateCandlestick(withTransition, isSub) {
- var _this2 = this;
+ var _this = this;
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
$el = $$.$el,
$T = $$.$T,
$root = isSub ? $el.subchart : $el,
@@ -19928,15 +20280,12 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
initialOpacity = $$.initialOpacity.bind($$),
candlestick = $root.main.selectAll("." + $CANDLESTICK.chartCandlestick).selectAll("." + $CANDLESTICK.candlestick).data($$.labelishData.bind($$));
$T(candlestick.exit(), withTransition).style("opacity", "0").remove();
- var candlestickEnter = candlestick.enter().filter(function (d) {
- _newArrowCheck(this, _this2);
+ const candlestickEnter = candlestick.enter().filter(function (d) {
+ _newArrowCheck(this, _this);
return d.value;
}.bind(this)).append("g").attr("class", classSetter);
candlestickEnter.append("line");
candlestickEnter.append("path");
- if (!$root.candlestick) {
- $root.candlestick = {};
- }
$root.candlestick = candlestick.merge(candlestickEnter).style("opacity", initialOpacity);
},
/**
@@ -19947,32 +20296,32 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @private
*/
generateDrawCandlestick: function generateDrawCandlestick(indices, isSub) {
- var _this3 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
getPoints = $$.generateGetCandlestickPoints(indices, isSub),
isRotated = config.axis_rotated,
downColor = config.candlestick_color_down;
return function (d, i, g) {
var _value,
- _this4 = this;
- _newArrowCheck(this, _this3);
- var points = getPoints(d, i),
+ _this3 = this;
+ _newArrowCheck(this, _this2);
+ const points = getPoints(d, i),
value = $$.getCandlestickData(d),
isUp = (_value = value) == null ? void 0 : _value._isUp,
indexX = +isRotated; // switch points if axis is rotated, not applicable for sub chart
if (g.classed) {
g.classed($CANDLESTICK[isUp ? "valueUp" : "valueDown"], !0);
}
- var path = isRotated ? "H" + points[1][1] + " V" + points[1][0] + " H" + points[0][1] : "V" + points[1][1] + " H" + points[1][0] + " V" + points[0][1];
+ const path = isRotated ? "H" + points[1][1] + " V" + points[1][0] + " H" + points[0][1] : "V" + points[1][1] + " H" + points[1][0] + " V" + points[0][1];
g.select("path").attr("d", "M" + points[0][indexX] + "," + points[0][+!indexX] + path + "z").style("fill", function (d) {
- _newArrowCheck(this, _this4);
- var color = isUp ? $$.color(d) : isObject(downColor) ? downColor[d.id] : downColor;
+ _newArrowCheck(this, _this3);
+ const color = isUp ? $$.color(d) : isObject(downColor) ? downColor[d.id] : downColor;
return color || $$.color(d);
}.bind(this));
// set line position
- var line = g.select("line"),
+ const line = g.select("line"),
pos = isRotated ? {
x1: points[2][1],
x2: points[2][2],
@@ -19984,7 +20333,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
y1: points[2][1],
y2: points[2][2]
};
- for (var x in pos) {
+ for (const x in pos) {
line.attr(x, pos[x]);
}
}.bind(this);
@@ -19996,12 +20345,11 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @returns {Function}
*/
generateGetCandlestickPoints: function generateGetCandlestickPoints(indices, isSub) {
- var _this5 = this;
+ var _this4 = this;
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
- config = $$.config,
+ const $$ = this,
axis = isSub ? $$.axis.subX : $$.axis.x,
targetsNum = $$.getIndicesMax(indices) + 1,
barW = $$.getBarW("candlestick", axis, targetsNum),
@@ -20010,19 +20358,19 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
shapeOffset = $$.getShapeOffset($$.isBarType, indices, !!isSub),
yScale = $$.getYScaleById.bind($$);
return function (d, i) {
- _newArrowCheck(this, _this5);
- var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
+ _newArrowCheck(this, _this4);
+ const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
offset = shapeOffset(d, i) || y0,
width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
value = $$.getCandlestickData(d); // offset is for stacked bar chart
- var points;
- if (value) {
- var posX = {
+ let points;
+ if (value && isNumber(value.open) && isNumber(value.close)) {
+ const posX = {
start: x(d),
end: 0
};
posX.end = posX.start + width;
- var posY = {
+ const posY = {
start: y(value.open),
end: y(value.close)
},
@@ -20031,10 +20379,6 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
high: y(value.high),
low: y(value.low)
};
- // fix posY not to overflow opposite quadrant
- if (config.axis_rotated && (d.value > 0 && posY.start < y0 || d.value < 0 && y0 < posY.start)) {
- posY.start = y0;
- }
posY.start -= y0 - offset;
points = [[posX.start, posY.start], [posX.end, posY.end], [posLine.x, posLine.low, posLine.high]];
} else {
@@ -20054,14 +20398,14 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
$el = $$.$el,
$T = $$.$T,
_ref = isSub ? $el.subchart : $el,
candlestick = _ref.candlestick,
rand = getRandom(!0);
return [candlestick.each(function (d, i) {
- var g = $T((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), withTransition, rand);
+ const g = $T((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), withTransition, rand);
drawFn(d, i, g);
}).style("opacity", null)];
},
@@ -20073,10 +20417,10 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @private
*/
getCandlestickData: function getCandlestickData(_ref2) {
- var value = _ref2.value,
+ let value = _ref2.value,
d;
if (isArray(value)) {
- var open = value[0],
+ const open = value[0],
high = value[1],
low = value[2],
close = value[3],
@@ -20111,8 +20455,8 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
/* harmony default export */ var gauge = ({
initGauge: function initGauge() {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
arcs = $$.$el.arcs,
appendText = function (className) {
@@ -20120,7 +20464,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
arcs.append("text").attr("class", className).style("text-anchor", "middle").style("pointer-events", "none");
}.bind(this);
if ($$.hasType("gauge")) {
- var hasMulti = $$.hasMultiArcGauge();
+ const hasMulti = $$.hasMultiArcGauge();
arcs.append(hasMulti ? "g" : "path").attr("class", $ARC.chartArcsBackground).style("fill", !hasMulti && config.gauge_background || null);
config.gauge_units && appendText($GAUGE.chartArcsGaugeUnit);
if (config.gauge_label_show) {
@@ -20130,7 +20474,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
}
},
updateGaugeMax: function updateGaugeMax() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
hasMultiGauge = $$.hasMultiArcGauge(),
@@ -20144,8 +20488,8 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
}
},
redrawMultiArcGauge: function redrawMultiArcGauge() {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
$el = $$.$el,
@@ -20159,12 +20503,12 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
_newArrowCheck(this, _this2);
return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data);
}.bind(this)).style("display", config.gauge_label_show ? null : "none").each(function (d) {
- var lineLength = 0;
- var x = 0,
+ let lineLength = 0;
+ let x = 0,
y = 0,
transform = "";
if (hiddenTargetIds.indexOf(d.data.id) < 0) {
- var updated = $$.updateAngle(d),
+ const updated = $$.updateAngle(d),
innerLineLength = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length * (updated.index + 1),
lineAngle = updated.endAngle - Math.PI / 2,
arcInnerRadius = state.radius - innerLineLength,
@@ -20178,17 +20522,17 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
});
},
textForGaugeMinMax: function textForGaugeMinMax(value, isMax) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
format = config.gauge_label_extents;
return isFunction(format) ? format.bind($$.api)(value, isMax) : value;
},
getGaugeLabelHeight: function getGaugeLabelHeight() {
- var config = this.config;
+ const config = this.config;
return this.config.gauge_label_show && !config.gauge_fullCircle ? 20 : 0;
},
getPaddingBottomForGauge: function getPaddingBottomForGauge() {
- var $$ = this;
+ const $$ = this;
return $$.getGaugeLabelHeight() * ($$.config.gauge_label_show ? 2 : 2.5);
}
});
@@ -20206,7 +20550,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @private
*/
initBubble: function initBubble() {
- var $$ = this,
+ const $$ = this,
config = $$.config;
if ($$.hasType("bubble")) {
config.point_show = !0;
@@ -20219,12 +20563,12 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @private
*/
getBaseLength: function getBaseLength() {
- var $$ = this,
+ const $$ = this,
_$$$state = $$.state,
width = _$$$state.width,
height = _$$$state.height,
cacheKey = KEY.bubbleBaseLength;
- var baseLength = $$.cache.get(cacheKey);
+ let baseLength = $$.cache.get(cacheKey);
if (!baseLength) {
$$.cache.add(cacheKey, baseLength = getMinMax("min", [width, height]));
}
@@ -20237,15 +20581,15 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @private
*/
getBubbleR: function getBubbleR(d) {
- var _this = this,
- $$ = this,
- maxR = $$.config.bubble_maxR;
+ var _this = this;
+ const $$ = this;
+ let maxR = $$.config.bubble_maxR;
if (isFunction(maxR)) {
maxR = maxR.bind($$.api)(d);
} else if (!isNumber(maxR)) {
maxR = $$.getBaseLength() / ($$.getMaxDataCount() * 2) + 12;
}
- var max = getMinMax("max", $$.getMinMaxData().max.map(function (d) {
+ const max = getMinMax("max", $$.getMinMaxData().max.map(function (d) {
_newArrowCheck(this, _this);
return $$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "y") : isObject(d.value) ? d.value.mid : d.value;
}.bind(this))),
@@ -20276,12 +20620,12 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
/* harmony default export */ var line = ({
initLine: function initLine() {
- var $el = this.$el;
+ const $el = this.$el;
$el.line = $el.main.select("." + $COMMON.chart).append("g").attr("class", $LINE.chartLines).call(this.setCssRule(!1, "." + $LINE.chartLines, ["pointer-events:none"]));
},
updateTargetsForLine: function updateTargetsForLine(t) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
_$$$$el = $$.$el,
area = _$$$$el.area,
line = _$$$$el.line,
@@ -20292,7 +20636,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
if (!line) {
$$.initLine();
}
- var targets = t.filter(function (d) {
+ const targets = t.filter(function (d) {
_newArrowCheck(this, _this);
return !($$.isScatterType(d) || $$.isBubbleType(d));
}.bind(this)),
@@ -20306,7 +20650,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
// Areas
if ($$.hasTypeOf("Area")) {
- var mainLine = (!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter).filter($$.isAreaType.bind($$));
+ const mainLine = (!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter).filter($$.isAreaType.bind($$));
$$.initArea(mainLine);
}
$$.updateTargetForCircle(targets, mainLineEnter);
@@ -20322,7 +20666,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
extraLineClasses = $$.format.extraLineClasses,
$el = $$.$el,
$T = $$.$T,
@@ -20332,10 +20676,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
$root.line = line.enter().append("path").attr("class", function (d) {
_newArrowCheck(this, _this2);
return $$.getClass("line", !0)(d) + " " + (extraLineClasses(d) || "");
- }.bind(this)).style("stroke", $$.color).merge(line).style("opacity", $$.initialOpacity.bind($$)).style("shape-rendering", function (d) {
- _newArrowCheck(this, _this2);
- return $$.isStepType(d) ? "crispEdges" : "";
- }.bind(this)).attr("transform", null);
+ }.bind(this)).style("stroke", $$.color).merge(line).style("opacity", $$.initialOpacity.bind($$)).attr("transform", null);
},
/**
* Redraw function
@@ -20348,7 +20689,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
$el = $$.$el,
$T = $$.$T,
_ref = isSub ? $el.subchart : $el,
@@ -20362,14 +20703,14 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
* @private
*/
getCurve: function getCurve(d) {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
isRotatedStepType = $$.config.axis_rotated && $$.isStepType(d);
// when is step & rotated, should be computed in different way
// https://github.com/naver/billboard.js/issues/471
return isRotatedStepType ? function (context) {
_newArrowCheck(this, _this3);
- var step = $$.getInterpolate(d)(context);
+ const step = $$.getInterpolate(d)(context);
// keep the original method
step.orgPoint = step.point;
@@ -20377,7 +20718,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
// to get rotated path data
step.pointRotated = function (x, y) {
this._point === 1 && (this._point = 2);
- var y1 = this._y * (1 - this._t) + y * this._t;
+ const y1 = this._y * (1 - this._t) + y * this._t;
this._context.lineTo(this._x, y1);
this._context.lineTo(x, y1);
this._x = x;
@@ -20390,8 +20731,8 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
}.bind(this) : $$.getInterpolate(d);
},
generateDrawLine: function generateDrawLine(lineIndices, isSub) {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
config = $$.config,
scale = $$.scale,
lineConnectNull = config.line_connectNull,
@@ -20405,8 +20746,8 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
yValue = function (d, i) {
_newArrowCheck(this, _this4);
return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d));
- }.bind(this),
- line = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.line)();
+ }.bind(this);
+ let line = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.line)();
line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
if (!lineConnectNull) {
line = line.defined(function (d) {
@@ -20414,16 +20755,16 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
return $$.getBaseValue(d) !== null;
}.bind(this));
}
- var x = isSub ? scale.subX : scale.x;
+ const x = isSub ? scale.subX : scale.x;
return function (d) {
_newArrowCheck(this, _this4);
- var y = yScale(d.id, isSub);
- var values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
+ const y = yScale(d.id, isSub);
+ let values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
x0 = 0,
y0 = 0,
path;
if ($$.isLineType(d)) {
- var regions = config.data_regions[d.id];
+ const regions = config.data_regions[d.id];
if (regions) {
path = $$.lineWithRegions(values, scale.zoom || x, y, regions);
} else {
@@ -20443,27 +20784,26 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
}.bind(this);
},
lineWithRegions: function lineWithRegions(d, x, y, _regions) {
- var _this5 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
config = $$.config,
isRotated = config.axis_rotated,
isTimeSeries = $$.axis.isTimeSeries(),
regions = [],
- xp,
- yp,
- diff,
- diffx2; // default value
+ dasharray = "2 2";
+ // default value
+ let xp, yp, diff, diffx2;
// Check start/end of regions
if (isDefined(_regions)) {
- var getValue = function (v, def) {
+ const getValue = function (v, def) {
_newArrowCheck(this, _this5);
return isUndefined(v) ? def : isTimeSeries ? parseDate.call($$, v) : v;
}.bind(this);
- for (var i = 0, reg; reg = _regions[i]; i++) {
- var start = getValue(reg.start, d[0].x),
+ for (let i = 0, reg; reg = _regions[i]; i++) {
+ const start = getValue(reg.start, d[0].x),
end = getValue(reg.end, d[d.length - 1].x),
style = reg.style || {
- dasharray: "2 2"
+ dasharray: dasharray
};
regions[i] = {
start: start,
@@ -20474,7 +20814,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
}
// Set scales
- var xValue = isRotated ? function (dt) {
+ const xValue = isRotated ? function (dt) {
_newArrowCheck(this, _this5);
return y(dt.value);
}.bind(this) : function (dt) {
@@ -20494,7 +20834,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
}.bind(this),
sWithRegion = isTimeSeries ? function (d0, d1, k, timeseriesDiff) {
_newArrowCheck(this, _this5);
- var x0 = d0.x.getTime(),
+ const x0 = d0.x.getTime(),
xDiff = d1.x - d0.x,
xv0 = new Date(x0 + xDiff * k),
xv1 = new Date(x0 + xDiff * (k + timeseriesDiff)),
@@ -20502,7 +20842,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
return generateM(points);
}.bind(this) : function (d0, d1, k, otherDiff) {
_newArrowCheck(this, _this5);
- var points = isRotated ? [[y(yp(k), !0), x(xp(k))], [y(yp(k + otherDiff), !0), x(xp(k + otherDiff))]] : [[x(xp(k), !0), y(yp(k))], [x(xp(k + otherDiff), !0), y(yp(k + otherDiff))]];
+ const points = isRotated ? [[y(yp(k), !0), x(xp(k))], [y(yp(k + otherDiff), !0), x(xp(k + otherDiff))]] : [[x(xp(k), !0), y(yp(k))], [x(xp(k + otherDiff), !0), y(yp(k + otherDiff))]];
return generateM(points);
}.bind(this),
axisType = {
@@ -20510,11 +20850,11 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
y: $$.axis.getAxisType("y")
}; // Define svg generator function for region
// Generate
- var path = "";
- for (var _i = 0, data; data = d[_i]; _i++) {
- var prevData = d[_i - 1],
+ let path = "";
+ for (let i = 0, data; data = d[i]; i++) {
+ const prevData = d[i - 1],
hasPrevData = prevData && isValue(prevData.value);
- var style = $$.isWithinRegions(data.x, regions);
+ let style = $$.isWithinRegions(data.x, regions);
// https://github.com/naver/billboard.js/issues/1172
if (!isValue(data.value)) {
@@ -20523,23 +20863,23 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
// Draw as normal
if (isUndefined(regions) || !style || !hasPrevData) {
- path += "" + (_i && hasPrevData ? "L" : "M") + xValue(data) + "," + yValue(data);
+ path += "" + (i && hasPrevData ? "L" : "M") + xValue(data) + "," + yValue(data);
} else if (hasPrevData) {
try {
style = style.dasharray.split(" ");
} catch (e) {
- style = "2 2".split(" ");
+ style = dasharray.split(" ");
}
// Draw with region // TODO: Fix for horizotal charts
xp = getScale(axisType.x, prevData.x, data.x);
yp = getScale(axisType.y, prevData.value, data.value);
- var dx = x(data.x) - x(prevData.x),
+ const dx = x(data.x) - x(prevData.x),
dy = y(data.value) - y(prevData.value),
dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
diff = style[0] / dd;
diffx2 = diff * style[1];
- for (var j = diff; j <= 1; j += diffx2) {
+ for (let j = diff; j <= 1; j += diffx2) {
path += sWithRegion(prevData, data, j, diff);
// to make sure correct line drawing
@@ -20552,7 +20892,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
return path;
},
isWithinRegions: function isWithinRegions(withinX, withinRegions) {
- for (var i = 0, reg; reg = withinRegions[i]; i++) {
+ for (let i = 0, reg; reg = withinRegions[i]; i++) {
if (reg.start < withinX && withinX <= reg.end) {
return reg.style;
}
@@ -20563,7 +20903,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
},
shouldDrawPointsForLine: function shouldDrawPointsForLine(d) {
- var linePoint = this.config.line_point;
+ const linePoint = this.config.line_point;
return linePoint === !0 || isArray(linePoint) && linePoint.indexOf(d.id) !== -1;
}
});
@@ -20578,7 +20918,7 @@ var point_this = undefined;
-var getTransitionName = function () {
+const getTransitionName = function () {
_newArrowCheck(this, point_this);
return getRandom();
}.bind(undefined);
@@ -20587,29 +20927,30 @@ var getTransitionName = function () {
return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
},
hasValidPointDrawMethods: function hasValidPointDrawMethods(type) {
- var pointType = type || this.config.point_type;
+ const pointType = type || this.config.point_type;
return isObjectType(pointType) && isFunction(pointType.create) && isFunction(pointType.update);
},
initialOpacityForCircle: function initialOpacityForCircle(d) {
- var config = this.config,
+ const config = this.config,
withoutFadeIn = this.state.withoutFadeIn;
- var opacity = config.point_opacity;
+ let opacity = config.point_opacity;
if (isUndefined(opacity)) {
opacity = this.getBaseValue(d) !== null && withoutFadeIn[d.id] ? this.opacityForCircle(d) : "0";
}
return opacity;
},
opacityForCircle: function opacityForCircle(d) {
- var config = this.config;
- var opacity = config.point_opacity;
+ const config = this.config;
+ let opacity = config.point_opacity;
if (isUndefined(opacity)) {
- opacity = config.point_show && !config.point_focus_only ? null : "0";
+ var _this$isPointFocusOnl;
+ opacity = config.point_show && !((_this$isPointFocusOnl = this.isPointFocusOnly) != null && _this$isPointFocusOnl.call(this)) ? null : "0";
opacity = isValue(this.getBaseValue(d)) ? this.isBubbleType(d) || this.isScatterType(d) ? "0.5" : opacity : "0";
}
return opacity;
},
initCircle: function initCircle() {
- var $$ = this,
+ const $$ = this,
main = $$.$el.main;
$$.point = $$.generatePoint();
if (($$.hasType("bubble") || $$.hasType("scatter")) && main.select("." + $CIRCLE.chartCircles).empty()) {
@@ -20617,8 +20958,8 @@ var getTransitionName = function () {
}
},
updateTargetForCircle: function updateTargetForCircle(targetsValue, enterNodeValue) {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
data = $$.data,
$el = $$.$el,
@@ -20629,7 +20970,7 @@ var getTransitionName = function () {
return;
}
$el.circle || $$.initCircle();
- var targets = targetsValue,
+ let targets = targetsValue,
enterNode = enterNodeValue;
// only for scatter & bubble type should generate seprate node
if (!targets) {
@@ -20637,7 +20978,7 @@ var getTransitionName = function () {
_newArrowCheck(this, _this2);
return this.isScatterType(d) || this.isBubbleType(d);
}.bind(this));
- var mainCircle = $el.main.select("." + $CIRCLE.chartCircles).style("pointer-events", "none").selectAll("." + $CIRCLE.circles).data(targets);
+ const mainCircle = $el.main.select("." + $CIRCLE.chartCircles).style("pointer-events", "none").selectAll("." + $CIRCLE.circles).data(targets);
mainCircle.exit().remove();
enterNode = mainCircle.enter();
}
@@ -20652,7 +20993,7 @@ var getTransitionName = function () {
$$.setCssRule(!0, "." + $CIRCLE.circles, ["cursor:pointer"], isSelectable)(selection);
$$.setCssRule(!0, " ." + $CIRCLE.circle, ["fill", "stroke"], $$.color)(selection);
}.bind(this)).style("opacity", function () {
- var parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode);
+ const parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode);
// if the parent node is .bb-chart-circles (bubble, scatter), initialize with opacity "0"
return parent.attr("class").indexOf($CIRCLE.chartCircles) > -1 ? "0" : null;
@@ -20673,27 +21014,39 @@ var getTransitionName = function () {
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
$el = $$.$el,
- focusOnly = config.point_focus_only,
+ focusOnly = $$.isPointFocusOnly(),
$root = isSub ? $el.subchart : $el;
if (config.point_show && !state.toggling) {
- var circles = $root.main.selectAll("." + $CIRCLE.circles).selectAll("." + $CIRCLE.circle).data(function (d) {
+ config.point_radialGradient && $$.updateLinearGradient();
+ const circles = $root.main.selectAll("." + $CIRCLE.circles).selectAll("." + $CIRCLE.circle).data(function (d) {
_newArrowCheck(this, _this4);
return $$.isLineType(d) && $$.shouldDrawPointsForLine(d) || $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ? focusOnly ? [d.values[0]] : d.values : [];
}.bind(this));
circles.exit().remove();
- circles.enter().filter(Boolean).append($$.point("create", this, $$.pointR.bind($$), $$.getStylePropValue($$.color)));
+ circles.enter().filter(Boolean).append($$.point("create", this, $$.pointR.bind($$), $$.updateCircleColor.bind($$)));
$root.circle = $root.main.selectAll("." + $CIRCLE.circles + " ." + $CIRCLE.circle).style("stroke", $$.getStylePropValue($$.color)).style("opacity", $$.initialOpacityForCircle.bind($$));
}
},
+ /**
+ * Update circle color
+ * @param {object} d Data object
+ * @returns {string} Color string
+ * @private
+ */
+ updateCircleColor: function updateCircleColor(d) {
+ const $$ = this,
+ fn = $$.getStylePropValue($$.color);
+ return $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
+ },
redrawCircle: function redrawCircle(cx, cy, withTransition, flow, isSub) {
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
rendered = $$.state.rendered,
$el = $$.$el,
$T = $$.$T,
@@ -20702,13 +21055,13 @@ var getTransitionName = function () {
if (!$$.config.point_show) {
return [];
}
- var fn = $$.point("update", $$, cx, cy, $$.getStylePropValue($$.color), withTransition, flow, selectedCircles),
+ const fn = $$.point("update", $$, cx, cy, $$.updateCircleColor.bind($$), withTransition, flow, selectedCircles),
posAttr = $$.isCirclePoint() ? "c" : "",
t = getRandom(),
opacityStyleFn = $$.opacityForCircle.bind($$),
mainCircles = [];
$root.circle.each(function (d) {
- var result = fn.bind(this)(d);
+ let result = fn.bind(this)(d);
result = $T(result, withTransition || !rendered, t).style("opacity", opacityStyleFn);
mainCircles.push(result);
});
@@ -20720,35 +21073,34 @@ var getTransitionName = function () {
* @private
*/
showCircleFocus: function showCircleFocus(d) {
- var $$ = this,
- config = $$.config,
+ const $$ = this,
_$$$state = $$.state,
hasRadar = _$$$state.hasRadar,
resizing = _$$$state.resizing,
toggling = _$$$state.toggling,
transiting = _$$$state.transiting,
$el = $$.$el;
- var circle = $el.circle;
- if (transiting === !1 && config.point_focus_only && circle) {
- var cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$),
+ let circle = $el.circle;
+ if (transiting === !1 && circle && $$.isPointFocusOnly()) {
+ const cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$),
cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$),
withTransition = toggling || isUndefined(d),
fn = $$.point("update", $$, cx, cy, $$.getStylePropValue($$.color), resizing ? !1 : withTransition);
if (d) {
circle = circle.filter(function (t) {
- var _this5 = this,
- data = d.filter == null ? void 0 : d.filter(function (v) {
- _newArrowCheck(this, _this5);
- return v.id === t.id;
- }.bind(this));
+ var _this5 = this;
+ const data = d.filter == null ? void 0 : d.filter(function (v) {
+ _newArrowCheck(this, _this5);
+ return v.id === t.id;
+ }.bind(this));
return data.length ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).datum(data[0]) : !1;
});
}
circle.attr("class", this.updatePointClass.bind(this)).style("opacity", null).each(function (d) {
- var id = d.id,
+ const id = d.id,
index = d.index,
value = d.value;
- var visibility = "hidden";
+ let visibility = "hidden";
if (isValue(value)) {
fn.bind(this)(d);
$$.expandCircles(index, id);
@@ -20763,10 +21115,9 @@ var getTransitionName = function () {
* @private
*/
hideCircleFocus: function hideCircleFocus() {
- var $$ = this,
- config = $$.config,
+ const $$ = this,
circle = $$.$el.circle;
- if (config.point_focus_only && circle) {
+ if ($$.isPointFocusOnly() && circle) {
$$.unexpandCircles();
circle.style("visibility", "hidden");
}
@@ -20779,19 +21130,19 @@ var getTransitionName = function () {
if (isSub === void 0) {
isSub = !1;
}
- var $$ = this,
+ const $$ = this,
getPoints = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType), isSub);
return function (d, i) {
_newArrowCheck(this, _this6);
- var id = d.id;
+ const id = d.id;
return $$.isGrouped(id) ? getPoints(d, i)[0][1] : $$.getYScaleById(id, isSub)($$.getBaseValue(d));
}.bind(this);
},
expandCircles: function expandCircles(i, id, reset) {
- var $$ = this,
+ const $$ = this,
r = $$.pointExpandedR.bind($$);
reset && $$.unexpandCircles();
- var circles = $$.getShapeByIndex("circle", i, id).classed($COMMON.EXPANDED, !0),
+ const circles = $$.getShapeByIndex("circle", i, id).classed($COMMON.EXPANDED, !0),
scale = r(circles) / $$.config.point_r,
ratio = 1 - scale;
if ($$.isCirclePoint()) {
@@ -20799,11 +21150,11 @@ var getTransitionName = function () {
} else {
// transform must be applied to each node individually
circles.each(function () {
- var point = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
+ const point = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
if (this.tagName === "circle") {
point.attr("r", r);
} else {
- var _this$getBBox = this.getBBox(),
+ const _this$getBBox = this.getBBox(),
width = _this$getBBox.width,
height = _this$getBBox.height,
x = ratio * (+point.attr("x") + width / 2),
@@ -20814,22 +21165,22 @@ var getTransitionName = function () {
}
},
unexpandCircles: function unexpandCircles(i) {
- var $$ = this,
+ const $$ = this,
r = $$.pointR.bind($$),
circles = $$.getShapeByIndex("circle", i).filter(function () {
return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($COMMON.EXPANDED);
}).classed($COMMON.EXPANDED, !1);
circles.attr("r", r);
if (!$$.isCirclePoint()) {
- var _scale = r(circles) / $$.config.point_r;
- circles.attr("transform", _scale !== 1 ? "scale(" + _scale + ")" : null);
+ const scale = r(circles) / $$.config.point_r;
+ circles.attr("transform", scale !== 1 ? "scale(" + scale + ")" : null);
}
},
pointR: function (d) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
pointR = config.point_r;
- var r = pointR;
+ let r = pointR;
if ($$.isBubbleType(d)) {
r = $$.getBubbleR(d);
} else if (isFunction(pointR)) {
@@ -20839,52 +21190,80 @@ var getTransitionName = function () {
return r;
},
pointExpandedR: function pointExpandedR(d) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
scale = $$.isBubbleType(d) ? 1.15 : 1.75;
return config.point_focus_expand_enabled ? config.point_focus_expand_r || $$.pointR(d) * scale : $$.pointR(d);
},
pointSelectR: function pointSelectR(d) {
- var $$ = this,
+ const $$ = this,
selectR = $$.config.point_select_r;
return isFunction(selectR) ? selectR(d) : selectR || $$.pointR(d) * 4;
},
+ /**
+ * Check if point.focus.only option can be applied.
+ * @returns {boolean}
+ * @private
+ */
+ isPointFocusOnly: function isPointFocusOnly() {
+ const $$ = this;
+ return $$.config.point_focus_only && !$$.hasType("bubble") && !$$.hasType("scatter") && !$$.hasArcType(null, ["radar"]);
+ },
isWithinCircle: function isWithinCircle(node, r) {
- var mouse = getPointer(this.state.event, node),
+ const config = this.config,
+ state = this.state,
+ mouse = getPointer(state.event, node),
element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(node),
- prefix = this.isCirclePoint(node) ? "c" : "";
- var cx = +element.attr(prefix + "x"),
+ prefix = this.isCirclePoint(node) ? "c" : "",
+ sensitivity = config.point_sensitivity === "radius" ? node.getAttribute("r") : config.point_sensitivity;
+ let cx = +element.attr(prefix + "x"),
cy = +element.attr(prefix + "y");
// if node don't have cx/y or x/y attribute value
if (!(cx || cy) && node.nodeType === 1) {
- var _getBoundingRect = getBoundingRect(node),
+ const _getBoundingRect = getBoundingRect(node),
x = _getBoundingRect.x,
y = _getBoundingRect.y;
cx = x;
cy = y;
}
- return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < (r || this.config.point_sensitivity);
+ return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < (r || sensitivity);
+ },
+ /**
+ * Get data point sensitivity radius
+ * @param {object} d Data point object
+ * @returns {number} return the sensitivity value
+ */
+ getPointSensitivity: function getPointSensitivity(d) {
+ const $$ = this;
+ let sensitivity = $$.config.point_sensitivity;
+ if (isFunction(sensitivity)) {
+ sensitivity = sensitivity.call($$.api, d);
+ } else if (sensitivity === "radius") {
+ sensitivity = d.r;
+ }
+ return sensitivity;
},
insertPointInfoDefs: function insertPointInfoDefs(point, id) {
var _this7 = this,
- $$ = this,
+ _node$childNodes;
+ const $$ = this,
copyAttr = function (from, target) {
_newArrowCheck(this, _this7);
- for (var attribs = from.attributes, i = 0, name; name = attribs[i]; i++) {
+ const attribs = from.attributes;
+ for (let i = 0, name; name = attribs[i]; i++) {
name = name.name;
target.setAttribute(name, from.getAttribute(name));
}
}.bind(this),
doc = new DOMParser().parseFromString(point, "image/svg+xml"),
node = doc.documentElement,
- clone = browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, node.nodeName.toLowerCase()),
- _node$childNodes;
+ clone = browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, node.nodeName.toLowerCase());
clone.id = id;
clone.style.fill = "inherit";
clone.style.stroke = "inherit";
copyAttr(node, clone);
if ((_node$childNodes = node.childNodes) != null && _node$childNodes.length) {
- var parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(clone);
+ const parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(clone);
if ("innerHTML" in clone) {
parent.html(node.innerHTML);
} else {
@@ -20900,12 +21279,12 @@ var getTransitionName = function () {
return this.$el.defs.select("#" + id);
},
updatePointClass: function updatePointClass(d) {
- var $$ = this,
+ const $$ = this,
circle = $$.$el.circle;
- var pointClass = !1;
+ let pointClass = !1;
if (isObject(d) || circle) {
pointClass = d === !0 ? circle.each(function (d) {
- var className = $$.getClass("circle", !0)(d);
+ let className = $$.getClass("circle", !0)(d);
if (this.getAttribute("class").indexOf($COMMON.EXPANDED) > -1) {
className += " " + $COMMON.EXPANDED;
}
@@ -20915,19 +21294,20 @@ var getTransitionName = function () {
return pointClass;
},
generateGetLinePoints: function generateGetLinePoints(lineIndices, isSub) {
- var _this8 = this,
- $$ = this,
+ var _this8 = this;
+ // partial duplication of generateGetBarPoints
+ const $$ = this,
config = $$.config,
x = $$.getShapeX(0, lineIndices, isSub),
y = $$.getShapeY(isSub),
lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, isSub),
- yScale = $$.getYScaleById.bind($$); // partial duplication of generateGetBarPoints
+ yScale = $$.getYScaleById.bind($$);
return function (d, i) {
_newArrowCheck(this, _this8);
- var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
+ const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
offset = lineOffset(d, i) || y0,
posX = x(d); // offset is for stacked area chart
- var posY = y(d);
+ let posY = y(d);
// fix posY not to overflow opposite quadrant
if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
@@ -20935,14 +21315,14 @@ var getTransitionName = function () {
}
// 1 point that marks the line position
- var point = [posX, posY - (y0 - offset)];
+ const point = [posX, posY - (y0 - offset)];
return [point, point,
// from here and below, needed for compatibility
point, point];
}.bind(this);
},
generatePoint: function generatePoint() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
datetimeId = $$.state.datetimeId,
ids = [],
@@ -20952,15 +21332,15 @@ var getTransitionName = function () {
args[_key - 2] = arguments[_key];
}
return function (d) {
- var _d$data,
- id = $$.getTargetSelectorSuffix(d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d),
+ var _d$data;
+ const id = $$.getTargetSelectorSuffix(d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d),
element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
ids.indexOf(id) < 0 && ids.push(id);
- var point = pattern[ids.indexOf(id) % pattern.length];
+ let point = pattern[ids.indexOf(id) % pattern.length];
if ($$.hasValidPointType(point)) {
point = $$[point];
} else if (!$$.hasValidPointDrawMethods(point)) {
- var pointId = datetimeId + "-point" + id,
+ const pointId = datetimeId + "-point" + id,
pointFromDefs = $$.pointFromDefs(pointId);
if (pointFromDefs.size() < 1) {
$$.insertPointInfoDefs(point, pointId);
@@ -20980,8 +21360,8 @@ var getTransitionName = function () {
return element.append("use").attr("xlink:href", "#" + id).attr("class", this.updatePointClass.bind(this)).style("fill", fillStyleFn).node();
},
update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
- var _this9 = this,
- $$ = this,
+ var _this9 = this;
+ const $$ = this,
_element$node$getBBox = element.node().getBBox(),
width = _element$node$getBBox.width,
height = _element$node$getBBox.height,
@@ -20992,8 +21372,8 @@ var getTransitionName = function () {
yPosFn2 = function (d) {
_newArrowCheck(this, _this9);
return isValue(d.value) ? yPosFn(d) - height / 2 : 0;
- }.bind(this),
- mainCircles = element;
+ }.bind(this);
+ let mainCircles = element;
if (withTransition) {
flow && mainCircles.attr("x", xPosFn2);
mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
@@ -21008,8 +21388,8 @@ var getTransitionName = function () {
return element.append("circle").attr("class", this.updatePointClass.bind(this)).attr("r", sizeFn).style("fill", fillStyleFn).node();
},
update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
- var $$ = this;
- var mainCircles = element;
+ const $$ = this;
+ let mainCircles = element;
// when '.load()' called, bubble size should be updated
if ($$.hasType("bubble")) {
@@ -21028,16 +21408,16 @@ var getTransitionName = function () {
// 'rectangle' data point
rectangle: {
create: function create(element, sizeFn, fillStyleFn) {
- var _this10 = this,
- rectSizeFn = function (d) {
- _newArrowCheck(this, _this10);
- return sizeFn(d) * 2;
- }.bind(this);
+ var _this10 = this;
+ const rectSizeFn = function (d) {
+ _newArrowCheck(this, _this10);
+ return sizeFn(d) * 2;
+ }.bind(this);
return element.append("rect").attr("class", this.updatePointClass.bind(this)).attr("width", rectSizeFn).attr("height", rectSizeFn).style("fill", fillStyleFn).node();
},
update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
- var _this11 = this,
- $$ = this,
+ var _this11 = this;
+ const $$ = this,
r = $$.config.point_r,
rectXPosFn = function (d) {
_newArrowCheck(this, _this11);
@@ -21046,8 +21426,8 @@ var getTransitionName = function () {
rectYPosFn = function (d) {
_newArrowCheck(this, _this11);
return yPosFn(d) - r;
- }.bind(this),
- mainCircles = element;
+ }.bind(this);
+ let mainCircles = element;
if (withTransition) {
flow && mainCircles.attr("x", rectXPosFn);
mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
@@ -21072,8 +21452,8 @@ var getTransitionName = function () {
* @private
*/
function getDataMax($$) {
- var levelMax = $$.config.polar_level_max;
- var dataMax = $$.getMinMaxData().max[0].value;
+ const levelMax = $$.config.polar_level_max;
+ let dataMax = $$.getMinMaxData().max[0].value;
// Apply level max only when is greater than the data max value
if (levelMax && levelMax > dataMax) {
@@ -21087,7 +21467,7 @@ function getDataMax($$) {
* @private
*/
initPolar: function initPolar() {
- var $$ = this,
+ const $$ = this,
arcs = $$.$el.arcs,
config = $$.config,
levelTextShow = config.polar_level_text_show,
@@ -21108,8 +21488,8 @@ function getDataMax($$) {
* @private
*/
getPolarOuterRadius: function getPolarOuterRadius(d, outerRadius) {
- var _d$data$values$0$valu,
- dataMax = getDataMax(this);
+ var _d$data$values$0$valu;
+ const dataMax = getDataMax(this);
return ((_d$data$values$0$valu = d == null ? void 0 : d.data.values[0].value) != null ? _d$data$values$0$valu : 0) / dataMax * outerRadius;
},
/**
@@ -21126,7 +21506,7 @@ function getDataMax($$) {
* @private
*/
redrawPolar: function redrawPolar() {
- var $$ = this,
+ const $$ = this,
config = $$.config;
config.polar_level_show && $$.updatePolarLevel();
},
@@ -21135,8 +21515,8 @@ function getDataMax($$) {
* @private
*/
updatePolarLevel: function updatePolarLevel() {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
levels = $$.$el.arcs.levels,
@@ -21151,7 +21531,7 @@ function getDataMax($$) {
levelTextFormat = (config.polar_level_text_format || function () {}).bind($$.api),
level = levels.selectAll("." + $LEVEL.level).data(levelData);
level.exit().remove();
- var levelEnter = level.enter().append("g").attr("class", function (d, i) {
+ const levelEnter = level.enter().append("g").attr("class", function (d, i) {
_newArrowCheck(this, _this);
return $LEVEL.level + " " + $LEVEL.level + "-" + i;
}.bind(this));
@@ -21163,7 +21543,7 @@ function getDataMax($$) {
return levelRatio[d];
}.bind(this));
if (config.polar_level_text_show) {
- var levelTextBackgroundColor = config.polar_level_text_backgroundColor,
+ const levelTextBackgroundColor = config.polar_level_text_backgroundColor,
defsId = "#" + state.datetimeId + "-labels-bg" + $$.getTargetSelectorSuffix(levelTextBackgroundColor);
levelEnter.append("text").style("text-anchor", "middle");
levelEnter.merge(level).selectAll("text").attr("dy", function (d) {
@@ -21199,17 +21579,17 @@ function getDataMax($$) {
* @private
*/
function getPosition(isClockwise, type, edge, pos, range, ratio) {
- var index = isClockwise && pos > 0 ? edge - pos : pos,
+ const index = isClockwise && pos > 0 ? edge - pos : pos,
r = 2 * Math.PI,
func = type === "x" ? Math.sin : Math.cos;
return range * (1 - ratio * func(index * r / edge));
}
// cache key
-var cacheKey = KEY.radarPoints;
+const cacheKey = KEY.radarPoints;
/* harmony default export */ var radar = ({
initRadar: function initRadar() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
current = $$.state.current,
$el = $$.$el;
@@ -21228,7 +21608,7 @@ var cacheKey = KEY.radarPoints;
}
},
getRadarSize: function getRadarSize() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
_$$$state = $$.state,
arcWidth = _$$$state.arcWidth,
@@ -21238,8 +21618,8 @@ var cacheKey = KEY.radarPoints;
return [size, size];
},
updateTargetsForRadar: function updateTargetsForRadar(targets) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config;
if (isEmpty(config.axis_x_categories)) {
config.axis_x_categories = getRange(0, getMinMax("max", targets.map(function (v) {
@@ -21250,8 +21630,8 @@ var cacheKey = KEY.radarPoints;
$$.generateRadarPoints();
},
getRadarPosition: function getRadarPosition(type, index, range, ratio) {
- var _this2 = this,
- $$ = this,
+ var _this2 = this;
+ const $$ = this,
config = $$.config,
_$$$getRadarSize = $$.getRadarSize(),
width = _$$$getRadarSize[0],
@@ -21269,8 +21649,8 @@ var cacheKey = KEY.radarPoints;
* @private
*/
generateRadarPoints: function generateRadarPoints() {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
targets = $$.data.targets,
_$$$getRadarSize2 = $$.getRadarSize(),
width = _$$$getRadarSize2[0],
@@ -21295,7 +21675,7 @@ var cacheKey = KEY.radarPoints;
}
},
redrawRadar: function redrawRadar() {
- var $$ = this,
+ const $$ = this,
_$$$$el = $$.$el,
radar = _$$$$el.radar,
main = _$$$$el.main,
@@ -21311,17 +21691,17 @@ var cacheKey = KEY.radarPoints;
}
},
generateGetRadarPoints: function generateGetRadarPoints() {
- var _this5 = this,
- points = this.cache.get(cacheKey);
+ var _this5 = this;
+ const points = this.cache.get(cacheKey);
return function (d, i) {
_newArrowCheck(this, _this5);
- var point = points[d.id][i];
+ const point = points[d.id][i];
return [point, point, point, point];
}.bind(this);
},
updateRadarLevel: function updateRadarLevel() {
- var _this6 = this,
- $$ = this,
+ var _this6 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
radar = $$.$el.radar,
@@ -21342,7 +21722,7 @@ var cacheKey = KEY.radarPoints;
points = levelData.map(function (v) {
var _this7 = this;
_newArrowCheck(this, _this6);
- var range = levelRatio[v],
+ const range = levelRatio[v],
pos = getRange(0, edge).map(function (i) {
_newArrowCheck(this, _this7);
return $$.getRadarPosition(["x", "y"], i, range, 1).join(",");
@@ -21350,10 +21730,11 @@ var cacheKey = KEY.radarPoints;
return pos.join(" ");
}.bind(this)),
level = radarLevels.selectAll("." + $LEVEL.level).data(levelData);
+
// Generate points
level.exit().remove();
- var levelEnter = level.enter().append("g").attr("class", function (d, i) {
+ const levelEnter = level.enter().append("g").attr("class", function (d, i) {
_newArrowCheck(this, _this6);
return $LEVEL.level + " " + $LEVEL.level + "-" + i;
}.bind(this));
@@ -21390,17 +21771,17 @@ var cacheKey = KEY.radarPoints;
}
},
updateRadarAxes: function updateRadarAxes() {
- var _this8 = this,
- $$ = this,
+ var _this8 = this;
+ const $$ = this,
config = $$.config,
radar = $$.$el.radar,
_$$$getRadarSize4 = $$.getRadarSize(),
width = _$$$getRadarSize4[0],
height = _$$$getRadarSize4[1],
- categories = config.axis_x_categories,
- axis = radar.axes.selectAll("g").data(categories);
+ categories = config.axis_x_categories;
+ let axis = radar.axes.selectAll("g").data(categories);
axis.exit().remove();
- var axisEnter = axis.enter().append("g").attr("class", function (d, i) {
+ const axisEnter = axis.enter().append("g").attr("class", function (d, i) {
_newArrowCheck(this, _this8);
return $AXIS.axis + "-" + i;
}.bind(this));
@@ -21421,7 +21802,7 @@ var cacheKey = KEY.radarPoints;
// axis text
if (config.radar_axis_text_show) {
- var _config$radar_axis_te = config.radar_axis_text_position,
+ const _config$radar_axis_te = config.radar_axis_text_position,
_config$radar_axis_te2 = _config$radar_axis_te.x,
x = _config$radar_axis_te2 === void 0 ? 0 : _config$radar_axis_te2,
_config$radar_axis_te3 = _config$radar_axis_te.y,
@@ -21441,7 +21822,7 @@ var cacheKey = KEY.radarPoints;
// cache evaluated axis text width
this.width = this.getBoundingClientRect().width / 2;
}
- var posX = $$.getRadarPosition("x", d.index, undefined, 1),
+ let posX = $$.getRadarPosition("x", d.index, undefined, 1),
posY = Math.round($$.getRadarPosition("y", d.index, undefined, 1));
if (posX > width) {
posX += this.width + x;
@@ -21463,34 +21844,25 @@ var cacheKey = KEY.radarPoints;
$$.bindRadarEvent();
},
bindRadarEvent: function bindRadarEvent() {
- var _this9 = this,
- $$ = this,
+ var _this9 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
_$$$$el2 = $$.$el,
radar = _$$$$el2.radar,
svg = _$$$$el2.svg,
- focusOnly = config.point_focus_only,
+ focusOnly = $$.isPointFocusOnly(),
_state = state,
inputType = _state.inputType,
transiting = _state.transiting;
if (config.interaction_enabled) {
- var isMouse = inputType === "mouse",
- getIndex = function (event) {
- _newArrowCheck(this, _this9);
- var target = event.target;
-
- // in case of multilined axis text
- if (/tspan/i.test(target.tagName)) {
- target = target.parentNode;
- }
- var d = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
- return d && Object.keys(d).length === 1 ? d.index : undefined;
- }.bind(this),
+ const isMouse = inputType === "mouse",
hide = function (event) {
_newArrowCheck(this, _this9);
state.event = event;
- var index = getIndex(event),
+
+ // const index = getIndex(event);
+ const index = $$.getDataIndexFromEvent(event),
noIndex = isUndefined(index);
if (isMouse || noIndex) {
$$.hideTooltip();
@@ -21509,8 +21881,8 @@ var cacheKey = KEY.radarPoints;
return;
}
state.event = event;
- var index = getIndex(event);
- $$.selectRectForSingle(svg.node(), null, index);
+ const index = $$.getDataIndexFromEvent(event);
+ $$.selectRectForSingle(svg.node(), index);
isMouse ? $$.setOverOut(!0, index) : $$.callOverOutForTouch(index);
}.bind(this)).on("mouseout", isMouse ? hide : null);
if (!isMouse) {
@@ -21519,8 +21891,8 @@ var cacheKey = KEY.radarPoints;
}
},
updateRadarShape: function updateRadarShape() {
- var _this10 = this,
- $$ = this,
+ var _this10 = this;
+ const $$ = this,
targets = $$.data.targets.filter(function (d) {
_newArrowCheck(this, _this10);
return $$.isRadarType(d);
@@ -21576,8 +21948,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
* @private
*/
function position(group, root) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
_$$$scale = $$.scale,
x = _$$$scale.x,
y = _$$$scale.y,
@@ -21601,11 +21973,11 @@ function position(group, root) {
* @private
*/
function convertDataToTreemapData(data) {
- var _this2 = this,
- $$ = this;
+ var _this2 = this;
+ const $$ = this;
return data.map(function (d) {
_newArrowCheck(this, _this2);
- var id = d.id,
+ const id = d.id,
values = d.values,
value = values[0].value;
return {
@@ -21619,8 +21991,8 @@ function convertDataToTreemapData(data) {
}
/* harmony default export */ var treemap = ({
initTreemap: function initTreemap() {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
$el = $$.$el,
_$$$state = $$.state,
_$$$state$current = _$$$state.current,
@@ -21633,7 +22005,7 @@ function convertDataToTreemapData(data) {
$$.treemapFn = function (data) {
var _this4 = this;
_newArrowCheck(this, _this3);
- var hierarchyData = (0,external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.hierarchy)(data).sum(function (d) {
+ const hierarchyData = (0,external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.hierarchy)(data).sum(function (d) {
_newArrowCheck(this, _this4);
return d.value;
}.bind(this)),
@@ -21649,16 +22021,16 @@ function convertDataToTreemapData(data) {
* @private
*/
bindTreemapEvent: function bindTreemapEvent() {
- var _this5 = this,
- $$ = this,
+ var _this5 = this;
+ const $$ = this,
$el = $$.$el,
config = $$.config,
state = $$.state,
getTarget = function (event) {
var _state$eventReceiver$, _data;
_newArrowCheck(this, _this5);
- var target = event.isTrusted ? event.target : (_state$eventReceiver$ = state.eventReceiver.rect) == null ? void 0 : _state$eventReceiver$.node(),
- data;
+ const target = event.isTrusted ? event.target : (_state$eventReceiver$ = state.eventReceiver.rect) == null ? void 0 : _state$eventReceiver$.node();
+ let data;
if (/^rect$/i.test(target.tagName)) {
state.event = event;
data = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
@@ -21666,17 +22038,17 @@ function convertDataToTreemapData(data) {
return (_data = data) == null ? void 0 : _data.data;
}.bind(this);
if (config.interaction_enabled) {
- var isTouch = state.inputType === "touch";
- $el.treemap.on(isTouch ? "touchstart" : "mousemove", function (event) {
+ const isTouch = state.inputType === "touch";
+ $el.treemap.on(isTouch ? "touchstart" : "mouseover mousemove", function (event) {
_newArrowCheck(this, _this5);
- var data = getTarget(event);
+ const data = getTarget(event);
if (data) {
$$.showTooltip([data], event.currentTarget);
- event.type === "mouseover" && $$.setOverOut(!0, data);
+ /^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(!0, data);
}
}.bind(this)).on(isTouch ? "touchend" : "mouseout", function (event) {
_newArrowCheck(this, _this5);
- var data = getTarget(event);
+ const data = getTarget(event);
$$.hideTooltip();
$$.setOverOut(!1, data);
}.bind(this));
@@ -21690,7 +22062,8 @@ function convertDataToTreemapData(data) {
getTreemapTile: function getTreemapTile() {
var _binary$dice$slice$sl,
_config$treemap_tile,
- $$ = this,
+ _this6 = this;
+ const $$ = this,
config = $$.config,
_$$$state$current2 = $$.state.current,
width = _$$$state$current2.width,
@@ -21702,13 +22075,12 @@ function convertDataToTreemapData(data) {
"sliceDice": external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapSliceDice,
"squarify": external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapSquarify,
"resquarify": external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapResquarify
- }[(_config$treemap_tile = config.treemap_tile) != null ? _config$treemap_tile : "binary"]) != null ? _binary$dice$slice$sl : external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapBinary,
- _this6 = this;
+ }[(_config$treemap_tile = config.treemap_tile) != null ? _config$treemap_tile : "binary"]) != null ? _binary$dice$slice$sl : external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapBinary;
return function (node, x0, y0, x1, y1) {
_newArrowCheck(this, _this6);
tile(node, 0, 0, width, height);
for (var _iterator = _createForOfIteratorHelperLoose(node.children), _step; !(_step = _iterator()).done;) {
- var child = _step.value;
+ const child = _step.value;
child.x0 = x0 + child.x0 / width * (x1 - x0);
child.x1 = x0 + child.x1 / width * (x1 - x0);
child.y0 = y0 + child.y0 / height * (y1 - y0);
@@ -21723,7 +22095,7 @@ function convertDataToTreemapData(data) {
* @private
*/
getTreemapData: function getTreemapData(targets) {
- var $$ = this;
+ const $$ = this;
return {
name: "root",
children: convertDataToTreemapData.bind($$)($$.filterTargetsToShow(targets.filter($$.isTreemapType, $$)))
@@ -21735,7 +22107,7 @@ function convertDataToTreemapData(data) {
* @private
*/
updateTargetsForTreemap: function updateTargetsForTreemap(targets) {
- var $$ = this,
+ const $$ = this,
treemap = $$.$el.treemap,
treemapData = $$.treemapFn($$.getTreemapData(targets != null ? targets : $$.data.targets));
// using $el.treemap reference can alter data, so select treemap again
@@ -21747,8 +22119,8 @@ function convertDataToTreemapData(data) {
* @private
*/
updateTreemap: function updateTreemap(durationForExit) {
- var _this7 = this,
- $$ = this,
+ var _this7 = this;
+ const $$ = this,
$el = $$.$el,
$T = $$.$T,
data = $el.treemap.datum(),
@@ -21767,8 +22139,8 @@ function convertDataToTreemapData(data) {
* @private
*/
generateGetTreemapPoints: function generateGetTreemapPoints() {
- var _this8 = this,
- $$ = this,
+ var _this8 = this;
+ const $$ = this,
$el = $$.$el,
_$$$scale2 = $$.scale,
x = _$$$scale2.x,
@@ -21790,7 +22162,7 @@ function convertDataToTreemapData(data) {
* @private
*/
redrawTreemap: function redrawTreemap(withTransition) {
- var $$ = this,
+ const $$ = this,
$el = $$.$el,
_$$$state$current3 = $$.state.current,
width = _$$$state$current3.width,
@@ -21806,7 +22178,7 @@ function convertDataToTreemapData(data) {
* @private
*/
treemapDataLabelFormat: function treemapDataLabelFormat(d) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
id = d.id,
value = d.value,
@@ -21839,6 +22211,13 @@ function convertDataToTreemapData(data) {
* @property {boolean} [point.show=true] Whether to show each point in line.
* @property {number|Function} [point.r=2.5] The radius size of each point.
* - **NOTE:** Disabled for 'bubble' type
+ * @property {boolean|object} [point.radialGradient=false] Set the radial gradient on point.
+ * Or customize by giving below object value:
+ * - cx {number}: `cx` value (default: `0.3`)
+ * - cy {number}: `cy` value (default: `0.3`)
+ * - r {number}: `r` value (default: `0.7`)
+ * - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
+ * - (default: `[[0.1, $DATA_COLOR, 1], [0.9, $DATA_COLOR, 0]]`)
* @property {boolean} [point.focus.expand.enabled=true] Whether to expand each point on focus.
* @property {number} [point.focus.expand.r=point.r*1.75] The radius size of each point on focus.
* - **NOTE:** For 'bubble' type, the default is `bubbleSize*1.15`
@@ -21881,6 +22260,7 @@ function convertDataToTreemapData(data) {
* (ex. ``)
* @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
* @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
+ * @see [Demo: point radialGradient](https://naver.github.io/billboard.js/demo/#Point.RadialGradientPoint)
* @see [Demo: point sensitivity](https://naver.github.io/billboard.js/demo/#Point.PointSensitivity)
* @example
* point: {
@@ -21893,6 +22273,32 @@ function convertDataToTreemapData(data) {
* return r;
* },
*
+ * // will generate follwing radialGradient:
+ * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/radialGradient
+ * //
+ * //
+ * //
+ * //
+ * radialGradient: true,
+ *
+ * // Or customized gradient
+ * radialGradient: {
+ * cx: 0.3, // cx attributes
+ * cy: 0.5, // cy attributes
+ * r: 0.7, // r attributes
+ * stops: [
+ * // offset, stop-color, stop-opacity
+ * [0, "#7cb5ec", 1],
+ *
+ * // setting 'null' for stop-color, will set its original data color
+ * [0.5, null, 0],
+ *
+ * // setting 'function' for stop-color, will pass data id as argument.
+ * // It should return color string or null value
+ * [1, function(id) { return id === "data1" ? "red" : "blue"; }, 0],
+ * ]
+ * },
+ *
* focus: {
* expand: {
* enabled: true,
@@ -21939,6 +22345,7 @@ function convertDataToTreemapData(data) {
*/
point_show: !0,
point_r: 2.5,
+ point_radialGradient: !1,
point_sensitivity: 10,
point_focus_expand_enabled: !0,
point_focus_expand_r: undefined,
@@ -21969,9 +22376,10 @@ function convertDataToTreemapData(data) {
* @property {boolean} [area.front=true] Set area node to be positioned over line node.
* @property {boolean|object} [area.linearGradient=false] Set the linear gradient on area.
* Or customize by giving below object value:
- * - x {Array}: `x1`, `x2` value
- * - y {Array}: `y1`, `y2` value
+ * - x {Array}: `x1`, `x2` value (default: `[0, 0]`)
+ * - y {Array}: `y1`, `y2` value (default: `[0, 1]`)
* - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
+ * - (default: `[[0, $DATA_COLOR, 1], [1, $DATA_COLOR, 0]]`)
* @property {boolean} [area.zerobased=true] Set if min or max value will be 0 on area chart.
* @see [MDN's <linearGradient>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient), [<stop>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/stop)
* @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
@@ -21988,6 +22396,7 @@ function convertDataToTreemapData(data) {
* front: false,
*
* // will generate follwing linearGradient:
+ * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
* //
* //
* //
@@ -22038,9 +22447,10 @@ function convertDataToTreemapData(data) {
* @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
* @property {boolean|object} [bar.linearGradient=false] Set the linear gradient on bar.
* Or customize by giving below object value:
- * - x {Array}: `x1`, `x2` value
- * - y {Array}: `y1`, `y2` value
+ * - x {Array}: `x1`, `x2` value (default: `[0, 0]`)
+ * - y {Array}: `y1`, `y2` value (default: `[0, 1]`)
* - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
+ * - (default: `[[0, $DATA_COLOR, 1], [1, $DATA_COLOR, 0]]`)
* @property {boolean} [bar.overlap=false] Bars will be rendered at same position, which will be overlapped each other. (for non-grouped bars only)
* @property {number} [bar.padding=0] The padding pixel value between each bar.
* @property {number} [bar.radius] Set the radius of bar edge in pixel.
@@ -22074,6 +22484,7 @@ function convertDataToTreemapData(data) {
* },
*
* // will generate follwing linearGradient:
+ * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
* //
* //
* //
@@ -23128,7 +23539,7 @@ function extendArc(module, option) {
}
// Area types
-var _area = function area() {
+let _area = function area() {
var _this2 = this;
_newArrowCheck(this, shape_this);
return extendLine(shape_area, [Options_shape_area]), (_area = function () {
@@ -23296,7 +23707,7 @@ function setSelection(isSelection, ids, indices, resetOther) {
if (isSelection === void 0) {
isSelection = !1;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
main = $$.$el.main,
selectionGrouped = config.data_selection_grouped,
@@ -23305,7 +23716,7 @@ function setSelection(isSelection, ids, indices, resetOther) {
return;
}
main.selectAll("." + $SHAPE.shapes).selectAll("." + $SHAPE.shape).each(function (d) {
- var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
+ const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
_ref = d.data ? d.data : d,
id = _ref.id,
index = _ref.index,
@@ -23348,8 +23759,8 @@ function setSelection(isSelection, ids, indices, resetOther) {
* chart.selected("data1");
*/
selected: function selected(targetId) {
- var _this = this,
- $$ = this.internal,
+ var _this = this;
+ const $$ = this.internal,
dataPoint = [];
$$.$el.main.selectAll("." + ($SHAPE.shapes + $$.getTargetSelectorSuffix(targetId))).selectAll("." + $SHAPE.shape).filter(function () {
return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($SELECT.SELECTED);
@@ -23384,7 +23795,7 @@ function setSelection(isSelection, ids, indices, resetOther) {
* chart.select("data1", [0, 3, 5]);
*/
select: function select(ids, indices, resetOther) {
- var $$ = this.internal;
+ const $$ = this.internal;
setSelection.bind($$)(!0, ids, indices, resetOther);
},
/**
@@ -23405,102 +23816,168 @@ function setSelection(isSelection, ids, indices, resetOther) {
* chart.unselect("data1", [2]);
*/
unselect: function unselect(ids, indices) {
- var $$ = this.internal;
+ const $$ = this.internal;
setSelection.bind($$)(!1, ids, indices);
}
});
;// CONCATENATED MODULE: ./src/Chart/api/subchart.ts
+
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
-/* harmony default export */ var subchart = ({
- subchart: {
- /**
- * Show subchart
- * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
- * @function subchart․show
- * @instance
- * @memberof Chart
- * @example
- * // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
- * import {subchart} from "billboard.js";
- *
- * const chart = bb.generate({
- * ...
- * subchart: {
- * // need to be instantiated by calling 'subchart()'
- * enabled: subchart()
- *
- * // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
- * enabled: !subchart()
- * }
- * });
- *
- * chart.subchart.show();
- */
- show: function () {
- var $$ = this.internal,
- subchart = $$.$el.subchart,
- config = $$.config,
- show = config.subchart_show;
- if (!show) {
- var _$target, _subchart$main2;
- // unbind zoom event bound to chart rect area
- $$.unbindZoomEvent();
- config.subchart_show = !show;
- subchart.main || $$.initSubchart();
- var $target = subchart.main.selectAll("." + $COMMON.target);
- // need to cover when new data has been loaded
- if ($$.data.targets.length !== $target.size()) {
- var _subchart$main;
- $$.updateSizes();
- $$.updateTargetsForSubchart($$.data.targets);
- $target = (_subchart$main = subchart.main) == null ? void 0 : _subchart$main.selectAll("." + $COMMON.target);
- }
- (_$target = $target) == null ? void 0 : _$target.style("opacity", null);
- (_subchart$main2 = subchart.main) == null ? void 0 : _subchart$main2.style("display", null);
- this.resize();
+/**
+ * Select subchart by giving x domain range.
+ * - **ℹ️ NOTE:**
+ * - Due to the limitations of floating point precision, domain value may not be exact returning approximately values.
+ * @function subchart
+ * @instance
+ * @memberof Chart
+ * @param {Array} domainValue If domain range is given, the subchart will be seleted to the given domain. If no argument is given, the current subchart selection domain will be returned.
+ * @returns {Array} domain value in array
+ * @example
+ * // Specify domain for subchart selection
+ * chart.subchart([1, 2]);
+ *
+ * // Get the current subchart selection domain range
+ * // Domain value may not be exact returning approximately values.
+ * chart.subchart();
+ */ // NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
+const subchart = function (domainValue) {
+ var _this = this;
+ const $$ = this.internal,
+ axis = $$.axis,
+ brush = $$.brush,
+ config = $$.config,
+ _$$$scale = $$.scale,
+ x = _$$$scale.x,
+ subX = _$$$scale.subX,
+ state = $$.state;
+ let domain;
+ if (config.subchart_show) {
+ domain = domainValue;
+ if (Array.isArray(domain)) {
+ if (axis.isTimeSeries()) {
+ domain = domain.map(function (x) {
+ _newArrowCheck(this, _this);
+ return parseDate.bind($$)(x);
+ }.bind(this));
}
- },
- /**
- * Hide generated subchart
- * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
- * @function subchart․hide
- * @instance
- * @memberof Chart
- * @example
- * chart.subchart.hide();
- */
- hide: function hide() {
- var $$ = this.internal,
- main = $$.$el.subchart.main,
- config = $$.config;
- if (config.subchart_show && (main == null ? void 0 : main.style("display")) !== "none") {
- config.subchart_show = !1;
- main.style("display", "none");
- this.resize();
+ const isWithinRange = $$.withinRange(domain, $$.getZoomDomain("subX", !0), $$.getZoomDomain("subX"));
+ if (isWithinRange) {
+ state.domain = domain;
+ brush.move(brush.getSelection(), domain.map(subX));
}
- },
- /**
- * Toggle the visiblity of subchart
- * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
- * @function subchart․toggle
- * @instance
- * @memberof Chart
- * @example
- * // When subchart is hidden, will be shown
- * // When subchart is shown, will be hidden
- * chart.subchart.toggle();
- */
- toggle: function toggle() {
- var $$ = this.internal,
- config = $$.config;
- this.subchart[config.subchart_show ? "hide" : "show"]();
+ } else {
+ var _state$domain;
+ domain = (_state$domain = state.domain) != null ? _state$domain : x.orgDomain();
}
}
+ return domain;
+};
+extend(subchart, {
+ /**
+ * Show subchart
+ * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
+ * @function subchart․show
+ * @instance
+ * @memberof Chart
+ * @example
+ * // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
+ * import {subchart} from "billboard.js";
+ *
+ * const chart = bb.generate({
+ * ...
+ * subchart: {
+ * // need to be instantiated by calling 'subchart()'
+ * enabled: subchart()
+ *
+ * // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
+ * enabled: !subchart()
+ * }
+ * });
+ *
+ * chart.subchart.show();
+ */
+ show: function () {
+ const $$ = this.internal,
+ subchart = $$.$el.subchart,
+ config = $$.config,
+ show = config.subchart_show;
+ if (!show) {
+ var _$target, _subchart$main2;
+ // unbind zoom event bound to chart rect area
+ $$.unbindZoomEvent();
+ config.subchart_show = !show;
+ subchart.main || $$.initSubchart();
+ let $target = subchart.main.selectAll("." + $COMMON.target);
+
+ // need to cover when new data has been loaded
+ if ($$.data.targets.length !== $target.size()) {
+ var _subchart$main;
+ $$.updateSizes();
+ $$.updateTargetsForSubchart($$.data.targets);
+ $target = (_subchart$main = subchart.main) == null ? void 0 : _subchart$main.selectAll("." + $COMMON.target);
+ }
+ (_$target = $target) == null || _$target.style("opacity", null);
+ (_subchart$main2 = subchart.main) == null || _subchart$main2.style("display", null);
+ this.resize();
+ }
+ },
+ /**
+ * Hide generated subchart
+ * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
+ * @function subchart․hide
+ * @instance
+ * @memberof Chart
+ * @example
+ * chart.subchart.hide();
+ */
+ hide: function hide() {
+ const $$ = this.internal,
+ main = $$.$el.subchart.main,
+ config = $$.config;
+ if (config.subchart_show && (main == null ? void 0 : main.style("display")) !== "none") {
+ config.subchart_show = !1;
+ main.style("display", "none");
+ this.resize();
+ }
+ },
+ /**
+ * Toggle the visiblity of subchart
+ * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
+ * @function subchart․toggle
+ * @instance
+ * @memberof Chart
+ * @example
+ * // When subchart is hidden, will be shown
+ * // When subchart is shown, will be hidden
+ * chart.subchart.toggle();
+ */
+ toggle: function toggle() {
+ const $$ = this.internal,
+ config = $$.config;
+ this.subchart[config.subchart_show ? "hide" : "show"]();
+ },
+ /**
+ * Reset subchart selection
+ * @function subchart․reset
+ * @instance
+ * @memberof Chart
+ * @example
+ * // Reset subchart selection
+ * chart.subchart.reset();
+ */
+ reset: function reset() {
+ const $$ = this.internal,
+ brush = $$.brush;
+ brush.clear(brush.getSelection());
+ }
+});
+/* harmony default export */ var api_subchart = ({
+ subchart: subchart
});
// EXTERNAL MODULE: external {"commonjs":"d3-zoom","commonjs2":"d3-zoom","amd":"d3-zoom","root":"d3"}
var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack_require__(14);
@@ -23512,38 +23989,13 @@ var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack
*/
-
-/**
- * Check if the given domain is within zoom range
- * @param {Array} domain Target domain value
- * @param {Array} current Current zoom domain value
- * @param {Array} range Zoom range value
- * @param {boolean} isInverted Whether the axis is inverted or not
- * @returns {boolean}
- * @private
- */
-function withinRange(domain, current, range, isInverted) {
- var _this = this;
- if (isInverted === void 0) {
- isInverted = !1;
- }
- var min = range[0],
- max = range[1];
- return domain.every(function (v, i) {
- var _this2 = this;
- _newArrowCheck(this, _this);
- return (i === 0 ? isInverted ? +v <= min : +v >= min : isInverted ? +v >= max : +v <= max) && !domain.every(function (v, i) {
- _newArrowCheck(this, _this2);
- return v === current[i];
- }.bind(this));
- }.bind(this));
-}
-
/**
* Zoom by giving x domain range.
- * - **NOTE:**
+ * - **ℹ️ NOTE:**
* - For `wheel` type zoom, the minimum zoom range will be set as the given domain range. To get the initial state, [.unzoom()](#unzoom) should be called.
* - To be used [zoom.enabled](Options.html#.zoom) option should be set as `truthy`.
+ * - When x axis type is `category`, domain range should be specified as index numbers.
+ * - Due to the limitations of floating point precision, domain value may not be exact returning approximately values.
* @function zoom
* @instance
* @memberof Chart
@@ -23553,62 +24005,70 @@ function withinRange(domain, current, range, isInverted) {
* // Zoom to specified domain range
* chart.zoom([10, 20]);
*
- * // For timeseries, the domain value can be string, but the format should match with the 'data.xFormat' option.
+ * // For timeseries x axis, the domain value can be string, but the format should match with the 'data.xFormat' option.
* chart.zoom(["2021-02-03", "2021-02-08"]);
*
+ * // For category x axis, the domain value should be index number.
+ * chart.zoom([0, 3]);
+ *
* // Get the current zoomed domain range
+ * // Domain value may not be exact returning approximately values.
* chart.zoom();
- */
-var zoom = function (domainValue) {
- var _this3 = this,
- $$ = this.internal,
+ */ // NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
+const zoom = function (domainValue) {
+ var _this = this,
+ _state$domain;
+ const $$ = this.internal,
$el = $$.$el,
axis = $$.axis,
config = $$.config,
org = $$.org,
scale = $$.scale,
+ state = $$.state,
isRotated = config.axis_rotated,
- isInverted = config.axis_x_inverted,
- isCategorized = axis.isCategorized(),
+ isCategorized = axis.isCategorized();
+ let domain;
+ if (config.zoom_enabled) {
domain = domainValue;
- if (config.zoom_enabled && domain) {
- if (axis.isTimeSeries()) {
- domain = domain.map(function (x) {
- _newArrowCheck(this, _this3);
- return parseDate.bind($$)(x);
- }.bind(this));
- }
- var isWithinRange = withinRange(domain, $$.getZoomDomain(!0), $$.getZoomDomain(), isInverted);
- if (isWithinRange) {
- if (isCategorized) {
- domain = domain.map(function (v, i) {
- _newArrowCheck(this, _this3);
- return +v + (i === 0 ? 0 : 1);
+ if (Array.isArray(domain)) {
+ if (axis.isTimeSeries()) {
+ domain = domain.map(function (x) {
+ _newArrowCheck(this, _this);
+ return parseDate.bind($$)(x);
}.bind(this));
}
+ const isWithinRange = $$.withinRange(domain, $$.getZoomDomain("zoom", !0), $$.getZoomDomain("zoom"));
+ if (isWithinRange) {
+ state.domain = domain;
+ if (isCategorized) {
+ domain = domain.map(function (v, i) {
+ _newArrowCheck(this, _this);
+ return +v + (i === 0 ? 0 : 1);
+ }.bind(this));
+ }
- // hide any possible tooltip show before the zoom
- $$.api.tooltip.hide();
- if (config.subchart_show) {
- var x = scale.zoom || scale.x;
- $$.brush.getSelection().call($$.brush.move, domain.map(x));
- // resultDomain = domain;
- } else {
- var _d3ZoomIdentity$scale,
- _x = isCategorized ? scale.x.orgScale() : org.xScale || scale.x,
- translate = [-_x(domain[0]), 0],
- transform = (_d3ZoomIdentity$scale = external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.scale(_x.range()[1] / (_x(domain[1]) - _x(domain[0])))).translate.apply(_d3ZoomIdentity$scale, isRotated ? translate.reverse() : translate); // in case of 'config.zoom_rescale=true', use org.xScale
- // Get transform from given domain value
- // https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
-
- $el.eventRect.call($$.zoom.transform, transform);
+ // hide any possible tooltip show before the zoom
+ $$.api.tooltip.hide();
+ if (config.subchart_show) {
+ const x = scale.zoom || scale.x;
+ $$.brush.getSelection().call($$.brush.move, domain.map(x));
+ // resultDomain = domain;
+ } else {
+ var _d3ZoomIdentity$scale;
+ // in case of 'config.zoom_rescale=true', use org.xScale
+ const x = isCategorized ? scale.x.orgScale() : org.xScale || scale.x,
+ translate = [-x(domain[0]), 0],
+ transform = (_d3ZoomIdentity$scale = external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.scale(x.range()[1] / (x(domain[1]) - x(domain[0])))).translate.apply(_d3ZoomIdentity$scale, isRotated ? translate.reverse() : translate); // Get transform from given domain value
+ // https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
+ $el.eventRect.call($$.zoom.transform, transform);
+ }
+ $$.setZoomResetButton();
}
- $$.setZoomResetButton();
+ } else {
+ domain = $$.zoom.getDomain();
}
- } else {
- domain = scale.zoom ? scale.zoom.domain() : scale.x.orgDomain();
}
- return domain;
+ return (_state$domain = state.domain) != null ? _state$domain : domain;
};
extend(zoom, {
/**
@@ -23630,7 +24090,7 @@ extend(zoom, {
* chart.zoom.enable(false);
*/
enable: function enable(enabled) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config;
if (/^(drag|wheel)$/.test(enabled)) {
config.zoom_type = enabled;
@@ -23656,7 +24116,7 @@ extend(zoom, {
* chart.zoom.max(20);
*/
max: function max(_max) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config,
xDomain = $$.org.xDomain;
if (_max === 0 || _max) {
@@ -23676,7 +24136,7 @@ extend(zoom, {
* chart.zoom.min(-1);
*/
min: function min(_min) {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config,
xDomain = $$.org.xDomain;
if (_min === 0 || _min) {
@@ -23702,9 +24162,9 @@ extend(zoom, {
* });
*/
range: function range(_range) {
- var zoom = this.zoom;
+ const zoom = this.zoom;
if (isObject(_range)) {
- var min = _range.min,
+ const min = _range.min,
max = _range.max;
isDefined(min) && zoom.min(min);
isDefined(max) && zoom.max(max);
@@ -23727,20 +24187,22 @@ extend(zoom, {
* chart.unzoom();
*/
unzoom: function unzoom() {
- var $$ = this.internal,
+ const $$ = this.internal,
config = $$.config,
_$$$$el = $$.$el,
eventRect = _$$$$el.eventRect,
- zoomResetBtn = _$$$$el.zoomResetBtn;
+ zoomResetBtn = _$$$$el.zoomResetBtn,
+ state = $$.state;
if ($$.scale.zoom) {
config.subchart_show ? $$.brush.getSelection().call($$.brush.move, null) : $$.zoom.updateTransformScale(external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
$$.updateZoom(!0);
- zoomResetBtn == null ? void 0 : zoomResetBtn.style("display", "none");
+ zoomResetBtn == null || zoomResetBtn.style("display", "none");
// reset transform
if ((0,external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomTransform)(eventRect.node()) !== external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity) {
$$.zoom.transform(eventRect, external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
}
+ state.domain = undefined;
}
}
});
@@ -23765,8 +24227,8 @@ extend(zoom, {
* @param {object} mouse Object
*/
drag: function drag(mouse) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
main = $$.$el.main,
@@ -23780,7 +24242,7 @@ extend(zoom, {
) {
return;
}
- var _ref = state.dragStart || [0, 0],
+ const _ref = state.dragStart || [0, 0],
sx = _ref[0],
sy = _ref[1],
mx = mouse[0],
@@ -23796,24 +24258,24 @@ extend(zoom, {
_newArrowCheck(this, _this);
return isSelectable == null ? void 0 : isSelectable.bind($$.api)(d);
}.bind(this)).each(function (d, i) {
- var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
+ const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
isSelected = shape.classed($SELECT.SELECTED),
isIncluded = shape.classed($DRAG.INCLUDED);
- var isWithin = !1,
+ let isWithin = !1,
toggle;
if (shape.classed($CIRCLE.circle)) {
- var x = +shape.attr("cx") * 1,
+ const x = +shape.attr("cx") * 1,
y = +shape.attr("cy") * 1;
toggle = $$.togglePoint;
isWithin = minX < x && x < maxX && minY < y && y < maxY;
} else if (shape.classed($BAR.bar)) {
- var _getPathBox = getPathBox(this),
- _x = _getPathBox.x,
+ const _getPathBox = getPathBox(this),
+ x = _getPathBox.x,
y = _getPathBox.y,
width = _getPathBox.width,
height = _getPathBox.height;
toggle = $$.togglePath;
- isWithin = !(maxX < _x || _x + width < minX) && !(maxY < y || y + height < minY);
+ isWithin = !(maxX < x || x + width < minX) && !(maxY < y || y + height < minY);
} else {
// line/area selection not supported yet
return;
@@ -23835,7 +24297,7 @@ extend(zoom, {
* @param {object} mouse Object
*/
dragstart: function dragstart(mouse) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
state = $$.state,
main = $$.$el.main;
@@ -23852,7 +24314,7 @@ extend(zoom, {
* @private
*/
dragend: function dragend() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
main = $$.$el.main,
$T = $$.$T;
@@ -23868,8 +24330,8 @@ extend(zoom, {
;// CONCATENATED MODULE: ./src/ChartInternal/internals/selection.ts
-function selection_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
-function selection_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? selection_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : selection_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+function selection_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
+function selection_objectSpread(e) { for (var r = 1, t; r < arguments.length; r++) { t = null != arguments[r] ? arguments[r] : {}; r % 2 ? selection_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : selection_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
@@ -23887,8 +24349,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
selectPoint: function selectPoint(target, d, i) {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
main = $$.$el.main,
$T = $$.$T,
@@ -23915,7 +24377,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
unselectPoint: function unselectPoint(target, d, i) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
main = $$.$el.main,
$T = $$.$T;
@@ -23933,7 +24395,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
togglePoint: function togglePoint(selected, target, d, i) {
- var method = (selected ? "" : "un") + "selectPoint";
+ const method = (selected ? "" : "un") + "selectPoint";
this[method](target, d, i);
},
/**
@@ -23943,7 +24405,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
selectPath: function selectPath(target, d) {
- var $$ = this,
+ const $$ = this,
config = $$.config;
callFn(config.data_onselected, $$.api, d, target.node());
if (config.interaction_brighten) {
@@ -23957,7 +24419,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @param {object} d Data object
*/
unselectPath: function unselectPath(target, d) {
- var $$ = this,
+ const $$ = this,
config = $$.config;
callFn(config.data_onunselected, $$.api, d, target.node());
if (config.interaction_brighten) {
@@ -23983,8 +24445,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
getToggle: function getToggle(that, d) {
- var _this2 = this,
- $$ = this;
+ var _this2 = this;
+ const $$ = this;
return that.nodeName === "path" ? $$.togglePath : $$.isStepType(d) ? function () {
_newArrowCheck(this, _this2);
}.bind(this) :
@@ -23999,22 +24461,22 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
toggleShape: function toggleShape(that, d, i) {
- var $$ = this,
+ const $$ = this,
config = $$.config,
main = $$.$el.main;
if (config.data_selection_enabled && config.data_selection_isselectable.bind($$.api)(d)) {
- var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
+ const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
isSelected = shape.classed($SELECT.SELECTED),
toggle = $$.getToggle(that, d).bind($$);
- var toggledShape;
+ let toggledShape;
if (!config.data_selection_multiple) {
- var focusOnly = config.point_focus_only;
- var selector = "." + (focusOnly ? $SELECT.selectedCircles : $SHAPE.shapes);
+ const focusOnly = $$.isPointFocusOnly == null ? void 0 : $$.isPointFocusOnly();
+ let selector = "." + (focusOnly ? $SELECT.selectedCircles : $SHAPE.shapes);
if (config.data_selection_grouped) {
selector += $$.getTargetSelectorSuffix(d.id);
}
main.selectAll(selector).selectAll(focusOnly ? "." + $SELECT.selectedCircle : "." + $SHAPE.shape + "." + $SELECT.SELECTED).classed($SELECT.SELECTED, !1).each(function (d) {
- var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
+ const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
toggledShape = shape;
toggle(!1, shape, d, d.index);
});
@@ -24042,42 +24504,44 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
initBrush: function initBrush() {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
scale = $$.scale,
subchart = $$.$el.subchart,
+ state = $$.state,
isRotated = config.axis_rotated,
- lastDomain,
- timeout;
+ height = config.subchart_size_height;
+ let lastDomain, lastSelection, timeout;
// set the brush
$$.brush = (isRotated ? (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushY)() : (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushX)()).handleSize(5);
- var getBrushSize = function () {
- _newArrowCheck(this, _this);
- var brush = $$.$el.svg.select("." + classes.brush + " .overlay"),
- brushSize = {
- width: 0,
- height: 0
- };
- if (brush.size()) {
- brushSize.width = +brush.attr("width");
- brushSize.height = +brush.attr("height");
- }
- return brushSize[isRotated ? "width" : "height"];
- }.bind(this);
// bind brush event
$$.brush.on("start brush end", function (event) {
var _this2 = this;
_newArrowCheck(this, _this);
- var selection = event.selection,
+ const selection = event.selection,
+ sourceEvent = event.sourceEvent,
target = event.target,
type = event.type;
if (type === "start") {
$$.state.inputType === "touch" && $$.hideTooltip();
+ lastSelection = sourceEvent ? selection : null;
+ // sourceEvent && (state.domain = null);
}
+
+ // if (type === "brush") {
if (/(start|brush)/.test(type)) {
- $$.redrawForBrush();
+ var _lastSelection;
+ // when brush selection updates happens on one edge, update only chainging edge and
+ // is only for adjustment of given domain range to be used to return current domain range.
+ type === "brush" && sourceEvent && state.domain && ((_lastSelection = lastSelection) == null ? void 0 : _lastSelection.forEach(function (v, i) {
+ _newArrowCheck(this, _this2);
+ if (v !== selection[i]) {
+ state.domain[i] = scale.x.orgDomain()[i];
+ }
+ }.bind(this)));
+ $$.redrawForBrush(type !== "start");
}
if (type === "end") {
lastDomain = scale.x.orgDomain();
@@ -24090,8 +24554,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
} else {
$$.brush.handle.attr("display", null).attr("transform", function (d, i) {
_newArrowCheck(this, _this2);
- var pos = isRotated ? [33, selection[i] - (i === 0 ? 30 : 24)] : [selection[i], 3];
- return "translate(" + pos + ")";
+ const pos = [selection[i], height / 2];
+ return "translate(" + (isRotated ? pos.reverse() : pos) + ")";
}.bind(this));
}
}
@@ -24101,28 +24565,28 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
timeout && clearTimeout(timeout);
timeout = setTimeout(function () {
_newArrowCheck(this, _this3);
- var selection = this.getSelection();
+ const selection = this.getSelection();
lastDomain && (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection.node()) && this.move(selection, lastDomain.map(scale.subX.orgScale()));
}.bind(this), 0);
};
$$.brush.update = function () {
- var _this4 = this,
- extent = this.extent()();
+ var _this4 = this;
+ const extent = this.extent()();
if (extent[1].filter(function (v) {
_newArrowCheck(this, _this4);
return isNaN(v);
}.bind(this)).length === 0) {
var _subchart$main;
- (_subchart$main = subchart.main) == null ? void 0 : _subchart$main.select("." + classes.brush).call(this);
+ (_subchart$main = subchart.main) == null || _subchart$main.select("." + classes.brush).call(this);
}
return this;
};
// set the brush extent
$$.brush.scale = function (scale) {
- var _this5 = this,
- h = config.subchart_size_height || getBrushSize(),
- extent = $$.getExtent();
+ var _this5 = this;
+ const h = config.subchart_size_height;
+ let extent = $$.getExtent();
if (!extent && scale.range) {
extent = [[0, 0], [scale.range()[1], h]];
} else if (isArray(extent)) {
@@ -24153,8 +24617,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
initSubchart: function initSubchart() {
- var _this6 = this,
- $$ = this,
+ var _this6 = this;
+ const $$ = this,
config = $$.config,
_$$$state = $$.state,
clip = _$$$state.clip,
@@ -24167,14 +24631,14 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
if (!hasAxis) {
return;
}
- var visibility = config.subchart_show ? null : "hidden",
+ const visibility = config.subchart_show ? null : "hidden",
clipId = clip.id + "-subchart",
clipPath = $$.getClipPath(clipId);
clip.idSubchart = clipId;
$$.appendClip(defs, clipId);
$$.initBrush();
subchart.main = svg.append("g").classed(classes.subchart, !0).attr("transform", $$.getTranslate("context"));
- var main = subchart.main;
+ const main = subchart.main;
main.style("visibility", visibility);
// Define g for chart area
@@ -24183,9 +24647,9 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
// Define g for chart types area
["bar", "line", "bubble", "candlestick", "scatter"].forEach(function (v) {
_newArrowCheck(this, _this6);
- var type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
+ const type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
if ($$.hasType(v) || $$.hasTypeOf(type)) {
- var chart = main.select("." + classes.chart),
+ const chart = main.select("." + classes.chart),
chartClassName = classes["chart" + type + "s"];
if (chart.select("." + chartClassName).empty()) {
chart.append("g").attr("class", chartClassName);
@@ -24194,7 +24658,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
}.bind(this));
// Add extent rect for Brush
- var brush = main.append("g").attr("clip-path", clipPath).attr("class", classes.brush).call($$.brush);
+ const brush = main.append("g").attr("clip-path", clipPath).attr("class", classes.brush).call($$.brush);
config.subchart_showHandle && $$.addBrushHandle(brush);
// ATTENTION: This must be called AFTER chart added
@@ -24208,12 +24672,13 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
addBrushHandle: function addBrushHandle(brush) {
- var _this7 = this,
- $$ = this,
+ var _this7 = this;
+ const $$ = this,
config = $$.config,
isRotated = config.axis_rotated,
initRange = config.subchart_init_range,
- path = isRotated ? ["M 5.2491724,29.749209 a 6,6 0 0 0 -5.50000003,-6.5 H -5.7508276 a 6,6 0 0 0 -6.0000004,6.5 z m -5.00000003,-2 H -6.7508276 m 6.99999997,-2 H -6.7508276Z", "M 5.2491724,23.249172 a 6,-6 0 0 1 -5.50000003,6.5 H -5.7508276 a 6,-6 0 0 1 -6.0000004,-6.5 z m -5.00000003,2 H -6.7508276 m 6.99999997,2 H -6.7508276Z"] : ["M 0 18 A 6 6 0 0 0 -6.5 23.5 V 29 A 6 6 0 0 0 0 35 Z M -2 23 V 30 M -4 23 V 30Z", "M 0 18 A 6 6 0 0 1 6.5 23.5 V 29 A 6 6 0 0 1 0 35 Z M 2 23 V 30 M 4 23 V 30Z"];
+ path = isRotated ? ["M8.5 0 a6 6 0 0 0 -6 -6.5 H-2.5 a 6 6 0 0 0 -6 6.5 z m-5 -2 H-3.5 m7 -2 H-3.5z", "M8.5 0 a6 -6 0 0 1 -6 6.5 H-2.5 a 6 -6 0 0 1 -6 -6.5z m-5 2 H-3.5 m7 2 H-3.5z"] : ["M0 -8.5 A6 6 0 0 0 -6.5 -3.5 V2.5 A6 6 0 0 0 0 8.5 Z M-2 -3.5 V3.5 M-4 -3.5 V3.5z", "M0 -8.5 A6 6 0 0 1 6.5 -3.5 V2.5 A6 6 0 0 1 0 8.5 Z M2 -3.5 V3.5 M4 -3.5 V3.5z"];
+
// brush handle shape's path
$$.brush.handle = brush.selectAll(".handle--custom").data(isRotated ? [{
@@ -24235,8 +24700,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
updateTargetsForSubchart: function updateTargetsForSubchart(targets) {
- var _this8 = this,
- $$ = this,
+ var _this8 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
main = $$.$el.subchart.main;
@@ -24246,17 +24711,17 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
return $$.hasType(v) || $$.hasTypeOf(capitalize(v));
}.bind(this)).forEach(function (v) {
_newArrowCheck(this, _this8);
- var isPointType = /^(bubble|scatter)$/.test(v),
+ const isPointType = /^(bubble|scatter)$/.test(v),
name = capitalize(isPointType ? "circle" : v),
chartClass = $$.getChartClass(name, !0),
shapeClass = $$.getClass(isPointType ? "circles" : v + "s", !0),
shapeChart = main.select("." + classes["chart" + (name + "s")]);
if (isPointType) {
- var circle = shapeChart.selectAll("." + classes.circles).data(targets.filter($$["is" + capitalize(v) + "Type"].bind($$))).attr("class", shapeClass);
+ const circle = shapeChart.selectAll("." + classes.circles).data(targets.filter($$["is" + capitalize(v) + "Type"].bind($$))).attr("class", shapeClass);
circle.exit().remove();
circle.enter().append("g").attr("class", shapeClass);
} else {
- var shapeUpdate = shapeChart.selectAll("." + classes["chart" + name]).attr("class", chartClass).data(targets.filter($$["is" + name + "Type"].bind($$))),
+ const shapeUpdate = shapeChart.selectAll("." + classes["chart" + name]).attr("class", chartClass).data(targets.filter($$["is" + name + "Type"].bind($$))),
shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
shapeUpdate.exit().remove();
@@ -24277,8 +24742,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @param {object} shape Shape's info
*/
redrawSubchart: function redrawSubchart(withSubchart, duration, shape) {
- var _this9 = this,
- $$ = this,
+ var _this9 = this;
+ const $$ = this,
config = $$.config,
main = $$.$el.subchart.main,
state = $$.state,
@@ -24295,38 +24760,47 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
// update subchart elements if needed
if (withSubchart) {
- var initRange = config.subchart_init_range;
+ const initRange = config.subchart_init_range;
// extent rect
brushEmpty($$) || $$.brush.update();
Object.keys(shape.type).forEach(function (v) {
_newArrowCheck(this, _this9);
- var name = capitalize(v),
+ const name = capitalize(v),
drawFn = $$["generateDraw" + name](shape.indices[v], !0);
// call shape's update & redraw method
$$["update" + name](withTransition, !0);
$$["redraw" + name](drawFn, withTransition, !0);
}.bind(this));
if ($$.hasType("bubble") || $$.hasType("scatter")) {
- var cx = shape.pos.cx,
+ const cx = shape.pos.cx,
cy = $$.updateCircleY(!0);
$$.updateCircle(!0);
$$.redrawCircle(cx, cy, withTransition, undefined, !0);
}
- !state.rendered && initRange && $$.brush.move($$.brush.getSelection(), initRange.map($$.scale.x));
+ if (!state.rendered && initRange) {
+ state.domain = initRange;
+ $$.brush.move($$.brush.getSelection(), initRange.map($$.scale.x));
+ }
}
}
},
/**
* Redraw the brush.
+ * @param {boolean} [callCallbck=true] Call 'onbrush' callback or not.
* @private
*/
- redrawForBrush: function redrawForBrush() {
- var $$ = this,
+ redrawForBrush: function redrawForBrush(callCallbck) {
+ var _state$domain;
+ if (callCallbck === void 0) {
+ callCallbck = !0;
+ }
+ const $$ = this,
_$$$config = $$.config,
onBrush = _$$$config.subchart_onbrush,
withY = _$$$config.zoom_rescale,
- scale = $$.scale;
+ scale = $$.scale,
+ state = $$.state;
$$.redraw({
withTransition: !1,
withY: withY,
@@ -24334,7 +24808,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
withUpdateXDomain: !0,
withDimension: !1
});
- onBrush.bind($$.api)(scale.x.orgDomain());
+ callCallbck && state.rendered && onBrush.bind($$.api)((_state$domain = state.domain) != null ? _state$domain : scale.x.orgDomain());
},
/**
* Transform context
@@ -24343,7 +24817,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
transformContext: function transformContext(withTransition, transitions) {
- var $$ = this,
+ const $$ = this,
subchart = $$.$el.subchart,
$T = $$.$T,
subXAxis = transitions != null && transitions.axisSubX ? transitions.axisSubX : $T(subchart.main.select("." + classes.axisX), withTransition);
@@ -24356,16 +24830,16 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
getExtent: function getExtent() {
- var _this10 = this,
- $$ = this,
+ var _this10 = this;
+ const $$ = this,
config = $$.config,
- scale = $$.scale,
- extent = config.axis_x_extent;
+ scale = $$.scale;
+ let extent = config.axis_x_extent;
if (extent) {
if (isFunction(extent)) {
extent = extent.bind($$.api)($$.getXDomain($$.data.targets), scale.subX);
} else if ($$.axis.isTimeSeries() && extent.every(isNaN)) {
- var fn = parseDate.bind($$);
+ const fn = parseDate.bind($$);
extent = extent.map(function (v) {
_newArrowCheck(this, _this10);
return scale.subX(fn(v));
@@ -24391,7 +24865,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
initZoom: function initZoom() {
- var $$ = this;
+ const $$ = this;
$$.scale.zoom = null;
$$.generateZoom();
$$.initZoomBehaviour();
@@ -24405,7 +24879,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
if (bind === void 0) {
bind = !0;
}
- var $$ = this,
+ const $$ = this,
config = $$.config,
zoomEnabled = config.zoom_enabled;
if (zoomEnabled && bind) {
@@ -24421,8 +24895,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
generateZoom: function generateZoom() {
- var _this = this,
- $$ = this,
+ var _this = this;
+ const $$ = this,
config = $$.config,
org = $$.org,
scale = $$.scale,
@@ -24431,13 +24905,13 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
// @ts-ignore
zoom.orgScaleExtent = function () {
_newArrowCheck(this, _this);
- var extent = config.zoom_extent || [1, 10];
+ const extent = config.zoom_extent || [1, 10];
return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
}.bind(this);
// @ts-ignore
zoom.updateScaleExtent = function () {
- var ratio = diffDomain($$.scale.x.orgDomain()) / diffDomain($$.getZoomDomain()),
+ const ratio = diffDomain($$.scale.x.orgDomain()) / diffDomain($$.getZoomDomain()),
extent = this.orgScaleExtent();
this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
return this;
@@ -24453,13 +24927,13 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
zoom.updateTransformScale = function (transform, correctTransform) {
var _org$xScale;
_newArrowCheck(this, _this);
- var isRotated = config.axis_rotated;
+ const isRotated = config.axis_rotated;
// in case of resize, update range of orgXScale
- (_org$xScale = org.xScale) == null ? void 0 : _org$xScale.range(scale.x.range());
+ (_org$xScale = org.xScale) == null || _org$xScale.range(scale.x.range());
// rescale from the original scale
- var newScale = transform[isRotated ? "rescaleY" : "rescaleX"](org.xScale || scale.x),
+ const newScale = transform[isRotated ? "rescaleY" : "rescaleX"](org.xScale || scale.x),
domain = $$.trimXDomain(newScale.domain()),
rescale = config.zoom_rescale;
newScale.domain(domain, org.xDomain);
@@ -24467,7 +24941,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
// prevent chart from panning off the edge and feeling "stuck"
// https://github.com/naver/billboard.js/issues/2588
if (correctTransform) {
- var t = newScale(scale.x.domain()[0]),
+ const t = newScale(scale.x.domain()[0]),
tX = isRotated ? transform.x : t,
tY = isRotated ? t : transform.y;
$$.$el.eventRect.property("__zoom", external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.translate(tX, tY).scale(transform.k));
@@ -24492,7 +24966,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
// @ts-ignore
zoom.getDomain = function () {
_newArrowCheck(this, _this);
- var domain = scale[scale.zoom ? "zoom" : "subX"].domain(),
+ const domain = scale[scale.zoom ? "zoom" : "subX"].domain(),
isCategorized = $$.axis.isCategorized();
if (isCategorized) {
domain[1] -= 2;
@@ -24507,7 +24981,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
onZoomStart: function onZoomStart(event) {
- var $$ = this,
+ const $$ = this,
sourceEvent = event.sourceEvent;
if (sourceEvent) {
$$.zoom.startEvent = sourceEvent;
@@ -24522,7 +24996,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
*/
onZoom: function onZoom(event) {
var _this2 = this,
- $$ = this,
+ _$$$state$domain;
+ const $$ = this,
config = $$.config,
scale = $$.scale,
state = $$.state,
@@ -24534,8 +25009,9 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
}
if (event.sourceEvent) {
state.zooming = !0;
+ state.domain = undefined;
}
- var isMousemove = (sourceEvent == null ? void 0 : sourceEvent.type) === "mousemove",
+ const isMousemove = (sourceEvent == null ? void 0 : sourceEvent.type) === "mousemove",
isZoomOut = (sourceEvent == null ? void 0 : sourceEvent.wheelDelta) < 0,
transform = event.transform;
if (!isMousemove && isZoomOut && scale.x.domain().every(function (v, i) {
@@ -24549,7 +25025,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
// do zoom transiton when:
// - zoom type 'drag'
// - when .unzoom() is called (event.transform === d3ZoomIdentity)
- var doTransition = config.transition_duration > 0 && !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
+ const doTransition = config.transition_duration > 0 && !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
$$.redraw({
withTransition: doTransition,
withY: config.zoom_rescale,
@@ -24560,7 +25036,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
$$.state.cancelClick = isMousemove;
// do not call event cb when is .unzoom() is called
- isUnZoom || callFn(config.zoom_onzoom, $$.api, $$.zoom.getDomain());
+ isUnZoom || callFn(config.zoom_onzoom, $$.api, (_$$$state$domain = $$.state.domain) != null ? _$$$state$domain : $$.zoom.getDomain());
},
/**
* 'end' event listener
@@ -24568,17 +25044,17 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
onZoomEnd: function onZoomEnd(event) {
- var _startEvent,
- $$ = this,
+ var _startEvent, _$$$state$domain2;
+ const $$ = this,
config = $$.config,
- state = $$.state,
- startEvent = $$.zoom.startEvent,
- e = event == null ? void 0 : event.sourceEvent,
- isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
+ state = $$.state;
+ let startEvent = $$.zoom.startEvent,
+ e = event == null ? void 0 : event.sourceEvent;
+ const isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
if (((_startEvent = startEvent) == null ? void 0 : _startEvent.type.indexOf("touch")) > -1) {
- var _e, _e$changedTouches;
+ var _e;
startEvent = startEvent.changedTouches[0];
- e = (_e = e) == null ? void 0 : (_e$changedTouches = _e.changedTouches) == null ? void 0 : _e$changedTouches[0];
+ e = (_e = e) == null || (_e = _e.changedTouches) == null ? void 0 : _e[0];
}
// if click, do nothing. otherwise, click interaction will be canceled.
@@ -24590,7 +25066,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
state.zooming = !1;
// do not call event cb when is .unzoom() is called
- !isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, $$.zoom.getDomain());
+ !isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, (_$$$state$domain2 = $$.state.domain) != null ? _$$$state$domain2 : $$.zoom.getDomain());
},
/**
* Update zoom
@@ -24598,13 +25074,13 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
updateZoom: function updateZoom(force) {
- var $$ = this,
+ const $$ = this,
_$$$scale = $$.scale,
subX = _$$$scale.subX,
x = _$$$scale.x,
zoom = _$$$scale.zoom;
if (zoom) {
- var zoomDomain = zoom.domain(),
+ const zoomDomain = zoom.domain(),
xDomain = subX.domain(),
delta = .015,
isfullyShown = $$.config.axis_x_inverted ? (zoomDomain[0] >= xDomain[0] || zoomDomain[0] + delta >= xDomain[0]) && (xDomain[1] >= zoomDomain[1] || xDomain[1] >= zoomDomain[1] + delta) : (zoomDomain[0] <= xDomain[0] || zoomDomain[0] - delta <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= zoomDomain[1] - delta); // arbitrary value
@@ -24621,8 +25097,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
* @private
*/
bindZoomOnEventRect: function bindZoomOnEventRect() {
- var _this3 = this,
- $$ = this,
+ var _this3 = this;
+ const $$ = this,
config = $$.config,
eventRect = $$.$el.eventRect,
behaviour = config.zoom_type === "drag" ? $$.zoomBehaviour : $$.zoom;
@@ -24631,26 +25107,26 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
$$.$el.svg.on("wheel", function () {
_newArrowCheck(this, _this3);
}.bind(this));
- eventRect.call(behaviour).on("dblclick.zoom", null);
+ eventRect == null || eventRect.call(behaviour).on("dblclick.zoom", null);
},
/**
* Initialize the drag behaviour used for zooming.
* @private
*/
initZoomBehaviour: function initZoomBehaviour() {
- var _this4 = this,
- $$ = this,
+ var _this4 = this;
+ const $$ = this,
config = $$.config,
state = $$.state,
- isRotated = config.axis_rotated,
- start = 0,
+ isRotated = config.axis_rotated;
+ let start = 0,
end = 0,
- zoomRect,
- prop = {
- axis: isRotated ? "y" : "x",
- attr: isRotated ? "height" : "width",
- index: isRotated ? 1 : 0
- };
+ zoomRect;
+ const prop = {
+ axis: isRotated ? "y" : "x",
+ attr: isRotated ? "height" : "width",
+ index: isRotated ? 1 : 0
+ };
$$.zoomBehaviour = (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().clickDistance(4).on("start", function (event) {
state.event = event;
$$.setDragStatus(!0);
@@ -24668,7 +25144,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
}).on("end", function (event) {
var _this5 = this;
_newArrowCheck(this, _this4);
- var scale = $$.scale.zoom || $$.scale.x;
+ const scale = $$.scale.zoom || $$.scale.x;
state.event = event;
zoomRect.attr(prop.axis, 0).attr(prop.attr, 0);
if (start > end) {
@@ -24690,7 +25166,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
}.bind(this));
},
setZoomResetButton: function setZoomResetButton() {
- var $$ = this,
+ const $$ = this,
config = $$.config,
$el = $$.$el,
resetButton = config.zoom_resetButton;
@@ -25037,7 +25513,7 @@ var interaction_this = undefined;
-var _selectionModule = function selectionModule() {
+let _selectionModule = function selectionModule() {
var _this2 = this;
_newArrowCheck(this, interaction_this);
extend(ChartInternal.prototype, internals_selection);
@@ -25052,7 +25528,7 @@ var _selectionModule = function selectionModule() {
var _this3 = this;
_newArrowCheck(this, interaction_this);
extend(ChartInternal.prototype, interactions_subchart);
- extend(Chart.prototype, subchart);
+ extend(Chart.prototype, api_subchart);
Options.setOptions([interaction_subchart]);
return (subchartModule = function () {
_newArrowCheck(this, _this3);
@@ -25080,13 +25556,13 @@ var _selectionModule = function selectionModule() {
// eslint-disable-next-line no-use-before-define
-var _defaults = {};
+let _defaults = {};
/**
* @namespace bb
- * @version 3.9.0
+ * @version 3.10.3
*/
-var bb = {
+const bb = {
/**
* Version information
* @property {string} version version
@@ -25094,7 +25570,7 @@ var bb = {
* bb.version; // "1.0.0"
* @memberof bb
*/
- version: "3.9.0",
+ version: "3.10.3",
/**
* Generate chart
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
@@ -25166,7 +25642,7 @@ var bb = {
* });
*/
generate: function generate(config) {
- var options = mergeObj({}, _defaults, config),
+ const options = mergeObj({}, _defaults, config),
inst = new Chart(options);
inst.internal.charts = this.instance;
this.instance.push(inst);