@carbon/charts 1.11.8 → 1.11.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{_baseEach-9b6a12fa.mjs → _baseEach-c7ca68a6.mjs} +2 -2
  3. package/dist/{_baseEach-9b6a12fa.mjs.map → _baseEach-c7ca68a6.mjs.map} +1 -1
  4. package/dist/{_baseEach-326db134.js → _baseEach-e8e98018.js} +2 -2
  5. package/dist/{_baseEach-326db134.js.map → _baseEach-e8e98018.js.map} +1 -1
  6. package/dist/{angle-utils-264ed176.mjs → angle-utils-7efc92a5.mjs} +2 -2
  7. package/dist/angle-utils-7efc92a5.mjs.map +1 -0
  8. package/dist/{angle-utils-ccc0d890.js → angle-utils-a22da679.js} +2 -2
  9. package/dist/angle-utils-a22da679.js.map +1 -0
  10. package/dist/axis-chart.d.ts +1 -1
  11. package/dist/chart.d.ts +1 -1
  12. package/dist/charts/choropleth.d.ts +1 -1
  13. package/dist/charts/heatmap.d.ts +1 -1
  14. package/dist/{choropleth-300f112d.js → choropleth-16598e45.js} +4 -4
  15. package/dist/choropleth-16598e45.js.map +1 -0
  16. package/dist/{choropleth-9123f871.mjs → choropleth-8d45a771.mjs} +4 -4
  17. package/dist/choropleth-8d45a771.mjs.map +1 -0
  18. package/dist/color-scale-utils-56bbe3f2.js +2 -0
  19. package/dist/color-scale-utils-56bbe3f2.js.map +1 -0
  20. package/dist/{color-scale-utils-b9604b2c.mjs → color-scale-utils-a737b2e5.mjs} +908 -910
  21. package/dist/color-scale-utils-a737b2e5.mjs.map +1 -0
  22. package/dist/components/axes/grid.d.ts +1 -1
  23. package/dist/components/component.d.ts +1 -1
  24. package/dist/components/index.js +1 -1
  25. package/dist/components/index.mjs +4 -4
  26. package/dist/demo/index.js +11 -15
  27. package/dist/demo/index.js.map +1 -1
  28. package/dist/demo/index.mjs +226 -228
  29. package/dist/demo/index.mjs.map +1 -1
  30. package/dist/demo/styles.css +8648 -8900
  31. package/dist/demo/styles.css.map +1 -1
  32. package/dist/{index-4b5d1e49.mjs → index-daeaa9f4.mjs} +28 -28
  33. package/dist/index-daeaa9f4.mjs.map +1 -0
  34. package/dist/{index-eace9da9.js → index-e014597a.js} +2 -2
  35. package/dist/index-e014597a.js.map +1 -0
  36. package/dist/index.js +1 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +8 -8
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/model/index.js +2 -2
  41. package/dist/model/index.js.map +1 -1
  42. package/dist/model/index.mjs +117 -117
  43. package/dist/model/index.mjs.map +1 -1
  44. package/dist/model/model.d.ts +1 -1
  45. package/dist/services/index.js +1 -1
  46. package/dist/services/index.mjs +4 -4
  47. package/dist/tools.d.ts +5 -8
  48. package/package.json +21 -21
  49. package/dist/angle-utils-264ed176.mjs.map +0 -1
  50. package/dist/angle-utils-ccc0d890.js.map +0 -1
  51. package/dist/choropleth-300f112d.js.map +0 -1
  52. package/dist/choropleth-9123f871.mjs.map +0 -1
  53. package/dist/color-scale-utils-2cd523be.js +0 -2
  54. package/dist/color-scale-utils-2cd523be.js.map +0 -1
  55. package/dist/color-scale-utils-b9604b2c.mjs.map +0 -1
  56. package/dist/index-4b5d1e49.mjs.map +0 -1
  57. package/dist/index-eace9da9.js.map +0 -1
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../color-scale-utils-2cd523be.js"),y=require("d3"),D=require("../enums-aa2efd99.js"),b=require("../_baseEach-326db134.js");require("../index-d865d500.js");function A(g,t,e,s){for(var a=-1,r=g==null?0:g.length;++a<r;){var o=g[a];t(s,o,e(o),g)}return s}function O(g,t,e,s){return b.baseEach(g,function(a,r,o){t(s,a,e(a),o)}),s}function G(g,t){return function(e,s){var a=n.isArray(e)?A:O,r=t?t():{};return a(e,g,n.baseIteratee(s),r)}}function M(g){for(var t=-1,e=g==null?0:g.length,s={};++t<e;){var a=g[t];s[a[0]]=a[1]}return s}var E=Object.prototype,q=E.hasOwnProperty,I=G(function(g,t,e){q.call(g,e)?g[e].push(t):n.baseAssignValue(g,e,[t])});const _=I;class m{constructor(t){this.state={options:{}},this.colorScale={},this.colorClassNames={},this.services=t}getAllDataFromDomain(t){if(!this.getData())return null;const e=this.getOptions();let s=this.getData();const a=this.getDataGroups(),{groupMapsTo:r}=n.getProperty(e,"data"),o=n.getProperty(e,"axes");return t&&(s=s.filter(i=>t.includes(i[r]))),o&&Object.keys(o).forEach(i=>{const l=o[i].mapsTo,c=o[i].scaleType;if((c===D.ScaleTypes.LINEAR||c===D.ScaleTypes.LOG)&&(s=s.map(p=>({...p,[l]:p[l]===null?p[l]:Number(p[l])}))),l&&o[i].domain)if(c===D.ScaleTypes.LABELS)s=s.filter(p=>o[i].domain.includes(p[l]));else{const[p,u]=o[i].domain;s=s.filter(h=>!(l in h)||h[l]>=p&&h[l]<=u)}}),s.filter(i=>a.find(l=>l.name===i[r]))}getDisplayData(t){if(!this.get("data"))return null;const{ACTIVE:e}=n.legend.items.status,s=this.getDataGroups(t),{groupMapsTo:a}=this.getOptions().data;return this.getAllDataFromDomain(t).filter(o=>s.find(i=>i.name===o[a]&&i.status===e))}getData(){return this.get("data")}isDataEmpty(){return!this.getData().length}setData(t){const e=this.sanitize(n.clone(t)),s=this.generateDataGroups(e);return this.set({data:e,dataGroups:s}),e}getDataGroups(t){return n.getProperty(this.getOptions(),"data","loading")?[]:t?this.get("dataGroups").filter(s=>t.includes(s.name)):this.get("dataGroups")}getActiveDataGroups(t){const{ACTIVE:e}=n.legend.items.status;return this.getDataGroups(t).filter(s=>s.status===e)}getDataGroupNames(t){return this.getDataGroups(t).map(s=>s.name)}getActiveDataGroupNames(t){return this.getActiveDataGroups(t).map(s=>s.name)}aggregateBinDataByGroup(t){return _(t,"group")}getBinConfigurations(){const t=this.getDisplayData(),e=this.getOptions(),s=this.services.cartesianScales.getMainXAxisPosition(),a=this.services.cartesianScales.getDomainIdentifier(),r=e.axes[s],{groupMapsTo:o}=e.data,{bins:i=n.histogram.defaultBins}=r,l=Array.isArray(i),c=y.bin().value(d=>d[a]).thresholds(i)(t);if(l)c[c.length-1].x1=i[i.length-1];else{const d=c[0].x1-c[0].x0;c[c.length-1].x1=+c[c.length-1].x0+d}const p=l?[i[0],i[i.length-1]]:[c[0].x0,c[c.length-1].x1],u=Array.from(new Set(t.map(d=>d[o]))),h=[];return c.forEach(d=>{const f=`${d.x0}-${d.x1}`,C=this.aggregateBinDataByGroup(d);u.forEach(P=>{h.push({group:P,key:f,value:C[P]||0,bin:d.x0})})}),{bins:c,binsDomain:p}}getBinnedStackedData(){const t=this.getOptions(),{groupMapsTo:e}=t.data,s=this.getActiveDataGroupNames(),{bins:a}=this.getBinConfigurations(),r=this.getDataValuesGroupedByKeys({bins:a});return y.stack().keys(s)(r).map((o,i)=>Object.keys(o).filter(l=>!isNaN(l)).map(l=>{const c=o[l];return c[e]=s[i],c}))}getGroupedData(t){const e=this.getDisplayData(t),s={},{groupMapsTo:a}=this.getOptions().data;return e.map(r=>{const o=r[a];s[o]!==null&&s[o]!==void 0?s[o].push(r):s[o]=[r]}),Object.keys(s).map(r=>({name:r,data:s[r]}))}getStackKeys({bins:t=null,groups:e=null}={bins:null,groups:null}){const s=this.getOptions(),a=this.getDisplayData(e);let r;t?r=t.map(l=>`${l.x0}-${l.x1}`):r=n.removeArrayDuplicates(a.map(l=>{const c=this.services.cartesianScales.getDomainIdentifier(l);return l[c]instanceof Date?n.formatDateTillMilliSeconds(l[c]):l[c]&&typeof l[c].toString=="function"?l[c].toString():l[c]}));const o=this.services.cartesianScales.domainAxisPosition,i=s.axes[o].scaleType;return i===D.ScaleTypes.TIME?r.sort((l,c)=>{const p=new Date(l),u=new Date(c);return p-u}):(i===D.ScaleTypes.LOG||i===D.ScaleTypes.LINEAR)&&r.sort((l,c)=>l-c),r}getDataValuesGroupedByKeys({bins:t=null,groups:e=null}){const s=this.getOptions(),{groupMapsTo:a}=s.data,r=this.getDisplayData(e),o=this.getDataGroupNames(),i=this.getStackKeys({bins:t,groups:e});return t?i.map(l=>{const[c,p]=l.split("-"),u={x0:c,x1:p},h=t.find(d=>d.x0.toString()===c.toString());return o.forEach(d=>{u[d]=h.filter(f=>f[a]===d).length}),u}):i.map(l=>{const c={sharedStackKey:l};return o.forEach(p=>{const u=r.find(d=>{const f=this.services.cartesianScales.getDomainIdentifier(d);return d[a]===p&&Object.prototype.hasOwnProperty.call(d,f)&&(d[f]instanceof Date?n.formatDateTillMilliSeconds(d[f])===l:d[f].toString()===l)}),h=this.services.cartesianScales.getRangeIdentifier(c);c[p]=u?u[h]:null}),c})}getStackedData({percentage:t=!1,groups:e=null,divergent:s=!1}){const a=this.getOptions(),{groupMapsTo:r}=a.data,o=this.getActiveDataGroupNames(e),i=this.getDataValuesGroupedByKeys({groups:e});if(t){const c=M(i.map(p=>[p.sharedStackKey,0]));i.forEach(p=>{o.forEach(u=>{c[p.sharedStackKey]+=p[u]})}),i.forEach(p=>{o.forEach(u=>{const h=c[p.sharedStackKey];c[p.sharedStackKey]?p[u]=p[u]/h*100:p[u]=0})})}return(s?y.stack().offset(y.stackOffsetDiverging):y.stack()).keys(o)(i).map((c,p)=>Object.keys(c).filter(u=>!isNaN(u)).map(u=>{const h=c[u];return h[r]=o[p],h}))}getOptions(){return this.state.options}set(t,e){this.state=Object.assign({},this.state,t);const s=Object.assign({skipUpdate:!1,animate:!0},e);s.skipUpdate||this.update(s.animate)}get(t){return t?this.state[t]:this.state}setOptions(t){const e=this.getOptions();n.updateLegendAdditionalItems(e,t),this.set({options:n.merge(e,t)})}update(t=!0){this.getDisplayData()&&(this.updateAllDataGroups(),this.setCustomColorScale(),this.setColorClassNames(),this.services.events.dispatchEvent(D.Events.Model.UPDATE,{animate:t}))}toggleDataLabel(t){const{ACTIVE:e,DISABLED:s}=n.legend.items.status,a=this.getDataGroups(),r=a.some(p=>p.status===s),o=a.filter(p=>p.status===e);if(r)if(o.length===1&&o[0].name===t)a.forEach((p,u)=>{a[u].status=e});else{const p=a.findIndex(u=>u.name===t);a[p].status=a[p].status===s?e:s}else a.forEach((p,u)=>{a[u].status=p.name===t?e:s});const i=a.filter(p=>p.status===e),l=this.getOptions();a.some(p=>p.status===s)?l.data.selectedGroups=i.map(p=>p.name):l.data.selectedGroups=[],this.services.events.dispatchEvent(D.Events.Legend.ITEMS_UPDATE,{dataGroups:a}),this.set({dataGroups:a})}getIsFilled(t,e,s,a){const r=this.getOptions();return r.getIsFilled?r.getIsFilled(t,e,s,a):a}getFillColor(t,e,s){const a=this.getOptions(),r=n.getProperty(this.colorScale,t);return a.getFillColor?a.getFillColor(t,e,s,r):r}getStrokeColor(t,e,s){const a=this.getOptions(),r=n.getProperty(this.colorScale,t);return a.getStrokeColor?a.getStrokeColor(t,e,s,r):r}isUserProvidedColorScaleValid(){const t=n.getProperty(this.getOptions(),"color","scale"),e=this.getDataGroups();return t==null||Object.keys(t).length==0?!1:e.some(s=>Object.keys(t).includes(s.name))}getColorClassName(t){const e=this.colorClassNames(t.dataGroupName);let s=t.originalClassName;return t.classNameTypes.forEach(a=>s=t.originalClassName?`${s} ${a}-${e}`:`${a}-${e}`),s||""}getStatus(){return null}getAllDataGroupsNames(){return this.allDataGroups}transformToTabularData(t){console.warn("We've updated the charting data format to be tabular by default. The current format you're using is deprecated and will be removed in v1.0, read more here https://carbon-design-system.github.io/carbon-charts/?path=/story/docs-tutorials--tabular-data-format");const e=[],{datasets:s,labels:a}=t;return s.forEach(r=>{r.data.forEach((o,i)=>{let l;const c=n.getProperty(r,"label");if(c===null){const u=n.getProperty(a,i);u?l=u:l="Ungrouped"}else l=c;const p={group:l,key:a[i]};isNaN(o)?(p.value=o.value,p.date=o.date):p.value=o,e.push(p)})}),e}getTabularDataArray(){return[]}exportToCSV(){const t=this.getTabularDataArray().map(a=>a.map(r=>`"${r==="&ndash;"?"–":r}"`));let e="",s="";t.forEach(function(a,r){s=a.join(","),e+=r<t.length?s+`
2
- `:s}),this.services.files.downloadCSV(e,"myChart.csv")}getTabularData(t){return Array.isArray(t)?t:this.transformToTabularData(t)}sanitize(t){return t=this.getTabularData(t),t}updateAllDataGroups(){this.allDataGroups?this.getDataGroupNames().forEach(t=>{this.allDataGroups.indexOf(t)===-1&&this.allDataGroups.push(t)}):this.allDataGroups=this.getDataGroupNames()}generateDataGroups(t){const{groupMapsTo:e}=this.getOptions().data,{ACTIVE:s,DISABLED:a}=n.legend.items.status,r=this.getOptions(),o=n.removeArrayDuplicates(t.map(l=>l[e]));r.data.selectedGroups.length&&(r.data.selectedGroups.every(c=>o.includes(c))||(r.data.selectedGroups=[]));const i=l=>!r.data.selectedGroups.length||r.data.selectedGroups.includes(l)?s:a;return o.map(l=>({name:l,status:i(l)}))}setCustomColorScale(){if(!this.isUserProvidedColorScaleValid())return;const t=this.getOptions(),e=n.getProperty(t,"color","scale");Object.keys(e).forEach(a=>{this.allDataGroups.includes(a)||console.warn(`"${a}" does not exist in data groups.`)}),this.allDataGroups.filter(a=>e[a]).forEach(a=>this.colorScale[a]=e[a])}setColorClassNames(){const t=n.getProperty(this.getOptions(),"color","pairing");let e=n.getProperty(t,"numberOfVariants");(!e||e<this.allDataGroups.length)&&(e=this.allDataGroups.length);let s=n.getProperty(t,"option");const a=n.color.pairingOptions,r=e>5?14:e,o=`${r}-color`;s=s<=a[o]?s:1;const i=this.allDataGroups.map((l,c)=>`${r}-${s}-${c%14+1}`);this.colorClassNames=y.scaleOrdinal().range(i).domain(this.allDataGroups)}}class x extends m{constructor(t){super(t),this.axisFlavor=D.AxisFlavor.DEFAULT}assignRangeAndDomains(){const{cartesianScales:t}=this.services,e=this.getOptions(),s=t.isDualAxes(),a={primaryDomain:t.domainAxisPosition,primaryRange:t.rangeAxisPosition,secondaryDomain:null,secondaryRange:null};return s&&(a.secondaryDomain=t.secondaryDomainAxisPosition,a.secondaryRange=t.secondaryRangeAxisPosition),Object.keys(a).forEach(r=>{const o=a[r];t.scales[o]?a[r]={position:o,label:t.getScaleLabel(o),identifier:n.getProperty(e,"axes",o,"mapsTo")}:a[r]=null}),a}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data,{cartesianScales:a}=this.services,{primaryDomain:r,primaryRange:o,secondaryDomain:i,secondaryRange:l}=this.assignRangeAndDomains(),c=a.getDomainAxisScaleType();let p;return c===D.ScaleTypes.TIME&&(p=h=>n.format(h,"MMM d, yyyy")),[["Group",r.label,o.label,...i?[i.label]:[],...l?[l.label]:[]],...t.map(h=>[h[s],h[r.identifier]===null?"&ndash;":p?p(h[r.identifier]):h[r.identifier],h[o.identifier]===null||isNaN(h[o.identifier])?"&ndash;":h[o.identifier].toLocaleString(),...i?[h[i.identifier]===null?"&ndash;":h[i.identifier]]:[],...l?[h[l.identifier]===null||isNaN(h[l.identifier])?"&ndash;":h[l.identifier]]:[]])]}setData(t){let e;if(t&&(e=super.setData(t),n.getProperty(this.getOptions(),"zoomBar",D.AxisPositions.TOP,"enabled"))){const s=n.getProperty(this.getOptions(),"zoomBar",D.AxisPositions.TOP,"data");this.setZoomBarData(s)}return e}setZoomBarData(t){const e=t?this.sanitize(n.clone(t)):this.getDisplayData();let s=e;const{cartesianScales:a}=this.services;if(e&&a.domainAxisPosition&&a.rangeAxisPosition){const r=a.getDomainIdentifier(),o=a.getRangeIdentifier();let i=e.map(l=>l[r].getTime());i=n.removeArrayDuplicates(i).sort(),s=i.map(l=>{let c=0;const p={};return e.forEach(u=>{u[r].getTime()===l&&(c+=u[o])}),p[r]=new Date(l),p[o]=c,p})}this.set({zoomBarData:s})}getZoomBarData(){return this.get("zoomBarData")}sanitizeDateValues(t){const e=this.getOptions();if(!e.axes)return t;const s=[];return Object.keys(D.AxisPositions).forEach(a=>{const r=D.AxisPositions[a],o=e.axes[r];if(o&&o.scaleType===D.ScaleTypes.TIME){const i=o.mapsTo;(i!==null||i!==void 0)&&s.push(i)}}),s.length>0&&t.forEach(a=>{s.forEach(r=>{n.getProperty(a,r,"getTime")===null&&(a[r]=new Date(a[r]))})}),t}sanitize(t){return t=super.sanitize(t),t=this.sanitizeDateValues(t),t}}class k extends x{constructor(t){super(t)}getTabularDataArray(){const t=this.getDisplayData();return t.sort((s,a)=>s.source.localeCompare(a.source)),[["Source","Target","Value"],...t.map(s=>[s.source,s.target,s.value])]}}class B extends x{constructor(t){super(t)}getBoxQuartiles(t){return{q_25:y.quantile(t,.25),q_50:y.quantile(t,.5),q_75:y.quantile(t,.75)}}getBoxplotData(){const t=this.getOptions(),{groupMapsTo:e}=t.data,s=this.getGroupedData(),a=[];for(const{name:r,data:o}of s){const i=this.services.cartesianScales.getRangeIdentifier(),l=o.map(v=>v[i]).sort(y.ascending),c={[e]:r,counts:l,quartiles:this.getBoxQuartiles(l),outliers:null,whiskers:null},p=c.quartiles.q_25,u=c.quartiles.q_75,h=(u-p)*1.5,d=p-h,f=u+h,C=[],P=[];for(const v of l)v<d||v>f?C.push(v):P.push(v);c.outliers=C;const T=y.min(P),S=y.max(P);c.whiskers={min:T||y.min([c.quartiles.q_25,c.quartiles.q_50,c.quartiles.q_75]),max:S||y.max([c.quartiles.q_25,c.quartiles.q_50,c.quartiles.q_75])},a.push(c)}return a}getTabularDataArray(){const t=this.getOptions(),{groupMapsTo:e}=t.data,s=this.getBoxplotData();return[["Group","Minimum","Q1","Median","Q3","Maximum","IQR","Outlier(s)"],...s.map(r=>{let o=n.getProperty(r,"outliers");return(o===null||o.length===0)&&(o=["&ndash;"]),[r[e],n.getProperty(r,"whiskers","min")!==null?n.getProperty(r,"whiskers","min").toLocaleString():"&ndash;",n.getProperty(r,"quartiles","q_25")!==null?n.getProperty(r,"quartiles","q_25").toLocaleString():"&ndash;",n.getProperty(r,"quartiles","q_50")!==null?n.getProperty(r,"quartiles","q_50").toLocaleString():"&ndash;",n.getProperty(r,"quartiles","q_75")!==null?n.getProperty(r,"quartiles","q_75").toLocaleString():"&ndash;",n.getProperty(r,"whiskers","max")!==null?n.getProperty(r,"whiskers","max").toLocaleString():"&ndash;",n.getProperty(r,"quartiles","q_75")!==null&&n.getProperty(r,"quartiles","q_25")!==null?(n.getProperty(r,"quartiles","q_75")-n.getProperty(r,"quartiles","q_25")).toLocaleString():"&ndash;",o.map(i=>i.toLocaleString()).join(",")]})]}setColorClassNames(){const e=n.getProperty(this.getOptions(),"color","pairing");let s=n.getProperty(e,"option");const a=n.color.pairingOptions;s=s<=a["1-color"]?s:1;const r=this.allDataGroups.map(()=>`1-${s}-1`);this.colorClassNames=y.scaleOrdinal().range(r).domain(this.allDataGroups)}}class N extends x{constructor(t){super(t)}getMatchingRangeIndexForDatapoint(t){let e;for(let s=t.ranges.length-1;s>0;s--){const a=t.ranges[s];if(t.value>=a)return e=s,e}return 0}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data,a=this.services.cartesianScales.getRangeIdentifier(),r=n.getProperty(e,"bullet","performanceAreaTitles");return[["Title","Group","Value","Target","Percentage","Performance"],...t.map(i=>[i.title,i[s],i.value===null?"&ndash;":i.value,n.getProperty(i,"marker")===null?"&ndash;":i.marker,n.getProperty(i,"marker")===null?"&ndash;":`${Math.floor(i[a]/i.marker*100)}%`,r[this.getMatchingRangeIndexForDatapoint(i)]])]}}class L extends m{constructor(t){super(t),this._colorScale=void 0,this._matrix={}}getFillColor(t){return this._colorScale(t)}getCombinedData(){if(n.isEmpty(this._matrix)){const t=this.getOptions(),e=this.getDisplayData();!n.isEmpty(e)&&!n.isEmpty(t.geoData.objects.countries)&&(t.geoData.objects.countries.geometries.forEach(s=>{this._matrix[s.properties.NAME]=s}),e.forEach(s=>{this._matrix[s.name]?this._matrix[s.name].value=s.value||null:console.warn(`Data point ${s} is missing geographical data.`)}))}return this._matrix}getTabularDataArray(){const t=this.getDisplayData();return[["Country ID","Country Name","Value"],...t.map(s=>[s.id===null?"&ndash;":s.id,s.name,s.value])]}getColorClassName(t){return`${t.originalClassName} ${this._colorScale(t.value)}`}setColorClassNames(){const t=n.getProperty(this.getOptions(),"color");this._colorScale=n.getColorScale(this.getDisplayData(),t)}}class V extends m{constructor(t){super(t),this.parentNode=!1,this.set({depth:2},{skipUpdate:!0})}setData(t){super.setData(t),this.setDataGroups(),t.length===1&&(this.parentNode=!0),this.setZoom()}setOptions(t){const e=this.getOptions(),s=n.merge({},t,this.getZoomOptions(t));n.updateLegendAdditionalItems(e,s);const a=this.getHierarchyLevel(),r=n.getProperty(e,"circlePack","hierarchyLevel");this.set({options:n.merge(e,s),depth:r&&r<4?r:a})}getZoomOptions(t){if(!this.getDisplayData())return{};const e=this.getDisplayData(),s=t||this.getOptions(),a=e.length===1&&n.getProperty(e,0,"children")?n.getProperty(e,0,"children"):e;let r=this.getHierarchyLevel();return a.some(o=>{if(o.children&&o.children.some(i=>i.children))return r=3,!1}),n.getProperty(s,"canvasZoom","enabled")===!0&&r>2?{legend:{additionalItems:[{type:D.LegendItemType.ZOOM,name:"Click to zoom"}]}}:null}setZoom(t){this.setOptions(this.getZoomOptions(t))}updateHierarchyLevel(t){this.set({depth:t})}getHierarchyLevel(){return this.get("depth")}hasParentNode(){return this.parentNode}setDataGroups(){const t=this.getData(),e=this.getOptions(),{groupMapsTo:s}=e.data,a=t.map(r=>{const o=r[s];return this.setChildrenDataGroup(r,o)});this.set({data:a},{skipUpdate:!0})}setChildrenDataGroup(t,e){return t.children?{...t,dataGroupName:e,children:t.children.map(s=>this.setChildrenDataGroup(s,e))}:{...t,dataGroupName:e}}getTabularDataArray(){const t=this.getDisplayData(),e=[["Child","Parent","Value"]];return t.forEach(s=>{let a=s.value?s.value:0;s.children&&(a+=this.getChildrenDatums(s.children,s.name,e,0)),e.push(["&ndash;",s.name,a])}),e}getChildrenDatums(t,e,s=[],a=0){const r=e;return t.forEach(o=>{const i=o.name;let l=0;if(o.children)o.children.length>0&&(typeof o.value=="number"&&(a+=o.value),l+=this.getChildrenDatums(o.children,i,s,l),s.push([i,r,l]),a+=l);else{let c=0;typeof o.value=="number"&&(c=o.value,a+=o.value),s.push([o.name,r,c])}}),a}}class R extends m{constructor(t){super(t)}getTabularData(t){const e=super.getTabularData(t);return t!==e&&e.forEach(s=>{s.key&&s.key!==s.group&&(s.group=s.key)}),e}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data;return[["Group","Value"],...t.map(r=>[r[s],r.value===null?"&ndash;":r.value.toLocaleString()])]}sanitize(t){return this.getTabularData(t).sort((s,a)=>a.value-s.value)}}class $ extends m{constructor(t){super(t)}getDataGroups(){return super.getDataGroups().filter(t=>t.name!=="delta")}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data;return[["Group","Value"],...t.map(r=>[r[s],r.value===null?"&ndash;":r.value.toLocaleString()])]}}class w extends x{constructor(t){super(t),this.axisFlavor=D.AxisFlavor.HOVERABLE,this._colorScale=void 0,this._domains=[],this._ranges=[],this._matrix={};const e=n.getProperty(this.getOptions(),"axes");if(n.getProperty(e,"left","scaleType")&&n.getProperty(e,"left","scaleType")!==D.ScaleTypes.LABELS||n.getProperty(e,"right","scaleType")&&n.getProperty(e,"right","scaleType")!==D.ScaleTypes.LABELS||n.getProperty(e,"top","scaleType")&&n.getProperty(e,"top","scaleType")!==D.ScaleTypes.LABELS||n.getProperty(e,"bottom","scaleType")&&n.getProperty(e,"bottom","scaleType")!==D.ScaleTypes.LABELS)throw Error("Heatmap only supports label scaletypes.")}getValueDomain(){const t=y.extent(this.getDisplayData(),s=>s.value),e=y.scaleLinear().domain(t).nice().domain();if(e[0]>0)e[0]=0;else if(e[0]===0&&e[1]===0)return[0,1];return e[0]<0&&e[1]>0&&(Math.abs(e[0])>e[1]?e[1]=Math.abs(e[0]):e[0]=-e[1]),e}getFillColor(t){return this._colorScale(t)}getUniqueDomain(){if(n.isEmpty(this._domains)){const t=this.getDisplayData(),{cartesianScales:e}=this.services,s=e.getDomainIdentifier(),a=e.getMainXAxisPosition(),r=e.getCustomDomainValuesByposition(a);if(r)return r;this._domains=Array.from(new Set(t.map(o=>o[s])))}return this._domains}getUniqueRanges(){if(n.isEmpty(this._ranges)){const t=this.getDisplayData(),{cartesianScales:e}=this.services,s=e.getRangeIdentifier(),a=e.getMainYAxisPosition(),r=e.getCustomDomainValuesByposition(a);if(r)return r;this._ranges=Array.from(new Set(t.map(o=>o[s])))}return this._ranges}getMatrix(){if(n.isEmpty(this._matrix)){const t=this.getUniqueDomain(),e=this.getUniqueRanges(),s=this.services.cartesianScales.getDomainIdentifier(),a=this.services.cartesianScales.getRangeIdentifier(),r={};e.forEach(o=>{r[o]={value:null,index:-1}}),t.forEach(o=>{this._matrix[o]=n.clone(r)}),this.getDisplayData().forEach((o,i)=>{this._matrix[o[s]][o[a]]={value:o.value,index:i}})}return this._matrix}setData(t){const e=this.sanitize(n.clone(t)),s=this.generateDataGroups(e);return this.set({data:e,dataGroups:s}),this._domains=[],this._ranges=[],this._matrix={},e}getMatrixAsArray(){n.isEmpty(this._matrix)&&this.getMatrix();const t=this.getUniqueDomain(),e=this.getUniqueRanges(),s=this.services.cartesianScales.getDomainIdentifier(),a=this.services.cartesianScales.getRangeIdentifier(),r=[];return t.forEach(o=>{e.forEach(i=>{const l={value:this._matrix[o][i].value,index:this._matrix[o][i].index};l[s]=o,l[a]=i,r.push(l)})}),r}getTabularDataArray(){const t=this.getDisplayData(),{primaryDomain:e,primaryRange:s}=this.assignRangeAndDomains();return[[e.label,s.label,"Value"],...t.map(r=>[r[e.identifier]===null?"&ndash;":r[e.identifier],r[s.identifier]===null?"&ndash;":r[s.identifier].toLocaleString(),r.value])]}getColorClassName(t){return`${t.originalClassName} ${this._colorScale(t.value)}`}setColorClassNames(){const t=this.getOptions(),e=n.getProperty(t,"color","gradient","colors"),s=!n.isEmpty(e);let a=n.getProperty(t,"color","pairing","option");const r=this.getValueDomain(),o=r[0]<0&&r[1]>0?"diverge":"mono";(a<1&&a>4&&o==="mono"||a<1&&a>2&&o==="diverge")&&(a=1);const i=s?e:[];if(!s){const c=o==="diverge"?17:11;for(let p=1;p<c+1;p++)i.push(`fill-${o}-${a}-${p}`)}this._colorScale=y.scaleQuantize().domain(r).range(i);const l=n.getProperty(this.getOptions(),"color");this._colorScale=n.getColorScale(this.getDisplayData(),l)}}class F extends x{getTabularDataArray(){const t=this.getOptions(),{groupMapsTo:e}=t.data,s=this.getBinnedStackedData();return[[n.get(t,"bins.rangeLabel")||"Range",...s.map(r=>n.get(r,`0.${e}`))],...n.get(s,0).map((r,o)=>[`${n.get(r,"data.x0")} – ${n.get(r,"data.x1")}`,...s.map(i=>n.get(i[o],`data.${n.get(i[o],e)}`))])]}}class z extends m{constructor(t){super(t)}getMaximumDomain(t){return t.reduce((s,a)=>s+a.value,0)}getFillColor(t){const e=this.getOptions(),s=n.getProperty(e,"color","scale"),a=this.getStatus();return s||!a?super.getFillColor(t):null}getStatus(){const t=this.getOptions(),e=n.getProperty(this.getDisplayData()),s=(e==null?void 0:e.reduce((o,i)=>o+i.value,0))??0,a=n.getProperty(t,"meter","proportional")?s:s>100?100:s,r=n.getProperty(t,"meter","status","ranges");if(r){const o=r.filter(i=>i.range[0]<=a&&a<=i.range[1]);if(o.length>0)return o[0].status}return null}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data,a=this.getStatus(),r=n.getProperty(e,"meter","proportional");let o=[],i;if(r===null){i=100;const l=t[0];o=[["Group","Value",...a?["Status"]:[]],[l[s],l.value,...a?[a]:[]]]}else{const l=n.getProperty(r,"total");i=l||this.getMaximumDomain(t),o=[["Group","Value","Percentage of total"],...t.map(c=>[c[s],c.value,(c.value/i*100).toFixed(2)+" %"])]}return o}}class U extends x{constructor(t){super(t)}getTabularDataArray(){const t=this.getOptions(),e=this.getGroupedData(),{angle:s,value:a}=n.getProperty(t,"radar","axes"),r=n.getProperty(e,"0","data").map(i=>i[s]);return[["Group",...r],...e.map(i=>[i.name,...r.map((l,c)=>n.getProperty(i,"data",c,a)!==null?n.getProperty(i,"data",c,a).toLocaleString():"&ndash;")])]}}class j extends m{constructor(t){super(t)}getTabularDataArray(){const t=this.getDisplayData(),e=[["Child","Parent"]];return t.forEach(s=>{this.getChildrenDatums(s,e),e.push([s.name,"&ndash;"])}),e}getChildrenDatums(t,e=[]){t.children&&t.children.length>0&&t.children.forEach(s=>{this.getChildrenDatums(s,e),e.push([s.name,t.name])})}}class K extends m{constructor(t){super(t)}getTabularDataArray(){const t=this.getDisplayData(),e=[["Child","Group","Value"]];return t.forEach(s=>{Array.isArray(s.children)?s.children.forEach(a=>{e.push([a.name,s.name,a.value])}):n.getProperty(s.name)!==null&&n.getProperty(s.value)&&e.push(["–",s.name,s.value])}),e}}class Z extends m{constructor(t){super(t)}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{fontSizeMapsTo:s,wordMapsTo:a}=e.wordCloud,{groupMapsTo:r}=e.data;return[[e.tooltip.wordLabel,"Group",e.tooltip.valueLabel],...t.map(i=>[i[a],i[r],i[s]])]}}exports.AlluvialChartModel=k;exports.BoxplotChartModel=B;exports.BulletChartModel=N;exports.ChartModel=m;exports.ChartModelBinned=F;exports.ChartModelCartesian=x;exports.ChoroplethModel=L;exports.CirclePackChartModel=V;exports.GaugeChartModel=$;exports.HeatmapModel=w;exports.MeterChartModel=z;exports.PieChartModel=R;exports.RadarChartModel=U;exports.TreeChartModel=j;exports.TreemapChartModel=K;exports.WordCloudModel=Z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../color-scale-utils-56bbe3f2.js"),f=require("d3"),D=require("../enums-aa2efd99.js"),b=require("../_baseEach-e8e98018.js");require("../index-d865d500.js");function O(g,t,e,s){for(var a=-1,r=g==null?0:g.length;++a<r;){var o=g[a];t(s,o,e(o),g)}return s}function A(g,t,e,s){return b.baseEach(g,function(a,r,o){t(s,a,e(a),o)}),s}function G(g,t){return function(e,s){var a=n.isArray(e)?O:A,r=t?t():{};return a(e,g,n.baseIteratee(s),r)}}function M(g){for(var t=-1,e=g==null?0:g.length,s={};++t<e;){var a=g[t];s[a[0]]=a[1]}return s}var E=Object.prototype,q=E.hasOwnProperty,I=G(function(g,t,e){q.call(g,e)?g[e].push(t):n.baseAssignValue(g,e,[t])});const _=I;class m{constructor(t){this.state={options:{}},this.colorScale={},this.colorClassNames={},this.services=t}getAllDataFromDomain(t){if(!this.getData())return null;const e=this.getOptions();let s=this.getData();const a=this.getDataGroups(),{groupMapsTo:r}=n.getProperty(e,"data"),o=n.getProperty(e,"axes");return t&&(s=s.filter(i=>t.includes(i[r]))),o&&Object.keys(o).forEach(i=>{const l=o[i].mapsTo,c=o[i].scaleType;if((c===D.ScaleTypes.LINEAR||c===D.ScaleTypes.LOG)&&(s=s.map(p=>({...p,[l]:p[l]===null?p[l]:Number(p[l])}))),l&&o[i].domain)if(c===D.ScaleTypes.LABELS)s=s.filter(p=>o[i].domain.includes(p[l]));else{const[p,u]=o[i].domain;s=s.filter(h=>!(l in h)||h[l]>=p&&h[l]<=u)}}),s.filter(i=>a.find(l=>l.name===i[r]))}getDisplayData(t){if(!this.get("data"))return null;const{ACTIVE:e}=n.legend.items.status,s=this.getDataGroups(t),{groupMapsTo:a}=this.getOptions().data;return this.getAllDataFromDomain(t).filter(o=>s.find(i=>i.name===o[a]&&i.status===e))}getData(){return this.get("data")}isDataEmpty(){return!this.getData().length}setData(t){const e=this.sanitize(n.cloneDeep(t)),s=this.generateDataGroups(e);return this.set({data:e,dataGroups:s}),e}getDataGroups(t){return n.getProperty(this.getOptions(),"data","loading")?[]:t?this.get("dataGroups").filter(s=>t.includes(s.name)):this.get("dataGroups")}getActiveDataGroups(t){const{ACTIVE:e}=n.legend.items.status;return this.getDataGroups(t).filter(s=>s.status===e)}getDataGroupNames(t){return this.getDataGroups(t).map(s=>s.name)}getActiveDataGroupNames(t){return this.getActiveDataGroups(t).map(s=>s.name)}aggregateBinDataByGroup(t){return _(t,"group")}getBinConfigurations(){const t=this.getDisplayData(),e=this.getOptions(),s=this.services.cartesianScales.getMainXAxisPosition(),a=this.services.cartesianScales.getDomainIdentifier(),r=e.axes[s],{groupMapsTo:o}=e.data,{bins:i=n.histogram.defaultBins}=r,l=Array.isArray(i),c=f.bin().value(d=>d[a]).thresholds(i)(t);if(l)c[c.length-1].x1=i[i.length-1];else{const d=c[0].x1-c[0].x0;c[c.length-1].x1=+c[c.length-1].x0+d}const p=l?[i[0],i[i.length-1]]:[c[0].x0,c[c.length-1].x1],u=Array.from(new Set(t.map(d=>d[o]))),h=[];return c.forEach(d=>{const y=`${d.x0}-${d.x1}`,C=this.aggregateBinDataByGroup(d);u.forEach(P=>{h.push({group:P,key:y,value:C[P]||0,bin:d.x0})})}),{bins:c,binsDomain:p}}getBinnedStackedData(){const t=this.getOptions(),{groupMapsTo:e}=t.data,s=this.getActiveDataGroupNames(),{bins:a}=this.getBinConfigurations(),r=this.getDataValuesGroupedByKeys({bins:a});return f.stack().keys(s)(r).map((o,i)=>Object.keys(o).filter(l=>!isNaN(l)).map(l=>{const c=o[l];return c[e]=s[i],c}))}getGroupedData(t){const e=this.getDisplayData(t),s={},{groupMapsTo:a}=this.getOptions().data;return e.map(r=>{const o=r[a];s[o]!==null&&s[o]!==void 0?s[o].push(r):s[o]=[r]}),Object.keys(s).map(r=>({name:r,data:s[r]}))}getStackKeys({bins:t=null,groups:e=null}={bins:null,groups:null}){const s=this.getOptions(),a=this.getDisplayData(e);let r;t?r=t.map(l=>`${l.x0}-${l.x1}`):r=n.uniq(a.map(l=>{const c=this.services.cartesianScales.getDomainIdentifier(l);return l[c]instanceof Date?n.formatDateTillMilliSeconds(l[c]):l[c]&&typeof l[c].toString=="function"?l[c].toString():l[c]}));const o=this.services.cartesianScales.domainAxisPosition,i=s.axes[o].scaleType;return i===D.ScaleTypes.TIME?r.sort((l,c)=>{const p=new Date(l),u=new Date(c);return p-u}):(i===D.ScaleTypes.LOG||i===D.ScaleTypes.LINEAR)&&r.sort((l,c)=>l-c),r}getDataValuesGroupedByKeys({bins:t=null,groups:e=null}){const s=this.getOptions(),{groupMapsTo:a}=s.data,r=this.getDisplayData(e),o=this.getDataGroupNames(),i=this.getStackKeys({bins:t,groups:e});return t?i.map(l=>{const[c,p]=l.split("-"),u={x0:c,x1:p},h=t.find(d=>d.x0.toString()===c.toString());return o.forEach(d=>{u[d]=h.filter(y=>y[a]===d).length}),u}):i.map(l=>{const c={sharedStackKey:l};return o.forEach(p=>{const u=r.find(d=>{const y=this.services.cartesianScales.getDomainIdentifier(d);return d[a]===p&&Object.prototype.hasOwnProperty.call(d,y)&&(d[y]instanceof Date?n.formatDateTillMilliSeconds(d[y])===l:d[y].toString()===l)}),h=this.services.cartesianScales.getRangeIdentifier(c);c[p]=u?u[h]:null}),c})}getStackedData({percentage:t=!1,groups:e=null,divergent:s=!1}){const a=this.getOptions(),{groupMapsTo:r}=a.data,o=this.getActiveDataGroupNames(e),i=this.getDataValuesGroupedByKeys({groups:e});if(t){const c=M(i.map(p=>[p.sharedStackKey,0]));i.forEach(p=>{o.forEach(u=>{c[p.sharedStackKey]+=p[u]})}),i.forEach(p=>{o.forEach(u=>{const h=c[p.sharedStackKey];c[p.sharedStackKey]?p[u]=p[u]/h*100:p[u]=0})})}return(s?f.stack().offset(f.stackOffsetDiverging):f.stack()).keys(o)(i).map((c,p)=>Object.keys(c).filter(u=>!isNaN(u)).map(u=>{const h=c[u];return h[r]=o[p],h}))}getOptions(){return this.state.options}set(t,e){this.state=Object.assign({},this.state,t);const s=Object.assign({skipUpdate:!1,animate:!0},e);s.skipUpdate||this.update(s.animate)}get(t){return t?this.state[t]:this.state}setOptions(t){const e=this.getOptions();n.updateLegendAdditionalItems(e,t),this.set({options:n.merge(e,t)})}update(t=!0){this.getDisplayData()&&(this.updateAllDataGroups(),this.setCustomColorScale(),this.setColorClassNames(),this.services.events.dispatchEvent(D.Events.Model.UPDATE,{animate:t}))}toggleDataLabel(t){const{ACTIVE:e,DISABLED:s}=n.legend.items.status,a=this.getDataGroups(),r=a.some(p=>p.status===s),o=a.filter(p=>p.status===e);if(r)if(o.length===1&&o[0].name===t)a.forEach((p,u)=>{a[u].status=e});else{const p=a.findIndex(u=>u.name===t);a[p].status=a[p].status===s?e:s}else a.forEach((p,u)=>{a[u].status=p.name===t?e:s});const i=a.filter(p=>p.status===e),l=this.getOptions();a.some(p=>p.status===s)?l.data.selectedGroups=i.map(p=>p.name):l.data.selectedGroups=[],this.services.events.dispatchEvent(D.Events.Legend.ITEMS_UPDATE,{dataGroups:a}),this.set({dataGroups:a})}getIsFilled(t,e,s,a){const r=this.getOptions();return r.getIsFilled?r.getIsFilled(t,e,s,a):a}getFillColor(t,e,s){const a=this.getOptions(),r=n.getProperty(this.colorScale,t);return a.getFillColor?a.getFillColor(t,e,s,r):r}getStrokeColor(t,e,s){const a=this.getOptions(),r=n.getProperty(this.colorScale,t);return a.getStrokeColor?a.getStrokeColor(t,e,s,r):r}isUserProvidedColorScaleValid(){const t=n.getProperty(this.getOptions(),"color","scale"),e=this.getDataGroups();return t==null||Object.keys(t).length==0?!1:e.some(s=>Object.keys(t).includes(s.name))}getColorClassName(t){const e=this.colorClassNames(t.dataGroupName);let s=t.originalClassName;return t.classNameTypes.forEach(a=>s=t.originalClassName?`${s} ${a}-${e}`:`${a}-${e}`),s||""}getStatus(){return null}getAllDataGroupsNames(){return this.allDataGroups}transformToTabularData(t){console.warn("We've updated the charting data format to be tabular by default. The current format you're using is deprecated and will be removed in v1.0, read more here https://carbon-design-system.github.io/carbon-charts/?path=/story/docs-tutorials--tabular-data-format");const e=[],{datasets:s,labels:a}=t;return s.forEach(r=>{r.data.forEach((o,i)=>{let l;const c=n.getProperty(r,"label");if(c===null){const u=n.getProperty(a,i);u?l=u:l="Ungrouped"}else l=c;const p={group:l,key:a[i]};isNaN(o)?(p.value=o.value,p.date=o.date):p.value=o,e.push(p)})}),e}getTabularDataArray(){return[]}exportToCSV(){const t=this.getTabularDataArray().map(a=>a.map(r=>`"${r==="&ndash;"?"–":r}"`));let e="",s="";t.forEach(function(a,r){s=a.join(","),e+=r<t.length?s+`
2
+ `:s}),this.services.files.downloadCSV(e,"myChart.csv")}getTabularData(t){return Array.isArray(t)?t:this.transformToTabularData(t)}sanitize(t){return t=this.getTabularData(t),t}updateAllDataGroups(){this.allDataGroups?this.getDataGroupNames().forEach(t=>{this.allDataGroups.indexOf(t)===-1&&this.allDataGroups.push(t)}):this.allDataGroups=this.getDataGroupNames()}generateDataGroups(t){const{groupMapsTo:e}=this.getOptions().data,{ACTIVE:s,DISABLED:a}=n.legend.items.status,r=this.getOptions(),o=n.uniq(t.map(l=>l[e]));r.data.selectedGroups.length&&(r.data.selectedGroups.every(c=>o.includes(c))||(r.data.selectedGroups=[]));const i=l=>!r.data.selectedGroups.length||r.data.selectedGroups.includes(l)?s:a;return o.map(l=>({name:l,status:i(l)}))}setCustomColorScale(){if(!this.isUserProvidedColorScaleValid())return;const t=this.getOptions(),e=n.getProperty(t,"color","scale");Object.keys(e).forEach(a=>{this.allDataGroups.includes(a)||console.warn(`"${a}" does not exist in data groups.`)}),this.allDataGroups.filter(a=>e[a]).forEach(a=>this.colorScale[a]=e[a])}setColorClassNames(){const t=n.getProperty(this.getOptions(),"color","pairing");let e=n.getProperty(t,"numberOfVariants");(!e||e<this.allDataGroups.length)&&(e=this.allDataGroups.length);let s=n.getProperty(t,"option");const a=n.color.pairingOptions,r=e>5?14:e,o=`${r}-color`;s=s<=a[o]?s:1;const i=this.allDataGroups.map((l,c)=>`${r}-${s}-${c%14+1}`);this.colorClassNames=f.scaleOrdinal().range(i).domain(this.allDataGroups)}}class x extends m{constructor(t){super(t),this.axisFlavor=D.AxisFlavor.DEFAULT}assignRangeAndDomains(){const{cartesianScales:t}=this.services,e=this.getOptions(),s=t.isDualAxes(),a={primaryDomain:t.domainAxisPosition,primaryRange:t.rangeAxisPosition,secondaryDomain:null,secondaryRange:null};return s&&(a.secondaryDomain=t.secondaryDomainAxisPosition,a.secondaryRange=t.secondaryRangeAxisPosition),Object.keys(a).forEach(r=>{const o=a[r];t.scales[o]?a[r]={position:o,label:t.getScaleLabel(o),identifier:n.getProperty(e,"axes",o,"mapsTo")}:a[r]=null}),a}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data,{cartesianScales:a}=this.services,{primaryDomain:r,primaryRange:o,secondaryDomain:i,secondaryRange:l}=this.assignRangeAndDomains(),c=a.getDomainAxisScaleType();let p;return c===D.ScaleTypes.TIME&&(p=h=>n.format(h,"MMM d, yyyy")),[["Group",r.label,o.label,...i?[i.label]:[],...l?[l.label]:[]],...t.map(h=>[h[s],h[r.identifier]===null?"&ndash;":p?p(h[r.identifier]):h[r.identifier],h[o.identifier]===null||isNaN(h[o.identifier])?"&ndash;":h[o.identifier].toLocaleString(),...i?[h[i.identifier]===null?"&ndash;":h[i.identifier]]:[],...l?[h[l.identifier]===null||isNaN(h[l.identifier])?"&ndash;":h[l.identifier]]:[]])]}setData(t){let e;if(t&&(e=super.setData(t),n.getProperty(this.getOptions(),"zoomBar",D.AxisPositions.TOP,"enabled"))){const s=n.getProperty(this.getOptions(),"zoomBar",D.AxisPositions.TOP,"data");this.setZoomBarData(s)}return e}setZoomBarData(t){const e=t?this.sanitize(n.cloneDeep(t)):this.getDisplayData();let s=e;const{cartesianScales:a}=this.services;if(e&&a.domainAxisPosition&&a.rangeAxisPosition){const r=a.getDomainIdentifier(),o=a.getRangeIdentifier();let i=e.map(l=>l[r].getTime());i=n.uniq(i).sort(),s=i.map(l=>{let c=0;const p={};return e.forEach(u=>{u[r].getTime()===l&&(c+=u[o])}),p[r]=new Date(l),p[o]=c,p})}this.set({zoomBarData:s})}getZoomBarData(){return this.get("zoomBarData")}sanitizeDateValues(t){const e=this.getOptions();if(!e.axes)return t;const s=[];return Object.keys(D.AxisPositions).forEach(a=>{const r=D.AxisPositions[a],o=e.axes[r];if(o&&o.scaleType===D.ScaleTypes.TIME){const i=o.mapsTo;(i!==null||i!==void 0)&&s.push(i)}}),s.length>0&&t.forEach(a=>{s.forEach(r=>{n.getProperty(a,r,"getTime")===null&&(a[r]=new Date(a[r]))})}),t}sanitize(t){return t=super.sanitize(t),t=this.sanitizeDateValues(t),t}}class k extends x{constructor(t){super(t)}getTabularDataArray(){const t=this.getDisplayData();return t.sort((s,a)=>s.source.localeCompare(a.source)),[["Source","Target","Value"],...t.map(s=>[s.source,s.target,s.value])]}}class B extends x{constructor(t){super(t)}getBoxQuartiles(t){return{q_25:f.quantile(t,.25),q_50:f.quantile(t,.5),q_75:f.quantile(t,.75)}}getBoxplotData(){const t=this.getOptions(),{groupMapsTo:e}=t.data,s=this.getGroupedData(),a=[];for(const{name:r,data:o}of s){const i=this.services.cartesianScales.getRangeIdentifier(),l=o.map(v=>v[i]).sort(f.ascending),c={[e]:r,counts:l,quartiles:this.getBoxQuartiles(l),outliers:null,whiskers:null},p=c.quartiles.q_25,u=c.quartiles.q_75,h=(u-p)*1.5,d=p-h,y=u+h,C=[],P=[];for(const v of l)v<d||v>y?C.push(v):P.push(v);c.outliers=C;const T=f.min(P),S=f.max(P);c.whiskers={min:T||f.min([c.quartiles.q_25,c.quartiles.q_50,c.quartiles.q_75]),max:S||f.max([c.quartiles.q_25,c.quartiles.q_50,c.quartiles.q_75])},a.push(c)}return a}getTabularDataArray(){const t=this.getOptions(),{groupMapsTo:e}=t.data,s=this.getBoxplotData();return[["Group","Minimum","Q1","Median","Q3","Maximum","IQR","Outlier(s)"],...s.map(r=>{let o=n.getProperty(r,"outliers");return(o===null||o.length===0)&&(o=["&ndash;"]),[r[e],n.getProperty(r,"whiskers","min")!==null?n.getProperty(r,"whiskers","min").toLocaleString():"&ndash;",n.getProperty(r,"quartiles","q_25")!==null?n.getProperty(r,"quartiles","q_25").toLocaleString():"&ndash;",n.getProperty(r,"quartiles","q_50")!==null?n.getProperty(r,"quartiles","q_50").toLocaleString():"&ndash;",n.getProperty(r,"quartiles","q_75")!==null?n.getProperty(r,"quartiles","q_75").toLocaleString():"&ndash;",n.getProperty(r,"whiskers","max")!==null?n.getProperty(r,"whiskers","max").toLocaleString():"&ndash;",n.getProperty(r,"quartiles","q_75")!==null&&n.getProperty(r,"quartiles","q_25")!==null?(n.getProperty(r,"quartiles","q_75")-n.getProperty(r,"quartiles","q_25")).toLocaleString():"&ndash;",o.map(i=>i.toLocaleString()).join(",")]})]}setColorClassNames(){const e=n.getProperty(this.getOptions(),"color","pairing");let s=n.getProperty(e,"option");const a=n.color.pairingOptions;s=s<=a["1-color"]?s:1;const r=this.allDataGroups.map(()=>`1-${s}-1`);this.colorClassNames=f.scaleOrdinal().range(r).domain(this.allDataGroups)}}class N extends x{constructor(t){super(t)}getMatchingRangeIndexForDatapoint(t){let e;for(let s=t.ranges.length-1;s>0;s--){const a=t.ranges[s];if(t.value>=a)return e=s,e}return 0}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data,a=this.services.cartesianScales.getRangeIdentifier(),r=n.getProperty(e,"bullet","performanceAreaTitles");return[["Title","Group","Value","Target","Percentage","Performance"],...t.map(i=>[i.title,i[s],i.value===null?"&ndash;":i.value,n.getProperty(i,"marker")===null?"&ndash;":i.marker,n.getProperty(i,"marker")===null?"&ndash;":`${Math.floor(i[a]/i.marker*100)}%`,r[this.getMatchingRangeIndexForDatapoint(i)]])]}}class L extends m{constructor(t){super(t),this._colorScale=void 0,this._matrix={}}getFillColor(t){return this._colorScale(t)}getCombinedData(){if(n.isEmpty(this._matrix)){const t=this.getOptions(),e=this.getDisplayData();!n.isEmpty(e)&&!n.isEmpty(t.geoData.objects.countries)&&(t.geoData.objects.countries.geometries.forEach(s=>{this._matrix[s.properties.NAME]=s}),e.forEach(s=>{this._matrix[s.name]?this._matrix[s.name].value=s.value||null:console.warn(`Data point ${s} is missing geographical data.`)}))}return this._matrix}getTabularDataArray(){const t=this.getDisplayData();return[["Country ID","Country Name","Value"],...t.map(s=>[s.id===null?"&ndash;":s.id,s.name,s.value])]}getColorClassName(t){return`${t.originalClassName} ${this._colorScale(t.value)}`}setColorClassNames(){const t=n.getProperty(this.getOptions(),"color");this._colorScale=n.getColorScale(this.getDisplayData(),t)}}class V extends m{constructor(t){super(t),this.parentNode=!1,this.set({depth:2},{skipUpdate:!0})}setData(t){super.setData(t),this.setDataGroups(),t.length===1&&(this.parentNode=!0),this.setZoom()}setOptions(t){const e=this.getOptions(),s=n.merge({},t,this.getZoomOptions(t));n.updateLegendAdditionalItems(e,s);const a=this.getHierarchyLevel(),r=n.getProperty(e,"circlePack","hierarchyLevel");this.set({options:n.merge(e,s),depth:r&&r<4?r:a})}getZoomOptions(t){if(!this.getDisplayData())return{};const e=this.getDisplayData(),s=t||this.getOptions(),a=e.length===1&&n.getProperty(e,0,"children")?n.getProperty(e,0,"children"):e;let r=this.getHierarchyLevel();return a.some(o=>{if(o.children&&o.children.some(i=>i.children))return r=3,!1}),n.getProperty(s,"canvasZoom","enabled")===!0&&r>2?{legend:{additionalItems:[{type:D.LegendItemType.ZOOM,name:"Click to zoom"}]}}:null}setZoom(t){this.setOptions(this.getZoomOptions(t))}updateHierarchyLevel(t){this.set({depth:t})}getHierarchyLevel(){return this.get("depth")}hasParentNode(){return this.parentNode}setDataGroups(){const t=this.getData(),e=this.getOptions(),{groupMapsTo:s}=e.data,a=t.map(r=>{const o=r[s];return this.setChildrenDataGroup(r,o)});this.set({data:a},{skipUpdate:!0})}setChildrenDataGroup(t,e){return t.children?{...t,dataGroupName:e,children:t.children.map(s=>this.setChildrenDataGroup(s,e))}:{...t,dataGroupName:e}}getTabularDataArray(){const t=this.getDisplayData(),e=[["Child","Parent","Value"]];return t.forEach(s=>{let a=s.value?s.value:0;s.children&&(a+=this.getChildrenDatums(s.children,s.name,e,0)),e.push(["&ndash;",s.name,a])}),e}getChildrenDatums(t,e,s=[],a=0){const r=e;return t.forEach(o=>{const i=o.name;let l=0;if(o.children)o.children.length>0&&(typeof o.value=="number"&&(a+=o.value),l+=this.getChildrenDatums(o.children,i,s,l),s.push([i,r,l]),a+=l);else{let c=0;typeof o.value=="number"&&(c=o.value,a+=o.value),s.push([o.name,r,c])}}),a}}class R extends m{constructor(t){super(t)}getTabularData(t){const e=super.getTabularData(t);return t!==e&&e.forEach(s=>{s.key&&s.key!==s.group&&(s.group=s.key)}),e}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data;return[["Group","Value"],...t.map(r=>[r[s],r.value===null?"&ndash;":r.value.toLocaleString()])]}sanitize(t){return this.getTabularData(t).sort((s,a)=>a.value-s.value)}}class $ extends m{constructor(t){super(t)}getDataGroups(){return super.getDataGroups().filter(t=>t.name!=="delta")}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data;return[["Group","Value"],...t.map(r=>[r[s],r.value===null?"&ndash;":r.value.toLocaleString()])]}}class w extends x{constructor(t){super(t),this.axisFlavor=D.AxisFlavor.HOVERABLE,this._colorScale=void 0,this._domains=[],this._ranges=[],this._matrix={};const e=n.getProperty(this.getOptions(),"axes");if(n.getProperty(e,"left","scaleType")&&n.getProperty(e,"left","scaleType")!==D.ScaleTypes.LABELS||n.getProperty(e,"right","scaleType")&&n.getProperty(e,"right","scaleType")!==D.ScaleTypes.LABELS||n.getProperty(e,"top","scaleType")&&n.getProperty(e,"top","scaleType")!==D.ScaleTypes.LABELS||n.getProperty(e,"bottom","scaleType")&&n.getProperty(e,"bottom","scaleType")!==D.ScaleTypes.LABELS)throw Error("Heatmap only supports label scaletypes.")}getValueDomain(){const t=f.extent(this.getDisplayData(),s=>s.value),e=f.scaleLinear().domain(t).nice().domain();if(e[0]>0)e[0]=0;else if(e[0]===0&&e[1]===0)return[0,1];return e[0]<0&&e[1]>0&&(Math.abs(e[0])>e[1]?e[1]=Math.abs(e[0]):e[0]=-e[1]),e}getFillColor(t){return this._colorScale(t)}getUniqueDomain(){if(n.isEmpty(this._domains)){const t=this.getDisplayData(),{cartesianScales:e}=this.services,s=e.getDomainIdentifier(),a=e.getMainXAxisPosition(),r=e.getCustomDomainValuesByposition(a);if(r)return r;this._domains=Array.from(new Set(t.map(o=>o[s])))}return this._domains}getUniqueRanges(){if(n.isEmpty(this._ranges)){const t=this.getDisplayData(),{cartesianScales:e}=this.services,s=e.getRangeIdentifier(),a=e.getMainYAxisPosition(),r=e.getCustomDomainValuesByposition(a);if(r)return r;this._ranges=Array.from(new Set(t.map(o=>o[s])))}return this._ranges}getMatrix(){if(n.isEmpty(this._matrix)){const t=this.getUniqueDomain(),e=this.getUniqueRanges(),s=this.services.cartesianScales.getDomainIdentifier(),a=this.services.cartesianScales.getRangeIdentifier(),r={};e.forEach(o=>{r[o]={value:null,index:-1}}),t.forEach(o=>{this._matrix[o]=n.cloneDeep(r)}),this.getDisplayData().forEach((o,i)=>{this._matrix[o[s]][o[a]]={value:o.value,index:i}})}return this._matrix}setData(t){const e=this.sanitize(n.cloneDeep(t)),s=this.generateDataGroups(e);return this.set({data:e,dataGroups:s}),this._domains=[],this._ranges=[],this._matrix={},e}getMatrixAsArray(){n.isEmpty(this._matrix)&&this.getMatrix();const t=this.getUniqueDomain(),e=this.getUniqueRanges(),s=this.services.cartesianScales.getDomainIdentifier(),a=this.services.cartesianScales.getRangeIdentifier(),r=[];return t.forEach(o=>{e.forEach(i=>{const l={value:this._matrix[o][i].value,index:this._matrix[o][i].index};l[s]=o,l[a]=i,r.push(l)})}),r}getTabularDataArray(){const t=this.getDisplayData(),{primaryDomain:e,primaryRange:s}=this.assignRangeAndDomains();return[[e.label,s.label,"Value"],...t.map(r=>[r[e.identifier]===null?"&ndash;":r[e.identifier],r[s.identifier]===null?"&ndash;":r[s.identifier].toLocaleString(),r.value])]}getColorClassName(t){return`${t.originalClassName} ${this._colorScale(t.value)}`}setColorClassNames(){const t=this.getOptions(),e=n.getProperty(t,"color","gradient","colors"),s=!n.isEmpty(e);let a=n.getProperty(t,"color","pairing","option");const r=this.getValueDomain(),o=r[0]<0&&r[1]>0?"diverge":"mono";(a<1&&a>4&&o==="mono"||a<1&&a>2&&o==="diverge")&&(a=1);const i=s?e:[];if(!s){const c=o==="diverge"?17:11;for(let p=1;p<c+1;p++)i.push(`fill-${o}-${a}-${p}`)}this._colorScale=f.scaleQuantize().domain(r).range(i);const l=n.getProperty(this.getOptions(),"color");this._colorScale=n.getColorScale(this.getDisplayData(),l)}}class F extends x{getTabularDataArray(){const t=this.getOptions(),{groupMapsTo:e}=t.data,s=this.getBinnedStackedData();return[[n.get(t,"bins.rangeLabel")||"Range",...s.map(r=>n.get(r,`0.${e}`))],...n.get(s,0).map((r,o)=>[`${n.get(r,"data.x0")} – ${n.get(r,"data.x1")}`,...s.map(i=>n.get(i[o],`data.${n.get(i[o],e)}`))])]}}class z extends m{constructor(t){super(t)}getMaximumDomain(t){return t.reduce((s,a)=>s+a.value,0)}getFillColor(t){const e=this.getOptions(),s=n.getProperty(e,"color","scale"),a=this.getStatus();return s||!a?super.getFillColor(t):null}getStatus(){const t=this.getOptions(),e=n.getProperty(this.getDisplayData()),s=(e==null?void 0:e.reduce((o,i)=>o+i.value,0))??0,a=n.getProperty(t,"meter","proportional")?s:s>100?100:s,r=n.getProperty(t,"meter","status","ranges");if(r){const o=r.filter(i=>i.range[0]<=a&&a<=i.range[1]);if(o.length>0)return o[0].status}return null}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{groupMapsTo:s}=e.data,a=this.getStatus(),r=n.getProperty(e,"meter","proportional");let o=[],i;if(r===null){i=100;const l=t[0];o=[["Group","Value",...a?["Status"]:[]],[l[s],l.value,...a?[a]:[]]]}else{const l=n.getProperty(r,"total");i=l||this.getMaximumDomain(t),o=[["Group","Value","Percentage of total"],...t.map(c=>[c[s],c.value,(c.value/i*100).toFixed(2)+" %"])]}return o}}class U extends x{constructor(t){super(t)}getTabularDataArray(){const t=this.getOptions(),e=this.getGroupedData(),{angle:s,value:a}=n.getProperty(t,"radar","axes"),r=n.getProperty(e,"0","data").map(i=>i[s]);return[["Group",...r],...e.map(i=>[i.name,...r.map((l,c)=>n.getProperty(i,"data",c,a)!==null?n.getProperty(i,"data",c,a).toLocaleString():"&ndash;")])]}}class j extends m{constructor(t){super(t)}getTabularDataArray(){const t=this.getDisplayData(),e=[["Child","Parent"]];return t.forEach(s=>{this.getChildrenDatums(s,e),e.push([s.name,"&ndash;"])}),e}getChildrenDatums(t,e=[]){t.children&&t.children.length>0&&t.children.forEach(s=>{this.getChildrenDatums(s,e),e.push([s.name,t.name])})}}class K extends m{constructor(t){super(t)}getTabularDataArray(){const t=this.getDisplayData(),e=[["Child","Group","Value"]];return t.forEach(s=>{Array.isArray(s.children)?s.children.forEach(a=>{e.push([a.name,s.name,a.value])}):n.getProperty(s.name)!==null&&n.getProperty(s.value)&&e.push(["–",s.name,s.value])}),e}}class Z extends m{constructor(t){super(t)}getTabularDataArray(){const t=this.getDisplayData(),e=this.getOptions(),{fontSizeMapsTo:s,wordMapsTo:a}=e.wordCloud,{groupMapsTo:r}=e.data;return[[e.tooltip.wordLabel,"Group",e.tooltip.valueLabel],...t.map(i=>[i[a],i[r],i[s]])]}}exports.AlluvialChartModel=k;exports.BoxplotChartModel=B;exports.BulletChartModel=N;exports.ChartModel=m;exports.ChartModelBinned=F;exports.ChartModelCartesian=x;exports.ChoroplethModel=L;exports.CirclePackChartModel=V;exports.GaugeChartModel=$;exports.HeatmapModel=w;exports.MeterChartModel=z;exports.PieChartModel=R;exports.RadarChartModel=U;exports.TreeChartModel=j;exports.TreemapChartModel=K;exports.WordCloudModel=Z;
3
3
  //# sourceMappingURL=index.js.map