@kyndryl-design-system/shidoka-charts 2.5.2 → 2.5.3

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.
@@ -1,2 +1,2 @@
1
- import{getComputedColorPalette as o}from"../colorPalettes.js";import{getTextColor as e}from"../../helpers/helpers.js";import{getTokenThemeVal as t}from'./../../../external/@kyndryl-design-system/shidoka-foundation/common/helpers/color.js';const r="treemap",n=o=>({plugins:{legend:{display:!1}},spacing:function(o){return void 0!==o.dataset.groups?0:1},borderWidth:function(o){return o.dataset.groups?1:0},borderColor:t("--kd-color-background-page-default"),labels:{align:"left",display:!0,color:function(o){return e(o.element.options.backgroundColor)},font:{size:12,weight:500},position:"top",overflow:"hidden"},captions:{align:"center",display:!0,color:function(o){return e(o.element.options.backgroundColor)},font:{size:12,weight:700},padding:2}}),s=(e,t)=>({backgroundColor:function(t){return o(e.options.colorPalette||"categorical")[a(t)]}}),a=o=>{const e=o.dataset;let t=0;if(void 0!==e.groups){const r=o.dataIndex,n=e.groups?e.groups[0]:null,s="object"==typeof e.tree&&!Array.isArray(e.tree);let a=[];if(s){if(a=Object.keys(e.tree),o.raw){const e=o.raw._data.path.split(".")[0];t=a.indexOf(e)}}else{e.tree.forEach((o=>{a.includes(o[n])||a.push(o[n])}));const o=e.data[r];o&&(t=a.indexOf(o._data[n]))}}return t<0?0:t};export{s as datasetOptions,n as options,r as type};
1
+ import{getComputedColorPalette as t}from"../colorPalettes.js";import{getTextColor as e}from"../../helpers/helpers.js";import{getTokenThemeVal as o}from'./../../../external/@kyndryl-design-system/shidoka-foundation/common/helpers/color.js';const r="treemap",n=t=>({plugins:{legend:{display:!1}},spacing:function(t){return void 0!==t.dataset.groups?0:1},borderWidth:function(t){return t.dataset.groups?1:0},borderColor:o("--kd-color-background-page-default"),labels:{align:"left",display:!0,color:function(t){return e(t.element.options.backgroundColor)},font:{size:12,weight:500},position:"top",overflow:"hidden"},captions:{align:"center",display:!0,color:function(t){return e(t.element.options.backgroundColor)},font:{size:12,weight:700},padding:2}}),a=(e,o)=>{const r=t(e.options?.colorPalette||"categorical");return{backgroundColor:function(t){const e=t.dataset,o="number"==typeof t.dataIndex?t.dataIndex:0,n=r&&r.length||1;if(e&&void 0!==e.groups){const e=s(t);return r[e%n]}if("object"==typeof(e&&e.tree)&&!Array.isArray(e&&e.tree)&&t.raw&&t.raw._data&&"string"==typeof t.raw._data.path){const o=String(t.raw._data.path).split(".")[0],a=Object.keys(e.tree||{}),s=Math.max(0,a.indexOf(o));return r[s%n]}return r[o%n]}}},s=t=>{const e=t.dataset;let o=0;if(void 0!==e.groups){const r=t.dataIndex,n=e.groups?e.groups[0]:null,a="object"==typeof e.tree&&!Array.isArray(e.tree);let s=[];if(a){if(s=Object.keys(e.tree),t.raw){const e=t.raw._data.path.split(".")[0];o=s.indexOf(e)}}else{e.tree.forEach((t=>{s.includes(t[n])||s.push(t[n])}));const t=e.data[r];t&&(o=s.indexOf(t._data[n]))}}return o<0?0:o};export{a as datasetOptions,n as options,r as type};
2
2
  //# sourceMappingURL=treemap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treemap.js","sources":["../../../../src/common/config/chartTypes/treemap.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\nimport { getTextColor } from '../../helpers/helpers';\nimport { getTokenThemeVal } from '@kyndryl-design-system/shidoka-foundation/common/helpers/color';\n\nexport const type = 'treemap';\n\nexport const options = (ctx) => {\n const BorderColor = getTokenThemeVal('--kd-color-background-page-default');\n\n return {\n plugins: {\n legend: {\n display: false,\n },\n },\n spacing: function (context) {\n const Dataset = context.dataset;\n const Grouped = Dataset.groups !== undefined;\n\n return Grouped ? 0 : 1;\n },\n borderWidth: function (context) {\n const Dataset = context.dataset;\n return Dataset.groups ? 1 : 0;\n },\n borderColor: BorderColor,\n labels: {\n align: 'left',\n display: true,\n color: function (context) {\n return getTextColor(context.element.options.backgroundColor);\n },\n font: {\n size: 12,\n weight: 500,\n },\n position: 'top',\n overflow: 'hidden',\n },\n captions: {\n align: 'center',\n display: true,\n color: function (context) {\n return getTextColor(context.element.options.backgroundColor);\n },\n font: {\n size: 12,\n weight: 700,\n },\n padding: 2,\n },\n };\n};\n\nexport const datasetOptions = (ctx, index) => {\n return {\n backgroundColor: function (context) {\n return getComputedColorPalette(ctx.options.colorPalette || 'categorical')[\n getGroupColorIndex(context)\n ]; // + '80'\n },\n };\n};\n\n/**\n * The function `getGroupColorIndex` returns the index of a group color based on the context provided.\n * Works for grouped charts, not nested data charts yet.\n * @param context - The `context` parameter is an object that contains information about the current\n * context or state of the program. It is used to determine the group color index based on the dataset\n * and data index.\n * @returns the index of the group color for a given context.\n */\nconst getGroupColorIndex = (context) => {\n const Dataset = context.dataset;\n let index = 0;\n\n if (Dataset.groups !== undefined) {\n const DataIndex = context.dataIndex;\n const GroupKey = Dataset.groups ? Dataset.groups[0] : null;\n const Nested =\n typeof Dataset.tree === 'object' && !Array.isArray(Dataset.tree);\n let Groups = [];\n\n if (Nested) {\n Groups = Object.keys(Dataset.tree);\n\n if (context.raw) {\n const Path = context.raw._data.path;\n const Parent = Path.split('.')[0];\n\n index = Groups.indexOf(Parent);\n }\n } else {\n Dataset.tree.forEach((leaf) => {\n if (!Groups.includes(leaf[GroupKey])) {\n Groups.push(leaf[GroupKey]);\n }\n });\n\n const Leaf = Dataset.data[DataIndex];\n\n if (Leaf) {\n index = Groups.indexOf(Leaf._data[GroupKey]);\n }\n }\n }\n\n return index < 0 ? 0 : index;\n};\n"],"names":["type","options","ctx","plugins","legend","display","spacing","context","undefined","dataset","groups","borderWidth","borderColor","getTokenThemeVal","labels","align","color","getTextColor","element","backgroundColor","font","size","weight","position","overflow","captions","padding","datasetOptions","index","getComputedColorPalette","colorPalette","getGroupColorIndex","Dataset","DataIndex","dataIndex","GroupKey","Nested","tree","Array","isArray","Groups","Object","keys","raw","Parent","_data","path","split","indexOf","forEach","leaf","includes","push","Leaf","data"],"mappings":"iPAIY,MAACA,EAAO,UAE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3B,IAGM,MAAMkB,EAAOrB,EAAQsB,KAAKrB,GAEtBoB,IACFzB,EAAQY,EAAOQ,QAAQK,EAAKR,MAAMV,IAE1C,CACA,CAEE,OAAOP,EAAQ,EAAI,EAAIA,CAAK"}
1
+ {"version":3,"file":"treemap.js","sources":["../../../../src/common/config/chartTypes/treemap.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\nimport { getTextColor } from '../../helpers/helpers';\nimport { getTokenThemeVal } from '@kyndryl-design-system/shidoka-foundation/common/helpers/color';\n\nexport const type = 'treemap';\n\nexport const options = (ctx) => {\n const BorderColor = getTokenThemeVal('--kd-color-background-page-default');\n\n return {\n plugins: {\n legend: {\n display: false,\n },\n },\n spacing: function (context) {\n const Dataset = context.dataset;\n const Grouped = Dataset.groups !== undefined;\n\n return Grouped ? 0 : 1;\n },\n borderWidth: function (context) {\n const Dataset = context.dataset;\n return Dataset.groups ? 1 : 0;\n },\n borderColor: BorderColor,\n labels: {\n align: 'left',\n display: true,\n color: function (context) {\n return getTextColor(context.element.options.backgroundColor);\n },\n font: {\n size: 12,\n weight: 500,\n },\n position: 'top',\n overflow: 'hidden',\n },\n captions: {\n align: 'center',\n display: true,\n color: function (context) {\n return getTextColor(context.element.options.backgroundColor);\n },\n font: {\n size: 12,\n weight: 700,\n },\n padding: 2,\n },\n };\n};\n\nexport const datasetOptions = (ctx, index) => {\n const palette = getComputedColorPalette(\n ctx.options?.colorPalette || 'categorical'\n );\n\n return {\n backgroundColor: function (context) {\n const Dataset = context.dataset;\n const dataIndex =\n typeof context.dataIndex === 'number' ? context.dataIndex : 0;\n const paletteLen = (palette && palette.length) || 1;\n\n if (Dataset && Dataset.groups !== undefined) {\n const groupIndex = getGroupColorIndex(context);\n return palette[groupIndex % paletteLen];\n }\n\n const nested =\n typeof (Dataset && Dataset.tree) === 'object' &&\n !Array.isArray(Dataset && Dataset.tree);\n if (\n nested &&\n context.raw &&\n context.raw._data &&\n typeof context.raw._data.path === 'string'\n ) {\n const parent = String(context.raw._data.path).split('.')[0];\n const groups = Object.keys(Dataset.tree || {});\n const idx = Math.max(0, groups.indexOf(parent));\n return palette[idx % paletteLen];\n }\n\n return palette[dataIndex % paletteLen];\n },\n };\n};\n\n/**\n * The function `getGroupColorIndex` returns the index of a group color based on the context provided.\n * Works for grouped charts, not nested data charts yet.\n * @param context - The `context` parameter is an object that contains information about the current\n * context or state of the program. It is used to determine the group color index based on the dataset\n * and data index.\n * @returns the index of the group color for a given context.\n */\nconst getGroupColorIndex = (context) => {\n const Dataset = context.dataset;\n let index = 0;\n\n if (Dataset.groups !== undefined) {\n const DataIndex = context.dataIndex;\n const GroupKey = Dataset.groups ? Dataset.groups[0] : null;\n const Nested =\n typeof Dataset.tree === 'object' && !Array.isArray(Dataset.tree);\n let Groups = [];\n\n if (Nested) {\n Groups = Object.keys(Dataset.tree);\n\n if (context.raw) {\n const Path = context.raw._data.path;\n const Parent = Path.split('.')[0];\n\n index = Groups.indexOf(Parent);\n }\n } else {\n Dataset.tree.forEach((leaf) => {\n if (!Groups.includes(leaf[GroupKey])) {\n Groups.push(leaf[GroupKey]);\n }\n });\n\n const Leaf = Dataset.data[DataIndex];\n\n if (Leaf) {\n index = Groups.indexOf(Leaf._data[GroupKey]);\n }\n }\n }\n\n return index < 0 ? 0 : index;\n};\n"],"names":["type","options","ctx","plugins","legend","display","spacing","context","undefined","dataset","groups","borderWidth","borderColor","getTokenThemeVal","labels","align","color","getTextColor","element","backgroundColor","font","size","weight","position","overflow","captions","padding","datasetOptions","index","palette","getComputedColorPalette","colorPalette","Dataset","dataIndex","paletteLen","length","groupIndex","getGroupColorIndex","tree","Array","isArray","raw","_data","path","parent","String","split","Object","keys","idx","Math","max","indexOf","DataIndex","GroupKey","Nested","Groups","Parent","forEach","leaf","includes","push","Leaf","data"],"mappings":"iPAIY,MAACA,EAAO,UAEPC,EAAWC,IAGf,CACLC,QAAS,CACPC,OAAQ,CACNC,SAAS,IAGbC,QAAS,SAAUC,GAIjB,YAFm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EAWGG,EAAsB9B,IAC1B,MAAMyB,EAAUzB,EAAQE,QACxB,IAAImB,EAAQ,EAEZ,QAAuBpB,IAAnBwB,EAAQtB,OAAsB,CAChC,MAAM2C,EAAY9C,EAAQ0B,UACpBqB,EAAWtB,EAAQtB,OAASsB,EAAQtB,OAAO,GAAK,KAChD6C,EACoB,iBAAjBvB,EAAQM,OAAsBC,MAAMC,QAAQR,EAAQM,MAC7D,IAAIkB,EAAS,GAEb,GAAID,GAGF,GAFAC,EAAST,OAAOC,KAAKhB,EAAQM,MAEzB/B,EAAQkC,IAAK,CACf,MACMgB,EADOlD,EAAQkC,IAAIC,MAAMC,KACXG,MAAM,KAAK,GAE/BlB,EAAQ4B,EAAOJ,QAAQK,EAC/B,MACW,CACLzB,EAAQM,KAAKoB,SAASC,IACfH,EAAOI,SAASD,EAAKL,KACxBE,EAAOK,KAAKF,EAAKL,GAC3B,IAGM,MAAMQ,EAAO9B,EAAQ+B,KAAKV,GAEtBS,IACFlC,EAAQ4B,EAAOJ,QAAQU,EAAKpB,MAAMY,IAE1C,CACA,CAEE,OAAO1B,EAAQ,EAAI,EAAIA,CAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyndryl-design-system/shidoka-charts",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Shidoka Charts",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -26,7 +26,7 @@
26
26
  "prepare": "npx husky install"
27
27
  },
28
28
  "dependencies": {
29
- "@kyndryl-design-system/shidoka-foundation": "^2.4.12",
29
+ "@kyndryl-design-system/shidoka-foundation": "^2.7.0",
30
30
  "@kyndryl-design-system/shidoka-icons": "^2.0.0",
31
31
  "@sgratzl/chartjs-chart-boxplot": "^4.4.4",
32
32
  "chart.js": "^4.4.0",