@kyndryl-design-system/shidoka-charts 2.0.2 → 2.1.0
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/common/config/chartTypes/bubble.js +1 -1
- package/common/config/chartTypes/bubble.js.map +1 -1
- package/common/config/chartTypes/bubbleMap.js +1 -1
- package/common/config/chartTypes/bubbleMap.js.map +1 -1
- package/common/config/chartTypes/choropleth.js +1 -1
- package/common/config/chartTypes/choropleth.js.map +1 -1
- package/common/config/chartTypes/doughnut.js +1 -1
- package/common/config/chartTypes/doughnut.js.map +1 -1
- package/common/config/chartTypes/matrix.js +2 -0
- package/common/config/chartTypes/matrix.js.map +1 -0
- package/common/config/chartTypes/meter.js +1 -1
- package/common/config/chartTypes/meter.js.map +1 -1
- package/common/config/chartTypes/pie.js +1 -1
- package/common/config/chartTypes/pie.js.map +1 -1
- package/common/plugins/gradientLegend.js +2 -0
- package/common/plugins/gradientLegend.js.map +1 -0
- package/components/chart/chart.d.ts.map +1 -1
- package/components/chart/chart.js +92 -58
- package/components/chart/chart.js.map +1 -1
- package/external/chartjs-chart-matrix/dist/chartjs-chart-matrix.esm.js +8 -0
- package/external/chartjs-chart-matrix/dist/chartjs-chart-matrix.esm.js.map +1 -0
- package/package.json +2 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getComputedColorPalette as o}from"../colorPalettes.js";const t="bubble",r=
|
|
1
|
+
import{getComputedColorPalette as o}from"../colorPalettes.js";const t="bubble",r=()=>({}),e=(t,r)=>{const e=o(t.options.colorPalette||"categorical"),l=Math.floor(r/(e.length-1));return{backgroundColor:e[r>e.length-1?r-(e.length-1)*l:r]+"80",borderColor:e[r]}};export{e as datasetOptions,r as options,t as type};
|
|
2
2
|
//# sourceMappingURL=bubble.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bubble.js","sources":["../../../../src/common/config/chartTypes/bubble.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'bubble';\n\nexport const options = (
|
|
1
|
+
{"version":3,"file":"bubble.js","sources":["../../../../src/common/config/chartTypes/bubble.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'bubble';\n\nexport const options = () => {\n return {};\n};\n\nexport const datasetOptions = (ctx, index) => {\n const Colors = getComputedColorPalette(\n ctx.options.colorPalette || 'categorical'\n );\n const ColorCycles = Math.floor(index / (Colors.length - 1));\n const Index =\n index > Colors.length - 1\n ? index - (Colors.length - 1) * ColorCycles\n : index;\n\n return {\n backgroundColor: Colors[Index] + '80', // 50% opacity\n borderColor: Colors[index],\n };\n};\n"],"names":["type","options","datasetOptions","ctx","index","Colors","getComputedColorPalette","colorPalette","ColorCycles","Math","floor","length","backgroundColor","borderColor"],"mappings":"8DAEY,MAACA,EAAO,SAEPC,EAAU,KACd,IAGIC,EAAiB,CAACC,EAAKC,KAClC,MAAMC,EAASC,EACbH,EAAIF,QAAQM,cAAgB,eAExBC,EAAcC,KAAKC,MAAMN,GAASC,EAAOM,OAAS,IAMxD,MAAO,CACLC,gBAAiBP,EALjBD,EAAQC,EAAOM,OAAS,EACpBP,GAASC,EAAOM,OAAS,GAAKH,EAC9BJ,GAG6B,KACjCS,YAAaR,EAAOD,GACrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getComputedColorPalette as o}from"../colorPalettes.js";import{getTokenThemeVal as e}from'./../../../external/@kyndryl-design-system/shidoka-foundation/common/helpers/color.js';const r="bubbleMap",a=r=>{const a=e("--kd-color-background-page-default"),t=e("--kd-color-text-variant-inversed"),l=o(r.options.colorPalette||"categorical"),n=e("--kd-color-data-viz-level-secondary"),d=e("--kd-color-border-variants-light");return{outlineBorderWidth:.5,outlineBorderColor:a,outlineBackgroundColor:n,backgroundColor:l[0],plugins:{legend:{display:!1},datalabels:{font:{size:12,weight:"bold"},color:t,display:function(o
|
|
1
|
+
import{getComputedColorPalette as o}from"../colorPalettes.js";import{getTokenThemeVal as e}from'./../../../external/@kyndryl-design-system/shidoka-foundation/common/helpers/color.js';const r="bubbleMap",a=r=>{const a=e("--kd-color-background-page-default"),t=e("--kd-color-text-variant-inversed"),l=o(r.options.colorPalette||"categorical"),n=e("--kd-color-data-viz-level-secondary"),d=e("--kd-color-border-variants-light");return{outlineBorderWidth:.5,outlineBorderColor:a,outlineBackgroundColor:n,backgroundColor:l[0],plugins:{legend:{display:!1},datalabels:{font:{size:12,weight:"bold"},color:t,display:function(o){const e=o.dataset.data[o.dataIndex].value,r=o.chart.scales.size._range;return e>(r.min+r.max)/2&&"auto"},align:"center",anchor:"center",formatter:function(o){return o.value}}},scales:{projection:{axis:"x",projection:"naturalEarth1"},x:{display:!1},y:{display:!1},size:{axis:"x",grid:{color:d},border:{color:d}}}}},t=()=>({});export{t as datasetOptions,a as options,r as type};
|
|
2
2
|
//# sourceMappingURL=bubbleMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bubbleMap.js","sources":["../../../../src/common/config/chartTypes/bubbleMap.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\nimport { getTokenThemeVal } from '@kyndryl-design-system/shidoka-foundation/common/helpers/color';\n\nexport const type = 'bubbleMap';\n\nexport const options = (ctx) => {\n const BorderColor = getTokenThemeVal('--kd-color-background-page-default');\n const LabelColor = getTokenThemeVal('--kd-color-text-variant-inversed');\n const Colors = getComputedColorPalette(\n ctx.options.colorPalette || 'categorical'\n );\n const BubbleColor = getTokenThemeVal('--kd-color-data-viz-level-secondary');\n const LegendTicksColor = getTokenThemeVal('--kd-color-border-variants-light');\n\n return {\n outlineBorderWidth: 0.5,\n outlineBorderColor: BorderColor,\n outlineBackgroundColor: BubbleColor,\n backgroundColor: Colors[0], // + '80', // 50% opacity\n plugins: {\n legend: {\n display: false,\n },\n datalabels: {\n font: {\n size: 12,\n weight: 'bold',\n },\n color: LabelColor,\n // display: 'auto',\n display: function (context
|
|
1
|
+
{"version":3,"file":"bubbleMap.js","sources":["../../../../src/common/config/chartTypes/bubbleMap.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\nimport { getTokenThemeVal } from '@kyndryl-design-system/shidoka-foundation/common/helpers/color';\n\nexport const type = 'bubbleMap';\n\nexport const options = (ctx) => {\n const BorderColor = getTokenThemeVal('--kd-color-background-page-default');\n const LabelColor = getTokenThemeVal('--kd-color-text-variant-inversed');\n const Colors = getComputedColorPalette(\n ctx.options.colorPalette || 'categorical'\n );\n const BubbleColor = getTokenThemeVal('--kd-color-data-viz-level-secondary');\n const LegendTicksColor = getTokenThemeVal('--kd-color-border-variants-light');\n\n return {\n outlineBorderWidth: 0.5,\n outlineBorderColor: BorderColor,\n outlineBackgroundColor: BubbleColor,\n backgroundColor: Colors[0], // + '80', // 50% opacity\n plugins: {\n legend: {\n display: false,\n },\n datalabels: {\n font: {\n size: 12,\n weight: 'bold',\n },\n color: LabelColor,\n // display: 'auto',\n display: function (context) {\n const Value = context.dataset.data[context.dataIndex].value;\n const Range = context.chart.scales.size._range;\n const Avg = (Range.min + Range.max) / 2;\n\n return Value > Avg ? 'auto' : false;\n },\n align: 'center',\n anchor: 'center',\n formatter: function (entry) {\n return entry.value;\n },\n },\n },\n scales: {\n projection: {\n axis: 'x',\n projection: 'naturalEarth1',\n },\n x: {\n display: false,\n },\n y: {\n display: false,\n },\n size: {\n axis: 'x',\n grid: {\n color: LegendTicksColor,\n },\n border: {\n color: LegendTicksColor,\n },\n },\n },\n };\n};\n\nexport const datasetOptions = () => {\n return {};\n};\n"],"names":["type","options","ctx","BorderColor","getTokenThemeVal","LabelColor","Colors","getComputedColorPalette","colorPalette","BubbleColor","LegendTicksColor","outlineBorderWidth","outlineBorderColor","outlineBackgroundColor","backgroundColor","plugins","legend","display","datalabels","font","size","weight","color","context","Value","dataset","data","dataIndex","value","Range","chart","scales","_range","min","max","align","anchor","formatter","entry","projection","axis","x","y","grid","border","datasetOptions"],"mappings":"yLAGY,MAACA,EAAO,YAEPC,EAAWC,IACtB,MAAMC,EAAcC,EAAiB,sCAC/BC,EAAaD,EAAiB,oCAC9BE,EAASC,EACbL,EAAID,QAAQO,cAAgB,eAExBC,EAAcL,EAAiB,uCAC/BM,EAAmBN,EAAiB,oCAE1C,MAAO,CACLO,mBAAoB,GACpBC,mBAAoBT,EACpBU,uBAAwBJ,EACxBK,gBAAiBR,EAAO,GACxBS,QAAS,CACPC,OAAQ,CACNC,SAAS,GAEXC,WAAY,CACVC,KAAM,CACJC,KAAM,GACNC,OAAQ,QAEVC,MAAOjB,EAEPY,QAAS,SAAUM,GACjB,MAAMC,EAAQD,EAAQE,QAAQC,KAAKH,EAAQI,WAAWC,MAChDC,EAAQN,EAAQO,MAAMC,OAAOX,KAAKY,OAGxC,OAAOR,GAFMK,EAAMI,IAAMJ,EAAMK,KAAO,GAEjB,MACtB,EACDC,MAAO,SACPC,OAAQ,SACRC,UAAW,SAAUC,GACnB,OAAOA,EAAMV,KACd,IAGLG,OAAQ,CACNQ,WAAY,CACVC,KAAM,IACND,WAAY,iBAEdE,EAAG,CACDxB,SAAS,GAEXyB,EAAG,CACDzB,SAAS,GAEXG,KAAM,CACJoB,KAAM,IACNG,KAAM,CACJrB,MAAOZ,GAETkC,OAAQ,CACNtB,MAAOZ,KAId,EAGUmC,EAAiB,KACrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getComputedColorPalette as o}from"../colorPalettes.js";import{getTokenThemeVal as r}from'./../../../external/@kyndryl-design-system/shidoka-foundation/common/helpers/color.js';const e="choropleth",t=e=>{const t=r("--kd-color-background-page-default"),l=r("--kd-color-border-variants-light");return{borderWidth:.5,borderColor:t,plugins:{legend:{display:!1}},scales:{projection:{axis:"x",projection:"naturalEarth1"},x:{display:!1},y:{display:!1},color:{axis:"x",interpolate:r=>{const t=o(e.options.colorPalette||"sequential01");return t[Math.round(r*(t.length-1))]},grid:{color:l},border:{color:l}}}}},l=(
|
|
1
|
+
import{getComputedColorPalette as o}from"../colorPalettes.js";import{getTokenThemeVal as r}from'./../../../external/@kyndryl-design-system/shidoka-foundation/common/helpers/color.js';const e="choropleth",t=e=>{const t=r("--kd-color-background-page-default"),l=r("--kd-color-border-variants-light");return{borderWidth:.5,borderColor:t,plugins:{legend:{display:!1}},scales:{projection:{axis:"x",projection:"naturalEarth1"},x:{display:!1},y:{display:!1},color:{axis:"x",interpolate:r=>{const t=o(e.options.colorPalette||"sequential01");return t[Math.round(r*(t.length-1))]},grid:{color:l},border:{color:l}}}}},l=()=>({});export{l as datasetOptions,t as options,e as type};
|
|
2
2
|
//# sourceMappingURL=choropleth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.js","sources":["../../../../src/common/config/chartTypes/choropleth.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\nimport { getTokenThemeVal } from '@kyndryl-design-system/shidoka-foundation/common/helpers/color';\n\nexport const type = 'choropleth';\n\nexport const options = (ctx) => {\n const BorderColor = getTokenThemeVal('--kd-color-background-page-default');\n const LegendTicksColor = getTokenThemeVal('--kd-color-border-variants-light');\n\n return {\n borderWidth: 0.5,\n borderColor: BorderColor,\n plugins: {\n legend: {\n display: false,\n },\n },\n scales: {\n projection: {\n axis: 'x',\n projection: 'naturalEarth1',\n },\n x: {\n display: false,\n },\n y: {\n display: false,\n },\n color: {\n axis: 'x',\n interpolate: (value) => {\n const Colors = getComputedColorPalette(\n ctx.options.colorPalette || 'sequential01'\n );\n const Index = Math.round(value * (Colors.length - 1));\n return Colors[Index];\n },\n grid: {\n color: LegendTicksColor,\n },\n border: {\n color: LegendTicksColor,\n },\n },\n },\n };\n};\n\nexport const datasetOptions = (
|
|
1
|
+
{"version":3,"file":"choropleth.js","sources":["../../../../src/common/config/chartTypes/choropleth.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\nimport { getTokenThemeVal } from '@kyndryl-design-system/shidoka-foundation/common/helpers/color';\n\nexport const type = 'choropleth';\n\nexport const options = (ctx) => {\n const BorderColor = getTokenThemeVal('--kd-color-background-page-default');\n const LegendTicksColor = getTokenThemeVal('--kd-color-border-variants-light');\n\n return {\n borderWidth: 0.5,\n borderColor: BorderColor,\n plugins: {\n legend: {\n display: false,\n },\n },\n scales: {\n projection: {\n axis: 'x',\n projection: 'naturalEarth1',\n },\n x: {\n display: false,\n },\n y: {\n display: false,\n },\n color: {\n axis: 'x',\n interpolate: (value) => {\n const Colors = getComputedColorPalette(\n ctx.options.colorPalette || 'sequential01'\n );\n const Index = Math.round(value * (Colors.length - 1));\n return Colors[Index];\n },\n grid: {\n color: LegendTicksColor,\n },\n border: {\n color: LegendTicksColor,\n },\n },\n },\n };\n};\n\nexport const datasetOptions = () => {\n return {};\n};\n"],"names":["type","options","ctx","BorderColor","getTokenThemeVal","LegendTicksColor","borderWidth","borderColor","plugins","legend","display","scales","projection","axis","x","y","color","interpolate","value","Colors","getComputedColorPalette","colorPalette","Math","round","length","grid","border","datasetOptions"],"mappings":"yLAGY,MAACA,EAAO,aAEPC,EAAWC,IACtB,MAAMC,EAAcC,EAAiB,sCAC/BC,EAAmBD,EAAiB,oCAE1C,MAAO,CACLE,YAAa,GACbC,YAAaJ,EACbK,QAAS,CACPC,OAAQ,CACNC,SAAS,IAGbC,OAAQ,CACNC,WAAY,CACVC,KAAM,IACND,WAAY,iBAEdE,EAAG,CACDJ,SAAS,GAEXK,EAAG,CACDL,SAAS,GAEXM,MAAO,CACLH,KAAM,IACNI,YAAcC,IACZ,MAAMC,EAASC,EACblB,EAAID,QAAQoB,cAAgB,gBAG9B,OAAOF,EADOG,KAAKC,MAAML,GAASC,EAAOK,OAAS,IAC9B,EAEtBC,KAAM,CACJT,MAAOX,GAETqB,OAAQ,CACNV,MAAOX,KAId,EAGUsB,EAAiB,KACrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getComputedColorPalette as t}from"../colorPalettes.js";const a="doughnut",e=
|
|
1
|
+
import{getComputedColorPalette as t}from"../colorPalettes.js";const a="doughnut",e=()=>({radius:"80%",plugins:{datalabels:{font:{size:14},display:"auto",align:"end",anchor:"end",formatter:function(t,a){const e=a.chart.data.datasets[0].data.filter(((t,e)=>!a.chart.legend.legendItems[e].hidden)).reduce(((t,a)=>t+a),0),o=Math.round(100*(t/e+Number.EPSILON))+"%";return e?o:""}}}}),o=a=>({backgroundColor:t(a.options.colorPalette||"categorical")});export{o as datasetOptions,e as options,a as type};
|
|
2
2
|
//# sourceMappingURL=doughnut.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doughnut.js","sources":["../../../../src/common/config/chartTypes/doughnut.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'doughnut';\n\nexport const options = (
|
|
1
|
+
{"version":3,"file":"doughnut.js","sources":["../../../../src/common/config/chartTypes/doughnut.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'doughnut';\n\nexport const options = () => {\n return {\n radius: '80%',\n plugins: {\n datalabels: {\n font: {\n size: 14,\n },\n display: 'auto',\n align: 'end',\n anchor: 'end',\n formatter: function (value, context) {\n const total = context.chart.data.datasets[0].data\n .filter(\n (dataPoint, index) =>\n !context.chart.legend.legendItems[index].hidden\n )\n .reduce((a, b) => a + b, 0);\n\n const percentage =\n Math.round((value / total + Number.EPSILON) * 100) + '%';\n\n return !total ? '' : percentage;\n },\n },\n },\n };\n};\n\nexport const datasetOptions = (ctx) => {\n return {\n backgroundColor: getComputedColorPalette(\n ctx.options.colorPalette || 'categorical'\n ),\n };\n};\n"],"names":["type","options","radius","plugins","datalabels","font","size","display","align","anchor","formatter","value","context","total","chart","data","datasets","filter","dataPoint","index","legend","legendItems","hidden","reduce","a","b","percentage","Math","round","Number","EPSILON","datasetOptions","ctx","backgroundColor","getComputedColorPalette","colorPalette"],"mappings":"8DAEY,MAACA,EAAO,WAEPC,EAAU,KACd,CACLC,OAAQ,MACRC,QAAS,CACPC,WAAY,CACVC,KAAM,CACJC,KAAM,IAERC,QAAS,OACTC,MAAO,MACPC,OAAQ,MACRC,UAAW,SAAUC,EAAOC,GAC1B,MAAMC,EAAQD,EAAQE,MAAMC,KAAKC,SAAS,GAAGD,KAC1CE,QACC,CAACC,EAAWC,KACTP,EAAQE,MAAMM,OAAOC,YAAYF,GAAOG,SAE5CC,QAAO,CAACC,EAAGC,IAAMD,EAAIC,GAAG,GAErBC,EACJC,KAAKC,MAAyC,KAAlCjB,EAAQE,EAAQgB,OAAOC,UAAkB,IAEvD,OAAQjB,EAAaa,EAAL,EACjB,MAMIK,EAAkBC,IACtB,CACLC,gBAAiBC,EACfF,EAAI/B,QAAQkC,cAAgB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getComputedColorPalette as t}from"../colorPalettes.js";const e="matrix",i=(t,e={})=>{const{xAxis:i,yAxis:l,xKey:o="x",yKey:a="y",valueKey:n="value"}=e;if(!(i&&l&&Array.isArray(i)&&Array.isArray(l)))throw new Error("xAxis and yAxis must be provided as arrays");const r=[],s=new Map;t.forEach((t=>{const e=`${t[o]}-${t[a]}`;s.set(e,t[n])}));for(let t=1;t<=l.length;t++)for(let e=1;e<=i.length;e++){const o=l[t-1],a=`${i[e-1]}-${o}`,n=s.has(a)?s.get(a):void 0;r.push({x:e,y:t,value:n})}return r};let l=!1;function o(t){l=!!t}function a(){return!!l||!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullscreenElement||document.msFullscreenElement)}function n(t,e){if(!t||"string"!=typeof t||!t.startsWith("#"))return`rgba(204, 204, 204, ${isNaN(e)?.7:e})`;const i=isNaN(e)?.7:e,{r:l,g:o,b:a}=function(t){if(!t||"string"!=typeof t||!t.startsWith("#")||t.length<7)return{r:0,g:0,b:0};const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),l=parseInt(t.slice(5,7),16);return{r:isNaN(e)?0:e,g:isNaN(i)?0:i,b:isNaN(l)?0:l}}(t);return`rgba(${l}, ${o}, ${a}, ${i})`}function r(t,e,i=50,l=15,o=1,a){if(!e||!Array.isArray(e)||0===e.length)return`rgba(204, 204, 204, ${o})`;if((a||"").toLowerCase().includes("divergent")){const i=-100,l=100,a=Math.floor(e.length/2);if(t<=0){const l=(t-i)/(0-i),r=Math.round(l*a);return n(e[Math.min(r,a)],o)}{const i=t/l,r=a+Math.round(i*(e.length-a-1));return n(e[Math.min(r,e.length-1)],o)}}{const i=0,l=(t-i)/(100-i),a=Math.round(l*(e.length-1));return n(e[Math.min(a,e.length-1)],o)}}const s={id:"gradientLegend",afterDraw(t,e,i){if(!i||!i.display)return;const l=i.colors||t.options.plugins?.gradientLegend?.colors||t.options.colorScale?.colors||t.data?.datasets?.[0]?._colorPalette;if(!l||!l.length)return;const o=t.ctx,a=t.chartArea,r=(i.paletteKey||"").toLowerCase().includes("divergent"),s=t.options.colorScale||{},c=s.min??(r?-100:0),d=s.neutral??(r?0:50),g=s.max??100,h={position:i.position||"bottom",width:i.width||Math.min(400,.8*a.width),height:i.height||20,margin:i.margin||10,borderRadius:i.borderRadius||4,gradientBorderRadius:1,title:i.title||"",titleFontSize:i.titleFontSize||12,labelFontSize:i.labelFontSize||12,labelMargin:i.labelMargin||5,opacity:"number"==typeof i.opacity?i.opacity:.7,...i};let u,p;"bottom"===h.position?(u=a.left+(a.width-h.width)/2,p=a.bottom+h.margin):"top"===h.position?(u=a.left+(a.width-h.width)/2,p=a.top-h.margin-h.height):"bottom-left"===h.position?(u=a.left-70,p=a.bottom+70):(u=a.left+(a.width-h.width)/2,p=a.bottom+h.margin);const f=o.createLinearGradient(u,p,u+h.width,p),b=l.findIndex((t=>t.toLowerCase().includes("neutral")));if(b>0){const t=l.slice(0,b),e=l[b],i=l.slice(b+1);t.forEach(((e,i)=>{const l=t.length>1?i/(t.length-1)*.5:0;f.addColorStop(l,n(e,h.opacity))})),f.addColorStop(.5,n(e,h.opacity)),i.forEach(((t,e)=>{const l=.5+(i.length>1?e/(i.length-1)*.5:0);f.addColorStop(l,n(t,h.opacity))}))}else l.forEach(((t,e)=>{f.addColorStop(e/(l.length-1),n(t,h.opacity))}));function m(t,e,i,l,a){o.beginPath(),o.moveTo(t+a,e),o.lineTo(t+i-a,e),o.arcTo(t+i,e,t+i,e+a,a),o.lineTo(t+i,e+l-a),o.arcTo(t+i,e+l,t+i-a,e+l,a),o.lineTo(t+a,e+l),o.arcTo(t,e+l,t,e+l-a,a),o.lineTo(t,e+a),o.arcTo(t,e,t+a,e,a),o.closePath()}h.title&&(o.font=`500 ${h.titleFontSize}px ${t.options.font?.family||"Arial"}`,o.textAlign="left",o.textBaseline="bottom",o.fillStyle=t.options.color||"#666",o.fillText(h.title,u,p-h.labelMargin)),o.fillStyle="#fff",m(u,p,h.width,h.height,h.borderRadius),o.fill(),o.fillStyle=f,m(u,p,h.width,h.height,h.gradientBorderRadius),o.fill(),o.font=`${h.labelFontSize}px ${t.options.font?.family||"Arial"}`,o.fillStyle=t.options.color||"#666";const y=t=>t.toString();o.textAlign="left",o.textBaseline="top",o.fillText(y(c),u,p+h.height+h.labelMargin),l.length>=3&&void 0!==d&&(o.textAlign="center",o.fillText(y(d),u+h.width/2,p+h.height+h.labelMargin)),o.textAlign="right",o.fillText(y(g),u+h.width,p+h.height+h.labelMargin)}},c=e=>{const i=e?.datasets?.[0],l=(i?.data??[]).map((t=>"number"==typeof t.value?t.value:void 0)).filter((t=>void 0!==t)),o=e.options?.colorPalette||"sequential02",n=t(o),r=l.length?Math.min(...l):0,s=l.length?Math.max(...l):0,c=o.toLowerCase().includes("divergent")?0:50,d=e.options?.plugins?.gradientLegend?.display;return{responsive:!1,maintainAspectRatio:!0,aspectRatio:2,layout:{padding:d?{bottom:30}:{bottom:0}},plugins:{tooltip:{callbacks:{title:()=>"",label(t){const i=t.dataset.data[t.dataIndex];return[`${e.labels.y?.[i.y-1]||e.labels[i.y-1]} - ${e.labels.x?.[i.x-1]||e.labels[i.x-1]}`,`Value: ${i.value??"N/A"}`]}}},legend:{display:!1},gradientLegend:{display:d,position:"bottom-left",title:e.options?.plugins?.gradientLegend?.title||"",margin:0,height:15,width:280,opacity:.8,colors:n,paletteKey:o,legendLabels:[r,c,s]}},colorPalette:n,colorScale:{min:r,neutral:c,max:s,colors:n},scales:{x:{grid:{display:!1},min:1,max:e.labels.x?.length??e.labels?.length??3,offset:!0,ticks:{autoSkip:!1,maxTicksLimit:15,callback:t=>e.labels.x?.[t-1]??e.labels?.[t-1]??"",padding:function(){return a()?30:20}},afterFit(t){d&&(t.height-=10)}},y:{grid:{display:!1},min:1,max:e.labels.y?.length??e.labels?.length??3,ticks:{autoSkip:!1,maxTicksLimit:15,callback:t=>e.labels.y?.[t-1]??e.labels?.[t-1]??"",padding:function(){return a()?15:8}}}}}},d=e=>{const i=e.options?.colorPalette||"categorical",l=t(i),o=e.labels.x?.length??e.labels?.length??3,n=e.labels.y?.length??e.labels?.length??3;return{borderWidth:0,borderColor:"transparent",width({chart:t}){const e=(t.chartArea?.width??0)/o-2;return e>0?e:1},height({chart:t}){const e=t.chartArea?.height??0,i=e/n-0;return a()?e/11.75:Math.min(i,60)},backgroundColor:({raw:t})=>void 0!==t?.value?r(t.value,l,50,15,.8,i):"rgba(204, 204, 204, 0.8)",hoverBackgroundColor:({raw:t})=>void 0!==t?.value?r(t.value,l,50,15,1,i):"#999"}};var g={options:c,datasetOptions:d,plugins:[s]};export{i as createMatrixData,d as datasetOptions,g as default,c as options,o as setMatrixFullscreen,e as type};
|
|
2
|
+
//# sourceMappingURL=matrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix.js","sources":["../../../../src/common/config/chartTypes/matrix.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'matrix';\n\nexport const createMatrixData = (data, options = {}) => {\n const { xAxis, yAxis, xKey = 'x', yKey = 'y', valueKey = 'value' } = options;\n\n if (!xAxis || !yAxis || !Array.isArray(xAxis) || !Array.isArray(yAxis)) {\n throw new Error('xAxis and yAxis must be provided as arrays');\n }\n\n const matrixData = [];\n const dataMap = new Map();\n\n data.forEach((item) => {\n const xValue = item[xKey];\n const yValue = item[yKey];\n const key = `${xValue}-${yValue}`;\n dataMap.set(key, item[valueKey]);\n });\n\n for (let y = 1; y <= yAxis.length; y++) {\n for (let x = 1; x <= xAxis.length; x++) {\n const yValue = yAxis[y - 1];\n const xValue = xAxis[x - 1];\n const key = `${xValue}-${yValue}`;\n const value = dataMap.has(key) ? dataMap.get(key) : undefined;\n matrixData.push({ x, y, value });\n }\n }\n\n return matrixData;\n};\n\nconst defaultOpacity = 0.8;\n\nlet isMatrixFullscreen = false;\n\nexport function setMatrixFullscreen(state) {\n isMatrixFullscreen = !!state;\n}\n\nfunction isFullScreen() {\n if (isMatrixFullscreen) {\n return true;\n }\n\n return !!(\n document.fullscreenElement ||\n document.webkitFullscreenElement ||\n document.mozFullscreenElement ||\n document.msFullscreenElement\n );\n}\n\nfunction parseColor(hex) {\n if (\n !hex ||\n typeof hex !== 'string' ||\n !hex.startsWith('#') ||\n hex.length < 7\n ) {\n return { r: 0, g: 0, b: 0 };\n }\n\n const r = parseInt(hex.slice(1, 3), 16);\n const g = parseInt(hex.slice(3, 5), 16);\n const b = parseInt(hex.slice(5, 7), 16);\n return { r: isNaN(r) ? 0 : r, g: isNaN(g) ? 0 : g, b: isNaN(b) ? 0 : b };\n}\n\nfunction getColorWithOpacity(color, opacity) {\n if (!color || typeof color !== 'string' || !color.startsWith('#')) {\n return `rgba(204, 204, 204, ${!isNaN(opacity) ? opacity : 0.7})`;\n }\n\n const finalOpacity = !isNaN(opacity) ? opacity : 0.7;\n const { r, g, b } = parseColor(color);\n return `rgba(${r}, ${g}, ${b}, ${finalOpacity})`;\n}\n\nfunction getPresetSymmetricColor(\n value,\n colors,\n neutral = 50,\n band = 15,\n opacity = 1,\n paletteKey\n) {\n if (!colors || !Array.isArray(colors) || colors.length === 0) {\n return `rgba(204, 204, 204, ${opacity})`;\n }\n\n const key = paletteKey || '';\n if (key.toLowerCase().includes('divergent')) {\n const minVal = -100;\n const maxVal = 100;\n const neutralIndex = Math.floor(colors.length / 2);\n if (value <= 0) {\n const ratio = (value - minVal) / (0 - minVal);\n const idx = Math.round(ratio * neutralIndex);\n return getColorWithOpacity(colors[Math.min(idx, neutralIndex)], opacity);\n } else {\n const ratio = value / maxVal;\n const idx =\n neutralIndex + Math.round(ratio * (colors.length - neutralIndex - 1));\n return getColorWithOpacity(\n colors[Math.min(idx, colors.length - 1)],\n opacity\n );\n }\n } else {\n const minVal = 0;\n const maxVal = 100;\n const ratio = (value - minVal) / (maxVal - minVal);\n const idx = Math.round(ratio * (colors.length - 1));\n return getColorWithOpacity(\n colors[Math.min(idx, colors.length - 1)],\n opacity\n );\n }\n}\n\nconst gradientLegendPlugin = {\n id: 'gradientLegend',\n afterDraw(chart, args, options) {\n if (!options || !options.display) return;\n const Colors =\n options.colors ||\n chart.options.plugins?.gradientLegend?.colors ||\n chart.options.colorScale?.colors ||\n chart.data?.datasets?.[0]?._colorPalette;\n if (!Colors || !Colors.length) return;\n\n const ctx = chart.ctx;\n const chartArea = chart.chartArea;\n const paletteKey = options.paletteKey || '';\n const isDivergentPalette = paletteKey.toLowerCase().includes('divergent');\n const computedScale = chart.options.colorScale || {};\n const minVal = computedScale.min ?? (isDivergentPalette ? -100 : 0);\n const neutralVal = computedScale.neutral ?? (isDivergentPalette ? 0 : 50);\n const maxVal = computedScale.max ?? (isDivergentPalette ? 100 : 100);\n\n const legendOptions = {\n position: options.position || 'bottom',\n width: options.width || Math.min(400, chartArea.width * 0.8),\n height: options.height || 20,\n margin: options.margin || 10,\n borderRadius: options.borderRadius || 4,\n gradientBorderRadius: 1,\n title: options.title || '',\n titleFontSize: options.titleFontSize || 12,\n labelFontSize: options.labelFontSize || 12,\n labelMargin: options.labelMargin || 5,\n opacity: typeof options.opacity === 'number' ? options.opacity : 0.7,\n ...options,\n };\n\n let x, y;\n if (legendOptions.position === 'bottom') {\n x = chartArea.left + (chartArea.width - legendOptions.width) / 2;\n y = chartArea.bottom + legendOptions.margin;\n } else if (legendOptions.position === 'top') {\n x = chartArea.left + (chartArea.width - legendOptions.width) / 2;\n y = chartArea.top - legendOptions.margin - legendOptions.height;\n } else if (legendOptions.position === 'bottom-left') {\n x = chartArea.left - 70;\n y = chartArea.bottom + 70;\n } else {\n x = chartArea.left + (chartArea.width - legendOptions.width) / 2;\n y = chartArea.bottom + legendOptions.margin;\n }\n\n const gradient = ctx.createLinearGradient(x, y, x + legendOptions.width, y);\n const neutralIndex = Colors.findIndex((c) =>\n c.toLowerCase().includes('neutral')\n );\n if (neutralIndex > 0) {\n const negativeColors = Colors.slice(0, neutralIndex);\n const neutralColor = Colors[neutralIndex];\n const positiveColors = Colors.slice(neutralIndex + 1);\n negativeColors.forEach((color, i) => {\n const t =\n negativeColors.length > 1\n ? (i / (negativeColors.length - 1)) * 0.5\n : 0;\n gradient.addColorStop(\n t,\n getColorWithOpacity(color, legendOptions.opacity)\n );\n });\n gradient.addColorStop(\n 0.5,\n getColorWithOpacity(neutralColor, legendOptions.opacity)\n );\n positiveColors.forEach((color, i) => {\n const t =\n 0.5 +\n (positiveColors.length > 1\n ? (i / (positiveColors.length - 1)) * 0.5\n : 0);\n gradient.addColorStop(\n t,\n getColorWithOpacity(color, legendOptions.opacity)\n );\n });\n } else {\n Colors.forEach((color, i) => {\n gradient.addColorStop(\n i / (Colors.length - 1),\n getColorWithOpacity(color, legendOptions.opacity)\n );\n });\n }\n\n if (legendOptions.title) {\n ctx.font = `500 ${legendOptions.titleFontSize}px ${\n chart.options.font?.family || 'Arial'\n }`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'bottom';\n ctx.fillStyle = chart.options.color || '#666';\n ctx.fillText(legendOptions.title, x, y - legendOptions.labelMargin);\n }\n\n function drawRoundedRect(xx, yy, w, h, radius) {\n ctx.beginPath();\n ctx.moveTo(xx + radius, yy);\n ctx.lineTo(xx + w - radius, yy);\n ctx.arcTo(xx + w, yy, xx + w, yy + radius, radius);\n ctx.lineTo(xx + w, yy + h - radius);\n ctx.arcTo(xx + w, yy + h, xx + w - radius, yy + h, radius);\n ctx.lineTo(xx + radius, yy + h);\n ctx.arcTo(xx, yy + h, xx, yy + h - radius, radius);\n ctx.lineTo(xx, yy + radius);\n ctx.arcTo(xx, yy, xx + radius, yy, radius);\n ctx.closePath();\n }\n\n ctx.fillStyle = '#fff';\n drawRoundedRect(\n x,\n y,\n legendOptions.width,\n legendOptions.height,\n legendOptions.borderRadius\n );\n ctx.fill();\n\n ctx.fillStyle = gradient;\n drawRoundedRect(\n x,\n y,\n legendOptions.width,\n legendOptions.height,\n legendOptions.gradientBorderRadius\n );\n ctx.fill();\n\n ctx.font = `${legendOptions.labelFontSize}px ${\n chart.options.font?.family || 'Arial'\n }`;\n ctx.fillStyle = chart.options.color || '#666';\n const formatValue = (val) => val.toString();\n\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n ctx.fillText(\n formatValue(minVal),\n x,\n y + legendOptions.height + legendOptions.labelMargin\n );\n\n if (Colors.length >= 3 && neutralVal !== undefined) {\n ctx.textAlign = 'center';\n ctx.fillText(\n formatValue(neutralVal),\n x + legendOptions.width / 2,\n y + legendOptions.height + legendOptions.labelMargin\n );\n }\n\n ctx.textAlign = 'right';\n ctx.fillText(\n formatValue(maxVal),\n x + legendOptions.width,\n y + legendOptions.height + legendOptions.labelMargin\n );\n },\n};\n\nexport const options = (ctx) => {\n const ds = ctx?.datasets?.[0];\n const data = ds?.data ?? [];\n const allValues = data\n .map((d) => (typeof d.value === 'number' ? d.value : undefined))\n .filter((v) => v !== undefined);\n\n const paletteKey = ctx.options?.colorPalette || 'sequential02';\n const Colors = getComputedColorPalette(paletteKey);\n const minValue = allValues.length ? Math.min(...allValues) : 0;\n const maxValue = allValues.length ? Math.max(...allValues) : 0;\n const isDivergent = paletteKey.toLowerCase().includes('divergent');\n const computedNeutral = isDivergent ? 0 : 50;\n const legendEnabled = ctx.options?.plugins?.gradientLegend?.display;\n const legendPadding = legendEnabled ? { bottom: 30 } : { bottom: 0 };\n\n return {\n responsive: false,\n maintainAspectRatio: true,\n aspectRatio: 2,\n layout: { padding: legendPadding },\n plugins: {\n tooltip: {\n callbacks: {\n title() {\n return '';\n },\n label(context) {\n const v = context.dataset.data[context.dataIndex];\n const rowLabel = ctx.labels.y?.[v.y - 1] || ctx.labels[v.y - 1];\n const colLabel = ctx.labels.x?.[v.x - 1] || ctx.labels[v.x - 1];\n return [`${rowLabel} - ${colLabel}`, `Value: ${v.value ?? 'N/A'}`];\n },\n },\n },\n legend: { display: false },\n gradientLegend: {\n display: legendEnabled,\n position: 'bottom-left',\n title: ctx.options?.plugins?.gradientLegend?.title || '',\n margin: 0,\n height: 15,\n width: 280,\n opacity: defaultOpacity,\n colors: Colors,\n paletteKey,\n legendLabels: [minValue, computedNeutral, maxValue],\n },\n },\n colorPalette: Colors,\n colorScale: {\n min: minValue,\n neutral: computedNeutral,\n max: maxValue,\n colors: Colors,\n },\n scales: {\n x: {\n grid: { display: false },\n min: 1,\n max: ctx.labels.x?.length ?? ctx.labels?.length ?? 3,\n offset: true,\n ticks: {\n autoSkip: false,\n maxTicksLimit: 15,\n callback: (value) =>\n ctx.labels.x?.[value - 1] ?? ctx.labels?.[value - 1] ?? '',\n padding: function () {\n return isFullScreen() ? 30 : 20;\n },\n },\n afterFit(scale) {\n if (legendEnabled) {\n scale.height -= 10;\n }\n },\n },\n y: {\n grid: { display: false },\n min: 1,\n max: ctx.labels.y?.length ?? ctx.labels?.length ?? 3,\n ticks: {\n autoSkip: false,\n maxTicksLimit: 15,\n callback: (value) =>\n ctx.labels.y?.[value - 1] ?? ctx.labels?.[value - 1] ?? '',\n padding: function () {\n return isFullScreen() ? 15 : 8;\n },\n },\n },\n },\n };\n};\n\nexport const datasetOptions = (ctx) => {\n const paletteKey = ctx.options?.colorPalette || 'categorical';\n const Colors = getComputedColorPalette(paletteKey);\n const numCols = ctx.labels.x?.length ?? ctx.labels?.length ?? 3;\n const numRows = ctx.labels.y?.length ?? ctx.labels?.length ?? 3;\n\n return {\n borderWidth: 0,\n borderColor: 'transparent',\n width({ chart }) {\n const gap = 2;\n const totalWidth = chart.chartArea?.width ?? 0;\n const cellWidth = totalWidth / numCols - gap;\n return cellWidth > 0 ? cellWidth : 1;\n },\n height({ chart }) {\n const gap = 0;\n const totalHeight = chart.chartArea?.height ?? 0;\n const cellHeight = totalHeight / numRows - gap;\n return isFullScreen() ? totalHeight / 11.75 : Math.min(cellHeight, 60);\n },\n backgroundColor({ raw }) {\n if (raw?.value !== undefined) {\n return getPresetSymmetricColor(\n raw.value,\n Colors,\n 50,\n 15,\n defaultOpacity,\n paletteKey\n );\n }\n return 'rgba(204, 204, 204, 0.8)';\n },\n hoverBackgroundColor({ raw }) {\n if (raw?.value !== undefined) {\n return getPresetSymmetricColor(\n raw.value,\n Colors,\n 50,\n 15,\n 1,\n paletteKey\n );\n }\n return '#999';\n },\n };\n};\n\nexport default {\n options,\n datasetOptions,\n plugins: [gradientLegendPlugin],\n};\n"],"names":["type","createMatrixData","data","options","xAxis","yAxis","xKey","yKey","valueKey","Array","isArray","Error","matrixData","dataMap","Map","forEach","item","key","set","y","length","x","yValue","value","has","get","undefined","push","isMatrixFullscreen","setMatrixFullscreen","state","isFullScreen","document","fullscreenElement","webkitFullscreenElement","mozFullscreenElement","msFullscreenElement","getColorWithOpacity","color","opacity","startsWith","isNaN","finalOpacity","r","g","b","hex","parseInt","slice","parseColor","getPresetSymmetricColor","colors","neutral","band","paletteKey","toLowerCase","includes","minVal","maxVal","neutralIndex","Math","floor","ratio","idx","round","min","gradientLegendPlugin","id","afterDraw","chart","args","display","Colors","plugins","gradientLegend","colorScale","datasets","_colorPalette","ctx","chartArea","isDivergentPalette","computedScale","neutralVal","max","legendOptions","position","width","height","margin","borderRadius","gradientBorderRadius","title","titleFontSize","labelFontSize","labelMargin","left","bottom","top","gradient","createLinearGradient","findIndex","c","negativeColors","neutralColor","positiveColors","i","t","addColorStop","drawRoundedRect","xx","yy","w","h","radius","beginPath","moveTo","lineTo","arcTo","closePath","font","family","textAlign","textBaseline","fillStyle","fillText","fill","formatValue","val","toString","ds","allValues","map","d","filter","v","colorPalette","getComputedColorPalette","minValue","maxValue","computedNeutral","legendEnabled","responsive","maintainAspectRatio","aspectRatio","layout","padding","tooltip","callbacks","label","context","dataset","dataIndex","labels","legend","legendLabels","scales","grid","offset","ticks","autoSkip","maxTicksLimit","callback","afterFit","scale","datasetOptions","numCols","numRows","borderWidth","borderColor","cellWidth","totalHeight","cellHeight","backgroundColor","raw","hoverBackgroundColor","matrix"],"mappings":"8DAEY,MAACA,EAAO,SAEPC,EAAmB,CAACC,EAAMC,EAAU,MAC/C,MAAMC,MAAEA,EAAKC,MAAEA,EAAKC,KAAEA,EAAO,IAAGC,KAAEA,EAAO,IAAGC,SAAEA,EAAW,SAAYL,EAErE,KAAKC,GAAUC,GAAUI,MAAMC,QAAQN,IAAWK,MAAMC,QAAQL,IAC9D,MAAM,IAAIM,MAAM,8CAGlB,MAAMC,EAAa,GACbC,EAAU,IAAIC,IAEpBZ,EAAKa,SAASC,IACZ,MAEMC,EAAM,GAFGD,EAAKV,MACLU,EAAKT,KAEpBM,EAAQK,IAAID,EAAKD,EAAKR,GAAU,IAGlC,IAAK,IAAIW,EAAI,EAAGA,GAAKd,EAAMe,OAAQD,IACjC,IAAK,IAAIE,EAAI,EAAGA,GAAKjB,EAAMgB,OAAQC,IAAK,CACtC,MAAMC,EAASjB,EAAMc,EAAI,GAEnBF,EAAM,GADGb,EAAMiB,EAAI,MACAC,IACnBC,EAAQV,EAAQW,IAAIP,GAAOJ,EAAQY,IAAIR,QAAOS,EACpDd,EAAWe,KAAK,CAAEN,IAAGF,IAAGI,SACzB,CAGH,OAAOX,CAAU,EAKnB,IAAIgB,GAAqB,EAElB,SAASC,EAAoBC,GAClCF,IAAuBE,CACzB,CAEA,SAASC,IACP,QAAIH,MAKFI,SAASC,mBACTD,SAASE,yBACTF,SAASG,sBACTH,SAASI,oBAEb,CAkBA,SAAS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SAASoI,cAAgB,cAC1C/D,EAASgE,EAAwBlF,GACjC+G,EAAUvF,EAAI0E,OAAOnI,GAAGD,QAAU0D,EAAI0E,QAAQpI,QAAU,EACxDkJ,EAAUxF,EAAI0E,OAAOrI,GAAGC,QAAU0D,EAAI0E,QAAQpI,QAAU,EAE9D,MAAO,CACLmJ,YAAa,EACbC,YAAa,cACb,KAAAlF,EAAMjB,MAAEA,IACN,MAEMoG,GADapG,EAAMU,WAAWO,OAAS,GACd+E,EAFnB,EAGZ,OAAOI,EAAY,EAAIA,EAAY,CACpC,EACD,MAAAlF,EAAOlB,MAAEA,IACP,MACMqG,EAAcrG,EAAMU,WAAWQ,QAAU,EACzCoF,EAAaD,EAAcJ,EAFrB,EAGZ,OAAOvI,IAAiB2I,EAAc,MAAQ9G,KAAKK,IAAI0G,EAAY,GACpE,EACDC,gBAAe,EAACC,IAAEA,UACGnJ,IAAfmJ,GAAKtJ,MACA2B,EACL2H,EAAItJ,MACJiD,EACA,GACA,GA3Xa,GA6XblB,GAGG,2BAETwH,qBAAoB,EAACD,IAAEA,UACFnJ,IAAfmJ,GAAKtJ,MACA2B,EACL2H,EAAItJ,MACJiD,EACA,GACA,GACA,EACAlB,GAGG,OAEV,EAGH,IAAeyH,EAAA,CACb5K,UACAiK,iBACA3F,QAAS,CAACP"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getComputedColorPalette as t}from"../colorPalettes.js";const o="meter",a=()=>({radius:"80%",circumference:180,rotation:270,aspectRatio:1.3,borderWidth:2,cutout:"80%",datasets:{borderWidth:2,cutout:"80%"},plugins:{legend:{display:!1},datalabels:{font:function(t){return{size:t.chart.width<512?10:12,weight:"bold"}},display:"auto",align:"end",anchor:"end",formatter:function(t,o){return o.chart.data.labels[o.dataIndex]}}}}),e=
|
|
1
|
+
import{getComputedColorPalette as t}from"../colorPalettes.js";const o="meter",a=()=>({radius:"80%",circumference:180,rotation:270,aspectRatio:1.3,borderWidth:2,cutout:"80%",datasets:{borderWidth:2,cutout:"80%"},plugins:{legend:{display:!1},datalabels:{font:function(t){return{size:t.chart.width<512?10:12,weight:"bold"}},display:"auto",align:"end",anchor:"end",formatter:function(t,o){return o.chart.data.labels[o.dataIndex]}}}}),e=o=>({backgroundColor:t(o.options.colorPalette||"rag03")});export{e as datasetOptions,a as options,o as type};
|
|
2
2
|
//# sourceMappingURL=meter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter.js","sources":["../../../../src/common/config/chartTypes/meter.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'meter';\n\nexport const options = () => {\n return {\n radius: '80%',\n circumference: 180,\n rotation: 270,\n aspectRatio: 1.3,\n borderWidth: 2,\n cutout: '80%',\n datasets: {\n borderWidth: 2,\n cutout: '80%',\n },\n plugins: {\n legend: {\n display: false,\n },\n\n datalabels: {\n font: function (context) {\n var w = context.chart.width;\n return {\n size: w < 512 ? 10 : 12,\n weight: 'bold',\n };\n },\n display: 'auto',\n align: 'end',\n anchor: 'end',\n formatter: function (value, context) {\n return context.chart.data.labels[context.dataIndex];\n },\n },\n },\n };\n};\n\nexport const datasetOptions = (ctx
|
|
1
|
+
{"version":3,"file":"meter.js","sources":["../../../../src/common/config/chartTypes/meter.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'meter';\n\nexport const options = () => {\n return {\n radius: '80%',\n circumference: 180,\n rotation: 270,\n aspectRatio: 1.3,\n borderWidth: 2,\n cutout: '80%',\n datasets: {\n borderWidth: 2,\n cutout: '80%',\n },\n plugins: {\n legend: {\n display: false,\n },\n\n datalabels: {\n font: function (context) {\n var w = context.chart.width;\n return {\n size: w < 512 ? 10 : 12,\n weight: 'bold',\n };\n },\n display: 'auto',\n align: 'end',\n anchor: 'end',\n formatter: function (value, context) {\n return context.chart.data.labels[context.dataIndex];\n },\n },\n },\n };\n};\n\nexport const datasetOptions = (ctx) => {\n return {\n backgroundColor: getComputedColorPalette(\n ctx.options.colorPalette || 'rag03'\n ),\n };\n};\n"],"names":["type","options","radius","circumference","rotation","aspectRatio","borderWidth","cutout","datasets","plugins","legend","display","datalabels","font","context","size","chart","width","weight","align","anchor","formatter","value","data","labels","dataIndex","datasetOptions","ctx","backgroundColor","getComputedColorPalette","colorPalette"],"mappings":"8DAEY,MAACA,EAAO,QAEPC,EAAU,KACd,CACLC,OAAQ,MACRC,cAAe,IACfC,SAAU,IACVC,YAAa,IACbC,YAAa,EACbC,OAAQ,MACRC,SAAU,CACRF,YAAa,EACbC,OAAQ,OAEVE,QAAS,CACPC,OAAQ,CACNC,SAAS,GAGXC,WAAY,CACVC,KAAM,SAAUC,GAEd,MAAO,CACLC,KAFMD,EAAQE,MAAMC,MAEV,IAAM,GAAK,GACrBC,OAAQ,OAEX,EACDP,QAAS,OACTQ,MAAO,MACPC,OAAQ,MACRC,UAAW,SAAUC,EAAOR,GAC1B,OAAOA,EAAQE,MAAMO,KAAKC,OAAOV,EAAQW,UAC1C,MAMIC,EAAkBC,IACtB,CACLC,gBAAiBC,EACfF,EAAI1B,QAAQ6B,cAAgB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getComputedColorPalette as t}from"../colorPalettes.js";const e="pie",a=
|
|
1
|
+
import{getComputedColorPalette as t}from"../colorPalettes.js";const e="pie",a=()=>({radius:"80%",plugins:{datalabels:{font:{size:14},display:"auto",align:"end",anchor:"end",formatter:function(t,e){const a=e.chart.data.datasets[0].data.filter(((t,a)=>!e.chart.legend.legendItems[a].hidden)).reduce(((t,e)=>t+e),0),o=Math.round(100*(t/a+Number.EPSILON))+"%";return a?o:""}}}}),o=e=>({backgroundColor:t(e.options.colorPalette||"categorical")});export{o as datasetOptions,a as options,e as type};
|
|
2
2
|
//# sourceMappingURL=pie.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie.js","sources":["../../../../src/common/config/chartTypes/pie.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'pie';\n\nexport const options = (
|
|
1
|
+
{"version":3,"file":"pie.js","sources":["../../../../src/common/config/chartTypes/pie.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'pie';\n\nexport const options = () => {\n return {\n radius: '80%',\n plugins: {\n datalabels: {\n font: {\n size: 14,\n },\n display: 'auto',\n align: 'end',\n anchor: 'end',\n formatter: function (value, context) {\n const total = context.chart.data.datasets[0].data\n .filter(\n (dataPoint, index) =>\n !context.chart.legend.legendItems[index].hidden\n )\n .reduce((a, b) => a + b, 0);\n\n const percentage =\n Math.round((value / total + Number.EPSILON) * 100) + '%';\n\n return !total ? '' : percentage;\n },\n },\n },\n };\n};\n\nexport const datasetOptions = (ctx) => {\n return {\n backgroundColor: getComputedColorPalette(\n ctx.options.colorPalette || 'categorical'\n ),\n };\n};\n"],"names":["type","options","radius","plugins","datalabels","font","size","display","align","anchor","formatter","value","context","total","chart","data","datasets","filter","dataPoint","index","legend","legendItems","hidden","reduce","a","b","percentage","Math","round","Number","EPSILON","datasetOptions","ctx","backgroundColor","getComputedColorPalette","colorPalette"],"mappings":"8DAEY,MAACA,EAAO,MAEPC,EAAU,KACd,CACLC,OAAQ,MACRC,QAAS,CACPC,WAAY,CACVC,KAAM,CACJC,KAAM,IAERC,QAAS,OACTC,MAAO,MACPC,OAAQ,MACRC,UAAW,SAAUC,EAAOC,GAC1B,MAAMC,EAAQD,EAAQE,MAAMC,KAAKC,SAAS,GAAGD,KAC1CE,QACC,CAACC,EAAWC,KACTP,EAAQE,MAAMM,OAAOC,YAAYF,GAAOG,SAE5CC,QAAO,CAACC,EAAGC,IAAMD,EAAIC,GAAG,GAErBC,EACJC,KAAKC,MAAyC,KAAlCjB,EAAQE,EAAQgB,OAAOC,UAAkB,IAEvD,OAAQjB,EAAaa,EAAL,EACjB,MAMIK,EAAkBC,IACtB,CACLC,gBAAiBC,EACfF,EAAI/B,QAAQkC,cAAgB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const t=(t,e)=>{const o=void 0===e||isNaN(e)?.7:e;return t&&"string"==typeof t&&t.startsWith("#")?((t,e)=>{if(!t||"string"!=typeof t||!t.startsWith("#")||t.length<7)return`rgba(204, 204, 204, ${e})`;const o=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),l=parseInt(t.slice(5,7),16);return`rgba(${isNaN(o)?0:o}, ${isNaN(i)?0:i}, ${isNaN(l)?0:l}, ${e})`})(t,o):`rgba(204, 204, 204, ${o})`};var e={id:"gradientLegend",_previousColorPalette:null,beforeDraw(t,e,o){if(!o?.display)return;const i=o.colors||t.options.plugins?.gradientLegend?.colors||t.options.colorScale?.colors||t.data?.datasets?.[0]?._colorPalette;if(!i||!i.length)return;const l=t.options.colorScale||{},n=(o.paletteKey||"").toLowerCase().includes("divergent"),a=n?-100:0,r=n?0:50,s=l.min??a,d=l.neutral??r,c=l.max??100,g=`${i.join(",")};${s};${d};${c}`;if(null!==this._previousColorPalette&&this._previousColorPalette!==g)return this._previousColorPalette=g,void(t._gradientLegendUpdateScheduled||(t._gradientLegendUpdateScheduled=!0,window.requestAnimationFrame((()=>{t.ctx&&t.update("none"),t._gradientLegendUpdateScheduled=!1}))));this._previousColorPalette=g},afterDraw(e,o,i){if(!i?.display)return;const l=i.colors||e.options.plugins?.gradientLegend?.colors||e.options.colorScale?.colors||e.data?.datasets?.[0]?._colorPalette;if(!l||!l.length)return;const n=e.ctx,a=e.chartArea,r=(i.paletteKey||"").toLowerCase().includes("divergent"),s=e.options.colorScale||{},d=r?-100:0,c=r?0:50,g=t=>{if(0===t)return 0;const e=Math.abs(t),o=50*Math.floor(e/50),i=e%50>=26?o+50:o;return t<0?-i:i},h=g(s.min??d),p=g(s.neutral??c),f=g(s.max??100),u={position:i.position||"bottom",width:i.width||Math.min(400,.8*a.width),height:i.height||20,margin:i.margin||10,borderRadius:i.borderRadius||4,gradientBorderRadius:1,title:i.title||"",titleFontSize:i.titleFontSize||12,labelFontSize:i.labelFontSize||12,labelMargin:i.labelMargin||5,opacity:"number"==typeof i.opacity?i.opacity:.7,...i};let b,m;"bottom"===u.position?(b=a.left+(a.width-u.width)/2,m=a.bottom+u.margin):"top"===u.position?(b=a.left+(a.width-u.width)/2,m=a.top-u.margin-u.height):"bottom-left"===u.position?(b=a.left-70,m=a.bottom+70):(b=a.left+(a.width-u.width)/2,m=a.bottom+u.margin);const S=n.createLinearGradient(b,m,b+u.width,m),w=l.findIndex((t=>t.toLowerCase().includes("neutral")));if(w>0){const e=l.slice(0,w),o=l[w],i=l.slice(w+1);e.forEach(((o,i)=>{const l=e.length>1?i/(e.length-1)*.5:0;S.addColorStop(l,t(o,u.opacity))})),S.addColorStop(.5,t(o,u.opacity)),i.forEach(((e,o)=>{const l=.5+(i.length>1?o/(i.length-1)*.5:0);S.addColorStop(l,t(e,u.opacity))}))}else l.forEach(((e,o)=>{S.addColorStop(o/(l.length-1),t(e,u.opacity))}));u.title&&(n.font=`500 ${u.titleFontSize}px ${e.options.font?.family||"Arial"}`,n.textAlign="left",n.textBaseline="bottom",n.fillStyle=e.options.color||"#666",n.fillText(u.title,b,m-u.labelMargin));const y=(t,e,o,i,l)=>{n.beginPath(),n.moveTo(t+l,e),n.lineTo(t+o-l,e),n.arcTo(t+o,e,t+o,e+l,l),n.lineTo(t+o,e+i-l),n.arcTo(t+o,e+i,t+o-l,e+i,l),n.lineTo(t+l,e+i),n.arcTo(t,e+i,t,e+i-l,l),n.lineTo(t,e+l),n.arcTo(t,e,t+l,e,l),n.closePath()};n.fillStyle="#fff",y(b,m,u.width,u.height,u.borderRadius),n.fill(),n.fillStyle=S,y(b,m,u.width,u.height,u.gradientBorderRadius),n.fill(),n.font=`${u.labelFontSize}px ${e.options.font?.family||"Arial"}`,n.fillStyle=e.options.color||"#666";const x=t=>g(t).toString();n.textAlign="left",n.textBaseline="top",n.fillText(x(h),b,m+u.height+u.labelMargin),l.length>=3&&void 0!==p&&(n.textAlign="center",n.fillText(x(p),b+u.width/2,m+u.height+u.labelMargin)),n.textAlign="right",n.fillText(x(f),b+u.width,m+u.height+u.labelMargin)}};export{e as default};
|
|
2
|
+
//# sourceMappingURL=gradientLegend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gradientLegend.js","sources":["../../../src/common/plugins/gradientLegend.js"],"sourcesContent":["/**\n * Chart.js plugin to add a color gradient legend for heatmap/matrix charts\n */\n\nconst hexToRgba = (hex, alpha) => {\n if (\n !hex ||\n typeof hex !== 'string' ||\n !hex.startsWith('#') ||\n hex.length < 7\n ) {\n return `rgba(204, 204, 204, ${alpha})`;\n }\n\n const r = parseInt(hex.slice(1, 3), 16);\n const g = parseInt(hex.slice(3, 5), 16);\n const b = parseInt(hex.slice(5, 7), 16);\n\n return `rgba(${isNaN(r) ? 0 : r}, ${isNaN(g) ? 0 : g}, ${\n isNaN(b) ? 0 : b\n }, ${alpha})`;\n};\n\nconst getColorWithOpacity = (color, opacity) => {\n const finalOpacity = opacity !== undefined && !isNaN(opacity) ? opacity : 0.7;\n\n if (!color || typeof color !== 'string' || !color.startsWith('#')) {\n return `rgba(204, 204, 204, ${finalOpacity})`;\n }\n\n return hexToRgba(color, finalOpacity);\n};\n\nexport default {\n id: 'gradientLegend',\n _previousColorPalette: null,\n\n beforeDraw(chart, args, options) {\n if (!options?.display) return;\n\n const Colors =\n options.colors ||\n chart.options.plugins?.gradientLegend?.colors ||\n chart.options.colorScale?.colors ||\n chart.data?.datasets?.[0]?._colorPalette;\n\n if (!Colors || !Colors.length) return;\n\n const colorScale = chart.options.colorScale || {};\n const paletteKey = options.paletteKey || '';\n const isDivergentPalette = paletteKey.toLowerCase().includes('divergent');\n const fallbackMin = isDivergentPalette ? -100 : 0;\n const fallbackNeutral = isDivergentPalette ? 0 : 50;\n const fallbackMax = isDivergentPalette ? 100 : 100;\n\n const minVal = colorScale.min ?? fallbackMin;\n const neutralVal = colorScale.neutral ?? fallbackNeutral;\n const maxVal = colorScale.max ?? fallbackMax;\n\n const signature = `${Colors.join(',')};${minVal};${neutralVal};${maxVal}`;\n\n if (\n this._previousColorPalette !== null &&\n this._previousColorPalette !== signature\n ) {\n this._previousColorPalette = signature;\n\n if (!chart._gradientLegendUpdateScheduled) {\n chart._gradientLegendUpdateScheduled = true;\n window.requestAnimationFrame(() => {\n if (chart.ctx) {\n chart.update('none');\n }\n chart._gradientLegendUpdateScheduled = false;\n });\n }\n return;\n }\n\n this._previousColorPalette = signature;\n },\n\n afterDraw(chart, args, options) {\n if (!options?.display) return;\n\n const Colors =\n options.colors ||\n chart.options.plugins?.gradientLegend?.colors ||\n chart.options.colorScale?.colors ||\n chart.data?.datasets?.[0]?._colorPalette;\n if (!Colors || !Colors.length) return;\n\n const ctx = chart.ctx;\n const chartArea = chart.chartArea;\n const paletteKey = options.paletteKey || '';\n const isDivergentPalette = paletteKey.toLowerCase().includes('divergent');\n\n const colorScale = chart.options.colorScale || {};\n const fallbackMin = isDivergentPalette ? -100 : 0;\n const fallbackNeutral = isDivergentPalette ? 0 : 50;\n const fallbackMax = isDivergentPalette ? 100 : 100;\n\n const roundToInterval = (value) => {\n if (value === 0) return 0;\n\n const absValue = Math.abs(value);\n const base = Math.floor(absValue / 50) * 50;\n\n const rounded = absValue % 50 >= 26 ? base + 50 : base;\n\n return value < 0 ? -rounded : rounded;\n };\n\n const minVal = roundToInterval(colorScale.min ?? fallbackMin);\n const neutralVal = roundToInterval(colorScale.neutral ?? fallbackNeutral);\n const maxVal = roundToInterval(colorScale.max ?? fallbackMax);\n\n const legendOptions = {\n position: options.position || 'bottom',\n width: options.width || Math.min(400, chartArea.width * 0.8),\n height: options.height || 20,\n margin: options.margin || 10,\n borderRadius: options.borderRadius || 4,\n gradientBorderRadius: 1,\n title: options.title || '',\n titleFontSize: options.titleFontSize || 12,\n labelFontSize: options.labelFontSize || 12,\n labelMargin: options.labelMargin || 5,\n opacity: typeof options.opacity === 'number' ? options.opacity : 0.7,\n ...options,\n };\n\n let x, y;\n if (legendOptions.position === 'bottom') {\n x = chartArea.left + (chartArea.width - legendOptions.width) / 2;\n y = chartArea.bottom + legendOptions.margin;\n } else if (legendOptions.position === 'top') {\n x = chartArea.left + (chartArea.width - legendOptions.width) / 2;\n y = chartArea.top - legendOptions.margin - legendOptions.height;\n } else if (legendOptions.position === 'bottom-left') {\n x = chartArea.left - 70;\n y = chartArea.bottom + 70;\n } else {\n x = chartArea.left + (chartArea.width - legendOptions.width) / 2;\n y = chartArea.bottom + legendOptions.margin;\n }\n\n const gradient = ctx.createLinearGradient(x, y, x + legendOptions.width, y);\n const neutralIndex = Colors.findIndex((c) =>\n c.toLowerCase().includes('neutral')\n );\n if (neutralIndex > 0) {\n const negativeColors = Colors.slice(0, neutralIndex);\n const neutralColor = Colors[neutralIndex];\n const positiveColors = Colors.slice(neutralIndex + 1);\n\n negativeColors.forEach((color, i) => {\n const t =\n negativeColors.length > 1\n ? (i / (negativeColors.length - 1)) * 0.5\n : 0;\n gradient.addColorStop(\n t,\n getColorWithOpacity(color, legendOptions.opacity)\n );\n });\n gradient.addColorStop(\n 0.5,\n getColorWithOpacity(neutralColor, legendOptions.opacity)\n );\n positiveColors.forEach((color, i) => {\n const t =\n 0.5 +\n (positiveColors.length > 1\n ? (i / (positiveColors.length - 1)) * 0.5\n : 0);\n gradient.addColorStop(\n t,\n getColorWithOpacity(color, legendOptions.opacity)\n );\n });\n } else {\n Colors.forEach((color, i) => {\n gradient.addColorStop(\n i / (Colors.length - 1),\n getColorWithOpacity(color, legendOptions.opacity)\n );\n });\n }\n\n if (legendOptions.title) {\n ctx.font = `500 ${legendOptions.titleFontSize}px ${\n chart.options.font?.family || 'Arial'\n }`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'bottom';\n ctx.fillStyle = chart.options.color || '#666';\n ctx.fillText(legendOptions.title, x, y - legendOptions.labelMargin);\n }\n\n const drawRoundedRect = (xx, yy, w, h, radius) => {\n ctx.beginPath();\n ctx.moveTo(xx + radius, yy);\n ctx.lineTo(xx + w - radius, yy);\n ctx.arcTo(xx + w, yy, xx + w, yy + radius, radius);\n ctx.lineTo(xx + w, yy + h - radius);\n ctx.arcTo(xx + w, yy + h, xx + w - radius, yy + h, radius);\n ctx.lineTo(xx + radius, yy + h);\n ctx.arcTo(xx, yy + h, xx, yy + h - radius, radius);\n ctx.lineTo(xx, yy + radius);\n ctx.arcTo(xx, yy, xx + radius, yy, radius);\n ctx.closePath();\n };\n\n ctx.fillStyle = '#fff';\n drawRoundedRect(\n x,\n y,\n legendOptions.width,\n legendOptions.height,\n legendOptions.borderRadius\n );\n ctx.fill();\n\n ctx.fillStyle = gradient;\n drawRoundedRect(\n x,\n y,\n legendOptions.width,\n legendOptions.height,\n legendOptions.gradientBorderRadius\n );\n ctx.fill();\n\n ctx.font = `${legendOptions.labelFontSize}px ${\n chart.options.font?.family || 'Arial'\n }`;\n ctx.fillStyle = chart.options.color || '#666';\n const formatValue = (val) => roundToInterval(val).toString();\n\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n ctx.fillText(\n formatValue(minVal),\n x,\n y + legendOptions.height + legendOptions.labelMargin\n );\n\n if (Colors.length >= 3 && neutralVal !== undefined) {\n ctx.textAlign = 'center';\n ctx.fillText(\n formatValue(neutralVal),\n x + legendOptions.width / 2,\n y + legendOptions.height + legendOptions.labelMargin\n );\n }\n\n ctx.textAlign = 'right';\n ctx.fillText(\n formatValue(maxVal),\n x + legendOptions.width,\n y + legendOptions.height + legendOptions.labelMargin\n );\n },\n};\n"],"names":["getColorWithOpacity","color","opacity","finalOpacity","undefined","isNaN","startsWith","hex","alpha","length","r","parseInt","slice","g","b","hexToRgba","gradientLegendPlugin","id","_previousColorPalette","beforeDraw","chart","args","options","display","Colors","colors","plugins","gradientLegend","colorScale","data","datasets","_colorPalette","isDivergentPalette","paletteKey","toLowerCase","includes","fallbackMin","fallbackNeutral","minVal","min","neutralVal","neutral","maxVal","max","signature","join","this","_gradientLegendUpdateScheduled","window","requestAnimationFrame","ctx","update","afterDraw","chartArea","roundToInterval","value","absValue","Math","abs","base","floor","rounded","legendOptions","position","width","height","margin","borderRadius","gradientBorderRadius","title","titleFontSize","labelFontSize","labelMargin","x","y","left","bottom","top","gradient","createLinearGradient","neutralIndex","findIndex","c","negativeColors","neutralColor","positiveColors","forEach","i","t","addColorStop","font","family","textAlign","textBaseline","fillStyle","fillText","drawRoundedRect","xx","yy","w","h","radius","beginPath","moveTo","lineTo","arcTo","closePath","fill","formatValue","val","toString"],"mappings":"AAIA,MAmBMA,EAAsB,CAACC,EAAOC,KAClC,MAAMC,OAA2BC,IAAZF,GAA0BG,MAAMH,GAAqB,GAAVA,EAEhE,OAAKD,GAA0B,iBAAVA,GAAuBA,EAAMK,WAAW,KAtB7C,EAACC,EAAKC,KACtB,IACGD,GACc,iBAARA,IACNA,EAAID,WAAW,MAChBC,EAAIE,OAAS,EAEb,MAAO,uBAAuBD,KAGhC,MAAME,EAAIC,SAASJ,EAAIK,MAAM,EAAG,GAAI,IAC9BC,EAAIF,SAASJ,EAAIK,MAAM,EAAG,GAAI,IAC9BE,EAAIH,SAASJ,EAAIK,MAAM,EAAG,GAAI,IAEpC,MAAO,QAAQP,MAAMK,GAAK,EAAIA,MAAML,MAAMQ,GAAK,EAAIA,MACjDR,MAAMS,GAAK,EAAIA,MACZN,IAAQ,EAUNO,CAAUd,EAAOE,GAHf,uBAAuBA,IAGK,EAGvC,IAAea,EAAA,CACbC,GAAI,iBACJC,sBAAuB,KAEvB,UAAAC,CAAWC,EAAOC,EAAMC,GACtB,IAAKA,GAASC,QAAS,OAEvB,MAAMC,EACJF,EAAQG,QACRL,EAAME,QAAQI,SAASC,gBAAgBF,QACvCL,EAAME,QAAQM,YAAYH,QAC1BL,EAAMS,MAAMC,WAAW,IAAIC,cAE7B,IAAKP,IAAWA,EAAOf,OAAQ,OAE/B,MAAMmB,EAAaR,EAAME,QAAQM,YAAc,CAAA,EAEzCI,GADaV,EAAQW,YAAc,IACHC,cAAcC,SAAS,aACvDC,EAAcJ,GAA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MAAMR,EAAIC,EAAID,EAAKI,EAAQH,EAAIG,GACnCnD,EAAIwD,WAAW,EAGjBxD,EAAI4C,UAAY,OAChBE,EACEvB,EACAC,EACAZ,EAAcE,MACdF,EAAcG,OACdH,EAAcK,cAEhBjB,EAAIyD,OAEJzD,EAAI4C,UAAYhB,EAChBkB,EACEvB,EACAC,EACAZ,EAAcE,MACdF,EAAcG,OACdH,EAAcM,sBAEhBlB,EAAIyD,OAEJzD,EAAIwC,KAAO,GAAG5B,EAAcS,mBAC1BnD,EAAME,QAAQoE,MAAMC,QAAU,UAEhCzC,EAAI4C,UAAY1E,EAAME,QAAQrB,OAAS,OACvC,MAAM2G,EAAeC,GAAQvD,EAAgBuD,GAAKC,WAElD5D,EAAI0C,UAAY,OAChB1C,EAAI2C,aAAe,MACnB3C,EAAI6C,SACFa,EAAYtE,GACZmC,EACAC,EAAIZ,EAAcG,OAASH,EAAcU,aAGvChD,EAAOf,QAAU,QAAoBL,IAAfoC,IACxBU,EAAI0C,UAAY,SAChB1C,EAAI6C,SACFa,EAAYpE,GACZiC,EAAIX,EAAcE,MAAQ,EAC1BU,EAAIZ,EAAcG,OAASH,EAAcU,cAI7CtB,EAAI0C,UAAY,QAChB1C,EAAI6C,SACFa,EAAYlE,GACZ+B,EAAIX,EAAcE,MAClBU,EAAIZ,EAAcG,OAASH,EAAcU,YAE5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/components/chart/chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAKvC,OAAO,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/components/chart/chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAKvC,OAAO,0BAA0B,CAAC;AA8ClC;;;;;;GAMG;AACH,qBACa,OAAQ,SAA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YAAY;IAKZ,OAAO,CAAC,YAAY,EAAE,GAAG;IA0FlC;;;OAGG;IACH,OAAO,CAAC,SAAS;IAgDjB;;;OAGG;YACW,YAAY;IAmE1B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,iBAAiB;IA2BzB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,sBAAsB;CAG/B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,OAAO,CAAC;KACrB;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{__decorate as t}from"../../_virtual/_tslib.js";import'./../../external/@lit/reactive-element/reactive-element.js';import{html as e}from'./../../external/lit-html/lit-html.js';import{LitElement as s}from'./../../external/lit-element/lit-element.js';import{customElement as o}from'./../../external/@lit/reactive-element/decorators/custom-element.js';import{property as i}from'./../../external/@lit/reactive-element/decorators/property.js';import{state as a}from'./../../external/@lit/reactive-element/decorators/state.js';import{query as r}from'./../../external/@lit/reactive-element/decorators/query.js';import'./../../external/@lit/reactive-element/decorators/query-assigned-elements.js';import{classMap as n}from'./../../external/lit-html/directives/class-map.js';import{deepmerge as l,deepmergeCustom as c}from'./../../external/deepmerge-ts/dist/node/index.js';import'./../../external/chart.js/auto/auto.js';import'./../../external/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.esm.js';import{ChoroplethController as d,BubbleMapController as h,GeoFeature as m,ColorScale as p,SizeScale as u,ProjectionScale as g}from'./../../external/chartjs-chart-geo/build/index.js';import{TreemapController as y,TreemapElement as v}from'./../../external/chartjs-chart-treemap/dist/chartjs-chart-treemap.esm.js';import b from"../../common/plugins/canvasBackground.js";import
|
|
1
|
+
import{__decorate as t}from"../../_virtual/_tslib.js";import'./../../external/@lit/reactive-element/reactive-element.js';import{html as e}from'./../../external/lit-html/lit-html.js';import{LitElement as s}from'./../../external/lit-element/lit-element.js';import{customElement as o}from'./../../external/@lit/reactive-element/decorators/custom-element.js';import{property as i}from'./../../external/@lit/reactive-element/decorators/property.js';import{state as a}from'./../../external/@lit/reactive-element/decorators/state.js';import{query as r}from'./../../external/@lit/reactive-element/decorators/query.js';import'./../../external/@lit/reactive-element/decorators/query-assigned-elements.js';import{classMap as n}from'./../../external/lit-html/directives/class-map.js';import{deepmerge as l,deepmergeCustom as c}from'./../../external/deepmerge-ts/dist/node/index.js';import'./../../external/chart.js/auto/auto.js';import'./../../external/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.esm.js';import{ChoroplethController as d,BubbleMapController as h,GeoFeature as m,ColorScale as p,SizeScale as u,ProjectionScale as g}from'./../../external/chartjs-chart-geo/build/index.js';import{TreemapController as y,TreemapElement as v}from'./../../external/chartjs-chart-treemap/dist/chartjs-chart-treemap.esm.js';import{MatrixController as b,MatrixElement as f}from'./../../external/chartjs-chart-matrix/dist/chartjs-chart-matrix.esm.js';import j from"../../common/plugins/canvasBackground.js";import T from"../../common/plugins/doughnutLabel.js";import $ from"../../common/plugins/meterGaugeNeedle.js";import w from"../../common/plugins/gradientLegend.js";import x from'./../../external/chartjs-plugin-a11y-legend/dist/plugin.js';import k from'./../../external/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.esm.js';import _ from'./../../external/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.esm.js';import{debounce as D,convertChartDataToCSV as O}from"../../common/helpers/helpers.js";import A from"./chart.scss.js";import C from"../../common/config/globalOptions.js";import L from"../../common/config/globalOptionsNonRadial.js";import M from"../../common/config/globalOptionsRadial.js";import V from'./../../external/@kyndryl-design-system/shidoka-icons/svg/monochrome/16/analytics.svg.js';import E from'./../../external/@kyndryl-design-system/shidoka-icons/svg/monochrome/16/table-view.svg.js';import S from'./../../external/@kyndryl-design-system/shidoka-icons/svg/monochrome/16/download.svg.js';import B from'./../../external/@kyndryl-design-system/shidoka-icons/svg/monochrome/16/expand.svg.js';import q from'./../../external/@kyndryl-design-system/shidoka-icons/svg/monochrome/16/shrink.svg.js';import{unsafeSVG as F}from'./../../external/lit-html/directives/unsafe-svg.js';import{getTokenThemeVal as z}from'./../../external/@kyndryl-design-system/shidoka-foundation/common/helpers/color.js';import{Chart as N}from'./../../external/chart.js/dist/chart.js';function P(t){switch(t){case"../../common/config/chartTypes/bar.js":return import("../../common/config/chartTypes/bar.js");case"../../common/config/chartTypes/bubble.js":return import("../../common/config/chartTypes/bubble.js");case"../../common/config/chartTypes/bubbleMap.js":return import("../../common/config/chartTypes/bubbleMap.js");case"../../common/config/chartTypes/choropleth.js":return import("../../common/config/chartTypes/choropleth.js");case"../../common/config/chartTypes/doughnut.js":return import("../../common/config/chartTypes/doughnut.js");case"../../common/config/chartTypes/line.js":return import("../../common/config/chartTypes/line.js");case"../../common/config/chartTypes/matrix.js":return import("../../common/config/chartTypes/matrix.js");case"../../common/config/chartTypes/meter.js":return import("../../common/config/chartTypes/meter.js");case"../../common/config/chartTypes/pie.js":return import("../../common/config/chartTypes/pie.js");case"../../common/config/chartTypes/polarArea.js":return import("../../common/config/chartTypes/polarArea.js");case"../../common/config/chartTypes/radar.js":return import("../../common/config/chartTypes/radar.js");case"../../common/config/chartTypes/scatter.js":return import("../../common/config/chartTypes/scatter.js");case"../../common/config/chartTypes/treemap.js":return import("../../common/config/chartTypes/treemap.js");default:return new Promise((function(e,s){("function"==typeof queueMicrotask?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}N.register(d,h,m,p,u,g,y,v,b,f,_,k);let R=class extends s{constructor(){super(...arguments),this.chartTitle="",this.description="",this.type="",this.options={},this.plugins=[],this.height=null,this.width=null,this.hideDescription=!1,this.hideCaptions=!1,this.hideHeader=!1,this.hideControls=!1,this.noBorder=!1,this.customLabels={toggleView:"Toggle View Mode",toggleFullscreen:"Toggle Fullscreen",downloadMenu:"Download Menu",downloadCsv:"Download as CSV",downloadPng:"Download as PNG",downloadJpg:"Download as JPG"},this.fullscreen=!1,this.chart=null,this.tableView=!1,this.tableDisabled=!1,this.mergedOptions={},this.mergedDatasets={},this._widget=!1,this._resizeObserver=new ResizeObserver(D((()=>{this._resizeChart()}))),this._themeObserver=new MutationObserver((()=>{this.chart&&this.mergeOptions().then((()=>{this.initChart()}))}))}render(){var t,s,o,i,a,r,l,c,d;const h={container:!0,fullscreen:this.fullscreen,"no-border":this.noBorder||this._widget,widget:this._widget};return e`
|
|
2
2
|
<div
|
|
3
|
-
class=${n(
|
|
3
|
+
class=${n(h)}
|
|
4
4
|
@fullscreenchange=${()=>this.handleFullscreenChange()}
|
|
5
5
|
>
|
|
6
6
|
${this.hideHeader&&this.hideControls?null:e`
|
|
@@ -30,7 +30,7 @@ import{__decorate as t}from"../../_virtual/_tslib.js";import'./../../external/@l
|
|
|
30
30
|
title=${this.customLabels.toggleView}
|
|
31
31
|
>
|
|
32
32
|
<span slot="icon">
|
|
33
|
-
${this.tableView?
|
|
33
|
+
${this.tableView?F(V):F(E)}
|
|
34
34
|
</span>
|
|
35
35
|
</button>
|
|
36
36
|
`}
|
|
@@ -42,7 +42,7 @@ import{__decorate as t}from"../../_virtual/_tslib.js";import'./../../external/@l
|
|
|
42
42
|
title=${this.customLabels.toggleFullscreen}
|
|
43
43
|
>
|
|
44
44
|
<span slot="icon">
|
|
45
|
-
${this.fullscreen?
|
|
45
|
+
${this.fullscreen?F(q):F(B)}
|
|
46
46
|
</span>
|
|
47
47
|
</button>
|
|
48
48
|
|
|
@@ -53,7 +53,7 @@ import{__decorate as t}from"../../_virtual/_tslib.js";import'./../../external/@l
|
|
|
53
53
|
title=${this.customLabels.downloadMenu}
|
|
54
54
|
>
|
|
55
55
|
<span slot="icon">
|
|
56
|
-
${S
|
|
56
|
+
${F(S)}
|
|
57
57
|
</span>
|
|
58
58
|
</button>
|
|
59
59
|
|
|
@@ -92,7 +92,7 @@ import{__decorate as t}from"../../_virtual/_tslib.js";import'./../../external/@l
|
|
|
92
92
|
<div
|
|
93
93
|
class="canvas-container"
|
|
94
94
|
style="${this.width?`width: ${this.width}px;`:""}
|
|
95
|
-
|
|
95
|
+
${this.height?`height: ${this.height}px;`:""}"
|
|
96
96
|
>
|
|
97
97
|
<canvas role="img" aria-labelledby="titleDesc"></canvas>
|
|
98
98
|
</div>
|
|
@@ -106,67 +106,101 @@ import{__decorate as t}from"../../_virtual/_tslib.js";import'./../../external/@l
|
|
|
106
106
|
${!this.tableDisabled&&this.tableView?e`
|
|
107
107
|
<div class="table">
|
|
108
108
|
<table>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
${"matrix"===this.type?e`
|
|
110
|
+
<thead>
|
|
111
|
+
<tr>
|
|
112
|
+
<th>
|
|
113
|
+
${(null===(i=null===(o=null===(s=null===(t=this.options)||void 0===t?void 0:t.scales)||void 0===s?void 0:s.y)||void 0===o?void 0:o.title)||void 0===i?void 0:i.text)||"Y Axis"}
|
|
114
|
+
</th>
|
|
115
|
+
<th>
|
|
116
|
+
${(null===(c=null===(l=null===(r=null===(a=this.options)||void 0===a?void 0:a.scales)||void 0===r?void 0:r.x)||void 0===l?void 0:l.title)||void 0===c?void 0:c.text)||"X Axis"}
|
|
117
|
+
</th>
|
|
118
|
+
${this.datasets.map((t=>e`<th>${t.label}</th>`))}
|
|
119
|
+
</tr>
|
|
120
|
+
</thead>
|
|
121
|
+
<tbody>
|
|
122
|
+
${this.datasets[0].data.map((t=>{var s,o;const i=Array.isArray(this.labels)?this.labels[t.x-1]||"":(null===(s=this.labels.x)||void 0===s?void 0:s[t.x-1])||"",a=Array.isArray(this.labels)?this.labels[t.y-1]||"":(null===(o=this.labels.y)||void 0===o?void 0:o[t.y-1])||"";return e`
|
|
118
123
|
<tr>
|
|
119
|
-
<td>${
|
|
120
|
-
<td>${
|
|
124
|
+
<td>${a}</td>
|
|
125
|
+
<td>${i}</td>
|
|
126
|
+
${this.datasets.map((()=>e`<td>${t.value}</td>`))}
|
|
121
127
|
</tr>
|
|
122
|
-
`))
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
`}))}
|
|
129
|
+
</tbody>
|
|
130
|
+
`:e`
|
|
131
|
+
<thead>
|
|
132
|
+
<tr>
|
|
133
|
+
${(null===(d=this.labels)||void 0===d?void 0:d.length)||"treemap"===this.type?e`<th>${this.getTableAxisLabel()}</th>`:null}
|
|
134
|
+
${this.datasets.map((t=>e`<th>${t.label}</th>`))}
|
|
135
|
+
</tr>
|
|
136
|
+
</thead>
|
|
137
|
+
<tbody>
|
|
138
|
+
${"treemap"===this.type?Array.isArray(this.datasets[0].tree)?this.datasets[0].tree.map((t=>e`
|
|
139
|
+
<tr>
|
|
140
|
+
<td>
|
|
141
|
+
${t[this.datasets[0].labelKey]}
|
|
142
|
+
</td>
|
|
143
|
+
<td>${t[this.datasets[0].key]}</td>
|
|
144
|
+
</tr>
|
|
145
|
+
`)):Object.entries(this.datasets[0].tree).map((t=>{const s=[];return t[1].value?s.push(e`
|
|
128
146
|
<tr>
|
|
129
147
|
<td>${t[0]}</td>
|
|
130
148
|
<td>${t[1].value}</td>
|
|
131
149
|
</tr>
|
|
132
|
-
`):Object.entries(t[1]).map((t=>{s.push(e`
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
150
|
+
`):Object.entries(t[1]).map((t=>{t[1].value?s.push(e`
|
|
151
|
+
<tr>
|
|
152
|
+
<td>${t[0]}</td>
|
|
153
|
+
<td>${t[1].value}</td>
|
|
154
|
+
</tr>
|
|
155
|
+
`):Object.entries(t[1]).map((t=>{s.push(e`
|
|
156
|
+
<tr>
|
|
157
|
+
<td>${t[0]}</td>
|
|
158
|
+
<td>
|
|
159
|
+
${t[1].value}
|
|
160
|
+
</td>
|
|
161
|
+
</tr>
|
|
162
|
+
`)}))})),s})):this.datasets[0].data.map(((t,s)=>{var o,i;const a=this.options.indexAxis||"x",r="x"===a?"y":"x";return e`
|
|
163
|
+
<tr>
|
|
164
|
+
${this.labels.length?e`
|
|
165
|
+
${"time"===(null===(i=null===(o=this.options)||void 0===o?void 0:o.scales[a])||void 0===i?void 0:i.type)?e`
|
|
166
|
+
<td>
|
|
167
|
+
${new Date(this.labels[s]).toLocaleString()}
|
|
168
|
+
</td>
|
|
169
|
+
`:e`
|
|
170
|
+
<td>${this.labels[s]}</td>
|
|
171
|
+
`}
|
|
172
|
+
`:null}
|
|
173
|
+
${this.datasets.map((t=>{var o,i;const a=t.data[s];return"bubbleMap"===this.type||"choropleth"===this.type?e`
|
|
174
|
+
<td>${t.data[s].value}</td>
|
|
175
|
+
`:"time"===(null===(i=null===(o=this.options)||void 0===o?void 0:o.scales[r])||void 0===i?void 0:i.type)?e`
|
|
176
|
+
<td>
|
|
177
|
+
${new Date(a).toLocaleString()}
|
|
178
|
+
</td>
|
|
179
|
+
`:Array.isArray(a)?e`
|
|
180
|
+
<td>
|
|
181
|
+
${a[0]}, ${a[1]}
|
|
182
|
+
</td>
|
|
183
|
+
`:"object"!=typeof a||Array.isArray(a)||null===a?e`
|
|
184
|
+
<td>${t.data[s]}</td>
|
|
185
|
+
`:e`
|
|
186
|
+
<td>
|
|
187
|
+
${Object.keys(a).map((t=>{var s,o,i;const r=(null===(o=null===(s=this.options.scales[t])||void 0===s?void 0:s.title)||void 0===o?void 0:o.text)||t,n="time"===(null===(i=this.options.scales[t])||void 0===i?void 0:i.type)?new Date(a[t]).toLocaleString():a[t];return e`
|
|
188
|
+
<div>
|
|
189
|
+
<strong>
|
|
190
|
+
${r}:
|
|
191
|
+
</strong>
|
|
192
|
+
${n}
|
|
193
|
+
</div>
|
|
194
|
+
`}))}
|
|
195
|
+
</td>
|
|
196
|
+
`}))}
|
|
197
|
+
</tr>
|
|
163
198
|
`}))}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
</tbody>
|
|
199
|
+
</tbody>
|
|
200
|
+
`}
|
|
167
201
|
</table>
|
|
168
202
|
</div>
|
|
169
203
|
`:null}
|
|
170
204
|
</div>
|
|
171
|
-
`}_resizeChart(){this.chart&&this.chart.resize()}connectedCallback(){super.connectedCallback(),this._themeObserver.observe(document.querySelector('meta[name="color-scheme"]'),{attributes:!0})}disconnectedCallback(){this._resizeObserver.disconnect(),this._themeObserver.disconnect(),super.disconnectedCallback()}firstUpdated(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".canvas-container");this._resizeObserver.observe(e)}updated(t){var e,s;this.chart&&(t.has("labels")||t.has("datasets")||t.has("options"))&&this.mergeOptions().then((()=>{this.chart.data.labels=this.labels,this.chart.options=this.mergedOptions,this.chart.data.datasets.forEach(((t,e)=>{this.mergedDatasets.find((e=>e.label===t.label))||this.chart.data.datasets.splice(e,1)})),this.mergedDatasets.forEach((t=>{const e=this.chart.data.datasets.find((e=>e.label===t.label));e?Object.keys(t).forEach((s=>{e[s]=t[s]})):this.chart.data.datasets.push(t)})),this.chart.update()}));let o=!1;if(this.datasets&&this.datasets.length)for(const t of this.datasets)if(o=(null===(e=t.data)||void 0===e?void 0:e.length)>0||(null===(s=t.tree)||void 0===s?void 0:s.length)>0||t.tree&&Object.keys(t.tree).length>0,!o){console.error("Missing data for one or more chart datasets.");break}!this.chart&&this.type&&t.has("datasets")&&o&&(this.mergeOptions().then((()=>{this.initChart()})),this.checkType()),this.chart&&(t.has("type")||t.has("plugins")||t.has("width")||t.has("height"))&&(this.mergeOptions().then((()=>{this.initChart()})),this.checkType()),this.chart&&t.has("noBorder")&&this.chart.resize()}initChart(){
|
|
205
|
+
`}_resizeChart(){this.chart&&this.chart.resize()}connectedCallback(){super.connectedCallback(),this._themeObserver.observe(document.querySelector('meta[name="color-scheme"]'),{attributes:!0})}disconnectedCallback(){this._resizeObserver.disconnect(),this._themeObserver.disconnect(),super.disconnectedCallback()}firstUpdated(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".canvas-container");this._resizeObserver.observe(e)}updated(t){var e,s;this.chart&&(t.has("labels")||t.has("datasets")||t.has("options"))&&this.mergeOptions().then((()=>{this.chart.data.labels=this.labels,this.chart.options=this.mergedOptions,this.chart.data.datasets.forEach(((t,e)=>{this.mergedDatasets.find((e=>e.label===t.label))||this.chart.data.datasets.splice(e,1)})),this.mergedDatasets.forEach((t=>{const e=this.chart.data.datasets.find((e=>e.label===t.label));e?Object.keys(t).forEach((s=>{e[s]=t[s]})):this.chart.data.datasets.push(t)})),this.chart.update()}));let o=!1;if(this.datasets&&this.datasets.length)for(const t of this.datasets)if(o=(null===(e=t.data)||void 0===e?void 0:e.length)>0||(null===(s=t.tree)||void 0===s?void 0:s.length)>0||t.tree&&Object.keys(t.tree).length>0,!o){console.error("Missing data for one or more chart datasets.");break}!this.chart&&this.type&&t.has("datasets")&&o&&(this.mergeOptions().then((()=>{this.initChart()})),this.checkType()),this.chart&&(t.has("type")||t.has("plugins")||t.has("width")||t.has("height"))&&(this.mergeOptions().then((()=>{this.initChart()})),this.checkType()),this.chart&&t.has("noBorder")&&this.chart.resize()}initChart(){N.defaults.color=z("--kd-color-text-level-primary");const t="meter"===this.type?$:T;let e=[j,t,w,...this.plugins];["choropleth","treemap","bubbleMap"].includes(this.type)||(e=[...e,x]),this.chart&&this.chart.destroy(),this.chart=new N(this.canvas,{type:"meter"===this.type?"doughnut":this.type,data:{labels:this.labels,datasets:this.mergedDatasets},options:this.mergedOptions,plugins:e})}async mergeOptions(){const t=[];this.datasets.forEach((e=>{e.type&&t.push(function(t){switch(t){case"../../common/config/chartTypes/bar.js":return import("../../common/config/chartTypes/bar.js");case"../../common/config/chartTypes/bubble.js":return import("../../common/config/chartTypes/bubble.js");case"../../common/config/chartTypes/bubbleMap.js":return import("../../common/config/chartTypes/bubbleMap.js");case"../../common/config/chartTypes/choropleth.js":return import("../../common/config/chartTypes/choropleth.js");case"../../common/config/chartTypes/doughnut.js":return import("../../common/config/chartTypes/doughnut.js");case"../../common/config/chartTypes/line.js":return import("../../common/config/chartTypes/line.js");case"../../common/config/chartTypes/matrix.js":return import("../../common/config/chartTypes/matrix.js");case"../../common/config/chartTypes/meter.js":return import("../../common/config/chartTypes/meter.js");case"../../common/config/chartTypes/pie.js":return import("../../common/config/chartTypes/pie.js");case"../../common/config/chartTypes/polarArea.js":return import("../../common/config/chartTypes/polarArea.js");case"../../common/config/chartTypes/radar.js":return import("../../common/config/chartTypes/radar.js");case"../../common/config/chartTypes/scatter.js":return import("../../common/config/chartTypes/scatter.js");case"../../common/config/chartTypes/treemap.js":return import("../../common/config/chartTypes/treemap.js");default:return new Promise((function(e,s){("function"==typeof queueMicrotask?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}(`../../common/config/chartTypes/${e.type}.js`))}));const e=await Promise.all([P(`../../common/config/chartTypes/${this.type}.js`),...t]);let s=C(this);["pie","doughnut","radar","polarArea","meter"].includes(this.type)?s=l(s,M()):["choropleth","treemap","bubbleMap"].includes(this.type)||(s=l(s,L(this)));const o=JSON.parse(JSON.stringify(this.datasets));e.forEach((t=>{s=l(s,t.options(this)),o.forEach(((e,s)=>{(!e.type&&t.type===this.type||e.type===t.type)&&(o[s]=l(e,t.datasetOptions(this,s)))}))})),this.options&&(s=l(s,this.options)),this.mergedOptions=s,o.forEach(((t,e)=>{const s=c({mergeArrays:!1});o[e]=s(t,this.datasets[e])})),this.mergedDatasets=o}getTableAxisLabel(){var t,e,s,o,i,a,r,n,l,c,d;let h="";return h="y"===(null===(t=this.options)||void 0===t?void 0:t.indexAxis)?(null===(i=null===(o=null===(s=null===(e=this.options)||void 0===e?void 0:e.scales)||void 0===s?void 0:s.y)||void 0===o?void 0:o.title)||void 0===i?void 0:i.text)?null===(a=this.options)||void 0===a?void 0:a.scales.y.title.text:"Y Axis":(null===(c=null===(l=null===(n=null===(r=this.options)||void 0===r?void 0:r.scales)||void 0===n?void 0:n.x)||void 0===l?void 0:l.title)||void 0===c?void 0:c.text)?null===(d=this.options)||void 0===d?void 0:d.scales.x.title.text:"X Axis",h}handleViewToggle(){this.tableView=!this.tableView}checkType(){this.tableDisabled=[].includes(this.type)}handleDownloadImage(t,e){t.preventDefault();const s=e?"image/jpeg":"image/png",o=e?"jpg":"png",i=document.createElement("a");i.href=this.chart.toBase64Image(s,1),i.download=this.chartTitle+"."+o,i.click()}handleDownloadCsv(t){t.preventDefault();let e="";for(let t=0;t<this.chart.data.datasets.length;t++)e+=O({data:this.chart.data.datasets[t],labels:this.labels});if(null==e)return;const s=this.chartTitle+".csv";e.match(/^data:text\/csv/i)||(e="data:text/csv;charset=utf-8,"+e);const o=encodeURI(e),i=document.createElement("a");i.setAttribute("href",o),i.setAttribute("download",s),document.body.appendChild(i),i.click(),document.body.removeChild(i)}handleFullscreen(){var t;(null===(t=this.shadowRoot)||void 0===t?void 0:t.fullscreenElement)?document.exitFullscreen():this.container.requestFullscreen()}handleFullscreenChange(){var t;this.fullscreen=null!==(null===(t=this.shadowRoot)||void 0===t?void 0:t.fullscreenElement)}};R.styles=A,t([i({type:String})],R.prototype,"chartTitle",void 0),t([i({type:String})],R.prototype,"description",void 0),t([i({type:String})],R.prototype,"type",void 0),t([i({type:Array})],R.prototype,"labels",void 0),t([i({type:Array})],R.prototype,"datasets",void 0),t([i({type:Object})],R.prototype,"options",void 0),t([i({type:Array})],R.prototype,"plugins",void 0),t([i({type:Number})],R.prototype,"height",void 0),t([i({type:Number})],R.prototype,"width",void 0),t([i({type:Boolean})],R.prototype,"hideDescription",void 0),t([i({type:Boolean})],R.prototype,"hideCaptions",void 0),t([i({type:Boolean})],R.prototype,"hideHeader",void 0),t([i({type:Boolean})],R.prototype,"hideControls",void 0),t([i({type:Boolean})],R.prototype,"noBorder",void 0),t([i({type:Object})],R.prototype,"customLabels",void 0),t([a()],R.prototype,"fullscreen",void 0),t([r(".container")],R.prototype,"container",void 0),t([r("canvas")],R.prototype,"canvas",void 0),t([r(".closed-caption")],R.prototype,"ccDiv",void 0),t([a()],R.prototype,"chart",void 0),t([a()],R.prototype,"tableView",void 0),t([a()],R.prototype,"tableDisabled",void 0),t([a()],R.prototype,"mergedOptions",void 0),t([a()],R.prototype,"mergedDatasets",void 0),t([a()],R.prototype,"_widget",void 0),R=t([o("kd-chart")],R);export{R as KDChart};
|
|
172
206
|
//# sourceMappingURL=chart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.js","sources":["../../../src/components/chart/chart.ts"],"sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, state, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { deepmerge, deepmergeCustom } from 'deepmerge-ts';\nimport Chart from 'chart.js/auto';\nimport 'chartjs-adapter-date-fns';\nimport {\n ChoroplethController,\n BubbleMapController,\n GeoFeature,\n ColorScale,\n SizeScale,\n ProjectionScale,\n} from 'chartjs-chart-geo';\nimport { TreemapController, TreemapElement } from 'chartjs-chart-treemap';\nimport canvasBackgroundPlugin from '../../common/plugins/canvasBackground';\nimport doughnutLabelPlugin from '../../common/plugins/doughnutLabel';\nimport meterGaugePlugin from '../../common/plugins/meterGaugeNeedle';\nimport a11yPlugin from 'chartjs-plugin-a11y-legend';\nimport datalabelsPlugin from 'chartjs-plugin-datalabels';\nimport annotationPlugin from 'chartjs-plugin-annotation';\nimport { convertChartDataToCSV, debounce } from '../../common/helpers/helpers';\nimport ChartScss from './chart.scss';\nimport globalOptions from '../../common/config/globalOptions';\nimport globalOptionsNonRadial from '../../common/config/globalOptionsNonRadial';\nimport globalOptionsRadial from '../../common/config/globalOptionsRadial';\nimport chartIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/analytics.svg';\nimport tableIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/table-view.svg';\nimport downloadIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/download.svg';\nimport maximizeIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/expand.svg';\nimport minimizeIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/shrink.svg';\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js';\nimport { getTokenThemeVal } from '@kyndryl-design-system/shidoka-foundation/common/helpers/color';\n\nChart.register(\n ChoroplethController,\n BubbleMapController,\n GeoFeature,\n ColorScale,\n SizeScale,\n ProjectionScale,\n TreemapController,\n TreemapElement,\n annotationPlugin,\n datalabelsPlugin\n);\n\n/**\n * Chart.js wrapper component.\n * @slot unnamed - Slot for custom content between header and chart.\n * @slot controls - Slot for custom controls such as an overflow menu.\n * @slot tooltip - Slot for tooltip in header.\n * @slot draghandle - Slot for widget drag handle.\n */\n@customElement('kd-chart')\nexport class KDChart extends LitElement {\n static override styles = ChartScss;\n\n /** Chart title. */\n @property({ type: String })\n chartTitle = '';\n\n /** Chart description. */\n @property({ type: String })\n description = '';\n\n /** Chart.js chart type. */\n @property({ type: String })\n type: any = '';\n\n /** Chart.js data.labels. */\n @property({ type: Array })\n labels!: Array<string>;\n\n /** Chart.js data.datasets. */\n @property({ type: Array })\n datasets!: Array<any>;\n\n /** Chart.js options. Can override Shidoka defaults. */\n @property({ type: Object })\n options: any = {};\n\n /** Chart.js additional plugins. Must be registerable inline via Chart.plugins array, not globally via Chart.register. */\n @property({ type: Array })\n plugins: any = [];\n\n /** Chart.js canvas height (px). Disables maintainAspectRatio option. */\n @property({ type: Number })\n height: any = null;\n\n /** Chart.js canvas width (px). Disables maintainAspectRatio option. */\n @property({ type: Number })\n width: any = null;\n\n /** Hides the description visually. */\n @property({ type: Boolean })\n hideDescription = false;\n\n /** Hides the closed captions visually. */\n @property({ type: Boolean })\n hideCaptions = false;\n\n /** Hides the title & description. */\n @property({ type: Boolean })\n hideHeader = false;\n\n /** Hides the controls. */\n @property({ type: Boolean })\n hideControls = false;\n\n /** Removes the outer border and padding. */\n @property({ type: Boolean })\n noBorder = false;\n\n /** Customizable text labels. */\n @property({ type: Object })\n customLabels = {\n toggleView: 'Toggle View Mode',\n toggleFullscreen: 'Toggle Fullscreen',\n downloadMenu: 'Download Menu',\n downloadCsv: 'Download as CSV',\n downloadPng: 'Download as PNG',\n downloadJpg: 'Download as JPG',\n };\n\n /** Fullscreen state.\n * @ignore\n */\n @state()\n fullscreen = false;\n\n /**\n * Queries the container element.\n * @ignore\n */\n @query('.container')\n container!: HTMLCanvasElement;\n\n /**\n * Queries the canvas element.\n * @ignore\n */\n @query('canvas')\n canvas!: HTMLCanvasElement;\n\n /**\n * Queries the closed caption div.\n * @ignore\n */\n @query('.closed-caption')\n ccDiv!: HTMLDivElement;\n\n /** The chart instance.\n * @ignore\n */\n @state()\n chart: any = null;\n\n /** Table view mode.\n * @ignore\n */\n @state()\n tableView = false;\n\n /** Disable table view feature.\n * @ignore\n */\n @state()\n tableDisabled = false;\n\n /** Merged options.\n * @ignore\n */\n @state()\n mergedOptions: any = {};\n\n /** Merged datasets.\n * @ignore\n */\n @state()\n mergedDatasets: any = {};\n\n /** Is Widget. Inherited from kyn-widget.\n * @internal\n */\n @state()\n _widget = false;\n\n /** ResizeObserver for canvas-container.\n * @internal\n */\n _resizeObserver: any = new ResizeObserver(\n debounce(() => {\n this._resizeChart();\n })\n );\n\n _themeObserver: any = new MutationObserver(() => {\n if (this.chart) {\n this.mergeOptions().then(() => {\n this.initChart();\n });\n }\n });\n\n override render() {\n const Classes = {\n container: true,\n fullscreen: this.fullscreen,\n 'no-border': this.noBorder || this._widget,\n widget: this._widget,\n };\n\n return html`\n <div\n class=${classMap(Classes)}\n @fullscreenchange=${() => this.handleFullscreenChange()}\n >\n ${!this.hideHeader || !this.hideControls\n ? html`\n <div class=\"header\">\n ${!this.hideHeader\n ? html`\n <slot name=\"draghandle\"></slot>\n\n <div id=\"titleDesc\">\n <div class=\"title\">\n ${this.chartTitle}\n <slot name=\"tooltip\"></slot>\n </div>\n <div\n class=\"description ${this.hideDescription\n ? 'hidden-visually'\n : ''}\"\n >\n ${this.description}\n </div>\n </div>\n `\n : null}\n ${!this.hideControls\n ? html`\n <div class=\"controls\">\n ${!this.tableDisabled\n ? html`\n <button\n class=\"control-button\"\n @click=${() => this.handleViewToggle()}\n aria-label=${this.customLabels.toggleView}\n title=${this.customLabels.toggleView}\n >\n <span slot=\"icon\">\n ${this.tableView\n ? unsafeSVG(chartIcon)\n : unsafeSVG(tableIcon)}\n </span>\n </button>\n `\n : null}\n\n <button\n class=\"control-button\"\n @click=${() => this.handleFullscreen()}\n aria-label=${this.customLabels.toggleFullscreen}\n title=${this.customLabels.toggleFullscreen}\n >\n <span slot=\"icon\">\n ${this.fullscreen\n ? unsafeSVG(minimizeIcon)\n : unsafeSVG(maximizeIcon)}\n </span>\n </button>\n\n <div class=\"download\">\n <button\n class=\"control-button\"\n aria-label=${this.customLabels.downloadMenu}\n title=${this.customLabels.downloadMenu}\n >\n <span slot=\"icon\">\n ${unsafeSVG(downloadIcon)}\n </span>\n </button>\n\n <div class=\"download-menu\">\n ${!this.tableDisabled\n ? html`\n <button\n @click=${(e: Event) =>\n this.handleDownloadCsv(e)}\n >\n ${this.customLabels.downloadCsv}\n </button>\n `\n : null}\n <button\n @click=${(e: Event) =>\n this.handleDownloadImage(e, false)}\n >\n ${this.customLabels.downloadPng}\n </button>\n <button\n @click=${(e: Event) =>\n this.handleDownloadImage(e, true)}\n >\n ${this.customLabels.downloadJpg}\n </button>\n </div>\n </div>\n\n <slot name=\"controls\"></slot>\n </div>\n `\n : null}\n </div>\n `\n : null}\n\n <div>\n <slot></slot>\n </div>\n\n <figure class=\"${this.tableView ? 'hidden' : ''}\">\n <div\n class=\"canvas-container\"\n style=\"${this.width ? `width: ${this.width}px;` : ''}\n ${this.height ? `height: ${this.height}px;` : ''}\"\n >\n <canvas role=\"img\" aria-labelledby=\"titleDesc\"></canvas>\n </div>\n <figcaption>\n <div\n class=\"closed-caption ${this.hideCaptions\n ? 'hidden-visually'\n : ''}\"\n ></div>\n </figcaption>\n </figure>\n\n ${!this.tableDisabled && this.tableView\n ? html`\n <div class=\"table\">\n <table>\n <thead>\n <tr>\n ${this.labels?.length || this.type === 'treemap'\n ? html`<th>${this.getTableAxisLabel()}</th>`\n : null}\n ${this.datasets.map((dataset) => {\n return html`<th>${dataset.label}</th>`;\n })}\n </tr>\n </thead>\n\n <tbody>\n ${this.type === 'treemap'\n ? Array.isArray(this.datasets[0].tree)\n ? this.datasets[0].tree.map((_value: any) => {\n return html`\n <tr>\n <td>${_value[this.datasets[0].labelKey]}</td>\n <td>${_value[this.datasets[0].key]}</td>\n </tr>\n `;\n })\n : Object.entries(this.datasets[0].tree).map(\n (_value: any) => {\n const HtmlStrings = [];\n\n if (_value[1].value) {\n HtmlStrings.push(html`\n <tr>\n <td>${_value[0]}</td>\n <td>${_value[1].value}</td>\n </tr>\n `);\n } else {\n Object.entries(_value[1]).map(\n (_subValue: any) => {\n if (_subValue[1].value) {\n HtmlStrings.push(html`\n <tr>\n <td>${_subValue[0]}</td>\n <td>${_subValue[1].value}</td>\n </tr>\n `);\n } else {\n Object.entries(_subValue[1]).map(\n (_subSubValue: any) => {\n HtmlStrings.push(html`\n <tr>\n <td>${_subSubValue[0]}</td>\n <td>${_subSubValue[1].value}</td>\n </tr>\n `);\n }\n );\n }\n }\n );\n }\n\n return HtmlStrings;\n }\n )\n : this.datasets[0].data.map((_value: any, i: number) => {\n const IndexAxis = this.options.indexAxis || 'x';\n const NonIndexAxis = IndexAxis === 'x' ? 'y' : 'x';\n\n return html`\n <tr>\n ${this.labels.length\n ? html`\n ${this.options?.scales[IndexAxis]?.type ===\n 'time'\n ? html`\n <td>\n ${new Date(\n this.labels[i]\n ).toLocaleString()}\n </td>\n `\n : html`<td>${this.labels[i]}</td>`}\n `\n : null}\n ${this.datasets.map((dataset) => {\n const dataPoint = dataset.data[i];\n\n if (\n this.type === 'bubbleMap' ||\n this.type === 'choropleth'\n ) {\n return html`\n <td>${dataset.data[i].value}</td>\n `;\n } else if (\n this.options?.scales[NonIndexAxis]?.type ===\n 'time'\n ) {\n return html`\n <td>\n ${new Date(dataPoint).toLocaleString()}\n </td>\n `;\n } else if (Array.isArray(dataPoint)) {\n // handle data in array format\n return html`\n <td>${dataPoint[0]}, ${dataPoint[1]}</td>\n `;\n } else if (\n typeof dataPoint === 'object' &&\n !Array.isArray(dataPoint) &&\n dataPoint !== null\n ) {\n // handle data in object format\n return html`\n <td>\n ${Object.keys(dataPoint).map((key) => {\n const Label =\n this.options.scales[key]?.title\n .text || key;\n const DisplayData =\n this.options.scales[key]?.type ===\n 'time'\n ? new Date(\n dataPoint[key]\n ).toLocaleString()\n : dataPoint[key];\n\n return html`\n <div>\n <strong>${Label}:</strong>\n ${DisplayData}\n </div>\n `;\n })}\n </td>\n `;\n } else {\n // handle data in number/basic format\n return html`<td>${dataset.data[i]}</td>`;\n }\n })}\n </tr>\n `;\n })}\n </tbody>\n </table>\n </div>\n `\n : null}\n </div>\n `;\n }\n\n private _resizeChart() {\n if (this.chart) {\n this.chart.resize();\n }\n }\n\n override connectedCallback() {\n super.connectedCallback();\n\n this._themeObserver.observe(\n document.querySelector('meta[name=\"color-scheme\"]'),\n { attributes: true }\n );\n }\n\n override disconnectedCallback() {\n this._resizeObserver.disconnect();\n this._themeObserver.disconnect();\n\n super.disconnectedCallback();\n }\n\n override firstUpdated() {\n const el = this.shadowRoot?.querySelector('.canvas-container');\n this._resizeObserver.observe(el);\n }\n\n override updated(changedProps: any) {\n // Update chart instance when data changes.\n if (\n this.chart &&\n (changedProps.has('labels') ||\n changedProps.has('datasets') ||\n changedProps.has('options'))\n ) {\n this.mergeOptions().then(() => {\n this.chart.data.labels = this.labels;\n this.chart.options = this.mergedOptions;\n\n // remove datasets not in mergedDatasets\n this.chart.data.datasets.forEach((dataset: any, index: number) => {\n const NewDataset = this.mergedDatasets.find(\n (newDataset: any) => newDataset.label === dataset.label\n );\n\n if (!NewDataset) {\n // remove\n this.chart.data.datasets.splice(index, 1);\n }\n });\n\n // update datasets, add new ones\n this.mergedDatasets.forEach((dataset: any) => {\n const OldDataset = this.chart.data.datasets.find(\n (oldDataset: any) => oldDataset.label === dataset.label\n );\n\n if (!OldDataset) {\n // add new dataset\n this.chart.data.datasets.push(dataset);\n } else {\n // update each key/entry in the dataset object\n Object.keys(dataset).forEach((key) => {\n OldDataset[key] = dataset[key];\n });\n }\n });\n\n this.chart.update();\n });\n }\n\n // init chart\n // check to make sure initial datasets + data have been provided\n let hasData = false;\n if (this.datasets && this.datasets.length) {\n for (const dataset of this.datasets) {\n hasData =\n dataset.data?.length > 0 ||\n dataset.tree?.length > 0 ||\n (dataset.tree && Object.keys(dataset.tree).length > 0);\n\n if (!hasData) {\n console.error('Missing data for one or more chart datasets.');\n break;\n }\n }\n }\n\n if (!this.chart && this.type && changedProps.has('datasets') && hasData) {\n this.mergeOptions().then(() => {\n this.initChart();\n });\n\n this.checkType();\n }\n\n // Re-init chart instance when type, plugins, colorPalette, width, or height change.\n if (\n this.chart &&\n (changedProps.has('type') ||\n changedProps.has('plugins') ||\n changedProps.has('width') ||\n changedProps.has('height'))\n ) {\n this.mergeOptions().then(() => {\n this.initChart();\n });\n\n this.checkType();\n }\n\n if (this.chart && changedProps.has('noBorder')) {\n this.chart.resize();\n }\n }\n\n /**\n * Initializes a bar chart using the Chart.js library with provided labels, datasets,\n * and options.\n */\n private initChart() {\n const ignoredTypes = ['choropleth', 'treemap', 'bubbleMap'];\n\n // Chart.defaults.font.family = getComputedStyle(\n // document.documentElement\n // ).getPropertyValue('--kd-font-family-secondary');\n Chart.defaults.color = getTokenThemeVal('--kd-color-text-level-primary');\n\n // let plugins = [\n // canvasBackgroundPlugin,\n // doughnutLabelPlugin,\n // meterGaugePlugin,\n // ...this.plugins,\n // ];\n\n // Select plugin when type='meter'. Otherwise both plugins (meterGaugePlugin & doughnutLabelPlugin) are called\n const pluginSelectForDoghnutMeter =\n this.type === 'meter' ? meterGaugePlugin : doughnutLabelPlugin;\n\n let plugins = [\n canvasBackgroundPlugin,\n pluginSelectForDoghnutMeter,\n ...this.plugins,\n ];\n\n // only add certain plugins for standard chart types\n if (!ignoredTypes.includes(this.type)) {\n // plugins = [...plugins, a11yPlugin, musicPlugin];\n plugins = [...plugins, a11yPlugin];\n }\n\n if (this.chart) {\n this.chart.destroy();\n }\n\n this.chart = new Chart(this.canvas, {\n //type: this.type,\n type: this.type === 'meter' ? 'doughnut' : this.type,\n data: {\n labels: this.labels,\n datasets: this.mergedDatasets,\n },\n options: this.mergedOptions,\n plugins: plugins,\n });\n }\n\n /**\n * Merges various chart type options and dataset options to create a\n * final set of options for a chart.\n */\n private async mergeOptions() {\n const radialTypes = ['pie', 'doughnut', 'radar', 'polarArea', 'meter'];\n const ignoredTypes = ['choropleth', 'treemap', 'bubbleMap'];\n\n const additionalTypeImports: any = [];\n this.datasets.forEach((dataset) => {\n // get chart types from datasets so we can import additional configs\n if (dataset.type) {\n additionalTypeImports.push(\n import(`../../common/config/chartTypes/${dataset.type}.js`)\n );\n }\n });\n\n // import main and additional chart type configs\n const chartTypeConfigs = await Promise.all([\n import(`../../common/config/chartTypes/${this.type}.js`),\n ...additionalTypeImports,\n ]);\n\n // start with global options\n let mergedOptions: any = globalOptions(this);\n\n // merge global type options\n if (radialTypes.includes(this.type)) {\n mergedOptions = deepmerge(mergedOptions, globalOptionsRadial(this));\n } else if (!ignoredTypes.includes(this.type)) {\n mergedOptions = deepmerge(mergedOptions, globalOptionsNonRadial(this));\n }\n\n const mergedDatasets: any = JSON.parse(JSON.stringify(this.datasets));\n\n chartTypeConfigs.forEach((chartTypeConfig: any) => {\n // merge all of the imported chart type options with the global options\n mergedOptions = deepmerge(mergedOptions, chartTypeConfig.options(this));\n\n // merge all of the imported chart type dataset options\n mergedDatasets.forEach((dataset: any, index: number) => {\n if (\n (!dataset.type && chartTypeConfig.type === this.type) ||\n dataset.type === chartTypeConfig.type\n ) {\n mergedDatasets[index] = deepmerge(\n dataset,\n chartTypeConfig.datasetOptions(this, index)\n );\n }\n });\n });\n\n if (this.options) {\n // merge any consumer supplied options with defaults\n mergedOptions = deepmerge(mergedOptions, this.options);\n }\n this.mergedOptions = mergedOptions;\n\n // merge default chart type dataset options with consumer supplied datasets\n mergedDatasets.forEach((dataset: object, index: number) => {\n const customDeepmerge = deepmergeCustom({\n mergeArrays: false,\n });\n mergedDatasets[index] = customDeepmerge(dataset, this.datasets[index]);\n });\n\n this.mergedDatasets = mergedDatasets;\n }\n\n private getTableAxisLabel() {\n let label = '';\n\n if (this.options?.indexAxis === 'y') {\n if (this.options?.scales?.y?.title?.text) {\n label = this.options?.scales.y.title.text;\n } else {\n label = 'Y Axis';\n }\n } else {\n if (this.options?.scales?.x?.title?.text) {\n label = this.options?.scales.x.title.text;\n } else {\n label = 'X Axis';\n }\n }\n\n return label;\n }\n\n private handleViewToggle() {\n this.tableView = !this.tableView;\n }\n\n private checkType() {\n // chart types that can't have a data table view\n const blacklist: any = [];\n this.tableDisabled = blacklist.includes(this.type);\n }\n\n private handleDownloadImage(e: Event, jpeg: boolean) {\n e.preventDefault();\n\n const imgFormat = jpeg ? 'image/jpeg' : 'image/png';\n const fileExt = jpeg ? 'jpg' : 'png';\n const a = document.createElement('a');\n\n a.href = this.chart.toBase64Image(imgFormat, 1);\n a.download = this.chartTitle + '.' + fileExt;\n\n // trigger the download\n a.click();\n }\n\n private handleDownloadCsv(e: Event) {\n e.preventDefault();\n let csv = '';\n\n for (let i = 0; i < this.chart.data.datasets.length; i++) {\n csv += convertChartDataToCSV({\n data: this.chart.data.datasets[i],\n labels: this.labels,\n });\n }\n if (csv == null) return;\n\n const filename = this.chartTitle + '.csv';\n if (!csv.match(/^data:text\\/csv/i)) {\n csv = 'data:text/csv;charset=utf-8,' + csv;\n }\n\n // not sure if anything below this comment works\n const data = encodeURI(csv);\n const link = document.createElement('a');\n link.setAttribute('href', data);\n link.setAttribute('download', filename);\n document.body.appendChild(link); // Required for FF\n link.click();\n document.body.removeChild(link);\n }\n\n private handleFullscreen() {\n if (this.shadowRoot?.fullscreenElement) {\n document.exitFullscreen();\n } else {\n this.container.requestFullscreen();\n }\n }\n\n private handleFullscreenChange() {\n this.fullscreen = this.shadowRoot?.fullscreenElement !== null;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kd-chart': KDChart;\n }\n}\n"],"names":["Chart","register","ChoroplethController","BubbleMapController","GeoFeature","ColorScale","SizeScale","ProjectionScale","TreemapController","TreemapElement","annotationPlugin","datalabelsPlugin","KDChart","LitElement","constructor","this","chartTitle","description","type","options","plugins","height","width","hideDescription","hideCaptions","hideHeader","hideControls","noBorder","customLabels","toggleView","toggleFullscreen","downloadMenu","downloadCsv","downloadPng","downloadJpg","fullscreen","chart","tableView","tableDisabled","mergedOptions","mergedDatasets","_widget","_resizeObserver","ResizeObserver","debounce","_resizeChart","_themeObserver","MutationObserver","mergeOptions","then","initChart","render","Classes","container","widget","html","classMap","handleFullscreenChange","handleViewToggle","unsafeSVG","chartIcon","tableIcon","handleFullscreen","minimizeIcon","maximizeIcon","downloadIcon","e","handleDownloadCsv","handleDownloadImage","_a","labels","length","getTableAxisLabel","datasets","map","dataset","label","Array","isArray","tree","_value","labelKey","key","Object","entries","HtmlStrings","value","push","_subValue","_subSubValue","data","i","IndexAxis","indexAxis","NonIndexAxis","_b","scales","Date","toLocaleString","dataPoint","keys","Label","title","text","DisplayData","resize","connectedCallback","super","observe","document","querySelector","attributes","disconnectedCallback","disconnect","firstUpdated","el","shadowRoot","updated","changedProps","has","forEach","index","find","newDataset","splice","OldDataset","oldDataset","update","hasData","console","error","checkType","defaults","color","getTokenThemeVal","pluginSelectForDoghnutMeter","meterGaugePlugin","doughnutLabelPlugin","canvasBackgroundPlugin","includes","a11yPlugin","destroy","canvas","additionalTypeImports","__variableDynamicImportRuntime0__","chartTypeConfigs","Promise","all","__variableDynamicImportRuntime1__","globalOptions","deepmerge","globalOptionsRadial","globalOptionsNonRadial","JSON","parse","stringify","chartTypeConfig","datasetOptions","customDeepmerge","deepmergeCustom","mergeArrays","_e","_d","_c","y","_f","_k","_j","_h","_g","x","_l","jpeg","preventDefault","imgFormat","fileExt","a","createElement","href","toBase64Image","download","click","csv","convertChartDataToCSV","filename","match","encodeURI","link","setAttribute","body","appendChild","removeChild","fullscreenElement","exitFullscreen","requestFullscreen","styles","ChartScss","__decorate","property","String","prototype","Number","Boolean","state","query","customElement"],"mappings":"kuIAkCAA,EAAMC,SACJC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAWK,IAAMC,EAAN,cAAsBC,EAAtB,WAAAC,uBAKLC,KAAUC,WAAG,GAIbD,KAAWE,YAAG,GAIdF,KAAIG,KAAQ,GAYZH,KAAOI,QAAQ,GAIfJ,KAAOK,QAAQ,GAIfL,KAAMM,OAAQ,KAIdN,KAAKO,MAAQ,KAIbP,KAAeQ,iBAAG,EAIlBR,KAAYS,cAAG,EAIfT,KAAUU,YAAG,EAIbV,KAAYW,cAAG,EAIfX,KAAQY,UAAG,EAIXZ,KAAAa,aAAe,CACbC,WAAY,mBACZC,iBAAkB,oBAClBC,aAAc,gBACdC,YAAa,kBACbC,YAAa,kBACbC,YAAa,mBAOfnB,KAAUoB,YAAG,EA2BbpB,KAAKqB,MAAQ,KAMbrB,KAASsB,WAAG,EAMZtB,KAAauB,eAAG,EAMhBvB,KAAawB,cAAQ,GAMrBxB,KAAcyB,eAAQ,GAMtBzB,KAAO0B,SAAG,EAKV1B,KAAA2B,gBAAuB,IAAIC,eACzBC,GAAS,KACP7B,KAAK8B,cAAc,KAIvB9B,KAAA+B,eAAsB,IAAI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AAA,CADCM,KACkB/L,EAAA4L,UAAA,kBAAA,GAOnBH,EAAA,CADCO,EAAM,eACuBhM,EAAA4L,UAAA,iBAAA,GAO9BH,EAAA,CADCO,EAAM,WACoBhM,EAAA4L,UAAA,cAAA,GAO3BH,EAAA,CADCO,EAAM,oBACgBhM,EAAA4L,UAAA,aAAA,GAMvBH,EAAA,CADCM,KACiB/L,EAAA4L,UAAA,aAAA,GAMlBH,EAAA,CADCM,KACiB/L,EAAA4L,UAAA,iBAAA,GAMlBH,EAAA,CADCM,KACqB/L,EAAA4L,UAAA,qBAAA,GAMtBH,EAAA,CADCM,KACuB/L,EAAA4L,UAAA,qBAAA,GAMxBH,EAAA,CADCM,KACwB/L,EAAA4L,UAAA,sBAAA,GAMzBH,EAAA,CADCM,KACe/L,EAAA4L,UAAA,eAAA,GAnIL5L,EAAOyL,EAAA,CADnBQ,EAAc,aACFjM"}
|
|
1
|
+
{"version":3,"file":"chart.js","sources":["../../../src/components/chart/chart.ts"],"sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, state, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { deepmerge, deepmergeCustom } from 'deepmerge-ts';\nimport Chart from 'chart.js/auto';\nimport 'chartjs-adapter-date-fns';\nimport {\n ChoroplethController,\n BubbleMapController,\n GeoFeature,\n ColorScale,\n SizeScale,\n ProjectionScale,\n} from 'chartjs-chart-geo';\nimport { TreemapController, TreemapElement } from 'chartjs-chart-treemap';\nimport { MatrixController, MatrixElement } from 'chartjs-chart-matrix';\nimport canvasBackgroundPlugin from '../../common/plugins/canvasBackground';\nimport doughnutLabelPlugin from '../../common/plugins/doughnutLabel';\nimport meterGaugePlugin from '../../common/plugins/meterGaugeNeedle';\nimport gradientLegendPlugin from '../../common/plugins/gradientLegend';\nimport a11yPlugin from 'chartjs-plugin-a11y-legend';\nimport datalabelsPlugin from 'chartjs-plugin-datalabels';\nimport annotationPlugin from 'chartjs-plugin-annotation';\nimport { convertChartDataToCSV, debounce } from '../../common/helpers/helpers';\nimport ChartScss from './chart.scss';\nimport globalOptions from '../../common/config/globalOptions';\nimport globalOptionsNonRadial from '../../common/config/globalOptionsNonRadial';\nimport globalOptionsRadial from '../../common/config/globalOptionsRadial';\nimport chartIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/analytics.svg';\nimport tableIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/table-view.svg';\nimport downloadIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/download.svg';\nimport maximizeIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/expand.svg';\nimport minimizeIcon from '@kyndryl-design-system/shidoka-icons/svg/monochrome/16/shrink.svg';\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js';\nimport { getTokenThemeVal } from '@kyndryl-design-system/shidoka-foundation/common/helpers/color';\n\nChart.register(\n ChoroplethController,\n BubbleMapController,\n GeoFeature,\n ColorScale,\n SizeScale,\n ProjectionScale,\n TreemapController,\n TreemapElement,\n MatrixController,\n MatrixElement,\n annotationPlugin,\n datalabelsPlugin\n);\n\n/**\n * Chart.js wrapper component.\n * @slot unnamed - Slot for custom content between header and chart.\n * @slot controls - Slot for custom controls such as an overflow menu.\n * @slot tooltip - Slot for tooltip in header.\n * @slot draghandle - Slot for widget drag handle.\n */\n@customElement('kd-chart')\nexport class KDChart extends LitElement {\n static override styles = ChartScss;\n\n /** Chart title. */\n @property({ type: String })\n chartTitle = '';\n\n /** Chart description. */\n @property({ type: String })\n description = '';\n\n /** Chart.js chart type. */\n @property({ type: String })\n type: any = '';\n\n /** Chart.js data.labels. */\n @property({ type: Array })\n labels!: Array<string>;\n\n /** Chart.js data.datasets. */\n @property({ type: Array })\n datasets!: Array<any>;\n\n /** Chart.js options. Can override Shidoka defaults. */\n @property({ type: Object })\n options: any = {};\n\n /** Chart.js additional plugins. Must be registerable inline via Chart.plugins array, not globally via Chart.register. */\n @property({ type: Array })\n plugins: any = [];\n\n /** Chart.js canvas height (px). Disables maintainAspectRatio option. */\n @property({ type: Number })\n height: any = null;\n\n /** Chart.js canvas width (px). Disables maintainAspectRatio option. */\n @property({ type: Number })\n width: any = null;\n\n /** Hides the description visually. */\n @property({ type: Boolean })\n hideDescription = false;\n\n /** Hides the closed captions visually. */\n @property({ type: Boolean })\n hideCaptions = false;\n\n /** Hides the title & description. */\n @property({ type: Boolean })\n hideHeader = false;\n\n /** Hides the controls. */\n @property({ type: Boolean })\n hideControls = false;\n\n /** Removes the outer border and padding. */\n @property({ type: Boolean })\n noBorder = false;\n\n /** Customizable text labels. */\n @property({ type: Object })\n customLabels = {\n toggleView: 'Toggle View Mode',\n toggleFullscreen: 'Toggle Fullscreen',\n downloadMenu: 'Download Menu',\n downloadCsv: 'Download as CSV',\n downloadPng: 'Download as PNG',\n downloadJpg: 'Download as JPG',\n };\n\n /** Fullscreen state.\n * @ignore\n */\n @state()\n fullscreen = false;\n\n /**\n * Queries the container element.\n * @ignore\n */\n @query('.container')\n container!: HTMLCanvasElement;\n\n /**\n * Queries the canvas element.\n * @ignore\n */\n @query('canvas')\n canvas!: HTMLCanvasElement;\n\n /**\n * Queries the closed caption div.\n * @ignore\n */\n @query('.closed-caption')\n ccDiv!: HTMLDivElement;\n\n /** The chart instance.\n * @ignore\n */\n @state()\n chart: any = null;\n\n /** Table view mode.\n * @ignore\n */\n @state()\n tableView = false;\n\n /** Disable table view feature.\n * @ignore\n */\n @state()\n tableDisabled = false;\n\n /** Merged options.\n * @ignore\n */\n @state()\n mergedOptions: any = {};\n\n /** Merged datasets.\n * @ignore\n */\n @state()\n mergedDatasets: any = {};\n\n /** Is Widget. Inherited from kyn-widget.\n * @internal\n */\n @state()\n _widget = false;\n\n /** ResizeObserver for canvas-container.\n * @internal\n */\n _resizeObserver: any = new ResizeObserver(\n debounce(() => {\n this._resizeChart();\n })\n );\n\n _themeObserver: any = new MutationObserver(() => {\n if (this.chart) {\n this.mergeOptions().then(() => {\n this.initChart();\n });\n }\n });\n\n override render() {\n const Classes = {\n container: true,\n fullscreen: this.fullscreen,\n 'no-border': this.noBorder || this._widget,\n widget: this._widget,\n };\n\n return html`\n <div\n class=${classMap(Classes)}\n @fullscreenchange=${() => this.handleFullscreenChange()}\n >\n ${!this.hideHeader || !this.hideControls\n ? html`\n <div class=\"header\">\n ${!this.hideHeader\n ? html`\n <slot name=\"draghandle\"></slot>\n\n <div id=\"titleDesc\">\n <div class=\"title\">\n ${this.chartTitle}\n <slot name=\"tooltip\"></slot>\n </div>\n <div\n class=\"description ${this.hideDescription\n ? 'hidden-visually'\n : ''}\"\n >\n ${this.description}\n </div>\n </div>\n `\n : null}\n ${!this.hideControls\n ? html`\n <div class=\"controls\">\n ${!this.tableDisabled\n ? html`\n <button\n class=\"control-button\"\n @click=${() => this.handleViewToggle()}\n aria-label=${this.customLabels.toggleView}\n title=${this.customLabels.toggleView}\n >\n <span slot=\"icon\">\n ${this.tableView\n ? unsafeSVG(chartIcon)\n : unsafeSVG(tableIcon)}\n </span>\n </button>\n `\n : null}\n\n <button\n class=\"control-button\"\n @click=${() => this.handleFullscreen()}\n aria-label=${this.customLabels.toggleFullscreen}\n title=${this.customLabels.toggleFullscreen}\n >\n <span slot=\"icon\">\n ${this.fullscreen\n ? unsafeSVG(minimizeIcon)\n : unsafeSVG(maximizeIcon)}\n </span>\n </button>\n\n <div class=\"download\">\n <button\n class=\"control-button\"\n aria-label=${this.customLabels.downloadMenu}\n title=${this.customLabels.downloadMenu}\n >\n <span slot=\"icon\">\n ${unsafeSVG(downloadIcon)}\n </span>\n </button>\n\n <div class=\"download-menu\">\n ${!this.tableDisabled\n ? html`\n <button\n @click=${(e: Event) =>\n this.handleDownloadCsv(e)}\n >\n ${this.customLabels.downloadCsv}\n </button>\n `\n : null}\n <button\n @click=${(e: Event) =>\n this.handleDownloadImage(e, false)}\n >\n ${this.customLabels.downloadPng}\n </button>\n <button\n @click=${(e: Event) =>\n this.handleDownloadImage(e, true)}\n >\n ${this.customLabels.downloadJpg}\n </button>\n </div>\n </div>\n\n <slot name=\"controls\"></slot>\n </div>\n `\n : null}\n </div>\n `\n : null}\n\n <div>\n <slot></slot>\n </div>\n\n <figure class=\"${this.tableView ? 'hidden' : ''}\">\n <div\n class=\"canvas-container\"\n style=\"${this.width ? `width: ${this.width}px;` : ''}\n ${this.height ? `height: ${this.height}px;` : ''}\"\n >\n <canvas role=\"img\" aria-labelledby=\"titleDesc\"></canvas>\n </div>\n <figcaption>\n <div\n class=\"closed-caption ${this.hideCaptions\n ? 'hidden-visually'\n : ''}\"\n ></div>\n </figcaption>\n </figure>\n\n ${!this.tableDisabled && this.tableView\n ? html`\n <div class=\"table\">\n <table>\n ${this.type === 'matrix'\n ? html`\n <thead>\n <tr>\n <th>\n ${this.options?.scales?.y?.title?.text ||\n 'Y Axis'}\n </th>\n <th>\n ${this.options?.scales?.x?.title?.text ||\n 'X Axis'}\n </th>\n ${this.datasets.map(\n (dataset) => html`<th>${dataset.label}</th>`\n )}\n </tr>\n </thead>\n <tbody>\n ${this.datasets[0].data.map((cell: any) => {\n const xLabel = Array.isArray(this.labels)\n ? this.labels[cell.x - 1] || ''\n : (this.labels as any).x?.[cell.x - 1] || '';\n const yLabel = Array.isArray(this.labels)\n ? this.labels[cell.y - 1] || ''\n : (this.labels as any).y?.[cell.y - 1] || '';\n return html`\n <tr>\n <td>${yLabel}</td>\n <td>${xLabel}</td>\n ${this.datasets.map(\n () => html`<td>${cell.value}</td>`\n )}\n </tr>\n `;\n })}\n </tbody>\n `\n : html`\n <thead>\n <tr>\n ${this.labels?.length || this.type === 'treemap'\n ? html`<th>${this.getTableAxisLabel()}</th>`\n : null}\n ${this.datasets.map(\n (dataset) => html`<th>${dataset.label}</th>`\n )}\n </tr>\n </thead>\n <tbody>\n ${this.type === 'treemap'\n ? Array.isArray(this.datasets[0].tree)\n ? this.datasets[0].tree.map(\n (_value: any) => html`\n <tr>\n <td>\n ${_value[this.datasets[0].labelKey]}\n </td>\n <td>${_value[this.datasets[0].key]}</td>\n </tr>\n `\n )\n : Object.entries(this.datasets[0].tree).map(\n (_value: any) => {\n const HtmlStrings = [];\n if (_value[1].value) {\n HtmlStrings.push(html`\n <tr>\n <td>${_value[0]}</td>\n <td>${_value[1].value}</td>\n </tr>\n `);\n } else {\n Object.entries(_value[1]).map(\n (_subValue: any) => {\n if (_subValue[1].value) {\n HtmlStrings.push(html`\n <tr>\n <td>${_subValue[0]}</td>\n <td>${_subValue[1].value}</td>\n </tr>\n `);\n } else {\n Object.entries(_subValue[1]).map(\n (_subSubValue: any) => {\n HtmlStrings.push(html`\n <tr>\n <td>${_subSubValue[0]}</td>\n <td>\n ${_subSubValue[1].value}\n </td>\n </tr>\n `);\n }\n );\n }\n }\n );\n }\n return HtmlStrings;\n }\n )\n : this.datasets[0].data.map(\n (_value: any, i: number) => {\n const IndexAxis =\n this.options.indexAxis || 'x';\n const NonIndexAxis =\n IndexAxis === 'x' ? 'y' : 'x';\n return html`\n <tr>\n ${this.labels.length\n ? html`\n ${this.options?.scales[IndexAxis]\n ?.type === 'time'\n ? html`\n <td>\n ${new Date(\n this.labels[i]\n ).toLocaleString()}\n </td>\n `\n : html`\n <td>${this.labels[i]}</td>\n `}\n `\n : null}\n ${this.datasets.map((dataset) => {\n const dataPoint = dataset.data[i];\n if (\n this.type === 'bubbleMap' ||\n this.type === 'choropleth'\n ) {\n return html`\n <td>${dataset.data[i].value}</td>\n `;\n } else if (\n this.options?.scales[NonIndexAxis]\n ?.type === 'time'\n ) {\n return html`\n <td>\n ${new Date(\n dataPoint\n ).toLocaleString()}\n </td>\n `;\n } else if (Array.isArray(dataPoint)) {\n return html`\n <td>\n ${dataPoint[0]}, ${dataPoint[1]}\n </td>\n `;\n } else if (\n typeof dataPoint === 'object' &&\n !Array.isArray(dataPoint) &&\n dataPoint !== null\n ) {\n return html`\n <td>\n ${Object.keys(dataPoint).map(\n (key) => {\n const Label =\n this.options.scales[key]\n ?.title?.text || key;\n const DisplayData =\n this.options.scales[key]\n ?.type === 'time'\n ? new Date(\n dataPoint[key]\n ).toLocaleString()\n : dataPoint[key];\n return html`\n <div>\n <strong>\n ${Label}:\n </strong>\n ${DisplayData}\n </div>\n `;\n }\n )}\n </td>\n `;\n } else {\n return html`\n <td>${dataset.data[i]}</td>\n `;\n }\n })}\n </tr>\n `;\n }\n )}\n </tbody>\n `}\n </table>\n </div>\n `\n : null}\n </div>\n `;\n }\n\n private _resizeChart() {\n if (this.chart) {\n this.chart.resize();\n }\n }\n\n override connectedCallback() {\n super.connectedCallback();\n\n this._themeObserver.observe(\n document.querySelector('meta[name=\"color-scheme\"]'),\n { attributes: true }\n );\n }\n\n override disconnectedCallback() {\n this._resizeObserver.disconnect();\n this._themeObserver.disconnect();\n\n super.disconnectedCallback();\n }\n\n override firstUpdated() {\n const el = this.shadowRoot?.querySelector('.canvas-container');\n this._resizeObserver.observe(el);\n }\n\n override updated(changedProps: any) {\n // Update chart instance when data changes.\n if (\n this.chart &&\n (changedProps.has('labels') ||\n changedProps.has('datasets') ||\n changedProps.has('options'))\n ) {\n this.mergeOptions().then(() => {\n this.chart.data.labels = this.labels;\n this.chart.options = this.mergedOptions;\n\n // remove datasets not in mergedDatasets\n this.chart.data.datasets.forEach((dataset: any, index: number) => {\n const NewDataset = this.mergedDatasets.find(\n (newDataset: any) => newDataset.label === dataset.label\n );\n\n if (!NewDataset) {\n // remove\n this.chart.data.datasets.splice(index, 1);\n }\n });\n\n // update datasets, add new ones\n this.mergedDatasets.forEach((dataset: any) => {\n const OldDataset = this.chart.data.datasets.find(\n (oldDataset: any) => oldDataset.label === dataset.label\n );\n\n if (!OldDataset) {\n // add new dataset\n this.chart.data.datasets.push(dataset);\n } else {\n // update each key/entry in the dataset object\n Object.keys(dataset).forEach((key) => {\n OldDataset[key] = dataset[key];\n });\n }\n });\n\n this.chart.update();\n });\n }\n\n // init chart\n // check to make sure initial datasets + data have been provided\n let hasData = false;\n if (this.datasets && this.datasets.length) {\n for (const dataset of this.datasets) {\n hasData =\n dataset.data?.length > 0 ||\n dataset.tree?.length > 0 ||\n (dataset.tree && Object.keys(dataset.tree).length > 0);\n\n if (!hasData) {\n console.error('Missing data for one or more chart datasets.');\n break;\n }\n }\n }\n\n if (!this.chart && this.type && changedProps.has('datasets') && hasData) {\n this.mergeOptions().then(() => {\n this.initChart();\n });\n\n this.checkType();\n }\n\n // Re-init chart instance when type, plugins, colorPalette, width, or height change.\n if (\n this.chart &&\n (changedProps.has('type') ||\n changedProps.has('plugins') ||\n changedProps.has('width') ||\n changedProps.has('height'))\n ) {\n this.mergeOptions().then(() => {\n this.initChart();\n });\n\n this.checkType();\n }\n\n if (this.chart && changedProps.has('noBorder')) {\n this.chart.resize();\n }\n }\n\n /**\n * Initializes a bar chart using the Chart.js library with provided labels, datasets,\n * and options.\n */\n private initChart() {\n const ignoredTypes = ['choropleth', 'treemap', 'bubbleMap'];\n\n // Chart.defaults.font.family = getComputedStyle(\n // document.documentElement\n // ).getPropertyValue('--kd-font-family-secondary');\n Chart.defaults.color = getTokenThemeVal('--kd-color-text-level-primary');\n\n // let plugins = [\n // canvasBackgroundPlugin,\n // doughnutLabelPlugin,\n // meterGaugePlugin,\n // ...this.plugins,\n // ];\n\n // Select plugin when type='meter'. Otherwise both plugins (meterGaugePlugin & doughnutLabelPlugin) are called\n const pluginSelectForDoghnutMeter =\n this.type === 'meter' ? meterGaugePlugin : doughnutLabelPlugin;\n\n let plugins = [\n canvasBackgroundPlugin,\n pluginSelectForDoghnutMeter,\n gradientLegendPlugin,\n ...this.plugins,\n ];\n\n // only add certain plugins for standard chart types\n if (!ignoredTypes.includes(this.type)) {\n // plugins = [...plugins, a11yPlugin, musicPlugin];\n plugins = [...plugins, a11yPlugin];\n }\n\n if (this.chart) {\n this.chart.destroy();\n }\n\n this.chart = new Chart(this.canvas, {\n //type: this.type,\n type: this.type === 'meter' ? 'doughnut' : this.type,\n data: {\n labels: this.labels,\n datasets: this.mergedDatasets,\n },\n options: this.mergedOptions,\n plugins: plugins,\n });\n }\n\n /**\n * Merges various chart type options and dataset options to create a\n * final set of options for a chart.\n */\n private async mergeOptions() {\n const radialTypes = ['pie', 'doughnut', 'radar', 'polarArea', 'meter'];\n const ignoredTypes = ['choropleth', 'treemap', 'bubbleMap'];\n\n const additionalTypeImports: any = [];\n this.datasets.forEach((dataset) => {\n // get chart types from datasets so we can import additional configs\n if (dataset.type) {\n additionalTypeImports.push(\n import(`../../common/config/chartTypes/${dataset.type}.js`)\n );\n }\n });\n\n // import main and additional chart type configs\n const chartTypeConfigs = await Promise.all([\n import(`../../common/config/chartTypes/${this.type}.js`),\n ...additionalTypeImports,\n ]);\n\n // start with global options\n let mergedOptions: any = globalOptions(this);\n\n // merge global type options\n if (radialTypes.includes(this.type)) {\n mergedOptions = deepmerge(mergedOptions, globalOptionsRadial(this));\n } else if (!ignoredTypes.includes(this.type)) {\n mergedOptions = deepmerge(mergedOptions, globalOptionsNonRadial(this));\n }\n\n const mergedDatasets: any = JSON.parse(JSON.stringify(this.datasets));\n\n chartTypeConfigs.forEach((chartTypeConfig: any) => {\n // merge all of the imported chart type options with the global options\n mergedOptions = deepmerge(mergedOptions, chartTypeConfig.options(this));\n\n // merge all of the imported chart type dataset options\n mergedDatasets.forEach((dataset: any, index: number) => {\n if (\n (!dataset.type && chartTypeConfig.type === this.type) ||\n dataset.type === chartTypeConfig.type\n ) {\n mergedDatasets[index] = deepmerge(\n dataset,\n chartTypeConfig.datasetOptions(this, index)\n );\n }\n });\n });\n\n if (this.options) {\n // merge any consumer supplied options with defaults\n mergedOptions = deepmerge(mergedOptions, this.options);\n }\n this.mergedOptions = mergedOptions;\n\n // merge default chart type dataset options with consumer supplied datasets\n mergedDatasets.forEach((dataset: object, index: number) => {\n const customDeepmerge = deepmergeCustom({\n mergeArrays: false,\n });\n mergedDatasets[index] = customDeepmerge(dataset, this.datasets[index]);\n });\n\n this.mergedDatasets = mergedDatasets;\n }\n\n private getTableAxisLabel() {\n let label = '';\n\n if (this.options?.indexAxis === 'y') {\n if (this.options?.scales?.y?.title?.text) {\n label = this.options?.scales.y.title.text;\n } else {\n label = 'Y Axis';\n }\n } else {\n if (this.options?.scales?.x?.title?.text) {\n label = this.options?.scales.x.title.text;\n } else {\n label = 'X Axis';\n }\n }\n\n return label;\n }\n\n private handleViewToggle() {\n this.tableView = !this.tableView;\n }\n\n private checkType() {\n // chart types that can't have a data table view\n const blacklist: any = [];\n this.tableDisabled = blacklist.includes(this.type);\n }\n\n private handleDownloadImage(e: Event, jpeg: boolean) {\n e.preventDefault();\n\n const imgFormat = jpeg ? 'image/jpeg' : 'image/png';\n const fileExt = jpeg ? 'jpg' : 'png';\n const a = document.createElement('a');\n\n a.href = this.chart.toBase64Image(imgFormat, 1);\n a.download = this.chartTitle + '.' + fileExt;\n\n // trigger the download\n a.click();\n }\n\n private handleDownloadCsv(e: Event) {\n e.preventDefault();\n let csv = '';\n\n for (let i = 0; i < this.chart.data.datasets.length; i++) {\n csv += convertChartDataToCSV({\n data: this.chart.data.datasets[i],\n labels: this.labels,\n });\n }\n if (csv == null) return;\n\n const filename = this.chartTitle + '.csv';\n if (!csv.match(/^data:text\\/csv/i)) {\n csv = 'data:text/csv;charset=utf-8,' + csv;\n }\n\n // not sure if anything below this comment works\n const data = encodeURI(csv);\n const link = document.createElement('a');\n link.setAttribute('href', data);\n link.setAttribute('download', filename);\n document.body.appendChild(link); // Required for FF\n link.click();\n document.body.removeChild(link);\n }\n\n private handleFullscreen() {\n if (this.shadowRoot?.fullscreenElement) {\n document.exitFullscreen();\n } else {\n this.container.requestFullscreen();\n }\n }\n\n private handleFullscreenChange() {\n this.fullscreen = this.shadowRoot?.fullscreenElement !== null;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kd-chart': KDChart;\n }\n}\n"],"names":["Chart","register","ChoroplethController","BubbleMapController","GeoFeature","ColorScale","SizeScale","ProjectionScale","TreemapController","TreemapElement","MatrixController","MatrixElement","annotationPlugin","datalabelsPlugin","KDChart","LitElement","constructor","this","chartTitle","description","type","options","plugins","height","width","hideDescription","hideCaptions","hideHeader","hideControls","noBorder","customLabels","toggleView","toggleFullscreen","downloadMenu","downloadCsv","downloadPng","downloadJpg","fullscreen","chart","tableView","tableDisabled","mergedOptions","mergedDatasets","_widget","_resizeObserver","ResizeObserver","debounce","_resizeChart","_themeObserver","MutationObserver","mergeOptions","then","initChart","render","Classes","container","widget","html","classMap","handleFullscreenChange","handleViewToggle","unsafeSVG","chartIcon","tableIcon","handleFullscreen","minimizeIcon","maximizeIcon","downloadIcon","e","handleDownloadCsv","handleDownloadImage","_d","_c","_b","_a","scales","y","title","text","_h","_g","_f","_e","x","datasets","map","dataset","label","data","cell","xLabel","Array","isArray","labels","yLabel","value","_j","length","getTableAxisLabel","tree","_value","labelKey","key","Object","entries","HtmlStrings","push","_subValue","_subSubValue","i","IndexAxis","indexAxis","NonIndexAxis","Date","toLocaleString","dataPoint","keys","Label","DisplayData","resize","connectedCallback","super","observe","document","querySelector","attributes","disconnectedCallback","disconnect","firstUpdated","el","shadowRoot","updated","changedProps","has","forEach","index","find","newDataset","splice","OldDataset","oldDataset","update","hasData","console","error","checkType","defaults","color","getTokenThemeVal","pluginSelectForDoghnutMeter","meterGaugePlugin","doughnutLabelPlugin","canvasBackgroundPlugin","gradientLegendPlugin","includes","a11yPlugin","destroy","canvas","additionalTypeImports","__variableDynamicImportRuntime0__","chartTypeConfigs","Promise","all","__variableDynamicImportRuntime1__","globalOptions","deepmerge","globalOptionsRadial","globalOptionsNonRadial","JSON","parse","stringify","chartTypeConfig","datasetOptions","customDeepmerge","deepmergeCustom","mergeArrays","_k","_l","jpeg","preventDefault","imgFormat","fileExt","a","createElement","href","toBase64Image","download","click","csv","convertChartDataToCSV","filename","match","encodeURI","link","setAttribute","body","appendChild","removeChild","fullscreenElement","exitFullscreen","requestFullscreen","styles","ChartScss","__decorate","property","String","prototype","Number","Boolean","state","query","customElement"],"mappings":"ggJAoCAA,EAAMC,SACJC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC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BH,EAAA,CADCC,EAAS,CAAExL,KAAM2L,UACAjM,EAAAgM,UAAA,aAAA,GAIlBH,EAAA,CADCC,EAAS,CAAExL,KAAM4L,WACMlM,EAAAgM,UAAA,uBAAA,GAIxBH,EAAA,CADCC,EAAS,CAAExL,KAAM4L,WACGlM,EAAAgM,UAAA,oBAAA,GAIrBH,EAAA,CADCC,EAAS,CAAExL,KAAM4L,WACClM,EAAAgM,UAAA,kBAAA,GAInBH,EAAA,CADCC,EAAS,CAAExL,KAAM4L,WACGlM,EAAAgM,UAAA,oBAAA,GAIrBH,EAAA,CADCC,EAAS,CAAExL,KAAM4L,WACDlM,EAAAgM,UAAA,gBAAA,GAIjBH,EAAA,CADCC,EAAS,CAAExL,KAAMmF,UAQhBzF,EAAAgM,UAAA,oBAAA,GAMFH,EAAA,CADCM,KACkBnM,EAAAgM,UAAA,kBAAA,GAOnBH,EAAA,CADCO,EAAM,eACuBpM,EAAAgM,UAAA,iBAAA,GAO9BH,EAAA,CADCO,EAAM,WACoBpM,EAAAgM,UAAA,cAAA,GAO3BH,EAAA,CADCO,EAAM,oBACgBpM,EAAAgM,UAAA,aAAA,GAMvBH,EAAA,CADCM,KACiBnM,EAAAgM,UAAA,aAAA,GAMlBH,EAAA,CADCM,KACiBnM,EAAAgM,UAAA,iBAAA,GAMlBH,EAAA,CADCM,KACqBnM,EAAAgM,UAAA,qBAAA,GAMtBH,EAAA,CADCM,KACuBnM,EAAAgM,UAAA,qBAAA,GAMxBH,EAAA,CADCM,KACwBnM,EAAAgM,UAAA,sBAAA,GAMzBH,EAAA,CADCM,KACenM,EAAAgM,UAAA,eAAA,GAnILhM,EAAO6L,EAAA,CADnBQ,EAAc,aACFrM"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{DatasetController as t,Element as e}from"../../chart.js/dist/chart.js";import{aw as i,au as r,i as n}from"../../chart.js/dist/chunks/helpers.segment.js";
|
|
2
|
+
/*!
|
|
3
|
+
* chartjs-chart-matrix v2.0.1
|
|
4
|
+
* https://chartjs-chart-matrix.pages.dev/
|
|
5
|
+
* (c) 2023 Jukka Kurkela
|
|
6
|
+
* Released under the MIT license
|
|
7
|
+
*/class o extends t{static id="matrix";static version="2.0.1";static defaults={dataElementType:"matrix",animations:{numbers:{type:"number",properties:["x","y","width","height"]}}};static overrides={interaction:{mode:"nearest",intersect:!0},scales:{x:{type:"linear",offset:!0},y:{type:"linear",reverse:!0}}};initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(t,e,i,r){const n=this,o="reset"===r,{xScale:h,yScale:l}=n._cachedMeta,d=n.resolveDataElementOptions(e,r),c=n.getSharedOptions(r,t[e],d);for(let d=e;d<e+i;d++){const e=!o&&n.getParsed(d),i=o?h.getBasePixel():h.getPixelForValue(e.x),c=o?l.getBasePixel():l.getPixelForValue(e.y),u=n.resolveDataElementOptions(d,r),{width:g,height:p,anchorX:x,anchorY:f}=u,m={x:s(x,i,g),y:a(f,c,p),width:g,height:p,options:u};n.updateElement(t[d],d,m,r)}n.updateSharedOptions(c,r)}draw(){const t=this,e=t.getMeta().data||[];let i,r;for(i=0,r=e.length;i<r;++i)e[i].draw(t._ctx)}}function s(t,e,i){return"left"===t||"start"===t?e:"right"===t||"end"===t?e-i:e-i/2}function a(t,e,i){return"top"===t||"start"===t?e:"bottom"===t||"end"===t?e-i:e-i/2}function h(t,e){const{x:i,y:r,width:n,height:o}=t.getProps(["x","y","width","height"],e);return{left:i,top:r,right:i+n,bottom:r+o}}function l(t,e,i){return Math.max(Math.min(t,i),e)}function d(t){const e=h(t),i=e.right-e.left,r=e.bottom-e.top,o=function(t,e,i){const r=t.options.borderWidth;let o,s,a,h;return n(r)?(o=+r.top||0,s=+r.right||0,a=+r.bottom||0,h=+r.left||0):o=s=a=h=+r||0,{t:l(o,0,i),r:l(s,0,e),b:l(a,0,i),l:l(h,0,e)}}(t,i/2,r/2);return{outer:{x:e.left,y:e.top,w:i,h:r},inner:{x:e.left+o.l,y:e.top+o.t,w:i-o.l-o.r,h:r-o.t-o.b}}}function c(t,e,i,r){const n=null===e,o=null===i,s=!(!t||n&&o)&&h(t,r);return s&&(n||e>=s.left&&e<=s.right)&&(o||i>=s.top&&i<=s.bottom)}class u extends e{static id="matrix";static defaults={backgroundColor:void 0,borderColor:void 0,borderWidth:void 0,borderRadius:0,anchorX:"center",anchorY:"center",width:20,height:20};constructor(t){super(),this.options=void 0,this.width=void 0,this.height=void 0,t&&Object.assign(this,t)}draw(t){const e=this.options,{inner:n,outer:o}=d(this),s=i(e.borderRadius);t.save(),o.w!==n.w||o.h!==n.h?(t.beginPath(),r(t,{x:o.x,y:o.y,w:o.w,h:o.h,radius:s}),r(t,{x:n.x,y:n.y,w:n.w,h:n.h,radius:s}),t.fillStyle=e.backgroundColor,t.fill(),t.fillStyle=e.borderColor,t.fill("evenodd")):(t.beginPath(),r(t,{x:n.x,y:n.y,w:n.w,h:n.h,radius:s}),t.fillStyle=e.backgroundColor,t.fill()),t.restore()}inRange(t,e,i){return c(this,t,e,i)}inXRange(t,e){return c(this,t,null,e)}inYRange(t,e){return c(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,width:r,height:n}=this.getProps(["x","y","width","height"],t);return{x:e+r/2,y:i+n/2}}tooltipPosition(){return this.getCenterPoint()}getRange(t){return"x"===t?this.width/2:this.height/2}}export{o as MatrixController,u as MatrixElement};
|
|
8
|
+
//# sourceMappingURL=chartjs-chart-matrix.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartjs-chart-matrix.esm.js","sources":["../../../../node_modules/chartjs-chart-matrix/dist/chartjs-chart-matrix.esm.js"],"sourcesContent":["/*!\n * chartjs-chart-matrix v2.0.1\n * https://chartjs-chart-matrix.pages.dev/\n * (c) 2023 Jukka Kurkela\n * Released under the MIT license\n */\nimport { DatasetController, Element } from 'chart.js';\nimport { toTRBLCorners, addRoundedRectPath, isObject } from 'chart.js/helpers';\n\nvar version = \"2.0.1\";\n\nclass MatrixController extends DatasetController {\n\n static id = 'matrix';\n static version = version;\n\n static defaults = {\n dataElementType: 'matrix',\n\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'width', 'height']\n }\n },\n };\n\n static overrides = {\n interaction: {\n mode: 'nearest',\n intersect: true\n },\n scales: {\n x: {\n type: 'linear',\n offset: true\n },\n y: {\n type: 'linear',\n reverse: true\n }\n },\n };\n\n initialize() {\n this.enableOptionSharing = true;\n super.initialize();\n }\n\n update(mode) {\n const me = this;\n const meta = me._cachedMeta;\n\n me.updateElements(meta.data, 0, meta.data.length, mode);\n }\n\n updateElements(rects, start, count, mode) {\n const me = this;\n const reset = mode === 'reset';\n const {xScale, yScale} = me._cachedMeta;\n const firstOpts = me.resolveDataElementOptions(start, mode);\n const sharedOptions = me.getSharedOptions(mode, rects[start], firstOpts);\n\n for (let i = start; i < start + count; i++) {\n const parsed = !reset && me.getParsed(i);\n const x = reset ? xScale.getBasePixel() : xScale.getPixelForValue(parsed.x);\n const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y);\n const options = me.resolveDataElementOptions(i, mode);\n const {width, height, anchorX, anchorY} = options;\n const properties = {\n x: resolveX(anchorX, x, width),\n y: resolveY(anchorY, y, height),\n width,\n height,\n options\n };\n me.updateElement(rects[i], i, properties, mode);\n }\n\n me.updateSharedOptions(sharedOptions, mode);\n }\n\n draw() {\n const me = this;\n const data = me.getMeta().data || [];\n let i, ilen;\n\n for (i = 0, ilen = data.length; i < ilen; ++i) {\n data[i].draw(me._ctx);\n }\n }\n}\n\nfunction resolveX(anchorX, x, width) {\n if (anchorX === 'left' || anchorX === 'start') {\n return x;\n }\n if (anchorX === 'right' || anchorX === 'end') {\n return x - width;\n }\n return x - width / 2;\n}\n\nfunction resolveY(anchorY, y, height) {\n if (anchorY === 'top' || anchorY === 'start') {\n return y;\n }\n if (anchorY === 'bottom' || anchorY === 'end') {\n return y - height;\n }\n return y - height / 2;\n}\n\n/**\n * Helper function to get the bounds of the rect\n * @param {MatrixElement} rect the rect\n * @param {boolean} [useFinalPosition]\n * @return {object} bounds of the rect\n * @private\n */\nfunction getBounds(rect, useFinalPosition) {\n const {x, y, width, height} = rect.getProps(['x', 'y', 'width', 'height'], useFinalPosition);\n return {left: x, top: y, right: x + width, bottom: y + height};\n}\n\nfunction limit(value, min, max) {\n return Math.max(Math.min(value, max), min);\n}\n\nfunction parseBorderWidth(rect, maxW, maxH) {\n const value = rect.options.borderWidth;\n let t, r, b, l;\n\n if (isObject(value)) {\n t = +value.top || 0;\n r = +value.right || 0;\n b = +value.bottom || 0;\n l = +value.left || 0;\n } else {\n t = r = b = l = +value || 0;\n }\n\n return {\n t: limit(t, 0, maxH),\n r: limit(r, 0, maxW),\n b: limit(b, 0, maxH),\n l: limit(l, 0, maxW)\n };\n}\n\nfunction boundingRects(rect) {\n const bounds = getBounds(rect);\n const width = bounds.right - bounds.left;\n const height = bounds.bottom - bounds.top;\n const border = parseBorderWidth(rect, width / 2, height / 2);\n\n return {\n outer: {\n x: bounds.left,\n y: bounds.top,\n w: width,\n h: height\n },\n inner: {\n x: bounds.left + border.l,\n y: bounds.top + border.t,\n w: width - border.l - border.r,\n h: height - border.t - border.b\n }\n };\n}\n\nfunction inRange(rect, x, y, useFinalPosition) {\n const skipX = x === null;\n const skipY = y === null;\n const bounds = !rect || (skipX && skipY) ? false : getBounds(rect, useFinalPosition);\n\n return bounds\n\t\t&& (skipX || x >= bounds.left && x <= bounds.right)\n\t\t&& (skipY || y >= bounds.top && y <= bounds.bottom);\n}\n\nclass MatrixElement extends Element {\n\n static id = 'matrix';\n\n static defaults = {\n backgroundColor: undefined,\n borderColor: undefined,\n borderWidth: undefined,\n borderRadius: 0,\n anchorX: 'center',\n anchorY: 'center',\n width: 20,\n height: 20\n };\n\n constructor(cfg) {\n super();\n\n this.options = undefined;\n this.width = undefined;\n this.height = undefined;\n\n if (cfg) {\n Object.assign(this, cfg);\n }\n }\n\n draw(ctx) {\n const options = this.options;\n const {inner, outer} = boundingRects(this);\n const radius = toTRBLCorners(options.borderRadius);\n\n ctx.save();\n\n if (outer.w !== inner.w || outer.h !== inner.h) {\n ctx.beginPath();\n addRoundedRectPath(ctx, {x: outer.x, y: outer.y, w: outer.w, h: outer.h, radius});\n addRoundedRectPath(ctx, {x: inner.x, y: inner.y, w: inner.w, h: inner.h, radius});\n ctx.fillStyle = options.backgroundColor;\n ctx.fill();\n ctx.fillStyle = options.borderColor;\n ctx.fill('evenodd');\n } else {\n ctx.beginPath();\n addRoundedRectPath(ctx, {x: inner.x, y: inner.y, w: inner.w, h: inner.h, radius});\n ctx.fillStyle = options.backgroundColor;\n ctx.fill();\n }\n\n ctx.restore();\n }\n\n inRange(mouseX, mouseY, useFinalPosition) {\n return inRange(this, mouseX, mouseY, useFinalPosition);\n }\n\n inXRange(mouseX, useFinalPosition) {\n return inRange(this, mouseX, null, useFinalPosition);\n }\n\n inYRange(mouseY, useFinalPosition) {\n return inRange(this, null, mouseY, useFinalPosition);\n }\n\n getCenterPoint(useFinalPosition) {\n const {x, y, width, height} = this.getProps(['x', 'y', 'width', 'height'], useFinalPosition);\n return {\n x: x + width / 2,\n y: y + height / 2\n };\n }\n\n tooltipPosition() {\n return this.getCenterPoint();\n }\n\n getRange(axis) {\n return axis === 'x' ? this.width / 2 : this.height / 2;\n }\n}\n\nexport { MatrixController, MatrixElement };\n"],"names":["MatrixController","DatasetController","static","dataElementType","animations","numbers","type","properties","interaction","mode","intersect","scales","x","offset","y","reverse","initialize","this","enableOptionSharing","super","update","meta","_cachedMeta","updateElements","data","length","rects","start","count","me","reset","xScale","yScale","firstOpts","resolveDataElementOptions","sharedOptions","getSharedOptions","i","parsed","getParsed","getBasePixel","getPixelForValue","options","width","height","anchorX","anchorY","resolveX","resolveY","updateElement","updateSharedOptions","draw","getMeta","ilen","_ctx","getBounds","rect","useFinalPosition","getProps","left","top","right","bottom","limit","value","min","max","Math","boundingRects","bounds","border","maxW","maxH","borderWidth","t","r","b","l","isObject","parseBorderWidth","outer","w","h","inner","inRange","skipX","skipY","MatrixElement","Element","backgroundColor","undefined","borderColor","borderRadius","constructor","cfg","Object","assign","ctx","radius","toTRBLCorners","save","beginPath","addRoundedRectPath","fillStyle","fill","restore","mouseX","mouseY","inXRange","inYRange","getCenterPoint","tooltipPosition","getRange","axis"],"mappings":";;;;;;GAWA,MAAMA,UAAyBC,EAE7BC,UAAY,SACZA,eALY,QAOZA,gBAAkB,CAChBC,gBAAiB,SAEjBC,WAAY,CACVC,QAAS,CACPC,KAAM,SACNC,WAAY,CAAC,IAAK,IAAK,QAAS,aAKtCL,iBAAmB,CACjBM,YAAa,CACXC,KAAM,UACNC,WAAW,GAEbC,OAAQ,CACNC,EAAG,CACDN,KAAM,SACNO,QAAQ,GAEVC,EAAG,CACDR,KAAM,SACNS,SAAS,KAKf,UAAAC,GACEC,KAAKC,qBAAsB,EAC3BC,MAAMH,YACP,CAED,MAAAI,CAAOX,GACL,MACMY,EADKJ,KACKK,YADLL,KAGRM,eAAeF,EAAKG,KAAM,EAAGH,EAAKG,KAAKC,OAAQhB,EACnD,CAED,cAAAc,CAAeG,EAAOC,EAAOC,EAAOnB,GAClC,MAAMoB,EAAKZ,KACLa,EAAiB,UAATrB,GACRsB,OAACA,EAAMC,OAAEA,GAAUH,EAAGP,YACtBW,EAAYJ,EAAGK,0BAA0BP,EAAOlB,GAChD0B,EAAgBN,EAAGO,iBAAiB3B,EAAMiB,EAAMC,GAAQM,GAE9D,IAAK,IAAII,EAAIV,EAAOU,EAAIV,EAAQC,EAAOS,IAAK,CAC1C,MAAMC,GAAUR,GAASD,EAAGU,UAAUF,GAChCzB,EAAIkB,EAAQC,EAAOS,eAAiBT,EAAOU,iBAAiBH,EAAO1B,GACnEE,EAAIgB,EAAQE,EAAOQ,eAAiBR,EAAOS,iBAAiBH,EAAOxB,GACnE4B,EAAUb,EAAGK,0BAA0BG,EAAG5B,IAC1CkC,MAACA,EAAKC,OAAEA,EAAM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AKyC,SAAS,CAAC,IAAK,IAAK,QAAS,UAAWD,GAC3E,MAAO,CACL7C,EAAGA,EAAI+B,EAAQ,EACf7B,EAAGA,EAAI8B,EAAS,EAEnB,CAED,eAAAmE,GACE,OAAO9F,KAAK6F,gBACb,CAED,QAAAE,CAASC,GACP,MAAgB,MAATA,EAAehG,KAAK0B,MAAQ,EAAI1B,KAAK2B,OAAS,CACtD","x_google_ignoreList":[0]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kyndryl-design-system/shidoka-charts",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Shidoka Charts",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"chart.js": "^4.4.0",
|
|
31
31
|
"chartjs-adapter-date-fns": "^3.0.0",
|
|
32
32
|
"chartjs-chart-geo": "^4.2.4",
|
|
33
|
+
"chartjs-chart-matrix": "^2.0.1",
|
|
33
34
|
"chartjs-chart-treemap": "^2.3.0",
|
|
34
35
|
"chartjs-plugin-a11y-legend": "^0.1.0",
|
|
35
36
|
"chartjs-plugin-annotation": "^3.0.1",
|