@kyndryl-design-system/shidoka-charts 2.5.3 → 2.5.4
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 t}from"../colorPalettes.js";const e="bar",o=t=>{const e="y"===t.options.indexAxis,o=t.datasets.find((t=>Array.isArray(t.data[0]))),
|
|
1
|
+
import{getComputedColorPalette as t}from"../colorPalettes.js";const e="bar",o=t=>{const e="y"===t.options.indexAxis,o=t.datasets.find((t=>Array.isArray(t.data[0]))),r=t.options.scales?.y?.stacked;return{interaction:{mode:r?"index":"nearest"},borderRadius:2,borderSkipped:!o&&"start",scales:{x:{grid:{display:o||e}},y:{grid:{display:!e}}},plugins:{tooltip:{callbacks:{title:t=>(e?t[0].chart.options.scales.y.title.text:t[0].chart.options.scales.x.title.text)+": "+t[0].label,footer:t=>{let o=0;t.forEach((function(t){o+=e?t.parsed.x:t.parsed.y}));const s=Math.round(100*(o+Number.EPSILON))/100;return r?"Total: "+s:null}}}}}},r=(e,o)=>{const r="y"===e.options.indexAxis,s=e.options.scales?.y?.stacked,a=e.datasets.filter((t=>"line"!==t.type)),l=t(e.options.colorPalette||"categorical"),i=Math.floor(o/(l.length-1));return{backgroundColor:l[o>l.length-1?o-(l.length-1)*i:o],borderWidth:{top:!r&&s&&o<a.length-1?2:0,right:r&&s&&o<a.length-1?2:0,bottom:0,left:0}}};export{r as datasetOptions,o as options,e as type};
|
|
2
2
|
//# sourceMappingURL=bar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar.js","sources":["../../../../src/common/config/chartTypes/bar.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'bar';\n\nexport const options = (ctx) => {\n const Horizontal = ctx.options.indexAxis === 'y';\n const FloatingBars = ctx.datasets.find((dataset) =>\n Array.isArray(dataset.data[0])\n );\n const Stacked = ctx.options.scales?.y?.stacked;\n\n return {\n interaction: {\n mode: Stacked ? 'index' : 'nearest',\n },\n borderRadius: 2,\n borderSkipped: FloatingBars ? false : 'start',\n scales: {\n x: {\n grid: {\n display: FloatingBars || Horizontal,\n },\n },\n y: {\n grid: {\n display: !Horizontal,\n },\n },\n },\n plugins: {\n tooltip: {\n callbacks: {\n title: (tooltipItems) => {\n // add axis label to tooltip title\n const AxisLabel = Horizontal\n ? tooltipItems[0].chart.options.scales.y.title.text\n : tooltipItems[0].chart.options.scales.x.title.text;\n const Label = tooltipItems[0].label;\n\n return AxisLabel + ': ' + Label;\n },\n footer: (tooltipItems) => {\n // add total row\n let sum = 0;\n\n tooltipItems.forEach(function (tooltipItem) {\n sum += Horizontal ? tooltipItem.parsed.x : tooltipItem.parsed.y;\n });\n\n return Stacked ? 'Total: ' +
|
|
1
|
+
{"version":3,"file":"bar.js","sources":["../../../../src/common/config/chartTypes/bar.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'bar';\n\nexport const options = (ctx) => {\n const Horizontal = ctx.options.indexAxis === 'y';\n const FloatingBars = ctx.datasets.find((dataset) =>\n Array.isArray(dataset.data[0])\n );\n const Stacked = ctx.options.scales?.y?.stacked;\n\n return {\n interaction: {\n mode: Stacked ? 'index' : 'nearest',\n },\n borderRadius: 2,\n borderSkipped: FloatingBars ? false : 'start',\n scales: {\n x: {\n grid: {\n display: FloatingBars || Horizontal,\n },\n },\n y: {\n grid: {\n display: !Horizontal,\n },\n },\n },\n plugins: {\n tooltip: {\n callbacks: {\n title: (tooltipItems) => {\n // add axis label to tooltip title\n const AxisLabel = Horizontal\n ? tooltipItems[0].chart.options.scales.y.title.text\n : tooltipItems[0].chart.options.scales.x.title.text;\n const Label = tooltipItems[0].label;\n\n return AxisLabel + ': ' + Label;\n },\n footer: (tooltipItems) => {\n // add total row\n let sum = 0;\n\n tooltipItems.forEach(function (tooltipItem) {\n sum += Horizontal ? tooltipItem.parsed.x : tooltipItem.parsed.y;\n });\n\n // Fix floating point rounding issues, show up to 2 decimals max\n const formattedSum = Math.round((sum + Number.EPSILON) * 100) / 100;\n\n return Stacked ? 'Total: ' + formattedSum : null;\n },\n },\n },\n },\n };\n};\n\nexport const datasetOptions = (ctx, index) => {\n const Horizontal = ctx.options.indexAxis === 'y';\n const Stacked = ctx.options.scales?.y?.stacked;\n const Datasets = ctx.datasets;\n const BarDatasets = Datasets.filter((dataset) => dataset.type !== 'line');\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],\n borderWidth: {\n top: !Horizontal && Stacked && index < BarDatasets.length - 1 ? 2 : 0, // stacked bars 2px gap\n right: Horizontal && Stacked && index < BarDatasets.length - 1 ? 2 : 0, // stacked bars 2px gap\n bottom: 0,\n left: 0,\n },\n };\n};\n"],"names":["type","options","ctx","Horizontal","indexAxis","FloatingBars","datasets","find","dataset","Array","isArray","data","Stacked","scales","y","stacked","interaction","mode","borderRadius","borderSkipped","x","grid","display","plugins","tooltip","callbacks","title","tooltipItems","chart","text","label","footer","sum","forEach","tooltipItem","parsed","formattedSum","Math","round","Number","EPSILON","datasetOptions","index","BarDatasets","filter","Colors","getComputedColorPalette","colorPalette","ColorCycles","floor","length","backgroundColor","borderWidth","top","right","bottom","left"],"mappings":"8DAEY,MAACA,EAAO,MAEPC,EAAWC,IACtB,MAAMC,EAAuC,MAA1BD,EAAID,QAAQG,UACzBC,EAAeH,EAAII,SAASC,MAAMC,GACtCC,MAAMC,QAAQF,EAAQG,KAAK,MAEvBC,EAAUV,EAAID,QAAQY,QAAQC,GAAGC,QAEvC,MAAO,CACLC,YAAa,CACXC,KAAML,EAAU,QAAU,WAE5BM,aAAc,EACdC,eAAed,GAAuB,QACtCQ,OAAQ,CACNO,EAAG,CACDC,KAAM,CACJC,QAASjB,GAAgBF,IAG7BW,EAAG,CACDO,KAAM,CACJC,SAAUnB,KAIhBoB,QAAS,CACPC,QAAS,CACPC,UAAW,CACTC,MAAQC,IAEYxB,EACdwB,EAAa,GAAGC,MAAM3B,QAAQY,OAAOC,EAAEY,MAAMG,KAC7CF,EAAa,GAAGC,MAAM3B,QAAQY,OAAOO,EAAEM,MAAMG,MAG9B,KAFLF,EAAa,GAAGG,MAIhCC,OAASJ,IAEP,IAAIK,EAAM,EAEVL,EAAaM,SAAQ,SAAUC,GAC7BF,GAAO7B,EAAa+B,EAAYC,OAAOf,EAAIc,EAAYC,OAAOrB,CAC5E,IAGY,MAAMsB,EAAeC,KAAKC,MAA+B,KAAxBN,EAAMO,OAAOC,UAAkB,IAEhE,OAAO5B,EAAU,UAAYwB,EAAe,IAAI,KAKzD,EAGUK,EAAiB,CAACvC,EAAKwC,KAClC,MAAMvC,EAAuC,MAA1BD,EAAID,QAAQG,UACzBQ,EAAUV,EAAID,QAAQY,QAAQC,GAAGC,QAEjC4B,EADWzC,EAAII,SACQsC,QAAQpC,GAA6B,SAAjBA,EAAQR,OACnD6C,EAASC,EACb5C,EAAID,QAAQ8C,cAAgB,eAExBC,EAAcX,KAAKY,MAAMP,GAASG,EAAOK,OAAS,IAMxD,MAAO,CACLC,gBAAiBN,EALjBH,EAAQG,EAAOK,OAAS,EACpBR,GAASG,EAAOK,OAAS,GAAKF,EAC9BN,GAIJU,YAAa,CACXC,KAAMlD,GAAcS,GAAW8B,EAAQC,EAAYO,OAAS,EAAI,EAAI,EACpEI,MAAOnD,GAAcS,GAAW8B,EAAQC,EAAYO,OAAS,EAAI,EAAI,EACrEK,OAAQ,EACRC,KAAM,GAET"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getComputedColorPalette as t}from"../colorPalettes.js";const o="line",r=t=>{const o="y"===t.options.indexAxis,r=t.datasets.find((t=>Array.isArray(t.data[0]))),e=t.options.scales?.y?.stacked;return{interaction:{mode:e?"index":"nearest"},pointRadius:6,pointHoverRadius:7,pointBorderWidth:1,scales:{x:{grid:{display:r||o}},y:{beginAtZero:!0,grid:{display:!o}}},plugins:{tooltip:{callbacks:{title:t=>(o?t[0].chart.options.scales.y.title.text:t[0].chart.options.scales.x.title.text)+": "+t[0].label,footer:t=>{let r=0;
|
|
1
|
+
import{getComputedColorPalette as t}from"../colorPalettes.js";const o="line",r=t=>{const o="y"===t.options.indexAxis,r=t.datasets.find((t=>Array.isArray(t.data[0]))),e=t.options.scales?.y?.stacked;return{interaction:{mode:e?"index":"nearest"},pointRadius:6,pointHoverRadius:7,pointBorderWidth:1,scales:{x:{grid:{display:r||o}},y:{beginAtZero:!0,grid:{display:!o}}},plugins:{tooltip:{callbacks:{title:t=>(o?t[0].chart.options.scales.y.title.text:t[0].chart.options.scales.x.title.text)+": "+t[0].label,footer:t=>{let r=0;t.forEach((function(t){r+=o?t.parsed.x:t.parsed.y}));const a=Math.round(100*(r+Number.EPSILON))/100;return e?"Total: "+a:null}}}}}},e=(o,r)=>{const e=t(o.options.colorPalette||"categorical"),a=Math.floor(r/(e.length-1)),n=r>e.length-1?r-(e.length-1)*a:r;return{pointBackgroundColor:e[n]+"80",borderColor:e[r],backgroundColor:t=>{const o=t.chart.ctx.createLinearGradient(0,0,0,200);return o.addColorStop(0,e[n]+"99"),o.addColorStop(1,e[n]+"4D"),o},borderWidth:2}};export{e as datasetOptions,r as options,o as type};
|
|
2
2
|
//# sourceMappingURL=line.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.js","sources":["../../../../src/common/config/chartTypes/line.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'line';\n\nexport const options = (ctx) => {\n const Horizontal = ctx.options.indexAxis === 'y';\n const FloatingBars = ctx.datasets.find((dataset) =>\n Array.isArray(dataset.data[0])\n );\n const Stacked = ctx.options.scales?.y?.stacked;\n\n return {\n interaction: {\n mode: Stacked ? 'index' : 'nearest',\n },\n pointRadius: 6,\n pointHoverRadius: 7,\n pointBorderWidth: 1,\n scales: {\n x: {\n grid: {\n display: FloatingBars || Horizontal,\n },\n },\n y: {\n beginAtZero: true,\n grid: {\n display: !Horizontal,\n },\n },\n },\n plugins: {\n tooltip: {\n callbacks: {\n title: (tooltipItems) => {\n // add axis label to tooltip title\n const AxisLabel = Horizontal\n ? tooltipItems[0].chart.options.scales.y.title.text\n : tooltipItems[0].chart.options.scales.x.title.text;\n const Label = tooltipItems[0].label;\n\n return AxisLabel + ': ' + Label;\n },\n footer: (tooltipItems) => {\n // add total row\n let sum = 0;\n\n tooltipItems.forEach(function (tooltipItem) {\n sum += Horizontal ? tooltipItem.parsed.x : tooltipItem.parsed.y;\n });\n\n return Stacked ? 'Total: ' +
|
|
1
|
+
{"version":3,"file":"line.js","sources":["../../../../src/common/config/chartTypes/line.js"],"sourcesContent":["import { getComputedColorPalette } from '../colorPalettes';\n\nexport const type = 'line';\n\nexport const options = (ctx) => {\n const Horizontal = ctx.options.indexAxis === 'y';\n const FloatingBars = ctx.datasets.find((dataset) =>\n Array.isArray(dataset.data[0])\n );\n const Stacked = ctx.options.scales?.y?.stacked;\n\n return {\n interaction: {\n mode: Stacked ? 'index' : 'nearest',\n },\n pointRadius: 6,\n pointHoverRadius: 7,\n pointBorderWidth: 1,\n scales: {\n x: {\n grid: {\n display: FloatingBars || Horizontal,\n },\n },\n y: {\n beginAtZero: true,\n grid: {\n display: !Horizontal,\n },\n },\n },\n plugins: {\n tooltip: {\n callbacks: {\n title: (tooltipItems) => {\n // add axis label to tooltip title\n const AxisLabel = Horizontal\n ? tooltipItems[0].chart.options.scales.y.title.text\n : tooltipItems[0].chart.options.scales.x.title.text;\n const Label = tooltipItems[0].label;\n\n return AxisLabel + ': ' + Label;\n },\n footer: (tooltipItems) => {\n // add total row\n let sum = 0;\n\n tooltipItems.forEach(function (tooltipItem) {\n sum += Horizontal ? tooltipItem.parsed.x : tooltipItem.parsed.y;\n });\n\n // Fix floating point rounding issues, show up to 2 decimals max\n const formattedSum = Math.round((sum + Number.EPSILON) * 100) / 100;\n\n return Stacked ? 'Total: ' + formattedSum : null;\n },\n },\n },\n },\n };\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 // pointBorderColor:\n // getColorPalette(ctx.options.colorPalette || 'default')[index],\n pointBackgroundColor: Colors[Index] + '80', // 50% opacity\n borderColor: Colors[index],\n // backgroundColor: Colors[Index] + '80',\n backgroundColor: (context) => {\n const ctx = context.chart.ctx;\n const gradient = ctx.createLinearGradient(0, 0, 0, 200);\n gradient.addColorStop(0, Colors[Index] + '99'); // 60% opacity\n gradient.addColorStop(1, Colors[Index] + '4D'); // 30% opacity\n return gradient;\n },\n borderWidth: 2,\n };\n};\n"],"names":["type","options","ctx","Horizontal","indexAxis","FloatingBars","datasets","find","dataset","Array","isArray","data","Stacked","scales","y","stacked","interaction","mode","pointRadius","pointHoverRadius","pointBorderWidth","x","grid","display","beginAtZero","plugins","tooltip","callbacks","title","tooltipItems","chart","text","label","footer","sum","forEach","tooltipItem","parsed","formattedSum","Math","round","Number","EPSILON","datasetOptions","index","Colors","getComputedColorPalette","colorPalette","ColorCycles","floor","length","Index","pointBackgroundColor","borderColor","backgroundColor","context","gradient","createLinearGradient","addColorStop","borderWidth"],"mappings":"8DAEY,MAACA,EAAO,OAEPC,EAAWC,IACtB,MAAMC,EAAuC,MAA1BD,EAAID,QAAQG,UACzBC,EAAeH,EAAII,SAASC,MAAMC,GACtCC,MAAMC,QAAQF,EAAQG,KAAK,MAEvBC,EAAUV,EAAID,QAAQY,QAAQC,GAAGC,QAEvC,MAAO,CACLC,YAAa,CACXC,KAAML,EAAU,QAAU,WAE5BM,YAAa,EACbC,iBAAkB,EAClBC,iBAAkB,EAClBP,OAAQ,CACNQ,EAAG,CACDC,KAAM,CAC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