@carbon/charts-react 1.27.8 → 1.27.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
<svg xmlns="http://www.w3.org/2000/svg" class="arrow-right" width="32" height="32" viewBox="0 0 32 32">
|
|
64
64
|
<polygon points="18 6 16.57 7.393 24.15 15 4 15 4 17 24.15 17 16.57 24.573 18 26 28 16 18 6"/>
|
|
65
65
|
<rect width="32" height="32"/>
|
|
66
|
-
</svg>`}destroy(){this.parent.selectAll("path.line,.node-group").on("mouseover",null).on("mousemove",null).on("click",null).on("mouseout",null)}}class we extends gt{constructor(){super(...arguments),this.type="grid",this.renderType=rt.SVG}render(t=!0){const n=y(this.getOptions(),"grid","x","enabled"),r=y(this.getOptions(),"grid","y","enabled");this.drawBackdrop(n,r),!(!n&&!r)&&(n&&(N.appendOrSelect(this.backdrop,"g.x.grid"),this.drawXGrid(t)),r&&(N.appendOrSelect(this.backdrop,"g.y.grid"),this.drawYGrid(t)))}drawXGrid(t){const n=this.parent,r=this.backdrop.attr("height"),i=this.services.cartesianScales.getMainXScale(),s=gc(i).tickSizeInner(-r).tickSizeOuter(0);if(y(this.getOptions(),"grid","x","alignWithAxisTicks")){const o=this.services.cartesianScales.getDomainAxisPosition(),l=y(this.getOptions(),"axes",o,"ticks","values");l&&s.tickValues(l)}else{const o=y(this.getOptions(),"grid","x","numberOfTicks");s.ticks(o)}const a=n.select(".x.grid").attr("transform",`translate(${-this.backdrop.attr("x")}, ${r})`);t?a.transition().call(o=>this.services.transitions.setupTransition({transition:o,name:"grid-update",animate:t})).call(s):a.call(s),this.cleanGrid(a)}drawYGrid(t){const n=this.parent,r=this.backdrop.attr("width"),i=this.services.cartesianScales.getMainYScale(),s=im(i).tickSizeInner(-r).tickSizeOuter(0);if(y(this.getOptions(),"grid","y","alignWithAxisTicks")){const o=this.services.cartesianScales.getRangeAxisPosition(),l=y(this.getOptions(),"axes",o,"ticks","values");l&&s.tickValues(l)}else{const o=y(this.getOptions(),"grid","y","numberOfTicks");s.ticks(o)}const a=n.select(".y.grid").attr("transform",`translate(0, ${-this.backdrop.attr("y")})`);t?a.transition().call(o=>this.services.transitions.setupTransition({transition:o,name:"grid-update",animate:t})).call(s):a.call(s),this.cleanGrid(a)}getGridlineThreshold(t){const n=this.parent,r=n.selectAll(".x.grid .tick").nodes().sort((u,d)=>Number(xn(u).tx)-Number(xn(d).tx));let i=-1;if(!r.length)return;r.forEach(u=>{t[0]>=+xn(u).tx&&i++});const s=i+1<r.length?i+1:r.length,a=r[i],o=r[s];let l;if(!a)l=+xn(o).tx;else if(o)l=+xn(o).tx-+xn(a).tx;else{const u=n.select("rect.chart-grid-backdrop").node();l=N.getSVGElementSize(u).width-+xn(a).tx}const{threshold:c}=this.getOptions().tooltip.gridline;return l*c}getActiveGridline(t){const n=y(this.getOptions,"tooltip","gridline","threshold"),r=n||this.getGridlineThreshold(t);return this.parent.selectAll(".x.grid .tick").filter(function(){const i=xn(this),s={min:Number(i.tx)-r,max:Number(i.tx)+r};return s.min<=t[0]&&t[0]<=s.max})}drawBackdrop(t,n){const r=this.parent,i=this.services.cartesianScales.getMainXScale(),s=this.services.cartesianScales.getMainYScale(),[a,o]=i.range(),[l,c]=s.range();this.backdrop=N.appendOrSelect(r,"svg.chart-grid-backdrop").attr("role","presentation");const u=N.appendOrSelect(this.backdrop,t||n?"rect.chart-grid-backdrop.stroked":"rect.chart-grid-backdrop");this.backdrop.merge(u).attr("x",a).attr("y",c).attr("width",Math.abs(o-a)).attr("height",Math.abs(l-c)).lower(),u.attr("width","100%").attr("height","100%")}cleanGrid(t){t.selectAll("text").remove(),t.select(".domain").remove()}}class Hg extends gt{constructor(){super(...arguments),this.type="area",this.renderType=rt.SVG,this.gradient_id="gradient-id-"+Math.floor(Math.random()*99999999999),this.handleLegendOnHover=t=>{const{hoveredElement:n}=t.detail;this.parent.selectAll("path.area").transition("legend-hover-area").call(r=>this.services.transitions.setupTransition({transition:r,name:"legend-hover-area"})).attr("opacity",r=>r.name!==n.datum().name?yn.opacity.unselected:yn.opacity.selected)},this.handleLegendMouseOut=()=>{this.parent.selectAll("path.area").transition("legend-mouseout-area").call(t=>this.services.transitions.setupTransition({transition:t,name:"legend-mouseout-area"})).attr("opacity",yn.opacity.selected)}}init(){const t=this.services.events;t.addEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.addEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut)}render(t=!0){const n=this.getComponentContainer({ariaLabel:"area graphs",withinChartClip:!0}),r=this.getOptions();let i=[0,0];const{cartesianScales:s}=this.services,a=s.getOrientation(),o=nu().curve(this.services.curves.getD3Curve()).defined(b=>{const S=s.getRangeIdentifier();return b[S]!=null}),l=this.model.getGroupedData(this.configs.groups),c=y(r,"bounds"),u=c&&l&&l.length===1;!u&&c&&console.warn(`Bounds can only be shown when having 1 single datagroup, you've supplied ${l.length}`);let d=0;const h=(b,S)=>{y(r,"axes",b,"includeZero")===!1&&S[0]>0&&S[1]>0&&(d=S[0])},p=b=>u?s.getBoundedScaledValues(b)[0]:s.getRangeValue(d),f=b=>u?s.getBoundedScaledValues(b)[1]:s.getRangeValue(b);a===Ft.VERTICAL?(i=s.getMainYScale().domain(),h(s.getMainYAxisPosition(),i),o.x(b=>s.getDomainValue(b)).y0(b=>p(b)).y1(b=>f(b))):(i=s.getMainXScale().domain(),h(s.getMainXAxisPosition(),i),o.x0(b=>p(b)).x1(b=>f(b)).y(b=>s.getDomainValue(b)));const g=y(r,"color","gradient","enabled"),m=l&&l.length===1&&g;l.length>1&&g&&console.error("Gradients can only be enabled when having 1 single dataset");const v=n.selectAll("path.area").data(l,b=>b.name),x=I(this.services.domUtils.getMainContainer());if(v.exit().attr("opacity",0).remove(),!l.length)return;if(m){const b=x.select(`path.${this.model.getColorClassName({classNameTypes:[st.STROKE],dataGroupName:l[0].name})}`).node();let S;if(b)S=getComputedStyle(b,null).getPropertyValue("stroke");else{const M=y(this.model.getOptions(),"color","scale");if(M!==null){const k=Object.keys(M);S=M[k[0]]}}fc.appendOrUpdateLinearGradient({svg:this.parent,id:this.services.domUtils.generateElementIDString(`${l[0].name.replace(" ","")}_${this.gradient_id}`),x1:"0%",x2:"0%",y1:"0%",y2:"100%",stops:fc.getStops(i,S)})}else this.parent.selectAll("defs linearGradient").empty()||this.parent.selectAll("defs linearGradient").each(function(){this.parentNode.remove()});const _=this,E=v.enter().append("path");m?E.merge(v).style("fill",b=>`url(#${this.services.domUtils.generateElementIDString(`${b.name.replace(" ","")}_${this.gradient_id}`)})`).attr("class","area").attr("class",b=>this.model.getColorClassName({classNameTypes:[st.FILL],dataGroupName:b.name,originalClassName:"area"})).attr("d",b=>{const{data:S}=b;return o(S)}):(E.attr("opacity",0).merge(v).attr("class","area").attr("class",b=>this.model.getColorClassName({classNameTypes:[st.FILL,st.STROKE],dataGroupName:b.name,originalClassName:"area"})).style("fill",b=>_.model.getFillColor(b.name,null,b.data)).transition().call(b=>this.services.transitions.setupTransition({transition:b,name:"area-update-enter",animate:t})).attr("opacity",u?1:yn.opacity.selected).attr("d",b=>{const{data:S}=b;return o(S)}),u&&E.attr("fill-opacity",yn.opacity.selected).style("stroke",b=>_.model.getStrokeColor(b.name,null,b.data)).style("stroke-dasharray","2, 2").attr("stroke-width",.7+"px"))}destroy(){const t=this.services.events;t.removeEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.removeEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut)}}class li extends gt{constructor(){super(...arguments),this.type="line",this.renderType=rt.SVG,this.handleLegendOnHover=t=>{const{hoveredElement:n}=t.detail;this.parent.selectAll("path.line").transition("legend-hover-line").call(r=>this.services.transitions.setupTransition({transition:r,name:"legend-hover-line"})).attr("opacity",r=>r.name!==n.datum().name?bn.opacity.unselected:bn.opacity.selected)},this.handleLegendMouseOut=()=>{this.parent.selectAll("path.line").transition("legend-mouseout-line").call(t=>this.services.transitions.setupTransition({transition:t,name:"legend-mouseout-line"})).attr("opacity",bn.opacity.selected)}}init(){const{events:t}=this.services;t.addEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.addEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut)}render(t=!0){const n=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,r=this.model.get("zoomDomain")!==void 0,i=n&&r?this.getComponentContainer({ariaLabel:"lines",withinChartClip:!1}):this.getComponentContainer({ariaLabel:"lines",withinChartClip:!0}),{cartesianScales:s,curves:a}=this.services,o=m=>s.getDomainValue(m),l=m=>s.getRangeValue(m),[c,u]=_n(o,l,s.getOrientation()),d=this.getOptions(),h=ys().x(c).y(u).curve(a.getD3Curve()).defined(m=>{const v=s.getRangeIdentifier(m);return m[v]!=null});let p=[];if(this.configs.stacked){const m=Object.keys(d.axes).some(x=>d.axes[x].percentage),{groupMapsTo:v}=d.data;p=this.model.getStackedData({groups:this.configs.groups,percentage:m}).map(x=>{const _=this.services.cartesianScales.getDomainIdentifier(x),E=this.services.cartesianScales.getRangeIdentifier(x);return{name:y(x,0,v),data:x.map(b=>({[_]:b.data.sharedStackKey,[v]:b[v],[E]:b[1]})),hidden:!wC(x,b=>b[0]!==b[1])}})}else p=this.model.getGroupedData(this.configs.groups);const f=i.selectAll("path.line").data(p,m=>m.name);f.exit().attr("opacity",0).remove();const g=f.enter().append("path").classed("line",!0).attr("opacity",0).merge(f).data(p,m=>m.name).attr("class",m=>this.model.getColorClassName({classNameTypes:[st.STROKE],dataGroupName:m.name,originalClassName:"line"})).style("stroke",m=>this.model.getStrokeColor(m.name,null,m.data)).attr("role",dt.GRAPHICS_SYMBOL).attr("aria-roledescription","line").attr("aria-label",m=>{const{data:v}=m;return v.map(x=>{const _=this.services.cartesianScales.getRangeIdentifier(x);return x[_]}).join(",")});if(n&&r){const m=s.getMainXScale(),v=s.getMainYScale();if(m&&v){const[x,_]=m.range(),[E,b]=v.range();i.style("overflow","hidden").style("clip",`rect(${b}px, ${_}px, ${E}px, ${x}px)`)}}g.transition().call(m=>this.services.transitions.setupTransition({transition:m,name:"line-update-enter",animate:t})).attr("opacity",m=>m.hidden?0:1).attr("d",m=>{const{data:v}=m;return h(v)})}destroy(){const t=this.services.events;t.removeEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.removeEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut)}}const Vg=5;function eD(e,t){return e>t-Vg&&e<t+Vg}class Fn extends gt{constructor(){super(...arguments),this.type="ruler",this.renderType=rt.SVG,this.isXGridEnabled=y(this.getOptions(),"grid","x","enabled"),this.isYGridEnabled=y(this.getOptions(),"grid","y","enabled"),this.isEventListenerAdded=!1}render(t=!1){const n=y(this.getOptions(),"ruler","enabled"),r=y(this.getOptions(),"tooltip","alwaysShowRulerTooltip"),i=n||r;this.drawBackdrop(),i&&!this.isEventListenerAdded?this.addBackdropEventListeners():!i&&this.isEventListenerAdded&&this.removeBackdropEventListeners()}removeBackdropEventListeners(){this.isEventListenerAdded=!1,this.backdrop.on("mousemove mouseover mouseout",null)}formatTooltipData(t){return t}showRuler(t,[n,r]){const i=this.parent,s=this.services.cartesianScales.getOrientation(),a=this.model.getDisplayData(),o=this.services.cartesianScales.getRangeScale(),[l,c]=o.range(),u=s===Ft.HORIZONTAL?r:n,d=N.appendOrSelect(i,"g.ruler").attr("aria-label","ruler"),h=N.appendOrSelect(d,"line.ruler-line"),p=i.selectAll("[role=graphics-symbol]"),f=a.map(m=>({domainValue:this.services.cartesianScales.getDomainValue(m),originalData:m})).filter(m=>eD(m.domainValue,u));if(this.pointsWithinLine&&f.length===this.pointsWithinLine.length&&f.map(m=>m.domainValue).join()===this.pointsWithinLine.map(m=>m.domainValue).join())return this.pointsWithinLine=f,this.services.events.dispatchEvent(T.Tooltip.MOVE,{mousePosition:[n,r]});this.pointsWithinLine=f;const g=this.pointsWithinLine.reduce((m,v)=>{if(m.length===0)return m.push(v),m;const x=m[0].domainValue,_=Math.abs(u-v.domainValue),E=Math.abs(u-x);return _>E||(_<E?m=[v]:m.push(v)),m},[]);if(g.length>0){const m=g.map(E=>E.originalData).filter(E=>{const b=this.services.cartesianScales.getRangeIdentifier(E);return E[b]!=null}),v=g.map(E=>E.domainValue),x=p.filter(E=>{const b=this.services.cartesianScales.getDomainValue(E);return v.includes(b)});this.elementsToHighlight&&this.elementsToHighlight.size()>0&&!em(this.elementsToHighlight,x)&&this.hideRuler(),x.dispatch("mouseover"),this.elementsToHighlight=x,this.services.events.dispatchEvent(T.Tooltip.SHOW,{event:t,mousePosition:[n,r],hoveredElement:h,data:this.formatTooltipData(m)}),d.attr("opacity",1);const _=g[0];s==="horizontal"?h.attr("x1",c).attr("x2",l).attr("y1",_.domainValue).attr("y2",_.domainValue):h.attr("y1",c).attr("y2",l).attr("x1",_.domainValue).attr("x2",_.domainValue)}else this.hideRuler()}hideRuler(){const t=this.parent,n=N.appendOrSelect(t,"g.ruler");t.selectAll("[role=graphics-symbol]").dispatch("mouseout"),this.services.events.dispatchEvent(T.Tooltip.HIDE),n.attr("opacity",0)}addBackdropEventListeners(){this.isEventListenerAdded=!0;const t=this,n=this.services.domUtils.getHolder(),r=this.model.getDisplayData();let i=function(s){const a=nr(s,t.parent.node());t.showRuler(s,a)};if(r.length>100){const s=r.length%50*12.5;i=QT(function(a){const{mousePosition:o}=this;t.showRuler(a,o)},s,n)}this.backdrop.on("mousemove mouseover",i).on("mouseout",this.hideRuler.bind(this))}drawBackdrop(){const t=this.parent;this.backdrop=N.appendOrSelect(t,"svg.chart-grid-backdrop")}}class un extends gt{constructor(){super(...arguments),this.type="scatter",this.renderType=rt.SVG,this.handleChartHolderOnHover=()=>{if(!this.parent)throw new Error("Parent not defined");this.parent.selectAll("circle.dot").transition("chart-holder-hover-scatter").call(t=>this.services.transitions?.setupTransition({transition:t,name:"chart-holder-hover-scatter"})).attr("opacity",1)},this.handleChartHolderOnMouseOut=()=>{if(!this.parent)throw new Error("Parent not defined");this.parent.selectAll("circle.dot").transition("chart-holder-mouseout-scatter").call(t=>this.services.transitions?.setupTransition({transition:t,name:"chart-holder-mouseout-scatter"})).attr("opacity",0)},this.handleLegendOnHover=t=>{const{hoveredElement:n}=t.detail,{groupMapsTo:r}=this.getOptions().data;if(!this.parent)throw new Error("Parent not defined");this.parent.selectAll("circle.dot").transition("legend-hover-scatter").call(i=>this.services.transitions?.setupTransition({transition:i,name:"legend-hover-scatter"})).attr("opacity",i=>i[r]!==n.datum().name?.3:1)},this.handleLegendMouseOut=()=>{if(!this.parent)throw new Error("Parent not defined");this.parent.selectAll("circle.dot").transition("legend-mouseout-scatter").call(t=>this.services.transitions?.setupTransition({transition:t,name:"legend-mouseout-scatter"})).attr("opacity",1)}}init(){const{events:t}=this.services;if(!t)throw new Error("Services events are undefined.");t.addEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.addEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut);const{fadeInOnChartHolderMouseover:n}=this.configs;n&&(t.addEventListener(T.Chart.MOUSEOVER,this.handleChartHolderOnHover),t.addEventListener(T.Chart.MOUSEOUT,this.handleChartHolderOnMouseOut))}filterBasedOnZoomDomain(t){const{cartesianScales:n}=this.services;if(!n)throw new Error("Services cartesianScales are undefined.");const r=n.getDomainIdentifier(t),i=this.model.get("zoomDomain");return i!==void 0?t.filter(s=>s[r].getTime()>=i[0].getTime()&&s[r].getTime()<=i[1].getTime()):t}getScatterData(){const t=this.getOptions(),{stacked:n}=this.configs;let r;if(n){const i=Object.keys(t.axes).some(s=>t.axes[s].percentage);r=this.model.getStackedData({groups:this.configs.groups,percentage:i})}else{const{cartesianScales:i}=this.services;if(!i)throw new Error("Services cartesianScales are undefined.");r=this.model.getDisplayData(this.configs.groups).filter(s=>{const a=i.getRangeIdentifier(s);return s[a]!==void 0&&s[a]!==null})}return this.filterBasedOnZoomDomain(r)}render(t){if(!(y(this.getOptions(),"points","enabled")||y(this.getOptions(),"bubble","enabled")))return;const n=this.services.zoom?.isZoomBarEnabled()||!1,r=this.getComponentContainer({ariaLabel:"scatter points",withinChartClip:n}),i=this.getOptions(),{groupMapsTo:s}=i.data,{cartesianScales:a}=this.services;if(!a)throw new Error("Services cartesianScales are undefined.");const o=a.getDomainIdentifier(),l=r.selectAll("circle.dot").data(this.getScatterData(),u=>`${u[s]}-${u[o]}`);l.exit().attr("opacity",0).remove();const c=l.enter().append("circle").classed("dot",!0).attr("opacity",0).merge(l);this.styleCircles(c,t),this.addEventListeners()}isDatapointThresholdAnomaly(t){const{handleThresholds:n}=this.configs;if(!n)return!1;const{cartesianScales:r}=this.services;if(!r)throw new Error("Cartesian scales service is undefined");const i=r.getOrientation(),[s,a]=_n(r.getHighestDomainThreshold(),r.getHighestRangeThreshold(),i),[o,l]=_n(d=>r.getDomainValue(d),d=>r.getRangeValue(d),i),c=o(t),u=l(t);return a&&s?u<=a.scaleValue&&c>=s.scaleValue:a?u<=a.scaleValue:s?c>=s.scaleValue:!1}styleCircles(t,n){const r=this.getOptions(),{filled:i,fillOpacity:s}=r.points,{cartesianScales:a}=this.services;if(!a)throw new Error("Cartesian scales service is undefined");const{groupMapsTo:o}=r.data,l=p=>a.getDomainValue(p),c=p=>a.getRangeValue(p),[u,d]=_n(l,c,a.getOrientation()),{fadeInOnChartHolderMouseover:h}=this.configs;t.raise().classed("dot",!0).attr("class",p=>{const f=a.getDomainIdentifier(p),g=this.model.getIsFilled(p[o],p[f],p,i)?[st.FILL,st.STROKE]:[st.STROKE];return this.model.getColorClassName({classNameTypes:g,dataGroupName:p[o],originalClassName:"dot"})||""}).classed("threshold-anomaly",p=>this.isDatapointThresholdAnomaly(p)).classed("filled",p=>{const f=a.getDomainIdentifier(p);return this.model.getIsFilled(p[o],p[f],p,i)}).classed("unfilled",p=>{const f=a.getDomainIdentifier(p);return!this.model.getIsFilled(p[o],p[f],p,i)}).transition().call(p=>this.services.transitions?.setupTransition({transition:p,name:"scatter-update-enter",animate:n})).attr("cx",u).attr("cy",d).attr("r",r.points.radius).style("fill",p=>{const f=a.getDomainIdentifier(p);if(this.model.getIsFilled(p[o],p[f],p,i))return this.model.getFillColor(p[o],p[f],p)}).style("stroke",p=>{const f=a.getDomainIdentifier(p);return this.model.getStrokeColor(p[o],p[f],p)}).attr("fill-opacity",i?s:1).attr("opacity",h?0:1).attr("role",dt.GRAPHICS_SYMBOL).attr("aria-roledescription","point").attr("aria-label",p=>{const f=a.getRangeIdentifier(p);return p[f]}),this.addEventListeners()}getTooltipAdditionalItems(t){return null}addEventListeners(){const t=this,{groupMapsTo:n}=t.getOptions().data,r=y(this.getOptions(),"tooltip","alwaysShowRulerTooltip");if(!this.parent)throw new Error("Parent not defined");const i=this.parent.selectAll("circle");r?i.style("pointer-events","none"):i.style("pointer-events",null),i.on("mouseover",function(s,a){const o=I(this);o.classed("hovered",!0).attr("class",l=>t.model.getColorClassName({classNameTypes:[st.FILL],dataGroupName:l[n],originalClassName:o.attr("class")})).style("fill",l=>{const c=t.services.cartesianScales?.getDomainIdentifier(l);return t.model.getFillColor(l[n],l[c],l)}).classed("unfilled",!1),r||t.services.events?.dispatchEvent(T.Tooltip.SHOW,{event:s,hoveredElement:o,data:[a],additionalItems:t.getTooltipAdditionalItems(a)}),t.services.events?.dispatchEvent(T.Scatter.SCATTER_MOUSEOVER,{event:s,element:o,datum:a})}).on("mousemove",function(s,a){const o=I(this);t.services.events?.dispatchEvent(T.Scatter.SCATTER_MOUSEMOVE,{event:s,element:o,datum:a}),t.services.events?.dispatchEvent(T.Tooltip.MOVE,{event:s})}).on("click",function(s,a){t.services.events?.dispatchEvent(T.Scatter.SCATTER_CLICK,{event:s,element:I(this),datum:a})}).on("mouseout",function(s,a){const o=I(this);if(o.classed("hovered",!1),!t.configs.filled){const{filled:l}=t.getOptions().points,c=t.services.cartesianScales?.getDomainIdentifier(a),u=t.model.getIsFilled(a[n],a[c],a,l);o.classed("unfilled",!u).style("fill",d=>u||l?t.model.getFillColor(d[n],d[c],d):null)}t.services.events?.dispatchEvent(T.Scatter.SCATTER_MOUSEOUT,{event:s,element:o,datum:a}),t.services.events?.dispatchEvent(T.Tooltip.HIDE,{hoveredElement:o})})}destroy(){this.parent?.selectAll("circle").on("mousemove",null).on("mouseout",null);const{events:t}=this.services;if(!t)throw new Error("Services events undefined");t.removeEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.removeEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut),t.removeEventListener(T.Chart.MOUSEOVER,this.handleChartHolderOnHover),t.removeEventListener(T.Chart.MOUSEOUT,this.handleChartHolderOnMouseOut)}}class Gg extends gt{constructor(t,n,r){super(t,n,r),this.type="axes",this.renderType=rt.SVG,this.truncation={[V.LEFT]:!1,[V.RIGHT]:!1,[V.TOP]:!1,[V.BOTTOM]:!1},r&&(this.configs=r),this.margins=this.configs.margins}render(t=!0){const{position:n}=this.configs,r=this.getOptions(),i=y(r,"axes",n,"visible"),s=this.getComponentContainer({ariaLabel:"axes"}),{width:a,height:o}=N.getSVGElementSize(s,{useAttrs:!0}),l=N.appendOrSelect(s,`g.axis.${n}`);let c,u;if(n===V.BOTTOM||n===V.TOP?(c=this.configs.axes[V.LEFT]?this.margins.left:0,u=this.configs.axes[V.RIGHT]?a-this.margins.right:a):(c=o-this.margins.bottom,u=this.margins.top),!this.services.cartesianScales)throw new Error("Services cartesianScales undefined");const d=this.services.cartesianScales.getScaleByPosition(n);this.scaleType===nt.LABELS||this.scaleType===nt.LABELS_RATIO?d.rangeRound([c,u]):d.range([c,u]);let h;switch(n){case V.LEFT:h=im;break;case V.BOTTOM:h=gc;break;case V.RIGHT:h=IC;break;case V.TOP:h=RC;break}l.attr("aria-label",`${n} axis`);const p=!l.select("g.ticks").empty();let f=N.appendOrSelect(l,"g.ticks");p||(f.attr("role",`${dt.GRAPHICS_OBJECT} ${dt.GROUP}`),f.attr("aria-label",`${n} ticks`));const g=N.appendOrSelect(l,"g.ticks.invisible").style("opacity","0").style("pointer-events","none").attr("aria-hidden",!0).attr("aria-label",`invisible ${n} ticks`),m=y(r,"axes",n),v=this.scaleType===nt.TIME||m.scaleType===nt.TIME,x=n===V.LEFT||n===V.RIGHT,_=this.model.get("zoomDomain");if(_&&v&&!x&&d.domain(_),!i){f.attr("aria-hidden",!0);return}const E=y(m,"scaleType"),b=y(r,"data","loading"),S=y(m,"ticks","number"),M=y(m,"ticks","values"),k=y(m,"truncation","type"),A=y(m,"truncation","threshold"),R=y(m,"truncation","numCharacter"),C=S!==null,H=y(r,"timeScale"),P=N.appendOrSelect(g,"g.tick"),B=N.appendOrSelect(P,"text").text("0"),O=N.getSVGElementSize(B.node(),{useBBox:!0}).height;P.remove();const $=this.scaleType||m.scaleType||nt.LINEAR,L=h(d).tickSizeOuter(0);if(d.ticks){let Y;if(C?Y=S:(Y=Pn.ticks.number,x&&(Y=this.getNumberOfFittingTicks(o,O,Pn.ticks.verticalSpaceRatio))),d.ticks().length===1&&d.ticks()[0]===0&&(Y=0),L.ticks(Y),v)if(!d.ticks(Y).length)L.tickValues([]);else{const et=y(r,"timeScale","addSpaceOnEdges"),at=y(r,"axes",n,"domain"),z=d.copy();et&&!at&&z.nice(Y);const q=z.ticks(Y);et&&q.length>2&&!at&&(q.splice(q.length-1,1),q.splice(0,1)),L.tickValues(q)}}let D;const U=y(m,"ticks","formatter"),{code:Q,number:W}=y(r,"locale");if(v){const Y=ql(L.tickValues(),y(r,"timeScale","timeInterval"));U===null?D=(et,at)=>Wl(et,at,L.tickValues(),Y,H,r.locale):D=(et,at)=>{const z=Wl(et,at,L.tickValues(),Y,H,r.locale);return U(et,at,z)}}else U===null?$===nt.LINEAR&&(D=Y=>W(Y,Q)):D=U;L.tickFormat(D);const[j,X]=this.services.cartesianScales.getScaleByPosition(n).domain();let ct;if(M){if(v)M.forEach((Y,et)=>{Y.getTime===void 0&&(M[et]=new Date(Y))}),ct=M.filter(Y=>{const et=Y.getTime();return et>=new Date(j).getTime()&&et<=new Date(X).getTime()});else if(E===nt.LABELS){const Y=this.services.cartesianScales.getScaleByPosition(n).domain();ct=M.filter(et=>Y.includes(et))}else ct=M.filter(Y=>Y>=j&&Y<=X);L.tickValues(ct)}switch(n){case V.LEFT:f.attr("transform",`translate(${this.margins.left}, 0)`);break;case V.BOTTOM:f.attr("transform",`translate(0, ${o-this.margins.bottom})`);break;case V.RIGHT:f.attr("transform",`translate(${a-this.margins.right}, 0)`);break;case V.TOP:f.attr("transform",`translate(0, ${this.margins.top})`);break}const tt=this.model.isDataEmpty();if(m.title){const Y=N.appendOrSelect(l,"text.axis-title").html(tt||b?"":cn(m.title)),et=y(m,"titleOrientation");let at;switch(n){case V.LEFT:et===ks.RIGHT?Y.attr("transform","rotate(90)").attr("y",0).attr("x",d.range()[0]/2).attr("dy","-0.5em").style("text-anchor","middle"):Y.attr("transform","rotate(-90)").attr("y",0).attr("x",-(d.range()[0]/2)).attr("dy","0.75em").style("text-anchor","middle");break;case V.BOTTOM:const z=o-bp;Y.attr("transform",`translate(${this.margins.left/2+d.range()[1]/2}, ${z})`);break;case V.RIGHT:et===ks.LEFT?Y.attr("transform","rotate(-90)").attr("y",a).attr("x",-(d.range()[0]/2)).style("text-anchor","middle"):Y.attr("transform","rotate(90)").attr("y",-a).attr("x",d.range()[0]/2).attr("dy","0.75em").style("text-anchor","middle");break;case V.TOP:at=N.getSVGElementSize(Y,{useBBox:!0}).height,Y.attr("transform",`translate(${this.margins.left/2+d.range()[1]/2}, ${at/2})`).style("text-anchor","middle");break}}if(v){const Y=ql(L.tickValues(),y(r,"timeScale","timeInterval")),et=H.showDayName,at=f;t&&(f=f.transition().call(z=>this.services.transitions.setupTransition({transition:z,name:"axis-update",animate:t}))),f=f.call(L),at.selectAll(".tick").data(L.tickValues(),d).order().select("text").attr("class",(z,q)=>Bp(z,q,L.tickValues(),Y,et)?"tick-label--primary":"tick-label")}else!t||!p?f=f.call(L):f=f.transition().call(Y=>this.services.transitions.setupTransition({transition:Y,name:"axis-update",animate:t})).call(L);if(g.call(L),n===V.BOTTOM||n===V.TOP){let Y=!1;const et=y(m,"ticks","rotation");if(et===vi.ALWAYS)Y=!0;else if(et===vi.NEVER)Y=!1;else if(!et||et===vi.AUTO)if(d.step)Y=g.selectAll("g.tick text").nodes().some(at=>N.getSVGElementSize(at,{useBBox:!0}).width>=d.step());else{Y=!1;const at=g.append("text").text("A"),z=N.getSVGElementSize(at.node(),{useBBox:!0}).width;let q;g.selectAll("g.tick").each(function(){const Z=I(this),F=parseFloat(y(xn(this),"tx"));F!==null&&q+Z.text().length*z*.8>=F&&(Y=!0),q=F}),at.remove()}Y?(C||(L.ticks(this.getNumberOfFittingTicks(a,O,Pn.ticks.horizontalSpaceRatio)),g.call(L),f.call(L)),l.selectAll("g.ticks g.tick text").attr("transform","rotate(-45)").attr("text-anchor",n===V.TOP?"start":"end")):l.selectAll("g.ticks g.tick text").attr("transform",null).attr("text-anchor",null)}if(b?l.attr("opacity",0):l.attr("opacity",1),f.selectAll("g.tick").attr("aria-label",Y=>Y),g.selectAll("g.tick").attr("aria-label",Y=>Y),k!==$e.NONE&&E===nt.LABELS&&!M){const Y=this.services.cartesianScales.getScaleDomain(n);if(Y.length>0){const et=s.select(`g.axis.${n} g.ticks g.tick`).html();l.selectAll("g.ticks g.tick").html(et);const at=this;l.selectAll("g.tick text").data(Y).text(function(z){return z.length>A?(at.truncation[n]=!0,Yi(z,k,R)):z}),this.getInvisibleAxisRef().selectAll("g.tick text").data(Y).text(function(z){return z.length>A?Yi(z,k,R):z}),l.selectAll("g.ticks").html(this.getInvisibleAxisRef().html()),l.selectAll("g.tick text").data(Y)}}this.addEventListeners()}addEventListeners(){const t=this.getComponentContainer(),{position:n}=this.configs,r=N.appendOrSelect(t,`g.axis.${n}`),i=this.getOptions(),s=y(i,"axes",n),a=y(s,"scaleType"),o=y(s,"truncation","threshold"),l=this;r.selectAll("g.tick text").on("mouseover",function(c,u){l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEOVER,{event:c,element:I(this),datum:u}),a===nt.LABELS&&u.length>o&&l.services.events.dispatchEvent(T.Tooltip.SHOW,{event:c,hoveredElement:I(this),content:u})}).on("mousemove",function(c,u){l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEMOVE,{event:c,element:I(this),datum:u}),a===nt.LABELS&&u.length>o&&l.services.events.dispatchEvent(T.Tooltip.MOVE,{event:c})}).on("click",function(c,u){l.services.events.dispatchEvent(T.Axis.LABEL_CLICK,{event:c,element:I(this),datum:u})}).on("mouseout",function(c,u){l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEOUT,{event:c,element:I(this),datum:u}),a===nt.LABELS&&l.services.events.dispatchEvent(T.Tooltip.HIDE)})}getInvisibleAxisRef(){const{position:t}=this.configs;return this.getComponentContainer().select(`g.axis.${t} g.ticks.invisible`)}getTitleRef(){const{position:t}=this.configs;return this.getComponentContainer().select(`g.axis.${t} text.axis-title`)}getNumberOfFittingTicks(t,n,r){const i=Math.floor(t/(n*r));return tm(i,2,Pn.ticks.number)}destroy(){const t=this.getComponentContainer(),{position:n}=this.configs;N.appendOrSelect(t,`g.axis.${n}`).selectAll("g.tick text").on("mouseover",null).on("mousemove",null).on("mouseout",null)}}class nD extends Gg{constructor(t,n,r){super(t,n,r)}render(t=!0){super.render(t),super.destroy();const n=this.configs.position,r=this.getComponentContainer({ariaLabel:"axes"}),i=N.appendOrSelect(r,`g.axis.${n}`),s=this;i.selectAll("g.tick").each(function(a,o){const l=I(this);l.classed("tick-hover",!0).attr("tabindex",o===0?0:-1);const c=l.select("text"),{width:u,height:d}=N.getSVGElementSize(c,{useBBox:!0}),h=N.appendOrSelect(l,"rect.axis-holder");let p=0,f=0;switch(n){case V.LEFT:p=-u+Number(c.attr("x")),f=-(d/2);break;case V.RIGHT:p=Math.abs(Number(c.attr("x"))),f=-(d/2);break;case V.TOP:p=-(u/2),f=-d+Number(c.attr("y"))/2,s.truncation[n]&&(p=0,h.attr("transform","rotate(-45)"));break;case V.BOTTOM:p=-(u/2),f=d/2-2,s.truncation[n]&&(p=-u,h.attr("transform","rotate(-45)"));break}h.attr("x",p-Pn.hover.rectanglePadding).attr("y",f).attr("width",u+Pn.hover.rectanglePadding*2).attr("height",d).lower()}),this.addEventListeners()}addEventListeners(){const t=this.getComponentContainer(),{position:n}=this.configs,r=N.appendOrSelect(t,`g.axis.${n}`),i=this.getOptions(),s=y(i,"axes",n),a=y(s,"scaleType"),o=y(s,"truncation","threshold"),l=this;r.selectAll("g.tick.tick-hover").on("mouseover",function(c){const u=I(this).select("text"),d=u.datum();l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEOVER,{event:c,element:u,datum:d}),a===nt.LABELS&&d.length>o&&l.services.events.dispatchEvent(T.Tooltip.SHOW,{event:c,element:u,datum:d})}).on("mousemove",function(c){const u=I(this).select("text"),d=u.datum();l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEMOVE,{event:c,element:u,datum:d}),l.services.events.dispatchEvent(T.Tooltip.MOVE,{event:c})}).on("click",function(c){l.services.events.dispatchEvent(T.Axis.LABEL_CLICK,{event:c,element:I(this).select("text"),datum:I(this).select("text").datum()})}).on("mouseout",function(c){l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEOUT,{event:c,element:I(this).select("text"),datum:I(this).select("text").datum()}),a===nt.LABELS&&l.services.events.dispatchEvent(T.Tooltip.HIDE)}).on("focus",function(c){const u={clientX:0,clientY:0};if(c.target){c.target.focus();const d=c.target.getBoundingClientRect();u.clientX=d.x,u.clientY=d.y}l.services.events.dispatchEvent(T.Axis.LABEL_FOCUS,{event:{...c,...u},element:I(this),datum:I(this).select("text").datum()})}).on("blur",function(c){l.services.events.dispatchEvent(T.Axis.LABEL_BLUR,{event:c,element:I(this),datum:I(this).select("text").datum()})}).on("keydown",function(c){c.key&&c.key==="Escape"&&(l.services.events.dispatchEvent(T.Tooltip.HIDE),l.services.events.dispatchEvent(T.Axis.LABEL_BLUR,{event:c,element:I(this),datum:I(this).select("text").datum()})),n===V.LEFT||n===V.RIGHT?c.key&&c.key==="ArrowUp"?l.goNext(this,c):c.key&&c.key==="ArrowDown"&&l.goPrevious(this,c):c.key&&c.key==="ArrowLeft"?l.goPrevious(this,c):c.key&&c.key==="ArrowRight"&&l.goNext(this,c)})}goNext(t,n){t.nextElementSibling&&t.nextElementSibling.tagName!=="path"&&t.nextElementSibling.dispatchEvent(new Event("focus")),n.preventDefault()}goPrevious(t,n){t.previousElementSibling&&t.previousElementSibling.tagName!=="path"&&t.previousElementSibling.dispatchEvent(new Event("focus")),n.preventDefault()}destroy(){const t=this.getComponentContainer(),{position:n}=this.configs;N.appendOrSelect(t,`g.axis.${n}`).selectAll("g.tick.tick-hover").on("mouseover",null).on("mousemove",null).on("mouseout",null).on("focus",null).on("blur",null)}}class ge extends gt{constructor(){super(...arguments),this.type="2D-axes",this.renderType=rt.SVG,this.children={},this.thresholds=[],this.margins={top:0,right:0,bottom:0,left:0}}render(t=!1){const n={},r=Object.keys(V),i=y(this.getOptions(),"axes");r.forEach(a=>{i[V[a]]&&(n[V[a]]=!0)}),this.configs.axes=n,r.forEach(a=>{const o=V[a];if(this.configs.axes[o]&&!this.children[o]){const l={position:o,axes:this.configs.axes,margins:this.margins},c=this.model.axisFlavor===bi.DEFAULT?new Gg(this.model,this.services,l):new nD(this.model,this.services,l);c.setModel(this.model),c.setServices(this.services),c.setParent(this.parent),this.children[o]=c}}),Object.keys(this.children).forEach(a=>{this.children[a].render(t)});const s={};Object.keys(this.children).forEach(a=>{const o=this.children[a],l=o.configs.position,c=o.getInvisibleAxisRef(),{width:u,height:d}=N.getSVGElementSize(c,{useBBox:!0});let h=0;if(!o.getTitleRef().empty()){const g=N.getSVGElementSize(o.getTitleRef(),{useBBox:!0}).height;l===V.LEFT||l===V.RIGHT?h=g+5:l===V.BOTTOM?h=g+bp:h=g}const p=u,f=d;switch(l){case V.TOP:s.top=f+h;break;case V.BOTTOM:s.bottom=f+h;break;case V.LEFT:s.left=p+h;break;case V.RIGHT:s.right=p+h;break}}),this.services.events.dispatchEvent(T.Axis.RENDER_COMPLETE),Object.keys(s).some(a=>this.margins[a]!==s[a])&&(this.margins=Object.assign(this.margins,s),this.model.set({axesMargins:this.margins},{skipUpdate:!0}),this.services.events.dispatchEvent(T.ZoomBar.UPDATE),Object.keys(this.children).forEach(a=>{const o=this.children[a];o.margins=this.margins}),this.render(!0))}}class ue extends gt{constructor(){super(...arguments),this.type="skeleton"}render(t=!0){const n=y(this.getOptions(),"data","loading");n?this.renderSkeleton(n):this.removeSkeleton()}renderSkeleton(t){if(this.configs.skeleton===jt.GRID)this.renderGridSkeleton(t);else if(this.configs.skeleton===jt.VERT_OR_HORIZ)this.renderVertOrHorizSkeleton(t);else if(this.configs.skeleton===jt.PIE)this.renderPieSkeleton(t);else if(this.configs.skeleton===jt.DONUT)this.renderDonutSkeleton(t);else throw new Error(`"${this.configs.skeleton}" is not a valid Skeleton type.`)}renderGridSkeleton(t){this.setScales(),this.drawBackdrop(t),this.drawXGrid(t),this.drawYGrid(t),t&&this.setShimmerEffect("shimmer-lines")}renderVertOrHorizSkeleton(t){const n=this.services.cartesianScales.getOrientation();this.setScales(),this.drawBackdrop(t),n===Ft.VERTICAL&&this.drawYGrid(t),n===Ft.HORIZONTAL&&this.drawXGrid(t),this.setShimmerEffect("shimmer-lines")}renderPieSkeleton(t){const n=this.computeOuterRadius();this.drawRing(n,0,t),t&&this.setShimmerEffect("shimmer-areas")}renderDonutSkeleton(t){const n=this.computeOuterRadius(),r=this.computeInnerRadius();this.drawRing(n,r,t),t&&this.setShimmerEffect("shimmer-areas")}setScales(){const t=this.services.cartesianScales.getMainXScale().range(),n=this.services.cartesianScales.getMainYScale().range();this.xScale=je().domain([0,1]).range(t),this.yScale=je().domain([0,1]).range(n)}drawBackdrop(t){const n=this.parent,{width:r,height:i}=N.getSVGElementSize(n,{useAttrs:!0});this.backdrop=N.appendOrSelect(n,"svg.chart-skeleton.DAII").attr("role","presentation").attr("width",r).attr("height",i);const s=N.appendOrSelect(this.backdrop,"rect.chart-skeleton-backdrop");s.attr("width","100%").attr("height","100%");const[a]=this.xScale.range(),[,o]=this.yScale.range();this.backdrop.merge(s).attr("x",a).attr("y",o),s.classed("shimmer-effect-lines",t).classed("empty-state-lines",!t).style("stroke",t?`url(#${this.services.domUtils.generateElementIDString("shimmer-lines")})`:null)}drawXGrid(t){const n=+this.backdrop.attr("width"),r=y(this.getOptions(),"grid","x","numberOfTicks"),i=this.xScale.ticks(r).map(o=>o*n),s=N.appendOrSelect(this.backdrop,"g.x.skeleton"),a=s.selectAll("line").data(i);a.enter().append("line").merge(a).attr("x1",o=>o).attr("x2",o=>o).attr("y1",0).attr("y2","100%"),s.selectAll("line").classed("shimmer-effect-lines",t).classed("empty-state-lines",!t).style("stroke",t?`url(#${this.services.domUtils.generateElementIDString("shimmer-lines")})`:null)}drawYGrid(t){const n=+this.backdrop.attr("height"),r=this.backdrop.attr("width"),i=y(this.getOptions(),"grid","y","numberOfTicks"),s=this.xScale.ticks(i).map(l=>l*n),a=N.appendOrSelect(this.backdrop,"g.y.skeleton"),o=a.selectAll("line").data(s);o.enter().append("line").merge(o).attr("x1",0).attr("x2",r).attr("y1",l=>l).attr("y2",l=>l),a.selectAll("line").classed("shimmer-effect-lines",t).classed("empty-state-lines",!t).style("stroke",t?`url(#${this.services.domUtils.generateElementIDString("shimmer-lines")})`:null)}drawRing(t,n,r=!0){const i=this.parent,{width:s,height:a}=N.getSVGElementSize(i,{useAttrs:!0}),o=N.appendOrSelect(i,"svg.chart-skeleton").attr("width",s).attr("height",a).attr("role","presentation"),l=n===0?"pie":"donut",c=y(this.getOptions(),l,"alignment");N.appendOrSelect(o,"rect.chart-skeleton-area-container").attr("width",s).attr("height",a).attr("fill","none");const u=vs().innerRadius(n).outerRadius(t).startAngle(0).endAngle(Math.PI*2),d=t+Math.abs(kt.radiusOffset),h=t+(Math.min(s,a)-t*2)/2,p=N.appendOrSelect(o,"path").attr("class","skeleton-area-shape").attr("transform",`translate(${d}, ${h})`).attr("d",u).classed("shimmer-effect-areas",r).classed("empty-state-areas",!r).style("fill",r?`url(#${this.services.domUtils.generateElementIDString("shimmer-areas")})`:null);let f=t+kt.xOffset;c===zt.CENTER?f=s/2:c===zt.RIGHT&&(f=s-t-kt.xOffset);const g=t+kt.yOffset;p.attr("transform",`translate(${f}, ${g})`)}computeOuterRadius(){const{width:t,height:n}=N.getSVGElementSize(this.parent,{useAttrs:!0});return Math.min(t,n)/2+kt.radiusOffset}computeInnerRadius(){return this.computeOuterRadius()*(3/4)}setShimmerEffect(t){const n="stop-bg-shimmer",r="stop-shimmer",i=this.parent.select(".chart-skeleton"),{width:s}=N.getSVGElementSize(this.parent,{useAttrs:!0}),a=0,o=s,l=N.appendOrSelect(i,"defs").lower(),c=N.appendOrSelect(l,"linearGradient").attr("id",this.services.domUtils.generateElementIDString(t)).attr("class",t).attr("x1",a-3*.2*s).attr("x2",o).attr("y1",0).attr("y2",0).attr("gradientUnits","userSpaceOnUse").attr("gradientTransform","translate(0, 0)"),u=`
|
|
66
|
+
</svg>`}destroy(){this.parent.selectAll("path.line,.node-group").on("mouseover",null).on("mousemove",null).on("click",null).on("mouseout",null)}}class we extends gt{constructor(){super(...arguments),this.type="grid",this.renderType=rt.SVG}render(t=!0){const n=y(this.getOptions(),"grid","x","enabled"),r=y(this.getOptions(),"grid","y","enabled");this.drawBackdrop(n,r),!(!n&&!r)&&(n&&(N.appendOrSelect(this.backdrop,"g.x.grid"),this.drawXGrid(t)),r&&(N.appendOrSelect(this.backdrop,"g.y.grid"),this.drawYGrid(t)))}drawXGrid(t){const n=this.parent,r=this.backdrop.attr("height"),i=this.services.cartesianScales.getMainXScale(),s=gc(i).tickSizeInner(-r).tickSizeOuter(0);if(y(this.getOptions(),"grid","x","alignWithAxisTicks")){const o=this.services.cartesianScales.getDomainAxisPosition(),l=y(this.getOptions(),"axes",o,"ticks","values");l&&s.tickValues(l)}else{const o=y(this.getOptions(),"grid","x","numberOfTicks");s.ticks(o)}const a=n.select(".x.grid").attr("transform",`translate(${-this.backdrop.attr("x")}, ${r})`);t?a.transition().call(o=>this.services.transitions.setupTransition({transition:o,name:"grid-update",animate:t})).call(s):a.call(s),this.cleanGrid(a)}drawYGrid(t){const n=this.parent,r=this.backdrop.attr("width"),i=this.services.cartesianScales.getMainYScale(),s=im(i).tickSizeInner(-r).tickSizeOuter(0);if(y(this.getOptions(),"grid","y","alignWithAxisTicks")){const o=this.services.cartesianScales.getRangeAxisPosition(),l=y(this.getOptions(),"axes",o,"ticks","values");l&&s.tickValues(l)}else{const o=y(this.getOptions(),"grid","y","numberOfTicks");s.ticks(o)}const a=n.select(".y.grid").attr("transform",`translate(0, ${-this.backdrop.attr("y")})`);t?a.transition().call(o=>this.services.transitions.setupTransition({transition:o,name:"grid-update",animate:t})).call(s):a.call(s),this.cleanGrid(a)}getGridlineThreshold(t){const n=this.parent,r=n.selectAll(".x.grid .tick").nodes().sort((u,d)=>Number(xn(u).tx)-Number(xn(d).tx));let i=-1;if(!r.length)return;r.forEach(u=>{t[0]>=+xn(u).tx&&i++});const s=i+1<r.length?i+1:r.length,a=r[i],o=r[s];let l;if(!a)l=+xn(o).tx;else if(o)l=+xn(o).tx-+xn(a).tx;else{const u=n.select("rect.chart-grid-backdrop").node();l=N.getSVGElementSize(u).width-+xn(a).tx}const{threshold:c}=this.getOptions().tooltip.gridline;return l*c}getActiveGridline(t){const n=y(this.getOptions,"tooltip","gridline","threshold"),r=n||this.getGridlineThreshold(t);return this.parent.selectAll(".x.grid .tick").filter(function(){const i=xn(this),s={min:Number(i.tx)-r,max:Number(i.tx)+r};return s.min<=t[0]&&t[0]<=s.max})}drawBackdrop(t,n){const r=this.parent,i=this.services.cartesianScales.getMainXScale(),s=this.services.cartesianScales.getMainYScale(),[a,o]=i.range(),[l,c]=s.range();this.backdrop=N.appendOrSelect(r,"svg.chart-grid-backdrop").attr("role","presentation");const u=N.appendOrSelect(this.backdrop,t||n?"rect.chart-grid-backdrop.stroked":"rect.chart-grid-backdrop");this.backdrop.merge(u).attr("x",a).attr("y",c).attr("width",Math.abs(o-a)).attr("height",Math.abs(l-c)).lower(),u.attr("width","100%").attr("height","100%")}cleanGrid(t){t.selectAll("text").remove(),t.select(".domain").remove()}}class Hg extends gt{constructor(){super(...arguments),this.type="area",this.renderType=rt.SVG,this.gradient_id="gradient-id-"+Math.floor(Math.random()*99999999999),this.handleLegendOnHover=t=>{const{hoveredElement:n}=t.detail;this.parent.selectAll("path.area").transition("legend-hover-area").call(r=>this.services.transitions.setupTransition({transition:r,name:"legend-hover-area"})).attr("opacity",r=>r.name!==n.datum().name?yn.opacity.unselected:yn.opacity.selected)},this.handleLegendMouseOut=()=>{this.parent.selectAll("path.area").transition("legend-mouseout-area").call(t=>this.services.transitions.setupTransition({transition:t,name:"legend-mouseout-area"})).attr("opacity",yn.opacity.selected)}}init(){const t=this.services.events;t.addEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.addEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut)}render(t=!0){const n=this.getComponentContainer({ariaLabel:"area graphs",withinChartClip:!0}),r=this.getOptions();let i=[0,0];const{cartesianScales:s}=this.services,a=s.getOrientation(),o=nu().curve(this.services.curves.getD3Curve()).defined(b=>{const S=s.getRangeIdentifier();return b[S]!=null}),l=this.model.getGroupedData(this.configs.groups),c=y(r,"bounds"),u=c&&l&&l.length===1;!u&&c&&console.warn(`Bounds can only be shown when having 1 single datagroup, you've supplied ${l.length}`);let d=0;const h=(b,S)=>{y(r,"axes",b,"includeZero")===!1&&S[0]>0&&S[1]>0&&(d=S[0])},p=b=>u?s.getBoundedScaledValues(b)[0]:s.getRangeValue(d),f=b=>u?s.getBoundedScaledValues(b)[1]:s.getRangeValue(b);a===Ft.VERTICAL?(i=s.getMainYScale().domain(),h(s.getMainYAxisPosition(),i),o.x(b=>s.getDomainValue(b)).y0(b=>p(b)).y1(b=>f(b))):(i=s.getMainXScale().domain(),h(s.getMainXAxisPosition(),i),o.x0(b=>p(b)).x1(b=>f(b)).y(b=>s.getDomainValue(b)));const g=y(r,"color","gradient","enabled"),m=l&&l.length===1&&g;l.length>1&&g&&console.error("Gradients can only be enabled when having 1 single dataset");const v=n.selectAll("path.area").data(l,b=>b.name),x=I(this.services.domUtils.getMainContainer());if(v.exit().attr("opacity",0).remove(),!l.length)return;if(m){const b=x.select(`path.${this.model.getColorClassName({classNameTypes:[st.STROKE],dataGroupName:l[0].name})}`).node();let S;if(b)S=getComputedStyle(b,null).getPropertyValue("stroke");else{const M=y(this.model.getOptions(),"color","scale");if(M!==null){const k=Object.keys(M);S=M[k[0]]}}fc.appendOrUpdateLinearGradient({svg:this.parent,id:this.services.domUtils.generateElementIDString(`${l[0].name.replace(" ","")}_${this.gradient_id}`),x1:"0%",x2:"0%",y1:"0%",y2:"100%",stops:fc.getStops(i,S)})}else this.parent.selectAll("defs linearGradient").empty()||this.parent.selectAll("defs linearGradient").each(function(){this.parentNode.remove()});const _=this,E=v.enter().append("path");m?E.merge(v).style("fill",b=>`url(#${this.services.domUtils.generateElementIDString(`${b.name.replace(" ","")}_${this.gradient_id}`)})`).attr("class","area").attr("class",b=>this.model.getColorClassName({classNameTypes:[st.FILL],dataGroupName:b.name,originalClassName:"area"})).attr("d",b=>{const{data:S}=b;return o(S)}):(E.attr("opacity",0).merge(v).attr("class","area").attr("class",b=>this.model.getColorClassName({classNameTypes:[st.FILL,st.STROKE],dataGroupName:b.name,originalClassName:"area"})).style("fill",b=>_.model.getFillColor(b.name,null,b.data)).transition().call(b=>this.services.transitions.setupTransition({transition:b,name:"area-update-enter",animate:t})).attr("opacity",u?1:yn.opacity.selected).attr("d",b=>{const{data:S}=b;return o(S)}),u&&E.attr("fill-opacity",yn.opacity.selected).style("stroke",b=>_.model.getStrokeColor(b.name,null,b.data)).style("stroke-dasharray","2, 2").attr("stroke-width",.7+"px"))}destroy(){const t=this.services.events;t.removeEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.removeEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut)}}class li extends gt{constructor(){super(...arguments),this.type="line",this.renderType=rt.SVG,this.handleLegendOnHover=t=>{const{hoveredElement:n}=t.detail;this.parent.selectAll("path.line").transition("legend-hover-line").call(r=>this.services.transitions.setupTransition({transition:r,name:"legend-hover-line"})).attr("opacity",r=>r.name!==n.datum().name?bn.opacity.unselected:bn.opacity.selected)},this.handleLegendMouseOut=()=>{this.parent.selectAll("path.line").transition("legend-mouseout-line").call(t=>this.services.transitions.setupTransition({transition:t,name:"legend-mouseout-line"})).attr("opacity",bn.opacity.selected)}}init(){const{events:t}=this.services;t.addEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.addEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut)}render(t=!0){const n=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,r=this.model.get("zoomDomain")!==void 0,i=n&&r?this.getComponentContainer({ariaLabel:"lines",withinChartClip:!1}):this.getComponentContainer({ariaLabel:"lines",withinChartClip:!0}),{cartesianScales:s,curves:a}=this.services,o=m=>s.getDomainValue(m),l=m=>s.getRangeValue(m),[c,u]=_n(o,l,s.getOrientation()),d=this.getOptions(),h=ys().x(c).y(u).curve(a.getD3Curve()).defined(m=>{const v=s.getRangeIdentifier(m);return m[v]!=null});let p=[];if(this.configs.stacked){const m=Object.keys(d.axes).some(x=>d.axes[x].percentage),{groupMapsTo:v}=d.data;p=this.model.getStackedData({groups:this.configs.groups,percentage:m}).map(x=>{const _=this.services.cartesianScales.getDomainIdentifier(x),E=this.services.cartesianScales.getRangeIdentifier(x);return{name:y(x,0,v),data:x.map(b=>({[_]:b.data.sharedStackKey,[v]:b[v],[E]:b[1]})),hidden:!wC(x,b=>b[0]!==b[1])}})}else p=this.model.getGroupedData(this.configs.groups);const f=i.selectAll("path.line").data(p,m=>m.name);f.exit().attr("opacity",0).remove();const g=f.enter().append("path").classed("line",!0).attr("opacity",0).merge(f).data(p,m=>m.name).attr("class",m=>this.model.getColorClassName({classNameTypes:[st.STROKE],dataGroupName:m.name,originalClassName:"line"})).style("stroke",m=>this.model.getStrokeColor(m.name,null,m.data)).attr("role",dt.GRAPHICS_SYMBOL).attr("aria-roledescription","line").attr("aria-label",m=>{const{data:v}=m;return v.map(x=>{const _=this.services.cartesianScales.getRangeIdentifier(x);return x[_]}).join(",")});if(n&&r){const m=s.getMainXScale(),v=s.getMainYScale();if(m&&v){const[x,_]=m.range(),[E,b]=v.range();i.style("overflow","hidden").style("clip",`rect(${b}px, ${_}px, ${E}px, ${x}px)`)}}g.transition().call(m=>this.services.transitions.setupTransition({transition:m,name:"line-update-enter",animate:t})).attr("opacity",m=>m.hidden?0:1).attr("d",m=>{const{data:v}=m;return h(v)})}destroy(){const t=this.services.events;t.removeEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.removeEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut)}}const Vg=5;function eD(e,t){return e>t-Vg&&e<t+Vg}class Fn extends gt{constructor(){super(...arguments),this.type="ruler",this.renderType=rt.SVG,this.isXGridEnabled=y(this.getOptions(),"grid","x","enabled"),this.isYGridEnabled=y(this.getOptions(),"grid","y","enabled"),this.isEventListenerAdded=!1}render(t=!1){const n=y(this.getOptions(),"ruler","enabled"),r=y(this.getOptions(),"tooltip","alwaysShowRulerTooltip"),i=n||r;this.drawBackdrop(),i&&!this.isEventListenerAdded?this.addBackdropEventListeners():!i&&this.isEventListenerAdded&&this.removeBackdropEventListeners()}removeBackdropEventListeners(){this.isEventListenerAdded=!1,this.backdrop.on("mousemove mouseover mouseout",null)}formatTooltipData(t){return t}showRuler(t,[n,r]){const i=this.parent,s=this.services.cartesianScales.getOrientation(),a=this.model.getDisplayData(),o=this.services.cartesianScales.getRangeScale(),[l,c]=o.range(),u=s===Ft.HORIZONTAL?r:n,d=N.appendOrSelect(i,"g.ruler").attr("aria-label","ruler"),h=N.appendOrSelect(d,"line.ruler-line"),p=i.selectAll("[role=graphics-symbol]"),f=a.map(m=>({domainValue:this.services.cartesianScales.getDomainValue(m),originalData:m})).filter(m=>eD(m.domainValue,u));if(this.pointsWithinLine&&f.length===this.pointsWithinLine.length&&f.map(m=>m.domainValue).join()===this.pointsWithinLine.map(m=>m.domainValue).join())return this.pointsWithinLine=f,this.services.events.dispatchEvent(T.Tooltip.MOVE,{mousePosition:[n,r]});this.pointsWithinLine=f;const g=this.pointsWithinLine.reduce((m,v)=>{if(m.length===0)return m.push(v),m;const x=m[0].domainValue,_=Math.abs(u-v.domainValue),E=Math.abs(u-x);return _>E||(_<E?m=[v]:m.push(v)),m},[]);if(g.length>0){const m=g.map(E=>E.originalData).filter(E=>{const b=this.services.cartesianScales.getRangeIdentifier(E);return E[b]!=null}),v=g.map(E=>E.domainValue),x=p.filter(E=>{const b=this.services.cartesianScales.getDomainValue(E);return v.includes(b)});this.elementsToHighlight&&this.elementsToHighlight.size()>0&&!em(this.elementsToHighlight,x)&&this.hideRuler(),x.dispatch("mouseover"),this.elementsToHighlight=x,this.services.events.dispatchEvent(T.Tooltip.SHOW,{event:t,mousePosition:[n,r],hoveredElement:h,data:this.formatTooltipData(m)}),d.attr("opacity",1);const _=g[0];s==="horizontal"?h.attr("x1",c).attr("x2",l).attr("y1",_.domainValue).attr("y2",_.domainValue):h.attr("y1",c).attr("y2",l).attr("x1",_.domainValue).attr("x2",_.domainValue)}else this.hideRuler()}hideRuler(){const t=this.parent,n=N.appendOrSelect(t,"g.ruler");t.selectAll("[role=graphics-symbol]").dispatch("mouseout"),this.services.events.dispatchEvent(T.Tooltip.HIDE),n.attr("opacity",0)}addBackdropEventListeners(){this.isEventListenerAdded=!0;const t=this,n=this.services.domUtils.getHolder(),r=this.model.getDisplayData();let i=function(s){const a=nr(s,t.parent.node());t.showRuler(s,a)};if(r.length>100){const s=r.length%50*12.5;i=QT(function(a){const{mousePosition:o}=this;t.showRuler(a,o)},s,n)}this.backdrop.on("mousemove mouseover",i).on("mouseout",this.hideRuler.bind(this))}drawBackdrop(){const t=this.parent;this.backdrop=N.appendOrSelect(t,"svg.chart-grid-backdrop")}}class un extends gt{constructor(){super(...arguments),this.type="scatter",this.renderType=rt.SVG,this.handleChartHolderOnHover=()=>{if(!this.parent)throw new Error("Parent not defined");this.parent.selectAll("circle.dot").transition("chart-holder-hover-scatter").call(t=>this.services.transitions?.setupTransition({transition:t,name:"chart-holder-hover-scatter"})).attr("opacity",1)},this.handleChartHolderOnMouseOut=()=>{if(!this.parent)throw new Error("Parent not defined");this.parent.selectAll("circle.dot").transition("chart-holder-mouseout-scatter").call(t=>this.services.transitions?.setupTransition({transition:t,name:"chart-holder-mouseout-scatter"})).attr("opacity",0)},this.handleLegendOnHover=t=>{const{hoveredElement:n}=t.detail,{groupMapsTo:r}=this.getOptions().data;if(!this.parent)throw new Error("Parent not defined");this.parent.selectAll("circle.dot").transition("legend-hover-scatter").call(i=>this.services.transitions?.setupTransition({transition:i,name:"legend-hover-scatter"})).attr("opacity",i=>i[r]!==n.datum().name?.3:1)},this.handleLegendMouseOut=()=>{if(!this.parent)throw new Error("Parent not defined");this.parent.selectAll("circle.dot").transition("legend-mouseout-scatter").call(t=>this.services.transitions?.setupTransition({transition:t,name:"legend-mouseout-scatter"})).attr("opacity",1)}}init(){const{events:t}=this.services;if(!t)throw new Error("Services events are undefined.");t.addEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.addEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut);const{fadeInOnChartHolderMouseover:n}=this.configs;n&&(t.addEventListener(T.Chart.MOUSEOVER,this.handleChartHolderOnHover),t.addEventListener(T.Chart.MOUSEOUT,this.handleChartHolderOnMouseOut))}filterBasedOnZoomDomain(t){const{cartesianScales:n}=this.services;if(!n)throw new Error("Services cartesianScales are undefined.");const r=n.getDomainIdentifier(t),i=this.model.get("zoomDomain");return i!==void 0?t.filter(s=>s[r].getTime()>=i[0].getTime()&&s[r].getTime()<=i[1].getTime()):t}getScatterData(){const t=this.getOptions(),{stacked:n}=this.configs;let r;if(n){const i=Object.keys(t.axes).some(s=>t.axes[s].percentage);r=this.model.getStackedData({groups:this.configs.groups,percentage:i})}else{const{cartesianScales:i}=this.services;if(!i)throw new Error("Services cartesianScales are undefined.");r=this.model.getDisplayData(this.configs.groups).filter(s=>{const a=i.getRangeIdentifier(s);return s[a]!==void 0&&s[a]!==null})}return this.filterBasedOnZoomDomain(r)}render(t){if(!(y(this.getOptions(),"points","enabled")||y(this.getOptions(),"bubble","enabled")))return;const n=this.services.zoom?.isZoomBarEnabled()||!1,r=this.getComponentContainer({ariaLabel:"scatter points",withinChartClip:n}),i=this.getOptions(),{groupMapsTo:s}=i.data,{cartesianScales:a}=this.services;if(!a)throw new Error("Services cartesianScales are undefined.");const o=a.getDomainIdentifier(),l=r.selectAll("circle.dot").data(this.getScatterData(),u=>`${u[s]}-${u[o]}`);l.exit().attr("opacity",0).remove();const c=l.enter().append("circle").classed("dot",!0).attr("opacity",0).merge(l);this.styleCircles(c,t),this.addEventListeners()}isDatapointThresholdAnomaly(t){const{handleThresholds:n}=this.configs;if(!n)return!1;const{cartesianScales:r}=this.services;if(!r)throw new Error("Cartesian scales service is undefined");const i=r.getOrientation(),[s,a]=_n(r.getHighestDomainThreshold(),r.getHighestRangeThreshold(),i),[o,l]=_n(d=>r.getDomainValue(d),d=>r.getRangeValue(d),i),c=o(t),u=l(t);return a&&s?u<=a.scaleValue&&c>=s.scaleValue:a?u<=a.scaleValue:s?c>=s.scaleValue:!1}styleCircles(t,n){const r=this.getOptions(),{filled:i,fillOpacity:s}=r.points,{cartesianScales:a}=this.services;if(!a)throw new Error("Cartesian scales service is undefined");const{groupMapsTo:o}=r.data,l=p=>a.getDomainValue(p),c=p=>a.getRangeValue(p),[u,d]=_n(l,c,a.getOrientation()),{fadeInOnChartHolderMouseover:h}=this.configs;t.raise().classed("dot",!0).attr("class",p=>{const f=a.getDomainIdentifier(p),g=this.model.getIsFilled(p[o],p[f],p,i)?[st.FILL,st.STROKE]:[st.STROKE];return this.model.getColorClassName({classNameTypes:g,dataGroupName:p[o],originalClassName:"dot"})||""}).classed("threshold-anomaly",p=>this.isDatapointThresholdAnomaly(p)).classed("filled",p=>{const f=a.getDomainIdentifier(p);return this.model.getIsFilled(p[o],p[f],p,i)}).classed("unfilled",p=>{const f=a.getDomainIdentifier(p);return!this.model.getIsFilled(p[o],p[f],p,i)}).transition().call(p=>this.services.transitions?.setupTransition({transition:p,name:"scatter-update-enter",animate:n})).attr("cx",u).attr("cy",d).attr("r",r.points.radius).style("fill",p=>{const f=a.getDomainIdentifier(p);if(this.model.getIsFilled(p[o],p[f],p,i))return this.model.getFillColor(p[o],p[f],p)}).style("stroke",p=>{const f=a.getDomainIdentifier(p);return this.model.getStrokeColor(p[o],p[f],p)}).attr("fill-opacity",i?s:1).attr("opacity",h?0:1).attr("role",dt.GRAPHICS_SYMBOL).attr("aria-roledescription","point").attr("aria-label",p=>{const f=a.getRangeIdentifier(p);return p[f]}),this.addEventListeners()}getTooltipAdditionalItems(t){return null}addEventListeners(){const t=this,{groupMapsTo:n}=t.getOptions().data,r=y(this.getOptions(),"tooltip","alwaysShowRulerTooltip");if(!this.parent)throw new Error("Parent not defined");const i=this.parent.selectAll("circle");r?i.style("pointer-events","none"):i.style("pointer-events",null),i.on("mouseover",function(s,a){const o=I(this);o.classed("hovered",!0).attr("class",l=>t.model.getColorClassName({classNameTypes:[st.FILL],dataGroupName:l[n],originalClassName:o.attr("class")})).style("fill",l=>{const c=t.services.cartesianScales?.getDomainIdentifier(l);return t.model.getFillColor(l[n],l[c],l)}).classed("unfilled",!1),r||t.services.events?.dispatchEvent(T.Tooltip.SHOW,{event:s,hoveredElement:o,data:[a],additionalItems:t.getTooltipAdditionalItems(a)}),t.services.events?.dispatchEvent(T.Scatter.SCATTER_MOUSEOVER,{event:s,element:o,datum:a})}).on("mousemove",function(s,a){const o=I(this);t.services.events?.dispatchEvent(T.Scatter.SCATTER_MOUSEMOVE,{event:s,element:o,datum:a}),t.services.events?.dispatchEvent(T.Tooltip.MOVE,{event:s})}).on("click",function(s,a){t.services.events?.dispatchEvent(T.Scatter.SCATTER_CLICK,{event:s,element:I(this),datum:a})}).on("mouseout",function(s,a){const o=I(this);if(o.classed("hovered",!1),!t.configs.filled){const{filled:l}=t.getOptions().points,c=t.services.cartesianScales?.getDomainIdentifier(a),u=t.model.getIsFilled(a[n],a[c],a,l);o.classed("unfilled",!u).style("fill",d=>u||l?t.model.getFillColor(d[n],d[c],d):null)}t.services.events?.dispatchEvent(T.Scatter.SCATTER_MOUSEOUT,{event:s,element:o,datum:a}),t.services.events?.dispatchEvent(T.Tooltip.HIDE,{hoveredElement:o})})}destroy(){this.parent?.selectAll("circle").on("mousemove",null).on("mouseout",null);const{events:t}=this.services;if(!t)throw new Error("Services events undefined");t.removeEventListener(T.Legend.ITEM_HOVER,this.handleLegendOnHover),t.removeEventListener(T.Legend.ITEM_MOUSEOUT,this.handleLegendMouseOut),t.removeEventListener(T.Chart.MOUSEOVER,this.handleChartHolderOnHover),t.removeEventListener(T.Chart.MOUSEOUT,this.handleChartHolderOnMouseOut)}}class Gg extends gt{constructor(t,n,r){super(t,n,r),this.type="axes",this.renderType=rt.SVG,this.truncation={[V.LEFT]:!1,[V.RIGHT]:!1,[V.TOP]:!1,[V.BOTTOM]:!1},r&&(this.configs=r),this.margins=this.configs.margins}render(t=!0){const{position:n}=this.configs,r=this.getOptions(),i=y(r,"axes",n,"visible"),s=this.getComponentContainer({ariaLabel:"axes"}),{width:a,height:o}=N.getSVGElementSize(s,{useAttrs:!0}),l=N.appendOrSelect(s,`g.axis.${n}`);let c,u;if(n===V.BOTTOM||n===V.TOP?(c=this.configs.axes[V.LEFT]?this.margins.left:0,u=this.configs.axes[V.RIGHT]?a-this.margins.right:a):(c=o-this.margins.bottom,u=this.margins.top),!this.services.cartesianScales)throw new Error("Services cartesianScales undefined");const d=this.services.cartesianScales.getScaleByPosition(n);this.scaleType===nt.LABELS||this.scaleType===nt.LABELS_RATIO?d.rangeRound([c,u]):d.range([c,u]);let h;switch(n){case V.LEFT:h=im;break;case V.BOTTOM:h=gc;break;case V.RIGHT:h=IC;break;case V.TOP:h=RC;break}l.attr("aria-label",`${n} axis`);const p=!l.select("g.ticks").empty();let f=N.appendOrSelect(l,"g.ticks");p||(f.attr("role",`${dt.GRAPHICS_OBJECT} ${dt.GROUP}`),f.attr("aria-label",`${n} ticks`));const g=N.appendOrSelect(l,"g.ticks.invisible").style("opacity","0").style("pointer-events","none").attr("aria-hidden",!0).attr("aria-label",`invisible ${n} ticks`),m=y(r,"axes",n),v=this.scaleType===nt.TIME||m.scaleType===nt.TIME,x=n===V.LEFT||n===V.RIGHT,_=this.model.get("zoomDomain");if(_&&v&&!x&&d.domain(_),!i){f.attr("aria-hidden",!0);return}const E=y(m,"scaleType"),b=y(r,"data","loading"),S=y(m,"ticks","number"),M=y(m,"ticks","values"),k=y(m,"truncation","type"),A=y(m,"truncation","threshold"),R=y(m,"truncation","numCharacter"),C=S!==null,H=y(r,"timeScale"),P=N.appendOrSelect(g,"g.tick"),B=N.appendOrSelect(P,"text").text("0"),O=N.getSVGElementSize(B.node(),{useBBox:!0}).height;P.remove();const $=this.scaleType||m.scaleType||nt.LINEAR,L=h(d).tickSizeOuter(0);if(d.ticks){let Y;if(C?Y=S:(Y=Pn.ticks.number,x&&(Y=this.getNumberOfFittingTicks(o,O,Pn.ticks.verticalSpaceRatio))),d.ticks().length===1&&d.ticks()[0]===0&&(Y=0),L.ticks(Y),v)if(!d.ticks(Y).length)L.tickValues([]);else{const et=y(r,"timeScale","addSpaceOnEdges"),at=y(r,"axes",n,"domain"),z=d.copy();et&&!at&&z.nice(Y);const q=z.ticks(Y);et&&q.length>2&&!at&&(q.splice(q.length-1,1),q.splice(0,1)),L.tickValues(q)}}let D;const U=y(m,"ticks","formatter"),{code:Q,number:W}=y(r,"locale");if(v){const Y=ql(L.tickValues(),y(r,"timeScale","timeInterval"));U===null?D=(et,at)=>Wl(et,at,L.tickValues(),Y,H,r.locale):D=(et,at)=>{const z=Wl(et,at,L.tickValues(),Y,H,r.locale);return U(et,at,z)}}else U===null?$===nt.LINEAR&&(D=Y=>W(Y,Q)):D=U;L.tickFormat(D);const[j,X]=this.services.cartesianScales.getScaleByPosition(n).domain();let ct;if(M){if(v)M.forEach((Y,et)=>{Y.getTime===void 0&&(M[et]=new Date(Y))}),ct=M.filter(Y=>{const et=Y.getTime();return et>=new Date(j).getTime()&&et<=new Date(X).getTime()});else if(E===nt.LABELS){const Y=this.services.cartesianScales.getScaleByPosition(n).domain();ct=M.filter(et=>Y.includes(et))}else ct=M.filter(Y=>Y>=j&&Y<=X);L.tickValues(ct)}switch(n){case V.LEFT:f.attr("transform",`translate(${this.margins.left}, 0)`);break;case V.BOTTOM:f.attr("transform",`translate(0, ${o-this.margins.bottom})`);break;case V.RIGHT:f.attr("transform",`translate(${a-this.margins.right}, 0)`);break;case V.TOP:f.attr("transform",`translate(0, ${this.margins.top})`);break}const tt=this.model.isDataEmpty();if(m.title){const Y=N.appendOrSelect(l,"text.axis-title").html(tt||b?"":cn(m.title)),et=y(m,"titleOrientation");let at;switch(n){case V.LEFT:et===ks.RIGHT?Y.attr("transform","rotate(90)").attr("y",0).attr("x",d.range()[0]/2).attr("dy","-0.5em").style("text-anchor","middle"):Y.attr("transform","rotate(-90)").attr("y",0).attr("x",-(d.range()[0]/2)).attr("dy","0.75em").style("text-anchor","middle");break;case V.BOTTOM:const z=o-bp;Y.attr("transform",`translate(${this.margins.left/2+d.range()[1]/2}, ${z})`);break;case V.RIGHT:et===ks.LEFT?Y.attr("transform","rotate(-90)").attr("y",a).attr("x",-(d.range()[0]/2)).style("text-anchor","middle"):Y.attr("transform","rotate(90)").attr("y",-a).attr("x",d.range()[0]/2).attr("dy","0.75em").style("text-anchor","middle");break;case V.TOP:at=N.getSVGElementSize(Y,{useBBox:!0}).height,Y.attr("transform",`translate(${this.margins.left/2+d.range()[1]/2}, ${at/2})`).style("text-anchor","middle");break}}if(v){const Y=ql(L.tickValues(),y(r,"timeScale","timeInterval")),et=H.showDayName,at=f;t&&(f=f.transition().call(z=>this.services.transitions.setupTransition({transition:z,name:"axis-update",animate:t}))),f=f.call(L),at.selectAll(".tick").data(L.tickValues(),d).order().select("text").attr("class",(z,q)=>Bp(z,q,L.tickValues(),Y,et)?"tick-label--primary":"tick-label")}else!t||!p?f=f.call(L):f=f.transition().call(Y=>this.services.transitions.setupTransition({transition:Y,name:"axis-update",animate:t})).call(L);if(g.call(L),n===V.BOTTOM||n===V.TOP){let Y=!1;const et=y(m,"ticks","rotation");if(et===vi.ALWAYS)Y=!0;else if(et===vi.NEVER)Y=!1;else if(!et||et===vi.AUTO)if(d.step)Y=g.selectAll("g.tick text").nodes().some(at=>N.getSVGElementSize(at,{useBBox:!0}).width>=d.step());else{Y=!1;const at=g.append("text").text("A"),z=N.getSVGElementSize(at.node(),{useBBox:!0}).width;let q;g.selectAll("g.tick").each(function(){const Z=I(this),F=parseFloat(y(xn(this),"tx"));F!==null&&q+Z.text().length*z*.8>=F&&(Y=!0),q=F}),at.remove()}Y?(C||(L.ticks(this.getNumberOfFittingTicks(a,O,Pn.ticks.horizontalSpaceRatio)),g.call(L),f.call(L)),l.selectAll("g.ticks g.tick text").attr("transform","rotate(-45)").attr("text-anchor",n===V.TOP?"start":"end")):l.selectAll("g.ticks g.tick text").attr("transform",null).attr("text-anchor",null)}if(b?l.attr("opacity",0):l.attr("opacity",1),f.selectAll("g.tick").attr("aria-label",Y=>Y),g.selectAll("g.tick").attr("aria-label",Y=>Y),k!==$e.NONE&&E===nt.LABELS&&!M){const Y=this.services.cartesianScales.getScaleDomain(n);if(Y.length>0){const et=s.select(`g.axis.${n} g.ticks g.tick`).html();l.selectAll("g.ticks g.tick").html(et);const at=this;l.selectAll("g.tick text").data(Y).text(function(z){return z.length>A?(at.truncation[n]=!0,Yi(z,k,R)):z}),this.getInvisibleAxisRef().selectAll("g.tick text").data(Y).text(function(z){return z.length>A?Yi(z,k,R):z}),l.selectAll("g.ticks").html(this.getInvisibleAxisRef().html()),l.selectAll("g.tick text").data(Y)}}this.addEventListeners()}addEventListeners(){const t=this.getComponentContainer(),{position:n}=this.configs,r=N.appendOrSelect(t,`g.axis.${n}`),i=this.getOptions(),s=y(i,"axes",n),a=y(s,"scaleType"),o=y(s,"truncation","threshold"),l=this;r.selectAll("g.tick text").on("mouseover",function(c,u){l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEOVER,{event:c,element:I(this),datum:u}),a===nt.LABELS&&u.length>o&&l.services.events.dispatchEvent(T.Tooltip.SHOW,{event:c,hoveredElement:I(this),content:u})}).on("mousemove",function(c,u){l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEMOVE,{event:c,element:I(this),datum:u}),a===nt.LABELS&&u.length>o&&l.services.events.dispatchEvent(T.Tooltip.MOVE,{event:c})}).on("click",function(c,u){l.services.events.dispatchEvent(T.Axis.LABEL_CLICK,{event:c,element:I(this),datum:u})}).on("mouseout",function(c,u){l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEOUT,{event:c,element:I(this),datum:u}),a===nt.LABELS&&l.services.events.dispatchEvent(T.Tooltip.HIDE)})}getInvisibleAxisRef(){const{position:t}=this.configs;return this.getComponentContainer().select(`g.axis.${t} g.ticks.invisible`)}getTitleRef(){const{position:t}=this.configs;return this.getComponentContainer().select(`g.axis.${t} text.axis-title`)}getNumberOfFittingTicks(t,n,r){const i=Math.floor(t/(n*r));return tm(i,2,Pn.ticks.number)}destroy(){const t=this.getComponentContainer(),{position:n}=this.configs;N.appendOrSelect(t,`g.axis.${n}`).selectAll("g.tick text").on("mouseover",null).on("mousemove",null).on("mouseout",null)}}class nD extends Gg{constructor(t,n,r){super(t,n,r)}render(t=!0){super.render(t),super.destroy();const n=this.configs.position,r=this.getComponentContainer({ariaLabel:"axes"}),i=N.appendOrSelect(r,`g.axis.${n}`),s=this;i.selectAll("g.tick").each(function(a,o){const l=I(this);l.classed("tick-hover",!0).attr("role","button").attr("tabindex",o===0?0:-1);const c=l.select("text"),{width:u,height:d}=N.getSVGElementSize(c,{useBBox:!0}),h=N.appendOrSelect(l,"rect.axis-holder");let p=0,f=0;switch(n){case V.LEFT:p=-u+Number(c.attr("x")),f=-(d/2);break;case V.RIGHT:p=Math.abs(Number(c.attr("x"))),f=-(d/2);break;case V.TOP:p=-(u/2),f=-d+Number(c.attr("y"))/2,s.truncation[n]&&(p=0,h.attr("transform","rotate(-45)"));break;case V.BOTTOM:p=-(u/2),f=d/2-2,s.truncation[n]&&(p=-u,h.attr("transform","rotate(-45)"));break}h.attr("x",p-Pn.hover.rectanglePadding).attr("y",f).attr("width",u+Pn.hover.rectanglePadding*2).attr("height",d).lower()}),this.addEventListeners()}addEventListeners(){const t=this.getComponentContainer(),{position:n}=this.configs,r=N.appendOrSelect(t,`g.axis.${n}`),i=this.getOptions(),s=y(i,"axes",n),a=y(s,"scaleType"),o=y(s,"truncation","threshold"),l=this;r.selectAll("g.tick.tick-hover").on("mouseover",function(c){const u=I(this).select("text"),d=u.datum();l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEOVER,{event:c,element:u,datum:d}),a===nt.LABELS&&d.length>o&&l.services.events.dispatchEvent(T.Tooltip.SHOW,{event:c,element:u,datum:d})}).on("mousemove",function(c){const u=I(this).select("text"),d=u.datum();l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEMOVE,{event:c,element:u,datum:d}),l.services.events.dispatchEvent(T.Tooltip.MOVE,{event:c})}).on("click",function(c){l.services.events.dispatchEvent(T.Axis.LABEL_CLICK,{event:c,element:I(this).select("text"),datum:I(this).select("text").datum()})}).on("mouseout",function(c){l.services.events.dispatchEvent(T.Axis.LABEL_MOUSEOUT,{event:c,element:I(this).select("text"),datum:I(this).select("text").datum()}),a===nt.LABELS&&l.services.events.dispatchEvent(T.Tooltip.HIDE)}).on("focus",function(c){const u={clientX:0,clientY:0};if(c.target){c.target.focus();const d=c.target.getBoundingClientRect();u.clientX=d.x,u.clientY=d.y}l.services.events.dispatchEvent(T.Axis.LABEL_FOCUS,{event:{...c,...u},element:I(this),datum:I(this).select("text").datum()})}).on("blur",function(c){l.services.events.dispatchEvent(T.Axis.LABEL_BLUR,{event:c,element:I(this),datum:I(this).select("text").datum()})}).on("keydown",function(c){c.key&&c.key==="Escape"&&(l.services.events.dispatchEvent(T.Tooltip.HIDE),l.services.events.dispatchEvent(T.Axis.LABEL_BLUR,{event:c,element:I(this),datum:I(this).select("text").datum()})),n===V.LEFT||n===V.RIGHT?c.key&&c.key==="ArrowUp"?l.goNext(this,c):c.key&&c.key==="ArrowDown"&&l.goPrevious(this,c):c.key&&c.key==="ArrowLeft"?l.goPrevious(this,c):c.key&&c.key==="ArrowRight"&&l.goNext(this,c)})}goNext(t,n){t.nextElementSibling&&t.nextElementSibling.tagName!=="path"&&t.nextElementSibling.dispatchEvent(new Event("focus")),n.preventDefault()}goPrevious(t,n){t.previousElementSibling&&t.previousElementSibling.tagName!=="path"&&t.previousElementSibling.dispatchEvent(new Event("focus")),n.preventDefault()}destroy(){const t=this.getComponentContainer(),{position:n}=this.configs;N.appendOrSelect(t,`g.axis.${n}`).selectAll("g.tick.tick-hover").on("mouseover",null).on("mousemove",null).on("mouseout",null).on("focus",null).on("blur",null)}}class ge extends gt{constructor(){super(...arguments),this.type="2D-axes",this.renderType=rt.SVG,this.children={},this.thresholds=[],this.margins={top:0,right:0,bottom:0,left:0}}render(t=!1){const n={},r=Object.keys(V),i=y(this.getOptions(),"axes");r.forEach(a=>{i[V[a]]&&(n[V[a]]=!0)}),this.configs.axes=n,r.forEach(a=>{const o=V[a];if(this.configs.axes[o]&&!this.children[o]){const l={position:o,axes:this.configs.axes,margins:this.margins},c=this.model.axisFlavor===bi.DEFAULT?new Gg(this.model,this.services,l):new nD(this.model,this.services,l);c.setModel(this.model),c.setServices(this.services),c.setParent(this.parent),this.children[o]=c}}),Object.keys(this.children).forEach(a=>{this.children[a].render(t)});const s={};Object.keys(this.children).forEach(a=>{const o=this.children[a],l=o.configs.position,c=o.getInvisibleAxisRef(),{width:u,height:d}=N.getSVGElementSize(c,{useBBox:!0});let h=0;if(!o.getTitleRef().empty()){const g=N.getSVGElementSize(o.getTitleRef(),{useBBox:!0}).height;l===V.LEFT||l===V.RIGHT?h=g+5:l===V.BOTTOM?h=g+bp:h=g}const p=u,f=d;switch(l){case V.TOP:s.top=f+h;break;case V.BOTTOM:s.bottom=f+h;break;case V.LEFT:s.left=p+h;break;case V.RIGHT:s.right=p+h;break}}),this.services.events.dispatchEvent(T.Axis.RENDER_COMPLETE),Object.keys(s).some(a=>this.margins[a]!==s[a])&&(this.margins=Object.assign(this.margins,s),this.model.set({axesMargins:this.margins},{skipUpdate:!0}),this.services.events.dispatchEvent(T.ZoomBar.UPDATE),Object.keys(this.children).forEach(a=>{const o=this.children[a];o.margins=this.margins}),this.render(!0))}}class ue extends gt{constructor(){super(...arguments),this.type="skeleton"}render(t=!0){const n=y(this.getOptions(),"data","loading");n?this.renderSkeleton(n):this.removeSkeleton()}renderSkeleton(t){if(this.configs.skeleton===jt.GRID)this.renderGridSkeleton(t);else if(this.configs.skeleton===jt.VERT_OR_HORIZ)this.renderVertOrHorizSkeleton(t);else if(this.configs.skeleton===jt.PIE)this.renderPieSkeleton(t);else if(this.configs.skeleton===jt.DONUT)this.renderDonutSkeleton(t);else throw new Error(`"${this.configs.skeleton}" is not a valid Skeleton type.`)}renderGridSkeleton(t){this.setScales(),this.drawBackdrop(t),this.drawXGrid(t),this.drawYGrid(t),t&&this.setShimmerEffect("shimmer-lines")}renderVertOrHorizSkeleton(t){const n=this.services.cartesianScales.getOrientation();this.setScales(),this.drawBackdrop(t),n===Ft.VERTICAL&&this.drawYGrid(t),n===Ft.HORIZONTAL&&this.drawXGrid(t),this.setShimmerEffect("shimmer-lines")}renderPieSkeleton(t){const n=this.computeOuterRadius();this.drawRing(n,0,t),t&&this.setShimmerEffect("shimmer-areas")}renderDonutSkeleton(t){const n=this.computeOuterRadius(),r=this.computeInnerRadius();this.drawRing(n,r,t),t&&this.setShimmerEffect("shimmer-areas")}setScales(){const t=this.services.cartesianScales.getMainXScale().range(),n=this.services.cartesianScales.getMainYScale().range();this.xScale=je().domain([0,1]).range(t),this.yScale=je().domain([0,1]).range(n)}drawBackdrop(t){const n=this.parent,{width:r,height:i}=N.getSVGElementSize(n,{useAttrs:!0});this.backdrop=N.appendOrSelect(n,"svg.chart-skeleton.DAII").attr("role","presentation").attr("width",r).attr("height",i);const s=N.appendOrSelect(this.backdrop,"rect.chart-skeleton-backdrop");s.attr("width","100%").attr("height","100%");const[a]=this.xScale.range(),[,o]=this.yScale.range();this.backdrop.merge(s).attr("x",a).attr("y",o),s.classed("shimmer-effect-lines",t).classed("empty-state-lines",!t).style("stroke",t?`url(#${this.services.domUtils.generateElementIDString("shimmer-lines")})`:null)}drawXGrid(t){const n=+this.backdrop.attr("width"),r=y(this.getOptions(),"grid","x","numberOfTicks"),i=this.xScale.ticks(r).map(o=>o*n),s=N.appendOrSelect(this.backdrop,"g.x.skeleton"),a=s.selectAll("line").data(i);a.enter().append("line").merge(a).attr("x1",o=>o).attr("x2",o=>o).attr("y1",0).attr("y2","100%"),s.selectAll("line").classed("shimmer-effect-lines",t).classed("empty-state-lines",!t).style("stroke",t?`url(#${this.services.domUtils.generateElementIDString("shimmer-lines")})`:null)}drawYGrid(t){const n=+this.backdrop.attr("height"),r=this.backdrop.attr("width"),i=y(this.getOptions(),"grid","y","numberOfTicks"),s=this.xScale.ticks(i).map(l=>l*n),a=N.appendOrSelect(this.backdrop,"g.y.skeleton"),o=a.selectAll("line").data(s);o.enter().append("line").merge(o).attr("x1",0).attr("x2",r).attr("y1",l=>l).attr("y2",l=>l),a.selectAll("line").classed("shimmer-effect-lines",t).classed("empty-state-lines",!t).style("stroke",t?`url(#${this.services.domUtils.generateElementIDString("shimmer-lines")})`:null)}drawRing(t,n,r=!0){const i=this.parent,{width:s,height:a}=N.getSVGElementSize(i,{useAttrs:!0}),o=N.appendOrSelect(i,"svg.chart-skeleton").attr("width",s).attr("height",a).attr("role","presentation"),l=n===0?"pie":"donut",c=y(this.getOptions(),l,"alignment");N.appendOrSelect(o,"rect.chart-skeleton-area-container").attr("width",s).attr("height",a).attr("fill","none");const u=vs().innerRadius(n).outerRadius(t).startAngle(0).endAngle(Math.PI*2),d=t+Math.abs(kt.radiusOffset),h=t+(Math.min(s,a)-t*2)/2,p=N.appendOrSelect(o,"path").attr("class","skeleton-area-shape").attr("transform",`translate(${d}, ${h})`).attr("d",u).classed("shimmer-effect-areas",r).classed("empty-state-areas",!r).style("fill",r?`url(#${this.services.domUtils.generateElementIDString("shimmer-areas")})`:null);let f=t+kt.xOffset;c===zt.CENTER?f=s/2:c===zt.RIGHT&&(f=s-t-kt.xOffset);const g=t+kt.yOffset;p.attr("transform",`translate(${f}, ${g})`)}computeOuterRadius(){const{width:t,height:n}=N.getSVGElementSize(this.parent,{useAttrs:!0});return Math.min(t,n)/2+kt.radiusOffset}computeInnerRadius(){return this.computeOuterRadius()*(3/4)}setShimmerEffect(t){const n="stop-bg-shimmer",r="stop-shimmer",i=this.parent.select(".chart-skeleton"),{width:s}=N.getSVGElementSize(this.parent,{useAttrs:!0}),a=0,o=s,l=N.appendOrSelect(i,"defs").lower(),c=N.appendOrSelect(l,"linearGradient").attr("id",this.services.domUtils.generateElementIDString(t)).attr("class",t).attr("x1",a-3*.2*s).attr("x2",o).attr("y1",0).attr("y2",0).attr("gradientUnits","userSpaceOnUse").attr("gradientTransform","translate(0, 0)"),u=`
|
|
67
67
|
<stop class="${n}" offset="${a}"></stop>
|
|
68
68
|
<stop class="${r}" offset="${a+.2}"></stop>
|
|
69
69
|
<stop class="${n}" offset="${a+2*.2}"></stop>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/charts-react",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.10",
|
|
4
4
|
"description": "Carbon Charts component library for React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"format": "prettier . --write --ignore-path ../../.prettierignore"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@carbon/charts": "1.27.
|
|
41
|
+
"@carbon/charts": "1.27.10",
|
|
42
42
|
"@carbon/icons-react": "^11.64.0",
|
|
43
43
|
"@ibm/telemetry-js": "^1.9.1"
|
|
44
44
|
},
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"url": "https://github.com/theiliad"
|
|
121
121
|
}
|
|
122
122
|
],
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "27017f088ef66fb4131d9aeddeb3db9fa7496d3f"
|
|
124
124
|
}
|