@carbon/charts 1.3.2 → 1.4.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/CHANGELOG.md +11 -0
- package/build/src/interfaces/charts.d.ts +5 -1
- package/build/src/interfaces/enums.d.ts +1 -1
- package/bundle.js +1 -1
- package/configuration.js +2 -1
- package/configuration.js.map +1 -1
- package/demo/styles.css +1 -1675
- package/demo/styles.css.map +1 -1
- package/demo/styles.min.css +1 -1
- package/demo/styles.min.css.map +1 -1
- package/demo/tsconfig.tsbuildinfo +1 -1
- package/demo/utils.js +14 -5
- package/demo/utils.js.map +1 -1
- package/interfaces/charts.d.ts +5 -1
- package/interfaces/charts.js.map +1 -1
- package/interfaces/enums.d.ts +1 -1
- package/interfaces/enums.js +1 -1
- package/interfaces/enums.js.map +1 -1
- package/package.json +1 -1
- package/services/essentials/dom-utils.js +5 -3
- package/services/essentials/dom-utils.js.map +1 -1
- package/tsconfig.tsbuildinfo +8 -8
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"signature": "04ee40ba0aafdd5f63fd3c6333754badb44fa9620700b4a5a1b3b3b8b26c2cd9"
|
|
127
127
|
},
|
|
128
128
|
"../../demo/utils.ts": {
|
|
129
|
-
"version": "
|
|
129
|
+
"version": "723cdfdef075c8cb53fc6b4b3ec8fc24058b67f3039a892b58f3c7e41912bc6c",
|
|
130
130
|
"signature": "4fe7f477469cf1883226ae5bcbdbbb8d0b5508efdbf4ea909e2f7dc4393483b2"
|
|
131
131
|
},
|
|
132
132
|
"../../demo/data/CHART_TYPES.ts": {
|
package/demo/utils.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
2
13
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
3
14
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
@@ -69,7 +80,7 @@ var generateColorPalettePickerHTML = function (container, chart, configs) {
|
|
|
69
80
|
export var addControls = function (container, demoGroup, chart, configs) {
|
|
70
81
|
if (configs === void 0) { configs = { colorPairingOptions: null }; }
|
|
71
82
|
var _a, _b;
|
|
72
|
-
generateThemePickerHTML(container,
|
|
83
|
+
generateThemePickerHTML(container, chart);
|
|
73
84
|
if (((_b = (_a = demoGroup) === null || _a === void 0 ? void 0 : _a.configs) === null || _b === void 0 ? void 0 : _b.excludeColorPaletteControl) !== true) {
|
|
74
85
|
generateColorPalettePickerHTML(container, chart, configs);
|
|
75
86
|
}
|
|
@@ -88,10 +99,8 @@ export var addRadioButtonEventListeners = function (container, chart, configs) {
|
|
|
88
99
|
radioButton.addEventListener('click', function (e) {
|
|
89
100
|
var theme = e.target.value;
|
|
90
101
|
document.documentElement.setAttribute('data-carbon-theme', theme);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
.setAttribute('data-carbon-theme', theme);
|
|
94
|
-
chart.update();
|
|
102
|
+
// Set selected theme to options
|
|
103
|
+
chart.model.setOptions(__assign(__assign({}, chart.model.getOptions()), { theme: theme }));
|
|
95
104
|
});
|
|
96
105
|
});
|
|
97
106
|
};
|
package/demo/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAM,uBAAuB,GAAG,UAAC,SAAS,EAAE,OAAO;IAClD,IAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,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C2D,CAAC;AAC7D,MAAM,CAAC,IAAM,wBAAwB,GAAG,UAAC,SAAS,EAAE,IAAI,EAAE,KAAK;IAC9D,+BAA+B;IAC/B,IAAM,IAAI,GAAG,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,IAAI,EAAE;QACT,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAC,CAAM;YACtC,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAM,iBAAiB,GACtB,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;YAC5C,KAAK,CAAC,KAAK,CAAC,OAAO,CAClB,kBAAkB,CAAC,iBAAiB,EAAE,GAAG,EAAE,GAAG,CAAC,CAC/C,CAAC;YACF,KAAK,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;KACH;AACF,CAAC,CAAC","sourcesContent":["const generateThemePickerHTML = (container, configs) => {\n\tconst div = document.createElement('div');\n\tdiv.id = 'theme-picker';\n\tdiv.innerHTML = `\n<fieldset class=\"cds--fieldset marginTop-45\">\n\t<legend class=\"cds--label\">Active theme</legend>\n\n\t<div class=\"cds--form-item\">\n\t\t<div class=\"cds--radio-button-group\">\n\t\t\t<div class=\"cds--radio-button-wrapper\">\n\t\t\t\t<input id=\"theme__white\" class=\"cds--radio-button\" type=\"radio\" value=\"white\" name=\"radio-button\" tabindex=\"0\">\n\t\t\t\t<label for=\"theme__white\" class=\"cds--radio-button__label\">\n\t\t\t\t<span class=\"cds--radio-button__appearance\"></span>\n\t\t\t\t<span class=\"cds--radio-button__label-text\">White</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\n\t\t\t<div class=\"cds--radio-button-wrapper\">\n\t\t\t\t<input id=\"theme__g10\" class=\"cds--radio-button\" type=\"radio\" value=\"g10\" name=\"radio-button\" tabindex=\"0\">\n\t\t\t\t<label for=\"theme__g10\" class=\"cds--radio-button__label\">\n\t\t\t\t<span class=\"cds--radio-button__appearance\"></span>\n\t\t\t\t<span class=\"cds--radio-button__label-text\">G10</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\n\t\t\t<div class=\"cds--radio-button-wrapper\">\n\t\t\t\t<input id=\"theme__g90\" class=\"cds--radio-button\" type=\"radio\" value=\"g90\" name=\"radio-button\" tabindex=\"0\">\n\t\t\t\t<label for=\"theme__g90\" class=\"cds--radio-button__label\">\n\t\t\t\t<span class=\"cds--radio-button__appearance\"></span>\n\t\t\t\t<span class=\"cds--radio-button__label-text\">G90</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\n\t\t\t<div class=\"cds--radio-button-wrapper\">\n\t\t\t\t<input id=\"theme__g100\" class=\"cds--radio-button\" type=\"radio\" value=\"g100\" name=\"radio-button\" tabindex=\"0\">\n\t\t\t\t<label for=\"theme__g100\" class=\"cds--radio-button__label\">\n\t\t\t\t<span class=\"cds--radio-button__appearance\"></span>\n\t\t\t\t<span class=\"cds--radio-button__label-text\">G100</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</fieldset>`;\n\n\tconst currentTheme = document.documentElement.getAttribute(\n\t\t'data-carbon-theme'\n\t);\n\tif (currentTheme) {\n\t\tdiv.querySelector(`input#theme__${currentTheme}`).setAttribute(\n\t\t\t'checked',\n\t\t\t'true'\n\t\t);\n\t} else {\n\t\tdiv.querySelector(`input#theme__white`).setAttribute('checked', 'true');\n\t}\n\n\tcontainer.querySelector('#charting-controls').appendChild(div);\n};\n\nconst generateColorPalettePickerHTML = (\n\tcontainer,\n\tchart,\n\tconfigs = { colorPairingOptions: null }\n) => {\n\tconst { colorPairingOptions } = configs;\n\n\tconst chartOptions = chart.model.getOptions();\n\tconst { numberOfVariants: variants, option } = chartOptions.color.pairing;\n\n\tconst numberOfChartDataGroups = chart.model.getAllDataGroupsNames().length;\n\tconst numberOfVariants = variants || numberOfChartDataGroups;\n\n\tlet onlyCategoricalPaletteIsApplicable = false;\n\tif (numberOfChartDataGroups > 5) {\n\t\tonlyCategoricalPaletteIsApplicable = true;\n\t}\n\n\tconst selectedColorPalette = `${numberOfVariants}-${option}`;\n\n\tconst div = document.createElement('div');\n\tdiv.id = 'color-palette-picker';\n\tdiv.innerHTML = `\n<div class=\"cds--form-item\">\n\t<div\n\tclass=\"cds--select\">\n\t<label for=\"color-palette-select\" class=\"cds--label\">Active color palette</label>\n\t\t<div class=\"cds--select-input__wrapper\">\n\t\t<select id=\"color-palette-select\" class=\"cds--select-input\">\n\t\t\t<option class=\"cds--select-option\" value=\"\" disabled selected hidden>\n\t\t\tChoose an option\n\t\t\t</option>\n\t\t\t${Object.keys(colorPairingOptions)\n\t\t\t\t.map((colorGroup) => {\n\t\t\t\t\tconst optionsCount = colorPairingOptions[colorGroup];\n\t\t\t\t\tlet optionsHTML = `<optgroup class=\"cds--select-optgroup\" label=\"${colorGroup} groups\">`;\n\n\t\t\t\t\tconst numberOfVariants = parseInt(colorGroup);\n\n\t\t\t\t\tif (numberOfVariants !== 14) {\n\t\t\t\t\t\tfor (let i = 1; i <= optionsCount; i++) {\n\t\t\t\t\t\t\toptionsHTML += `\n\t\t\t\t\t\t<option class=\"cds--select-option\" ${\n\t\t\t\t\t\t\tonlyCategoricalPaletteIsApplicable ||\n\t\t\t\t\t\t\tnumberOfVariants < numberOfChartDataGroups\n\t\t\t\t\t\t\t\t? 'disabled'\n\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t} value=\"${colorGroup}-option-${i}\" ${\n\t\t\t\t\t\t\t\tselectedColorPalette ===\n\t\t\t\t\t\t\t\t`${numberOfVariants}-${i}`\n\t\t\t\t\t\t\t\t\t? 'selected'\n\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t\t${numberOfVariants}-color groups, option ${i}\n\t\t\t\t\t\t</option>`;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\toptionsHTML += `<option class=\"cds--select-option\" value=\"14-color-option-1\" ${\n\t\t\t\t\t\t\tselectedColorPalette === `14-1` ||\n\t\t\t\t\t\t\tonlyCategoricalPaletteIsApplicable\n\t\t\t\t\t\t\t\t? 'selected'\n\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t}>\n\t\t\t\t\t\tCategorical palette\n\t\t\t\t\t</option>`;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn optionsHTML;\n\t\t\t\t})\n\t\t\t\t.join('')}\n\t\t</select>\n\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" style=\"will-change: transform;\" xmlns=\"http://www.w3.org/2000/svg\" class=\"cds--select__arrow\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z\"></path></svg>\n\t\t</div>\n\t</div>\n\t</div>\n</div>`;\n\n\tdiv.querySelector('#color-palette-select').addEventListener(\n\t\t'change',\n\t\t(e: any) => {\n\t\t\tconst { value } = e.target;\n\t\t\tconst [numberOfVariants, pairingOption] = value.split(\n\t\t\t\t'-color-option-'\n\t\t\t);\n\n\t\t\tchartOptions.color.pairing.numberOfVariants = numberOfVariants;\n\t\t\tchartOptions.color.pairing.option = pairingOption;\n\t\t\tchart.model.setOptions(chartOptions);\n\t\t}\n\t);\n\n\tcontainer.querySelector('#charting-controls').appendChild(div);\n};\n\nexport const addControls = (\n\tcontainer,\n\tdemoGroup,\n\tchart,\n\tconfigs = { colorPairingOptions: null }\n) => {\n\tgenerateThemePickerHTML(container, configs);\n\n\tif (demoGroup?.configs?.excludeColorPaletteControl !== true) {\n\t\tgenerateColorPalettePickerHTML(container, chart, configs);\n\t}\n\n\taddRadioButtonEventListeners(container, chart, configs);\n};\n\nexport const addRadioButtonEventListeners = (container, chart, configs) => {\n\t// Add event listeners for radio buttons\n\tconst radioButtons = container.querySelectorAll(\n\t\t'div#theme-picker input.cds--radio-button'\n\t);\n\n\tconst currentTheme = document.documentElement.getAttribute(\n\t\t'data-carbon-theme'\n\t);\n\tif (currentTheme) {\n\t\tchart.services.domUtils\n\t\t\t.getHolder()\n\t\t\t.setAttribute('data-carbon-theme', currentTheme);\n\t}\n\n\tradioButtons.forEach((radioButton) => {\n\t\tradioButton.addEventListener('click', (e: any) => {\n\t\t\tconst theme = e.target.value;\n\n\t\t\tdocument.documentElement.setAttribute('data-carbon-theme', theme);\n\t\t\tchart.services.domUtils\n\t\t\t\t.getHolder()\n\t\t\t\t.setAttribute('data-carbon-theme', theme);\n\n\t\t\tchart.update();\n\t\t});\n\t});\n};\n\nexport const addOtherVersions = (\n\tcontainer,\n\tdemoGroup,\n\tdemo,\n\tconfigs = { currentVersion: 'vanilla' }\n) => {\n\tconst { currentVersion } = configs;\n\n\tconst demoGroupClassification = (demoGroup.type || '').replace(\n\t\t'-chart',\n\t\t''\n\t);\n\n\tconst div = document.createElement('div');\n\tdiv.setAttribute('class', 'cds--row resource-card-group');\n\n\tlet htmlContent = '';\n\tconst otherVersions = [\n\t\t...(currentVersion !== 'vanilla'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'vanilla',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t\t...(currentVersion !== 'react'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'React',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/react/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t\t...(currentVersion !== 'angular'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Angular',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/angular/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t\t...(currentVersion !== 'vue'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Vue',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/vue/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t\t...(currentVersion !== 'svelte'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Svelte',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/svelte/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t];\n\n\totherVersions.forEach((otherVersion) => {\n\t\thtmlContent += `<div class=\"cds--no-gutter-sm cds--col-md-6 cds--col-lg-6\">\n\t\t<div class=\"cds--resource-card\">\n\t\t <div class=\"cds--aspect-ratio cds--aspect-ratio--2x1\">\n\t\t\t<div class=\"cds--aspect-ratio--object\">\n\t\t\t <a href=\"${otherVersion.link}\" class=\"cds--tile cds--tile--clickable\">\n\t\t\t\t<h5 class=\"cds--resource-card__subtitle\">${otherVersion.name}</h5>\n\t\t\t\t<div class=\"cds--resource-card__icon--img\"></div>\n\t\t\t\t<div class=\"cds--resource-card__icon--action\">\n\t\t\t\t <svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" aria-label=\"Open resource\" width=\"20\" height=\"20\" viewBox=\"0 0 32 32\" role=\"img\">\n\t\t\t\t\t<path d=\"M26,28H6a2.0027,2.0027,0,0,1-2-2V6A2.0027,2.0027,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0027,2.0027,0,0,1,26,28Z\"></path>\n\t\t\t\t\t<path d=\"M20 2L20 4 26.586 4 18 12.586 19.414 14 28 5.414 28 12 30 12 30 2 20 2z\"></path>\n\t\t\t\t </svg>\n\t\t\t\t</div>\n\t\t\t </a>\n\t\t\t</div>\n\t\t </div>\n\t\t</div>\n\t </div>`;\n\t});\n\n\tdiv.innerHTML = htmlContent;\n\tcontainer.querySelector('#other-versions').appendChild(div);\n};\n\n/**\n * Generates random data going backwards from now once a minute\n * @param {number} quantity number of data points to create\n * @param {number} min min range of integer value\n * @param {number} max max range of integer value\n * @returns {array} randomly generated array of objects with a date and value field\n */\nexport const generateRandomData = (quantity, min, max) => {\n\tconst now = Date.now();\n\treturn Array(quantity)\n\t\t.fill(0)\n\t\t.map((value, index) => {\n\t\t\treturn {\n\t\t\t\tgroup: 'group',\n\t\t\t\tvalue: Math.floor(Math.random() * (max - min + 1) + min),\n\t\t\t\tdate: new Date(now.valueOf() + (index - quantity) * 60000), // go forward a minute for every value\n\t\t\t};\n\t\t});\n};\n/**\n * Adds a generate demo data form to the story\n */\nexport const generateHighScaleDemoDataForm = () =>\n\t`<form id=\"demo-data\"><label for=\"demo-data-name\">Records to generate: </label><input type=\"number\" id=\"demo-data-number\" name=\"number\" required\n\t size=\"5\" value=\"100\"><input type=\"submit\"></label></form>`;\nexport const addDemoDataFormListeners = (container, demo, chart) => {\n\t// Add event listeners for form\n\tconst form = container.querySelector('form#demo-data');\n\tif (form) {\n\t\tform.addEventListener('submit', (e: any) => {\n\t\t\te.stopPropagation();\n\t\t\te.preventDefault();\n\t\t\tconst recordsToGenerate =\n\t\t\t\tparseInt(e.currentTarget[0].value) || 2000;\n\t\t\tchart.model.setData(\n\t\t\t\tgenerateRandomData(recordsToGenerate, 100, 500)\n\t\t\t);\n\t\t\tchart.update();\n\t\t});\n\t}\n};\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAM,uBAAuB,GAAG,UAAC,SAAS,EAAE,OAAO;IAClD,IAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,GAAG,CAA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UAAC,SAAS,EAAE,IAAI,EAAE,KAAK;IAC9D,+BAA+B;IAC/B,IAAM,IAAI,GAAG,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,IAAI,EAAE;QACT,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAC,CAAM;YACtC,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAM,iBAAiB,GACtB,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;YAC5C,KAAK,CAAC,KAAK,CAAC,OAAO,CAClB,kBAAkB,CAAC,iBAAiB,EAAE,GAAG,EAAE,GAAG,CAAC,CAC/C,CAAC;YACF,KAAK,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;KACH;AACF,CAAC,CAAC","sourcesContent":["const generateThemePickerHTML = (container, configs) => {\n\tconst div = document.createElement('div');\n\tdiv.id = 'theme-picker';\n\tdiv.innerHTML = `\n<fieldset class=\"cds--fieldset marginTop-45\">\n\t<legend class=\"cds--label\">Active theme</legend>\n\n\t<div class=\"cds--form-item\">\n\t\t<div class=\"cds--radio-button-group\">\n\t\t\t<div class=\"cds--radio-button-wrapper\">\n\t\t\t\t<input id=\"theme__white\" class=\"cds--radio-button\" type=\"radio\" value=\"white\" name=\"radio-button\" tabindex=\"0\">\n\t\t\t\t<label for=\"theme__white\" class=\"cds--radio-button__label\">\n\t\t\t\t<span class=\"cds--radio-button__appearance\"></span>\n\t\t\t\t<span class=\"cds--radio-button__label-text\">White</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\n\t\t\t<div class=\"cds--radio-button-wrapper\">\n\t\t\t\t<input id=\"theme__g10\" class=\"cds--radio-button\" type=\"radio\" value=\"g10\" name=\"radio-button\" tabindex=\"0\">\n\t\t\t\t<label for=\"theme__g10\" class=\"cds--radio-button__label\">\n\t\t\t\t<span class=\"cds--radio-button__appearance\"></span>\n\t\t\t\t<span class=\"cds--radio-button__label-text\">G10</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\n\t\t\t<div class=\"cds--radio-button-wrapper\">\n\t\t\t\t<input id=\"theme__g90\" class=\"cds--radio-button\" type=\"radio\" value=\"g90\" name=\"radio-button\" tabindex=\"0\">\n\t\t\t\t<label for=\"theme__g90\" class=\"cds--radio-button__label\">\n\t\t\t\t<span class=\"cds--radio-button__appearance\"></span>\n\t\t\t\t<span class=\"cds--radio-button__label-text\">G90</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\n\t\t\t<div class=\"cds--radio-button-wrapper\">\n\t\t\t\t<input id=\"theme__g100\" class=\"cds--radio-button\" type=\"radio\" value=\"g100\" name=\"radio-button\" tabindex=\"0\">\n\t\t\t\t<label for=\"theme__g100\" class=\"cds--radio-button__label\">\n\t\t\t\t<span class=\"cds--radio-button__appearance\"></span>\n\t\t\t\t<span class=\"cds--radio-button__label-text\">G100</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</fieldset>`;\n\n\tconst currentTheme = document.documentElement.getAttribute(\n\t\t'data-carbon-theme'\n\t);\n\tif (currentTheme) {\n\t\tdiv.querySelector(`input#theme__${currentTheme}`).setAttribute(\n\t\t\t'checked',\n\t\t\t'true'\n\t\t);\n\t} else {\n\t\tdiv.querySelector(`input#theme__white`).setAttribute('checked', 'true');\n\t}\n\n\tcontainer.querySelector('#charting-controls').appendChild(div);\n};\n\nconst generateColorPalettePickerHTML = (\n\tcontainer,\n\tchart,\n\tconfigs = { colorPairingOptions: null }\n) => {\n\tconst { colorPairingOptions } = configs;\n\n\tconst chartOptions = chart.model.getOptions();\n\tconst { numberOfVariants: variants, option } = chartOptions.color.pairing;\n\n\tconst numberOfChartDataGroups = chart.model.getAllDataGroupsNames().length;\n\tconst numberOfVariants = variants || numberOfChartDataGroups;\n\n\tlet onlyCategoricalPaletteIsApplicable = false;\n\tif (numberOfChartDataGroups > 5) {\n\t\tonlyCategoricalPaletteIsApplicable = true;\n\t}\n\n\tconst selectedColorPalette = `${numberOfVariants}-${option}`;\n\n\tconst div = document.createElement('div');\n\tdiv.id = 'color-palette-picker';\n\tdiv.innerHTML = `\n<div class=\"cds--form-item\">\n\t<div\n\tclass=\"cds--select\">\n\t<label for=\"color-palette-select\" class=\"cds--label\">Active color palette</label>\n\t\t<div class=\"cds--select-input__wrapper\">\n\t\t<select id=\"color-palette-select\" class=\"cds--select-input\">\n\t\t\t<option class=\"cds--select-option\" value=\"\" disabled selected hidden>\n\t\t\tChoose an option\n\t\t\t</option>\n\t\t\t${Object.keys(colorPairingOptions)\n\t\t\t\t.map((colorGroup) => {\n\t\t\t\t\tconst optionsCount = colorPairingOptions[colorGroup];\n\t\t\t\t\tlet optionsHTML = `<optgroup class=\"cds--select-optgroup\" label=\"${colorGroup} groups\">`;\n\n\t\t\t\t\tconst numberOfVariants = parseInt(colorGroup);\n\n\t\t\t\t\tif (numberOfVariants !== 14) {\n\t\t\t\t\t\tfor (let i = 1; i <= optionsCount; i++) {\n\t\t\t\t\t\t\toptionsHTML += `\n\t\t\t\t\t\t<option class=\"cds--select-option\" ${\n\t\t\t\t\t\t\tonlyCategoricalPaletteIsApplicable ||\n\t\t\t\t\t\t\tnumberOfVariants < numberOfChartDataGroups\n\t\t\t\t\t\t\t\t? 'disabled'\n\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t} value=\"${colorGroup}-option-${i}\" ${\n\t\t\t\t\t\t\t\tselectedColorPalette ===\n\t\t\t\t\t\t\t\t`${numberOfVariants}-${i}`\n\t\t\t\t\t\t\t\t\t? 'selected'\n\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t\t${numberOfVariants}-color groups, option ${i}\n\t\t\t\t\t\t</option>`;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\toptionsHTML += `<option class=\"cds--select-option\" value=\"14-color-option-1\" ${\n\t\t\t\t\t\t\tselectedColorPalette === `14-1` ||\n\t\t\t\t\t\t\tonlyCategoricalPaletteIsApplicable\n\t\t\t\t\t\t\t\t? 'selected'\n\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t}>\n\t\t\t\t\t\tCategorical palette\n\t\t\t\t\t</option>`;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn optionsHTML;\n\t\t\t\t})\n\t\t\t\t.join('')}\n\t\t</select>\n\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" style=\"will-change: transform;\" xmlns=\"http://www.w3.org/2000/svg\" class=\"cds--select__arrow\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z\"></path></svg>\n\t\t</div>\n\t</div>\n\t</div>\n</div>`;\n\n\tdiv.querySelector('#color-palette-select').addEventListener(\n\t\t'change',\n\t\t(e: any) => {\n\t\t\tconst { value } = e.target;\n\t\t\tconst [numberOfVariants, pairingOption] = value.split(\n\t\t\t\t'-color-option-'\n\t\t\t);\n\n\t\t\tchartOptions.color.pairing.numberOfVariants = numberOfVariants;\n\t\t\tchartOptions.color.pairing.option = pairingOption;\n\t\t\tchart.model.setOptions(chartOptions);\n\t\t}\n\t);\n\n\tcontainer.querySelector('#charting-controls').appendChild(div);\n};\n\nexport const addControls = (\n\tcontainer,\n\tdemoGroup,\n\tchart,\n\tconfigs = { colorPairingOptions: null }\n) => {\n\tgenerateThemePickerHTML(container, chart);\n\n\tif (demoGroup?.configs?.excludeColorPaletteControl !== true) {\n\t\tgenerateColorPalettePickerHTML(container, chart, configs);\n\t}\n\n\taddRadioButtonEventListeners(container, chart, configs);\n};\n\nexport const addRadioButtonEventListeners = (container, chart, configs) => {\n\t// Add event listeners for radio buttons\n\tconst radioButtons = container.querySelectorAll(\n\t\t'div#theme-picker input.cds--radio-button'\n\t);\n\n\tconst currentTheme = document.documentElement.getAttribute(\n\t\t'data-carbon-theme'\n\t);\n\tif (currentTheme) {\n\t\tchart.services.domUtils\n\t\t\t.getHolder()\n\t\t\t.setAttribute('data-carbon-theme', currentTheme);\n\t}\n\n\tradioButtons.forEach((radioButton) => {\n\t\tradioButton.addEventListener('click', (e: any) => {\n\t\t\tconst theme = e.target.value;\n\n\t\t\tdocument.documentElement.setAttribute('data-carbon-theme', theme);\n\t\t\t// Set selected theme to options\n\t\t\tchart.model.setOptions({ ...chart.model.getOptions(), theme });\n\t\t});\n\t});\n};\n\nexport const addOtherVersions = (\n\tcontainer,\n\tdemoGroup,\n\tdemo,\n\tconfigs = { currentVersion: 'vanilla' }\n) => {\n\tconst { currentVersion } = configs;\n\n\tconst demoGroupClassification = (demoGroup.type || '').replace(\n\t\t'-chart',\n\t\t''\n\t);\n\n\tconst div = document.createElement('div');\n\tdiv.setAttribute('class', 'cds--row resource-card-group');\n\n\tlet htmlContent = '';\n\tconst otherVersions = [\n\t\t...(currentVersion !== 'vanilla'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'vanilla',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t\t...(currentVersion !== 'react'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'React',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/react/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t\t...(currentVersion !== 'angular'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Angular',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/angular/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t\t...(currentVersion !== 'vue'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Vue',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/vue/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t\t...(currentVersion !== 'svelte'\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Svelte',\n\t\t\t\t\t\tlink: `https://carbon-design-system.github.io/carbon-charts/svelte/?path=/story/${demoGroupClassification}-charts-${demo.id}`,\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: []),\n\t];\n\n\totherVersions.forEach((otherVersion) => {\n\t\thtmlContent += `<div class=\"cds--no-gutter-sm cds--col-md-6 cds--col-lg-6\">\n\t\t<div class=\"cds--resource-card\">\n\t\t <div class=\"cds--aspect-ratio cds--aspect-ratio--2x1\">\n\t\t\t<div class=\"cds--aspect-ratio--object\">\n\t\t\t <a href=\"${otherVersion.link}\" class=\"cds--tile cds--tile--clickable\">\n\t\t\t\t<h5 class=\"cds--resource-card__subtitle\">${otherVersion.name}</h5>\n\t\t\t\t<div class=\"cds--resource-card__icon--img\"></div>\n\t\t\t\t<div class=\"cds--resource-card__icon--action\">\n\t\t\t\t <svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" aria-label=\"Open resource\" width=\"20\" height=\"20\" viewBox=\"0 0 32 32\" role=\"img\">\n\t\t\t\t\t<path d=\"M26,28H6a2.0027,2.0027,0,0,1-2-2V6A2.0027,2.0027,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0027,2.0027,0,0,1,26,28Z\"></path>\n\t\t\t\t\t<path d=\"M20 2L20 4 26.586 4 18 12.586 19.414 14 28 5.414 28 12 30 12 30 2 20 2z\"></path>\n\t\t\t\t </svg>\n\t\t\t\t</div>\n\t\t\t </a>\n\t\t\t</div>\n\t\t </div>\n\t\t</div>\n\t </div>`;\n\t});\n\n\tdiv.innerHTML = htmlContent;\n\tcontainer.querySelector('#other-versions').appendChild(div);\n};\n\n/**\n * Generates random data going backwards from now once a minute\n * @param {number} quantity number of data points to create\n * @param {number} min min range of integer value\n * @param {number} max max range of integer value\n * @returns {array} randomly generated array of objects with a date and value field\n */\nexport const generateRandomData = (quantity, min, max) => {\n\tconst now = Date.now();\n\treturn Array(quantity)\n\t\t.fill(0)\n\t\t.map((value, index) => {\n\t\t\treturn {\n\t\t\t\tgroup: 'group',\n\t\t\t\tvalue: Math.floor(Math.random() * (max - min + 1) + min),\n\t\t\t\tdate: new Date(now.valueOf() + (index - quantity) * 60000), // go forward a minute for every value\n\t\t\t};\n\t\t});\n};\n/**\n * Adds a generate demo data form to the story\n */\nexport const generateHighScaleDemoDataForm = () =>\n\t`<form id=\"demo-data\"><label for=\"demo-data-name\">Records to generate: </label><input type=\"number\" id=\"demo-data-number\" name=\"number\" required\n\t size=\"5\" value=\"100\"><input type=\"submit\"></label></form>`;\nexport const addDemoDataFormListeners = (container, demo, chart) => {\n\t// Add event listeners for form\n\tconst form = container.querySelector('form#demo-data');\n\tif (form) {\n\t\tform.addEventListener('submit', (e: any) => {\n\t\t\te.stopPropagation();\n\t\t\te.preventDefault();\n\t\t\tconst recordsToGenerate =\n\t\t\t\tparseInt(e.currentTarget[0].value) || 2000;\n\t\t\tchart.model.setData(\n\t\t\t\tgenerateRandomData(recordsToGenerate, 100, 500)\n\t\t\t);\n\t\t\tchart.update();\n\t\t});\n\t}\n};\n"]}
|
package/interfaces/charts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GaugeTypes, Statuses, ArrowDirections, Alignments, ChartTypes, TreeTypes, DividerStatus, ColorLegendType } from './enums';
|
|
1
|
+
import { GaugeTypes, Statuses, ArrowDirections, Alignments, ChartTypes, TreeTypes, DividerStatus, ColorLegendType, ChartTheme } from './enums';
|
|
2
2
|
import { LegendOptions, TooltipOptions, GridOptions, AxesOptions, ZoomBarsOptions } from './index';
|
|
3
3
|
import { BarOptions, StackedBarOptions, ToolbarOptions } from './components';
|
|
4
4
|
import { AxisOptions, BinnedAxisOptions, TimeScaleOptions } from './axis-scales';
|
|
@@ -26,6 +26,10 @@ export interface BaseChartOptions {
|
|
|
26
26
|
* Optionally specify a height for the chart
|
|
27
27
|
*/
|
|
28
28
|
height?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Optionally specify a theme for the chart
|
|
31
|
+
*/
|
|
32
|
+
theme?: ChartTheme;
|
|
29
33
|
/**
|
|
30
34
|
* tooltip configuration
|
|
31
35
|
*/
|
package/interfaces/charts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.js","sourceRoot":"","sources":["charts.ts"],"names":[],"mappings":"","sourcesContent":["import {\n\tGaugeTypes,\n\tStatuses,\n\tArrowDirections,\n\tAlignments,\n\tChartTypes,\n\tTreeTypes,\n\tDividerStatus,\n\tColorLegendType,\n} from './enums';\nimport {\n\tLegendOptions,\n\tTooltipOptions,\n\tGridOptions,\n\tAxesOptions,\n\tZoomBarsOptions,\n} from './index';\nimport { BarOptions, StackedBarOptions, ToolbarOptions } from './components';\nimport {\n\tAxisOptions,\n\tBinnedAxisOptions,\n\tTimeScaleOptions,\n} from './axis-scales';\n\n/**\n * Base chart options common to any chart\n */\nexport interface BaseChartOptions {\n\t/**\n\t * Optionally specify a title for the chart\n\t */\n\ttitle?: string;\n\t/**\n\t * boolean to disable animations (enabled by default)\n\t */\n\tanimations?: boolean;\n\t/**\n\t * boolean to prevent the container from resizing\n\t */\n\tresizable?: boolean;\n\t/**\n\t * Optionally specify a width for the chart\n\t */\n\twidth?: string;\n\t/**\n\t * Optionally specify a height for the chart\n\t */\n\theight?: string;\n\t/**\n\t * tooltip configuration\n\t */\n\ttooltip?: TooltipOptions;\n\t/**\n\t * legend configuration\n\t */\n\tlegend?: LegendOptions;\n\t/**\n\t * toolbar configurations\n\t */\n\ttoolbar?: ToolbarOptions;\n\t/**\n\t * Optional function to determine whether is filled based on datasetLabel, label, and/or data\n\t */\n\tgetIsFilled?: (\n\t\tdatasetLabel: any,\n\t\tlabel?: any,\n\t\tdata?: any,\n\t\tdefaultFilled?: boolean\n\t) => boolean;\n\t/**\n\t * Optional function to generate the fill color based on datasetLabel, label, and/or data\n\t */\n\tgetFillColor?: (\n\t\tgroup: string,\n\t\tlabel?: string,\n\t\tdata?: any,\n\t\tdefaultFillColor?: string\n\t) => string;\n\t/**\n\t * Optional function to generate the stroke color based on datasetLabel, label, and/or data\n\t * (note) - not all chart types support the stroke color (e.g. wordcloud)\n\t */\n\tgetStrokeColor?: (\n\t\tgroup: string,\n\t\tlabel?: any,\n\t\tdata?: any,\n\t\tdefaultStrokeColor?: string\n\t) => string;\n\t/**\n\t * stylesheet options\n\t */\n\tstyle?: {\n\t\t/**\n\t\t * optional prefixing string for css classes (defaults to 'cc')\n\t\t */\n\t\tprefix?: string;\n\t};\n\t/**\n\t * options related to charting data\n\t */\n\tdata?: {\n\t\t/**\n\t\t * identifier for data groups\n\t\t */\n\t\tgroupMapsTo?: string;\n\t\t/**\n\t\t * used to simulate data loading in skeleton way\n\t\t */\n\t\tloading?: boolean;\n\t\t/**\n\t\t * options related to pre-selected data groups\n\t\t * Remains empty if every legend item is active or dataset doesn't have the data groups.\n\t\t */\n\t\tselectedGroups?: string[];\n\t};\n\t/**\n\t * options related to color scales\n\t */\n\tcolor?: {\n\t\t/**\n\t\t * e.g. { 'Dataset 1': 'blue' }\n\t\t */\n\t\tscale?: object;\n\t\t/**\n\t\t * use a carbon dataviz preset color palette\n\t\t * put the index (selection of which variant)\n\t\t */\n\t\tpairing?: {\n\t\t\t/**\n\t\t\t * the number of color variants in the palette (defaults to using the number of data groups in the given data)\n\t\t\t */\n\t\t\tnumberOfVariants?: number;\n\t\t\t/**\n\t\t\t * the option number of the color paring\n\t\t\t */\n\t\t\toption?: number;\n\t\t};\n\t\t/*\n\t\t * options related to gradient\n\t\t * e.g. { enabled: true }\n\t\t */\n\t\tgradient?: {\n\t\t\tenabled?: boolean;\n\t\t\t/**\n\t\t\t * hex color array\n\t\t\t * e.g. ['#fff', '#000', ...]\n\t\t\t */\n\t\t\tcolors?: Array<String>;\n\t\t};\n\t};\n}\n\n/**\n * Options common to any chart with an axis\n */\nexport interface AxisChartOptions extends BaseChartOptions {\n\taxes?: AxesOptions<AxisOptions>;\n\tgrid?: GridOptions;\n\ttimeScale?: TimeScaleOptions;\n\t/**\n\t * zoombar configuration\n\t */\n\tzoomBar?: ZoomBarsOptions;\n}\n\n/**\n * Options common to binned charts with an axis\n */\nexport interface BinnedAxisChartOptions extends AxisChartOptions {\n\taxes?: AxesOptions<BinnedAxisOptions>;\n\tgrid?: GridOptions;\n\ttimeScale?: TimeScaleOptions;\n\t/**\n\t * zoombar configuration\n\t */\n\tzoomBar?: ZoomBarsOptions;\n}\n\n/**\n * options specific to boxplot charts\n */\nexport interface BoxplotChartOptions extends AxisChartOptions {}\n\n/**\n * options specific to bar charts\n */\nexport interface BarChartOptions extends AxisChartOptions {\n\tbars?: BarOptions;\n}\n\n/**\n * options specific to stacked bar charts\n */\nexport interface StackedBarChartOptions extends BarChartOptions {\n\tbars?: StackedBarOptions;\n}\n\n/**\n * options specific to scatter charts\n */\nexport interface ScatterChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the points\n\t */\n\tpoints?: {\n\t\t/**\n\t\t * sets the radius of the point\n\t\t */\n\t\tradius: number;\n\t\tfillOpacity?: number;\n\t\tfilled?: boolean;\n\t\tenabled?: boolean;\n\t};\n}\n\n/**\n * options specific to lollipop charts\n */\nexport interface LollipopChartOptions extends ScatterChartOptions {}\n\n/**\n * options specific to bubble charts\n */\nexport interface BubbleChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the individual bubbles\n\t */\n\tbubble?: {\n\t\t/**\n\t\t * the key to lookup in charting data for the bubble radius value\n\t\t */\n\t\tradiusMapsTo?: string;\n\t\t/**\n\t\t * options for what the bubble radius value maps to\n\t\t */\n\t\tradiusLabel?: string;\n\t\t/**\n\t\t * A function that would determine the range of the bubble radius to use\n\t\t * Returns an array with the 1st value being the min and the 2nd value being the max radius\n\t\t */\n\t\tradiusRange?: Function;\n\t\t/**\n\t\t * Opacity of the fills used within each circle\n\t\t */\n\t\tfillOpacity?: number;\n\t\t/**\n\t\t * enabled scatter dot or not\n\t\t */\n\t\tenabled?: boolean;\n\t};\n}\n\n/**\n * options specific to bullet charts\n */\nexport interface BulletChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the individual bullets\n\t */\n\tbullet?: {\n\t\tperformanceAreaTitles?: string[];\n\t};\n}\n\n/**\n * options specific to histogram charts\n */\nexport interface HistogramChartOptions extends AxisChartOptions {\n\t/**\n\t * options related to bins\n\t */\n\tbins?: {\n\t\trangeLabel?: string;\n\t};\n}\n\n/**\n * options specific to line charts\n */\nexport interface LineChartOptions extends ScatterChartOptions {\n\t/**\n\t * options for the curve of the line\n\t */\n\tcurve?:\n\t\t| string\n\t\t| {\n\t\t\t\tname: string;\n\t\t };\n}\n\n/**\n * options specific to area charts\n */\nexport interface AreaChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the curve of the line\n\t */\n\tcurve?:\n\t\t| string\n\t\t| {\n\t\t\t\tname: string;\n\t\t };\n\t/**\n\t * options to bound the area of the chart\n\t */\n\tbounds?: {\n\t\tupperBoundMapsTo?: string;\n\t\tlowerBoundMapsTo?: string;\n\t};\n}\n\n/**\n * options specific to area charts\n */\nexport interface StackedAreaChartOptions extends ScatterChartOptions {\n\t/**\n\t * options for the curve of the line\n\t */\n\tcurve?:\n\t\t| string\n\t\t| {\n\t\t\t\tname: string;\n\t\t };\n}\n\n/**\n * options specific to world cloud charts\n */\nexport interface WordCloudChartTooltipOptions extends TooltipOptions {\n\t/** the label that shows up by the highlighted word in the tooltip */\n\twordLabel?: string;\n\t/** the label that shows up by the value of the highlighted word in the tooltip */\n\tvalueLabel?: string;\n}\n\nexport interface WorldCloudChartOptions extends BaseChartOptions {\n\twordCloud?: {\n\t\t/** what key in your charting data will the font sizes map to? */\n\t\tfontSizeMapsTo?: string;\n\t\t/** a function (chartSize, data) => {} that'll decide the range of font sizes, e.g. [10, 80] */\n\t\tfontSizeRange?: Function;\n\t\t/** what key in your charting data will the words map to? */\n\t\twordMapsTo?: string;\n\t};\n\t/**\n\t * tooltip configuration\n\t */\n\ttooltip?: WordCloudChartTooltipOptions;\n}\n\n/**\n * options specific to pie charts\n */\nexport interface PieChartOptions extends BaseChartOptions {\n\tpie?: {\n\t\tlabels?: {\n\t\t\tformatter?: Function;\n\t\t\tenabled?: Boolean;\n\t\t};\n\t\talignment?: Alignments;\n\t\t/**\n\t\t * identifier for value key in your charting data\n\t\t * defaults to value\n\t\t */\n\t\tvalueMapsTo?: string;\n\t\tsortFunction?: (a: any, b: any) => number;\n\t};\n}\n\n/**\n * options specific to gauge charts\n */\nexport interface GaugeChartOptions extends BaseChartOptions {\n\tgauge?: {\n\t\tarcWidth?: number;\n\t\tdeltaArrow?: {\n\t\t\tdirection?: ArrowDirections;\n\t\t\tsize?: Function;\n\t\t\tenabled: Boolean;\n\t\t};\n\t\tshowPercentageSymbol?: Boolean;\n\t\tstatus?: Statuses;\n\t\tdeltaFontSize?: Function;\n\t\tnumberSpacing?: number;\n\t\tnumberFormatter?: Function;\n\t\tvalueFontSize?: Function;\n\t\ttype?: GaugeTypes;\n\t\talignment?: Alignments;\n\t};\n}\n\n/**\n * options specific to donut charts\n */\nexport interface DonutChartOptions extends PieChartOptions {\n\tdonut?: {\n\t\tcenter?: {\n\t\t\tlabel?: string;\n\t\t\tnumber?: number;\n\t\t\tnumberFontSize?: Function;\n\t\t\ttitleFontSize?: Function;\n\t\t\ttitleYPosition?: Function;\n\t\t\tnumberFormatter?: Function;\n\t\t};\n\t\talignment?: Alignments;\n\t};\n}\n\nexport interface MeterChartOptions extends BaseChartOptions {\n\tmeter?: {\n\t\tshowLabels?: boolean;\n\t\tproportional?: {\n\t\t\ttotal?: number;\n\t\t\tunit?: string;\n\t\t};\n\t\tpeak?: number;\n\t\tstatus?: {\n\t\t\tranges: Array<{\n\t\t\t\trange: [number, number];\n\t\t\t\tstatus: Statuses;\n\t\t\t}>;\n\t\t};\n\t\theight?: number;\n\t\ttitle?: {\n\t\t\tpercentageIndicator?: {\n\t\t\t\t/**\n\t\t\t\t * rendering of the percentage value relative to the dataset within title\n\t\t\t\t */\n\t\t\t\tenabled?: boolean;\n\t\t\t};\n\t\t};\n\t};\n}\n\nexport interface ProportionalMeterChartOptions extends BaseChartOptions {\n\tmeter?: {\n\t\tproportional?: {\n\t\t\ttotal?: number;\n\t\t\tunit?: string;\n\t\t};\n\t};\n}\n\n/**\n * options specific to radar charts\n */\nexport interface RadarChartOptions extends BaseChartOptions {\n\tradar?: {\n\t\taxes: {\n\t\t\tangle: string;\n\t\t\tvalue: string;\n\t\t};\n\t\talignment?: Alignments;\n\t};\n}\n\n/**\n * options specific to combo charts\n */\nexport interface ComboChartOptions extends AxisChartOptions {\n\tcomboChartTypes: Array<{\n\t\ttype: ChartTypes | any;\n\t\toptions?: object;\n\t\tcorrespondingDatasets: Array<string>;\n\t}>;\n}\n\n/*\n * options specific to treemap charts\n */\nexport interface TreemapChartOptions extends BaseChartOptions {}\n\n/*\n * options specific to tree charts\n */\nexport interface TreeChartOptions extends BaseChartOptions {\n\ttree?: {\n\t\ttype?: TreeTypes;\n\t\trootTitle?: string;\n\t};\n}\n\n/*\n * options specific to circle pack charts\n */\nexport interface CirclePackChartOptions extends BaseChartOptions {\n\tcirclePack?: {\n\t\tcircles: {\n\t\t\tfillOpacity: number;\n\t\t};\n\t\t// depth of nodes to display\n\t\thierachyLevel: number;\n\t\tpadding?: {\n\t\t\touter?: number;\n\t\t\tinner?: number;\n\t\t};\n\t};\n}\n\n/**\n * options specific to Alluvial charts\n */\nexport interface AlluvialChartOptions extends BaseChartOptions {\n\talluvial: {\n\t\tunits?: string;\n\t\t/**\n\t\t * List of nodes to draw\n\t\t */\n\t\tnodes: Array<{\n\t\t\tname: string;\n\t\t\tcategory?: string;\n\t\t}>;\n\t\t/**\n\t\t * Node alignment (Default is center)\n\t\t */\n\t\tnodeAlignment?: Alignments;\n\t\t/**\n\t\t * Set the node padding\n\t\t */\n\t\tnodePadding?: number;\n\t\t/**\n\t\t * Enable single color usage for lines\n\t\t */\n\t\tmonochrome?: boolean;\n\t};\n}\n\n/**\n * options specific to Heatmap charts\n */\nexport interface HeatmapChartOptions extends BaseChartOptions {\n\theatmap: {\n\t\t/**\n\t\t * Divider width state - will default to auto\n\t\t * No cell divider for cell dimensions less than 16\n\t\t */\n\t\tdivider?: {\n\t\t\tstate?: DividerStatus;\n\t\t};\n\t\t/**\n\t\t * customize color legend\n\t\t * enabled by default on select charts\n\t\t */\n\t\tcolorLegend?: {\n\t\t\t/**\n\t\t\t * Text to display beside or on top of the legend\n\t\t\t * Position is determined by text length\n\t\t\t */\n\t\t\ttitle?: string;\n\t\t\ttype: ColorLegendType;\n\t\t};\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"charts.js","sourceRoot":"","sources":["charts.ts"],"names":[],"mappings":"","sourcesContent":["import {\n\tGaugeTypes,\n\tStatuses,\n\tArrowDirections,\n\tAlignments,\n\tChartTypes,\n\tTreeTypes,\n\tDividerStatus,\n\tColorLegendType,\n\tChartTheme,\n} from './enums';\nimport {\n\tLegendOptions,\n\tTooltipOptions,\n\tGridOptions,\n\tAxesOptions,\n\tZoomBarsOptions,\n} from './index';\nimport { BarOptions, StackedBarOptions, ToolbarOptions } from './components';\nimport {\n\tAxisOptions,\n\tBinnedAxisOptions,\n\tTimeScaleOptions,\n} from './axis-scales';\n\n/**\n * Base chart options common to any chart\n */\nexport interface BaseChartOptions {\n\t/**\n\t * Optionally specify a title for the chart\n\t */\n\ttitle?: string;\n\t/**\n\t * boolean to disable animations (enabled by default)\n\t */\n\tanimations?: boolean;\n\t/**\n\t * boolean to prevent the container from resizing\n\t */\n\tresizable?: boolean;\n\t/**\n\t * Optionally specify a width for the chart\n\t */\n\twidth?: string;\n\t/**\n\t * Optionally specify a height for the chart\n\t */\n\theight?: string;\n\t/**\n\t * Optionally specify a theme for the chart\n\t */\n\ttheme?: ChartTheme;\n\t/**\n\t * tooltip configuration\n\t */\n\ttooltip?: TooltipOptions;\n\t/**\n\t * legend configuration\n\t */\n\tlegend?: LegendOptions;\n\t/**\n\t * toolbar configurations\n\t */\n\ttoolbar?: ToolbarOptions;\n\t/**\n\t * Optional function to determine whether is filled based on datasetLabel, label, and/or data\n\t */\n\tgetIsFilled?: (\n\t\tdatasetLabel: any,\n\t\tlabel?: any,\n\t\tdata?: any,\n\t\tdefaultFilled?: boolean\n\t) => boolean;\n\t/**\n\t * Optional function to generate the fill color based on datasetLabel, label, and/or data\n\t */\n\tgetFillColor?: (\n\t\tgroup: string,\n\t\tlabel?: string,\n\t\tdata?: any,\n\t\tdefaultFillColor?: string\n\t) => string;\n\t/**\n\t * Optional function to generate the stroke color based on datasetLabel, label, and/or data\n\t * (note) - not all chart types support the stroke color (e.g. wordcloud)\n\t */\n\tgetStrokeColor?: (\n\t\tgroup: string,\n\t\tlabel?: any,\n\t\tdata?: any,\n\t\tdefaultStrokeColor?: string\n\t) => string;\n\t/**\n\t * stylesheet options\n\t */\n\tstyle?: {\n\t\t/**\n\t\t * optional prefixing string for css classes (defaults to 'cc')\n\t\t */\n\t\tprefix?: string;\n\t};\n\t/**\n\t * options related to charting data\n\t */\n\tdata?: {\n\t\t/**\n\t\t * identifier for data groups\n\t\t */\n\t\tgroupMapsTo?: string;\n\t\t/**\n\t\t * used to simulate data loading in skeleton way\n\t\t */\n\t\tloading?: boolean;\n\t\t/**\n\t\t * options related to pre-selected data groups\n\t\t * Remains empty if every legend item is active or dataset doesn't have the data groups.\n\t\t */\n\t\tselectedGroups?: string[];\n\t};\n\t/**\n\t * options related to color scales\n\t */\n\tcolor?: {\n\t\t/**\n\t\t * e.g. { 'Dataset 1': 'blue' }\n\t\t */\n\t\tscale?: object;\n\t\t/**\n\t\t * use a carbon dataviz preset color palette\n\t\t * put the index (selection of which variant)\n\t\t */\n\t\tpairing?: {\n\t\t\t/**\n\t\t\t * the number of color variants in the palette (defaults to using the number of data groups in the given data)\n\t\t\t */\n\t\t\tnumberOfVariants?: number;\n\t\t\t/**\n\t\t\t * the option number of the color paring\n\t\t\t */\n\t\t\toption?: number;\n\t\t};\n\t\t/*\n\t\t * options related to gradient\n\t\t * e.g. { enabled: true }\n\t\t */\n\t\tgradient?: {\n\t\t\tenabled?: boolean;\n\t\t\t/**\n\t\t\t * hex color array\n\t\t\t * e.g. ['#fff', '#000', ...]\n\t\t\t */\n\t\t\tcolors?: Array<String>;\n\t\t};\n\t};\n}\n\n/**\n * Options common to any chart with an axis\n */\nexport interface AxisChartOptions extends BaseChartOptions {\n\taxes?: AxesOptions<AxisOptions>;\n\tgrid?: GridOptions;\n\ttimeScale?: TimeScaleOptions;\n\t/**\n\t * zoombar configuration\n\t */\n\tzoomBar?: ZoomBarsOptions;\n}\n\n/**\n * Options common to binned charts with an axis\n */\nexport interface BinnedAxisChartOptions extends AxisChartOptions {\n\taxes?: AxesOptions<BinnedAxisOptions>;\n\tgrid?: GridOptions;\n\ttimeScale?: TimeScaleOptions;\n\t/**\n\t * zoombar configuration\n\t */\n\tzoomBar?: ZoomBarsOptions;\n}\n\n/**\n * options specific to boxplot charts\n */\nexport interface BoxplotChartOptions extends AxisChartOptions {}\n\n/**\n * options specific to bar charts\n */\nexport interface BarChartOptions extends AxisChartOptions {\n\tbars?: BarOptions;\n}\n\n/**\n * options specific to stacked bar charts\n */\nexport interface StackedBarChartOptions extends BarChartOptions {\n\tbars?: StackedBarOptions;\n}\n\n/**\n * options specific to scatter charts\n */\nexport interface ScatterChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the points\n\t */\n\tpoints?: {\n\t\t/**\n\t\t * sets the radius of the point\n\t\t */\n\t\tradius: number;\n\t\tfillOpacity?: number;\n\t\tfilled?: boolean;\n\t\tenabled?: boolean;\n\t};\n}\n\n/**\n * options specific to lollipop charts\n */\nexport interface LollipopChartOptions extends ScatterChartOptions {}\n\n/**\n * options specific to bubble charts\n */\nexport interface BubbleChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the individual bubbles\n\t */\n\tbubble?: {\n\t\t/**\n\t\t * the key to lookup in charting data for the bubble radius value\n\t\t */\n\t\tradiusMapsTo?: string;\n\t\t/**\n\t\t * options for what the bubble radius value maps to\n\t\t */\n\t\tradiusLabel?: string;\n\t\t/**\n\t\t * A function that would determine the range of the bubble radius to use\n\t\t * Returns an array with the 1st value being the min and the 2nd value being the max radius\n\t\t */\n\t\tradiusRange?: Function;\n\t\t/**\n\t\t * Opacity of the fills used within each circle\n\t\t */\n\t\tfillOpacity?: number;\n\t\t/**\n\t\t * enabled scatter dot or not\n\t\t */\n\t\tenabled?: boolean;\n\t};\n}\n\n/**\n * options specific to bullet charts\n */\nexport interface BulletChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the individual bullets\n\t */\n\tbullet?: {\n\t\tperformanceAreaTitles?: string[];\n\t};\n}\n\n/**\n * options specific to histogram charts\n */\nexport interface HistogramChartOptions extends AxisChartOptions {\n\t/**\n\t * options related to bins\n\t */\n\tbins?: {\n\t\trangeLabel?: string;\n\t};\n}\n\n/**\n * options specific to line charts\n */\nexport interface LineChartOptions extends ScatterChartOptions {\n\t/**\n\t * options for the curve of the line\n\t */\n\tcurve?: string | { name: string };\n}\n\n/**\n * options specific to area charts\n */\nexport interface AreaChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the curve of the line\n\t */\n\tcurve?: string | { name: string };\n\t/**\n\t * options to bound the area of the chart\n\t */\n\tbounds?: {\n\t\tupperBoundMapsTo?: string;\n\t\tlowerBoundMapsTo?: string;\n\t};\n}\n\n/**\n * options specific to area charts\n */\nexport interface StackedAreaChartOptions extends ScatterChartOptions {\n\t/**\n\t * options for the curve of the line\n\t */\n\tcurve?: string | { name: string };\n}\n\n/**\n * options specific to world cloud charts\n */\nexport interface WordCloudChartTooltipOptions extends TooltipOptions {\n\t/** the label that shows up by the highlighted word in the tooltip */\n\twordLabel?: string;\n\t/** the label that shows up by the value of the highlighted word in the tooltip */\n\tvalueLabel?: string;\n}\n\nexport interface WorldCloudChartOptions extends BaseChartOptions {\n\twordCloud?: {\n\t\t/** what key in your charting data will the font sizes map to? */\n\t\tfontSizeMapsTo?: string;\n\t\t/** a function (chartSize, data) => {} that'll decide the range of font sizes, e.g. [10, 80] */\n\t\tfontSizeRange?: Function;\n\t\t/** what key in your charting data will the words map to? */\n\t\twordMapsTo?: string;\n\t};\n\t/**\n\t * tooltip configuration\n\t */\n\ttooltip?: WordCloudChartTooltipOptions;\n}\n\n/**\n * options specific to pie charts\n */\nexport interface PieChartOptions extends BaseChartOptions {\n\tpie?: {\n\t\tlabels?: {\n\t\t\tformatter?: Function;\n\t\t\tenabled?: Boolean;\n\t\t};\n\t\talignment?: Alignments;\n\t\t/**\n\t\t * identifier for value key in your charting data\n\t\t * defaults to value\n\t\t */\n\t\tvalueMapsTo?: string;\n\t\tsortFunction?: (a: any, b: any) => number;\n\t};\n}\n\n/**\n * options specific to gauge charts\n */\nexport interface GaugeChartOptions extends BaseChartOptions {\n\tgauge?: {\n\t\tarcWidth?: number;\n\t\tdeltaArrow?: {\n\t\t\tdirection?: ArrowDirections;\n\t\t\tsize?: Function;\n\t\t\tenabled: Boolean;\n\t\t};\n\t\tshowPercentageSymbol?: Boolean;\n\t\tstatus?: Statuses;\n\t\tdeltaFontSize?: Function;\n\t\tnumberSpacing?: number;\n\t\tnumberFormatter?: Function;\n\t\tvalueFontSize?: Function;\n\t\ttype?: GaugeTypes;\n\t\talignment?: Alignments;\n\t};\n}\n\n/**\n * options specific to donut charts\n */\nexport interface DonutChartOptions extends PieChartOptions {\n\tdonut?: {\n\t\tcenter?: {\n\t\t\tlabel?: string;\n\t\t\tnumber?: number;\n\t\t\tnumberFontSize?: Function;\n\t\t\ttitleFontSize?: Function;\n\t\t\ttitleYPosition?: Function;\n\t\t\tnumberFormatter?: Function;\n\t\t};\n\t\talignment?: Alignments;\n\t};\n}\n\nexport interface MeterChartOptions extends BaseChartOptions {\n\tmeter?: {\n\t\tshowLabels?: boolean;\n\t\tproportional?: {\n\t\t\ttotal?: number;\n\t\t\tunit?: string;\n\t\t};\n\t\tpeak?: number;\n\t\tstatus?: {\n\t\t\tranges: Array<{\n\t\t\t\trange: [number, number];\n\t\t\t\tstatus: Statuses;\n\t\t\t}>;\n\t\t};\n\t\theight?: number;\n\t\ttitle?: {\n\t\t\tpercentageIndicator?: {\n\t\t\t\t/**\n\t\t\t\t * rendering of the percentage value relative to the dataset within title\n\t\t\t\t */\n\t\t\t\tenabled?: boolean;\n\t\t\t};\n\t\t};\n\t};\n}\n\nexport interface ProportionalMeterChartOptions extends BaseChartOptions {\n\tmeter?: {\n\t\tproportional?: {\n\t\t\ttotal?: number;\n\t\t\tunit?: string;\n\t\t};\n\t};\n}\n\n/**\n * options specific to radar charts\n */\nexport interface RadarChartOptions extends BaseChartOptions {\n\tradar?: {\n\t\taxes: {\n\t\t\tangle: string;\n\t\t\tvalue: string;\n\t\t};\n\t\talignment?: Alignments;\n\t};\n}\n\n/**\n * options specific to combo charts\n */\nexport interface ComboChartOptions extends AxisChartOptions {\n\tcomboChartTypes: Array<{\n\t\ttype: ChartTypes | any;\n\t\toptions?: object;\n\t\tcorrespondingDatasets: Array<string>;\n\t}>;\n}\n\n/*\n * options specific to treemap charts\n */\nexport interface TreemapChartOptions extends BaseChartOptions {}\n\n/*\n * options specific to tree charts\n */\nexport interface TreeChartOptions extends BaseChartOptions {\n\ttree?: {\n\t\ttype?: TreeTypes;\n\t\trootTitle?: string;\n\t};\n}\n\n/*\n * options specific to circle pack charts\n */\nexport interface CirclePackChartOptions extends BaseChartOptions {\n\tcirclePack?: {\n\t\tcircles: {\n\t\t\tfillOpacity: number;\n\t\t};\n\t\t// depth of nodes to display\n\t\thierachyLevel: number;\n\t\tpadding?: {\n\t\t\touter?: number;\n\t\t\tinner?: number;\n\t\t};\n\t};\n}\n\n/**\n * options specific to Alluvial charts\n */\nexport interface AlluvialChartOptions extends BaseChartOptions {\n\talluvial: {\n\t\tunits?: string;\n\t\t/**\n\t\t * List of nodes to draw\n\t\t */\n\t\tnodes: Array<{\n\t\t\tname: string;\n\t\t\tcategory?: string;\n\t\t}>;\n\t\t/**\n\t\t * Node alignment (Default is center)\n\t\t */\n\t\tnodeAlignment?: Alignments;\n\t\t/**\n\t\t * Set the node padding\n\t\t */\n\t\tnodePadding?: number;\n\t\t/**\n\t\t * Enable single color usage for lines\n\t\t */\n\t\tmonochrome?: boolean;\n\t};\n}\n\n/**\n * options specific to Heatmap charts\n */\nexport interface HeatmapChartOptions extends BaseChartOptions {\n\theatmap: {\n\t\t/**\n\t\t * Divider width state - will default to auto\n\t\t * No cell divider for cell dimensions less than 16\n\t\t */\n\t\tdivider?: {\n\t\t\tstate?: DividerStatus;\n\t\t};\n\t\t/**\n\t\t * customize color legend\n\t\t * enabled by default on select charts\n\t\t */\n\t\tcolorLegend?: {\n\t\t\t/**\n\t\t\t * Text to display beside or on top of the legend\n\t\t\t * Position is determined by text length\n\t\t\t */\n\t\t\ttitle?: string;\n\t\t\ttype: ColorLegendType;\n\t\t};\n\t};\n}\n"]}
|
package/interfaces/enums.d.ts
CHANGED
package/interfaces/enums.js
CHANGED
package/interfaces/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["enums.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,UAAU,CAAC;AACvC,MAAM,CAAC,IAAM,MAAM,GAAG,UAAU,CAAC;AAEjC,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACtB,4BAAa,CAAA;IACb,0BAAW,CAAA;AACZ,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,
|
|
1
|
+
{"version":3,"file":"en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,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,0BAAS,CAAA;IACT,8BAAa,CAAA;IACb,4BAAW,CAAA;AACZ,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACrB,iCAAmB,CAAA;IACnB,qCAAuB,CAAA;AACxB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB","sourcesContent":["import * as EventEnums from './events';\nexport const Events = EventEnums;\n\nexport enum RenderTypes {\n\tHTML = 'html',\n\tSVG = 'svg',\n}\n\n/**\n * enum of all supported chart themes\n */\nexport enum ChartTheme {\n\tWHITE = 'white',\n\tG100 = 'g100',\n\tG90 = 'g90',\n\tG10 = 'g10',\n}\n\n/**\n * enum of all color classname types\n */\nexport enum ColorClassNameTypes {\n\tBACKGROUND = 'background',\n\tFILL = 'fill',\n\tSTROKE = 'stroke',\n\tTOOLTIP = 'tooltip',\n}\n\n/**\n * enum of all possible axis positions\n */\nexport enum AxisPositions {\n\tLEFT = 'left',\n\tRIGHT = 'right',\n\tTOP = 'top',\n\tBOTTOM = 'bottom',\n}\n\n/**\n * enum of all possible axis positions\n */\nexport enum ZoomBarTypes {\n\tGRAPH_VIEW = 'graph_view',\n\tSLIDER_VIEW = 'slider_view',\n}\n\n/**\n * enum of all possible truncation types\n */\nexport enum TruncationTypes {\n\tEND_LINE = 'end_line',\n\tMID_LINE = 'mid_line',\n\tFRONT_LINE = 'front_line',\n\tNONE = 'none',\n}\n\n/**\n * enum of all possible cartesian orientations\n * to be used for determining the orientation\n * of graphs being draw over\n * cartesian scales\n */\nexport enum CartesianOrientations {\n\tVERTICAL = 'vertical',\n\tHORIZONTAL = 'horizontal',\n}\n\n/**\n * enum of all possible scale types\n */\nexport enum ScaleTypes {\n\tTIME = 'time',\n\tLINEAR = 'linear',\n\tLOG = 'log',\n\tLABELS = 'labels',\n\tLABELS_RATIO = 'labels-ratio',\n}\n\n/**\n * enum of all possible legend positions\n */\nexport enum LegendPositions {\n\tRIGHT = 'right',\n\tLEFT = 'left',\n\tTOP = 'top',\n\tBOTTOM = 'bottom',\n}\n\n/**\n * enum of all possible alignments\n */\nexport enum Alignments {\n\tLEFT = 'left',\n\tCENTER = 'center',\n\tRIGHT = 'right',\n}\n\n/**\n * enum of all possible legend orientations\n */\nexport enum LegendOrientations {\n\tHORIZONTAL = 'horizontal',\n\tVERTICAL = 'vertical',\n}\n\n/**\n * enum of tree types for the tree chart\n */\nexport enum TreeTypes {\n\tTREE = 'tree',\n\tDENDROGRAM = 'dendrogram',\n}\n\n/**\n * enum of all possible layout directions\n */\nexport enum LayoutDirection {\n\tROW = 'row',\n\tCOLUMN = 'column',\n\tROW_REVERSE = 'row-reverse',\n\tCOLUMN_REVERSE = 'column-reverse',\n}\n\n/**\n * enum of all possible layout growth values\n */\nexport enum LayoutGrowth {\n\tFIXED = 'fixed',\n\tPREFERRED = 'preferred',\n\tSTRETCH = 'stretch',\n}\n\n/**\n * enum of all possible layout align-items values\n */\nexport enum LayoutAlignItems {\n\tCENTER = 'center',\n}\n\n/**\n * enum of all possible callout directions\n */\nexport enum CalloutDirections {\n\tLEFT = 'left',\n\tRIGHT = 'right',\n}\n\n/**\n * enum of all possible skeleton/empty state types\n */\nexport enum Skeletons {\n\tGRID = 'grid',\n\tVERT_OR_HORIZ = 'vertOrHoriz',\n\tPIE = 'pie',\n\tDONUT = 'donut',\n}\n\n/**\n * enum of all possible attributes used to aling text horizontally\n */\nexport enum TextAnchor {\n\tSTART = 'start',\n\tMIDDLE = 'middle',\n\tEND = 'end',\n}\n\n/**\n * enum of all possible attributes used to aling text vertically\n */\nexport enum DominantBaseline {\n\tBASELINE = 'baseline',\n\tMIDDLE = 'middle',\n\tHANGING = 'hanging',\n}\n\nexport enum GaugeTypes {\n\tSEMI = 'semi',\n\tFULL = 'full',\n}\n\n/**\n * enum of all possible callout directions\n */\nexport enum ArrowDirections {\n\tUP = 'up',\n\tDOWN = 'down',\n}\n\n/**\n * enum of carbon statuses\n */\nexport enum Statuses {\n\tSUCCESS = 'success',\n\tWARNING = 'warning',\n\tDANGER = 'danger',\n}\n\n/**\n * enum of axis ticks rotation\n */\nexport enum TickRotations {\n\tALWAYS = 'always',\n\tAUTO = 'auto',\n\tNEVER = 'never',\n}\n\n/**\n * enum of chartTypes that work with combo chart\n */\nexport enum ChartTypes {\n\tSCATTER = 'scatter',\n\tLINE = 'line',\n\tSIMPLE_BAR = 'simple-bar',\n\tSTACKED_BAR = 'stacked-bar',\n\tGROUPED_BAR = 'grouped-bar',\n\tAREA = 'area',\n\tSTACKED_AREA = 'stacked-area',\n}\n\n/**\n * enum of supported toolbar control types\n */\nexport enum ToolbarControlTypes {\n\tEXPORT_CSV = 'Export as CSV',\n\tEXPORT_PNG = 'Export as PNG',\n\tEXPORT_JPG = 'Export as JPG',\n\tZOOM_IN = 'Zoom in',\n\tZOOM_OUT = 'Zoom out',\n\tRESET_ZOOM = 'Reset zoom',\n\tMAKE_FULLSCREEN = 'Make fullscreen',\n\tSHOW_AS_DATATABLE = 'Show as data-table',\n\tCUSTOM = 'Custom',\n}\n\n/**\n * enum of title orientations for _vertical axes_\n */\nexport enum AxisTitleOrientations {\n\tLEFT = 'left',\n\tRIGHT = 'right',\n}\n\n/**\n * enum of legend item type\n */\nexport enum LegendItemType {\n\tCHECKBOX = 'checkbox',\n\tRADIUS = 'radius',\n\tAREA = 'area',\n\tSIZE = 'size',\n\tLINE = 'line',\n\tQUARTILE = 'quartile',\n\tZOOM = 'zoom',\n}\n\n/**\n * enum of color legend types\n */\nexport enum ColorLegendType {\n\tLINEAR = 'linear',\n\tQUANTIZE = 'quantize',\n}\n\n/**\n * enum of divider status for heatmap\n */\nexport enum DividerStatus {\n\tON = 'on',\n\tAUTO = 'auto',\n\tOFF = 'off',\n}\n\n/**\n * enum of axis flavor\n */\nexport enum AxisFlavor {\n\tDEFAULT = 'default',\n\tHOVERABLE = 'hoverable',\n}\n"]}
|
package/package.json
CHANGED
|
@@ -198,12 +198,10 @@ var DOMUtils = /** @class */ (function (_super) {
|
|
|
198
198
|
};
|
|
199
199
|
DOMUtils.prototype.styleHolderElement = function () {
|
|
200
200
|
var holderElement = this.getHolder();
|
|
201
|
-
// Add class to chart holder
|
|
202
|
-
select(this.getHolder()).classed(carbonPrefix + "--chart-holder", true);
|
|
203
201
|
// In order for resize events to not clash with these updates
|
|
204
202
|
// We'll check if the width & height values passed in options
|
|
205
203
|
// Have changed, before setting them to the holder
|
|
206
|
-
var _a = this.model.getOptions(), width = _a.width, height = _a.height;
|
|
204
|
+
var _a = this.model.getOptions(), width = _a.width, height = _a.height, theme = _a.theme;
|
|
207
205
|
if (width !== this.width) {
|
|
208
206
|
// Apply formatted width attribute to chart
|
|
209
207
|
holderElement.style.width = width;
|
|
@@ -214,6 +212,10 @@ var DOMUtils = /** @class */ (function (_super) {
|
|
|
214
212
|
holderElement.style.height = height;
|
|
215
213
|
this.height = height;
|
|
216
214
|
}
|
|
215
|
+
// Add class to chart holder
|
|
216
|
+
select(this.getHolder())
|
|
217
|
+
.classed(carbonPrefix + "--chart-holder", true)
|
|
218
|
+
.attr('data-carbon-theme', theme);
|
|
217
219
|
};
|
|
218
220
|
DOMUtils.prototype.getHolder = function () {
|
|
219
221
|
return this.model.get('holder');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-utils.js","sourceRoot":"","sources":["dom-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,aAAa;AACb,OAAO,EAAE,MAAM,EAAa,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,yCAAyC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE,OAAO;AACP,OA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QAAQ,CAAC,UAAC,OAAO,EAAE,QAAQ;YACvD,IAAI,CAAC,MAAM,EAAE;gBACZ,OAAO;aACP;YAED,IACC,IAAI,CAAC,GAAG,CAAC,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC;gBACjD,IAAI,CAAC,GAAG,CAAC,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,EAClD;gBACD,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC;gBACpC,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC;gBAEtC,KAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;aACxD;QACF,CAAC,EAAE,IAAI,CAAC,CAAC;QAET,kDAAkD;QAClD,IAAM,cAAc,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;QAC1D,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IACF,eAAC;AAAD,CAAC,AAheD,CAA8B,OAAO,GAgepC","sourcesContent":["// Internal Imports\nimport { Service } from '../service';\nimport { Events } from './../../interfaces';\n\n// D3 Imports\nimport { select, Selection } from 'd3-selection';\nimport { Tools } from '../../tools';\n\n// import the settings for the css prefix\nimport { carbonPrefix } from '../../configuration-non-customizable';\n\n// MISC\nimport ResizeObserver from 'resize-observer-polyfill';\n\nimport domToImage from './dom-to-image';\n\nconst CSS_VERIFIER_ELEMENT_CLASSNAME = 'DONT_STYLE_ME_css_styles_verifier';\n\ninterface getSVGElementSizeOptions {\n\tuseAttrs?: boolean;\n\tuseClientDimensions?: boolean;\n\tuseBBox?: boolean;\n\tuseBoundingRect?: boolean;\n}\n\nexport class DOMUtils extends Service {\n\t// Initialized in init\n\tprivate chartID;\n\n\tconstructor(model: any, services: any) {\n\t\tsuper(model, services);\n\t}\n\n\tstatic getHTMLElementSize(element: HTMLElement) {\n\t\treturn {\n\t\t\twidth: element.clientWidth,\n\t\t\theight: element.clientHeight,\n\t\t};\n\t}\n\n\tstatic getSVGElementSize(\n\t\tsvgSelector: Selection<any, any, any, any>,\n\t\toptions: getSVGElementSizeOptions = {\n\t\t\tuseAttrs: false,\n\t\t\tuseClientDimensions: false,\n\t\t\tuseBBox: false,\n\t\t\tuseBoundingRect: false,\n\t\t}\n\t) {\n\t\tif (!svgSelector.attr) {\n\t\t\tsvgSelector = select(svgSelector as any);\n\t\t}\n\n\t\tconst finalDimensions = {\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t};\n\n\t\tconst validateAndSetDimensions = (dimensions) => {\n\t\t\tif (dimensions) {\n\t\t\t\tObject.keys(finalDimensions).forEach((dimensionKey) => {\n\t\t\t\t\tif (dimensions[dimensionKey]) {\n\t\t\t\t\t\tconst dimension = dimensions[dimensionKey];\n\t\t\t\t\t\tconst dimensionNumber = parseFloat(dimension);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdimension &&\n\t\t\t\t\t\t\tdimensionNumber > finalDimensions[dimensionKey] &&\n\t\t\t\t\t\t\t('' + dimension).indexOf('%') === -1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tfinalDimensions[dimensionKey] = dimensionNumber;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tconst attrDimensions = {\n\t\t\twidth: svgSelector.attr('width'),\n\t\t\theight: svgSelector.attr('height'),\n\t\t};\n\n\t\tlet bbox, bboxDimensions, boundingRect, boundingRectDimensions;\n\t\t// In many versions of Firefox\n\t\t// getBBox will cause an \"NSFailure\" error\n\t\ttry {\n\t\t\tbbox = svgSelector.node().getBBox();\n\t\t\tbboxDimensions = {\n\t\t\t\twidth: bbox.width,\n\t\t\t\theight: bbox.height,\n\t\t\t};\n\t\t} catch (e) {}\n\n\t\ttry {\n\t\t\tboundingRect = svgSelector.node().getBoundingClientRect();\n\t\t\tboundingRectDimensions = {\n\t\t\t\twidth: boundingRect.width,\n\t\t\t\theight: boundingRect.height,\n\t\t\t};\n\t\t} catch (e) {}\n\n\t\tconst clientDimensions = {\n\t\t\twidth: svgSelector.node().clientWidth,\n\t\t\theight: svgSelector.node().clientHeight,\n\t\t};\n\n\t\t// If both attribute values are numbers\n\t\t// And not percentages or NaN\n\t\tif (options) {\n\t\t\tif (options.useAttrs) {\n\t\t\t\tvalidateAndSetDimensions(attrDimensions);\n\n\t\t\t\tif (finalDimensions.width > 0 && finalDimensions.height > 0) {\n\t\t\t\t\treturn finalDimensions;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options.useClientDimensions) {\n\t\t\t\tvalidateAndSetDimensions(clientDimensions);\n\n\t\t\t\tif (finalDimensions.width > 0 && finalDimensions.height > 0) {\n\t\t\t\t\treturn clientDimensions;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options.useBBox) {\n\t\t\t\tvalidateAndSetDimensions(bboxDimensions);\n\n\t\t\t\tif (finalDimensions.width > 0 && finalDimensions.height > 0) {\n\t\t\t\t\treturn bboxDimensions;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options.useBoundingRect) {\n\t\t\t\tvalidateAndSetDimensions(boundingRectDimensions);\n\n\t\t\t\tif (finalDimensions.width > 0 && finalDimensions.height > 0) {\n\t\t\t\t\treturn boundingRectDimensions;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst nativeDimensions = {\n\t\t\t\twidth: Tools.getProperty(\n\t\t\t\t\tsvgSelector.node(),\n\t\t\t\t\t'width',\n\t\t\t\t\t'baseVal',\n\t\t\t\t\t'value'\n\t\t\t\t),\n\t\t\t\theight: Tools.getProperty(\n\t\t\t\t\tsvgSelector.node(),\n\t\t\t\t\t'height',\n\t\t\t\t\t'baseVal',\n\t\t\t\t\t'value'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tvalidateAndSetDimensions(nativeDimensions);\n\t\t} catch (e) {\n\t\t\tvalidateAndSetDimensions(clientDimensions);\n\t\t\tvalidateAndSetDimensions(bboxDimensions);\n\t\t\tvalidateAndSetDimensions(attrDimensions);\n\t\t}\n\n\t\treturn finalDimensions;\n\t}\n\n\tstatic appendOrSelect(parent, query) {\n\t\tconst selection = parent.select(`${query}`);\n\n\t\tif (selection.empty()) {\n\t\t\t// see if there is an id\n\t\t\tlet querySections = query.split('#');\n\t\t\tlet elementToAppend;\n\t\t\tlet id;\n\t\t\t// if there is an id\n\t\t\tif (querySections.length === 2) {\n\t\t\t\t// take out the element to append\n\t\t\t\telementToAppend = querySections[0];\n\t\t\t\t// split it by classes\n\t\t\t\tquerySections = querySections[1].split('.');\n\t\t\t\t// the first string is the id\n\t\t\t\tid = querySections[0];\n\t\t\t} else {\n\t\t\t\tquerySections = query.split('.');\n\t\t\t\telementToAppend = querySections[0];\n\t\t\t}\n\n\t\t\treturn parent\n\t\t\t\t.append(elementToAppend)\n\t\t\t\t.attr('id', id)\n\t\t\t\t.attr('class', querySections.slice(1).join(' '));\n\t\t}\n\n\t\treturn selection;\n\t}\n\n\tprotected mainContainer: HTMLElement;\n\tprotected width: string;\n\tprotected height: string;\n\n\tinit() {\n\t\t// Add width & height to the chart holder if necessary, and add a classname\n\t\tthis.styleHolderElement();\n\n\t\t// Initialize chart ID\n\t\tthis.initializeID();\n\n\t\tthis.addMainContainer();\n\t\tthis.verifyCSSStylesBeingApplied();\n\n\t\tif (this.model.getOptions().resizable) {\n\t\t\tthis.addResizeListener();\n\t\t}\n\n\t\tthis.addHolderListeners();\n\n\t\tthis.handleFullscreenChange();\n\t}\n\n\tgetChartID() {\n\t\treturn this.chartID;\n\t}\n\n\tgenerateElementIDString(originalID) {\n\t\treturn `chart-${this.chartID}-${originalID}`;\n\t}\n\n\tprivate initializeID() {\n\t\tthis.chartID = Math.floor(\n\t\t\t(1 + Math.random()) * 0x1000000000000\n\t\t).toString(16);\n\t}\n\n\taddMainContainer() {\n\t\tconst options = this.model.getOptions();\n\t\tconst chartsprefix = Tools.getProperty(options, 'style', 'prefix');\n\n\t\tconst mainContainer = select(this.getHolder())\n\t\t\t.append('div')\n\t\t\t.classed(`${carbonPrefix}--${chartsprefix}--chart-wrapper`, true)\n\t\t\t.attr('id', `chart-${this.getChartID()}`)\n\t\t\t.style('height', '100%')\n\t\t\t.style('width', '100%');\n\n\t\tmainContainer.append('g').attr('class', CSS_VERIFIER_ELEMENT_CLASSNAME);\n\n\t\tthis.mainContainer = mainContainer.node();\n\t}\n\n\tupdate() {\n\t\tthis.styleHolderElement();\n\t}\n\n\tstyleHolderElement() {\n\t\tconst holderElement = this.getHolder() as HTMLElement;\n\n\t\t// Add class to chart holder\n\t\tselect(this.getHolder()).classed(`${carbonPrefix}--chart-holder`, true);\n\n\t\t// In order for resize events to not clash with these updates\n\t\t// We'll check if the width & height values passed in options\n\t\t// Have changed, before setting them to the holder\n\t\tconst { width, height } = this.model.getOptions();\n\t\tif (width !== this.width) {\n\t\t\t// Apply formatted width attribute to chart\n\t\t\tholderElement.style.width = width;\n\n\t\t\tthis.width = width;\n\t\t}\n\n\t\tif (height !== this.height) {\n\t\t\t// Apply formatted width attribute to chart\n\t\t\tholderElement.style.height = height;\n\n\t\t\tthis.height = height;\n\t\t}\n\t}\n\n\tgetHolder() {\n\t\treturn this.model.get('holder');\n\t}\n\n\texportToJPG() {\n\t\tconst self = this;\n\n\t\tconst holder = this.getHolder();\n\t\tconst holderSelection = select(holder);\n\t\tholderSelection.classed('filled', true);\n\n\t\tdomToImage\n\t\t\t.toJpeg(this.getMainContainer(), {\n\t\t\t\tbgcolor:\n\t\t\t\t\ttypeof window !== 'undefined'\n\t\t\t\t\t\t? window\n\t\t\t\t\t\t\t\t.getComputedStyle(holder)\n\t\t\t\t\t\t\t\t.getPropertyValue('background-color')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tquality: 1,\n\t\t\t\t// Remove the toolbar\n\t\t\t\tfilter: (node) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.classList &&\n\t\t\t\t\t\tnode.classList.contains('cds--cc--toolbar')\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t})\n\t\t\t.then(function (dataUrl) {\n\t\t\t\tself.services.files.downloadImage(dataUrl, 'myChart.jpg');\n\t\t\t\tholderSelection.classed('filled', false);\n\t\t\t});\n\t}\n\n\texportToPNG() {\n\t\tconst self = this;\n\n\t\tconst holder = this.getHolder();\n\t\tconst holderSelection = select(holder);\n\t\tholderSelection.classed('filled', true);\n\n\t\tdomToImage\n\t\t\t.toPng(this.getMainContainer(), {\n\t\t\t\tbgcolor:\n\t\t\t\t\ttypeof window !== 'undefined'\n\t\t\t\t\t\t? window\n\t\t\t\t\t\t\t\t.getComputedStyle(holder)\n\t\t\t\t\t\t\t\t.getPropertyValue('background-color')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tquality: 1,\n\t\t\t\t// Remove the toolbar\n\t\t\t\tfilter: (node) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.classList &&\n\t\t\t\t\t\tnode.classList.contains('cds--cc--toolbar')\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t})\n\t\t\t.then(function (dataUrl) {\n\t\t\t\tself.services.files.downloadImage(dataUrl, 'myChart.png');\n\t\t\t\tholderSelection.classed('filled', false);\n\t\t\t})\n\t\t\t.catch(function (error) {\n\t\t\t\tconsole.error('oops, something went wrong!', error);\n\t\t\t});\n\t}\n\n\ttoggleFullscreen() {\n\t\tconst holder = this.getHolder();\n\t\tconst holderSelection = select(holder);\n\n\t\tconst isFullScreen = holderSelection.classed('fullscreen');\n\n\t\tif (\n\t\t\tisFullScreen &&\n\t\t\t(document.fullscreenElement ||\n\t\t\t\tdocument['webkitFullscreenElement'] ||\n\t\t\t\tdocument['mozFullScreenElement'] ||\n\t\t\t\tdocument['msFullscreenElement'])\n\t\t) {\n\t\t\t// Call the correct function depending on the browser\n\t\t\tif (document.exitFullscreen) {\n\t\t\t\tdocument.exitFullscreen();\n\t\t\t} else if (document['webkitExitFullscreen']) {\n\t\t\t\tdocument['webkitExitFullscreen']();\n\t\t\t} else if (document['mozCancelFullScreen']) {\n\t\t\t\tdocument['mozCancelFullScreen']();\n\t\t\t} else if (document['msExitFullscreen']) {\n\t\t\t\tdocument['msExitFullscreen']();\n\t\t\t}\n\t\t} else {\n\t\t\t// Call the correct function depending on the browser\n\t\t\tif (holder.requestFullscreen) {\n\t\t\t\tholder.requestFullscreen();\n\t\t\t} else if (holder.webkitRequestFullscreen) {\n\t\t\t\tholder.webkitRequestFullscreen();\n\t\t\t} else if (holder.mozRequestFullScreen) {\n\t\t\t\tholder.mozRequestFullScreen();\n\t\t\t} else if (holder.msRequestFullscreen) {\n\t\t\t\tholder.msRequestFullscreen();\n\t\t\t}\n\t\t}\n\t}\n\n\thandleFullscreenChange() {\n\t\tdocument.addEventListener('fullscreenchange', () => {\n\t\t\tconst holderSelection = select(this.getHolder());\n\t\t\tconst isFullScreen = holderSelection.classed('fullscreen');\n\n\t\t\t// Toggle the `fullscreen` classname\n\t\t\tholderSelection.classed('fullscreen', !isFullScreen);\n\t\t});\n\t}\n\n\tverifyCSSStylesBeingApplied() {\n\t\t// setTimeout is needed here since in `addSVGElement()` we're appending the\n\t\t// CSS verifier element, and need to allow some time for it to become available\n\t\t// in the DOM\n\t\tsetTimeout(() => {\n\t\t\tconst cssVerifierElement = select(this.mainContainer)\n\t\t\t\t.select(`g.${CSS_VERIFIER_ELEMENT_CLASSNAME}`)\n\t\t\t\t.node();\n\t\t\tconst computedStyles = getComputedStyle(cssVerifierElement as any);\n\t\t\tif (\n\t\t\t\tcomputedStyles.getPropertyValue('overflow') !== 'hidden' ||\n\t\t\t\tcomputedStyles.getPropertyValue('opacity') !== '0'\n\t\t\t) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Missing CSS styles for Carbon Charts. Please read the Carbon Charts getting started guide.'\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t}\n\n\tsetSVGMaxHeight() {\n\t\t// if there is a set height on the holder, leave the chart svg height at 100%\n\t\tif (!this.model.getOptions().height) {\n\t\t\tconst { height: chartHeight } = DOMUtils.getSVGElementSize(\n\t\t\t\tselect(this.mainContainer),\n\t\t\t\t{ useBBox: true }\n\t\t\t);\n\t\t\tconst chartSVGSelector = select(this.mainContainer).attr('class');\n\t\t\tconst children = select(this.mainContainer).selectAll(\n\t\t\t\t`.${chartSVGSelector} > svg`\n\t\t\t);\n\n\t\t\t// get the height of the children SVGs (spacers, titles, etc)\n\t\t\tlet childrenHeight = 0;\n\t\t\tchildren.nodes().forEach(function (childSVG) {\n\t\t\t\tchildrenHeight += Number(\n\t\t\t\t\tDOMUtils.getSVGElementSize(select(childSVG), {\n\t\t\t\t\t\tuseBBox: true,\n\t\t\t\t\t}).height\n\t\t\t\t);\n\t\t\t});\n\n\t\t\t// set the chart svg height to the children height\n\t\t\t// forcing the chart not to take up any more space than it requires\n\t\t\tchildrenHeight <= chartHeight\n\t\t\t\t? select(this.mainContainer).attr('height', childrenHeight)\n\t\t\t\t: select(this.mainContainer).attr('height', '100%');\n\t\t}\n\t}\n\n\tgetMainContainer() {\n\t\treturn this.mainContainer;\n\t}\n\n\taddHolderListeners() {\n\t\tconst holder = this.getHolder();\n\n\t\tif (!holder) {\n\t\t\treturn;\n\t\t}\n\n\t\tselect(holder)\n\t\t\t.on('mouseover', () => {\n\t\t\t\t// Dispatch event\n\t\t\t\tthis.services.events.dispatchEvent(Events.Chart.MOUSEOVER);\n\t\t\t})\n\t\t\t.on('mouseout', () => {\n\t\t\t\t// Dispatch event\n\t\t\t\tthis.services.events.dispatchEvent(Events.Chart.MOUSEOUT);\n\t\t\t});\n\t}\n\n\taddResizeListener() {\n\t\tconst holder = this.getHolder();\n\n\t\tif (!holder) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Grab current dimensions of the chart holder\n\t\tlet containerWidth = holder.clientWidth;\n\t\tlet containerHeight = holder.clientHeight;\n\n\t\t// The resize callback function\n\t\tconst resizeCallback = Tools.debounce((entries, observer) => {\n\t\t\tif (!holder) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tMath.abs(containerWidth - holder.clientWidth) > 1 ||\n\t\t\t\tMath.abs(containerHeight - holder.clientHeight) > 1\n\t\t\t) {\n\t\t\t\tcontainerWidth = holder.clientWidth;\n\t\t\t\tcontainerHeight = holder.clientHeight;\n\n\t\t\t\tthis.services.events.dispatchEvent(Events.Chart.RESIZE);\n\t\t\t}\n\t\t}, 12.5);\n\n\t\t// Observe the behaviour of resizing on the holder\n\t\tconst resizeObserver = new ResizeObserver(resizeCallback);\n\t\tresizeObserver.observe(holder);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dom-utils.js","sourceRoot":"","sources":["dom-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,aAAa;AACb,OAAO,EAAE,MAAM,EAAa,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,yCAAyC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE,OAAO;AACP,OAAO,cAAc,MAAM,0BAA0B,CAAC;AAEtD,OAAO,UAAU,MAAM,gBAAgB,CAAC;AAExC,IAAM,8BAA8B,GAAG,mCAAmC,CAAC;AAS3E;IAA8B,4BAAO;IAIpC,kBAAY,KAAU,EAAE,QAAa;eACpC,kBAAM,KAAK,EAAE,QAAQ,CAAC;IACvB,CAAC;IAEM,2BAAkB,GAAzB,UAA0B,OAAoB;QAC7C,OAAO;YACN,KAAK,EAAE,OAAO,CAAC,WAAW;YAC1B,MAAM,EAAE,OAAO,CAAC,YAAY;SAC5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,WAAW,CAAC;gBACpC,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC;gBAEtC,KAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;aACxD;QACF,CAAC,EAAE,IAAI,CAAC,CAAC;QAET,kDAAkD;QAClD,IAAM,cAAc,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;QAC1D,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IACF,eAAC;AAAD,CAAC,AAleD,CAA8B,OAAO,GAkepC","sourcesContent":["// Internal Imports\nimport { Service } from '../service';\nimport { Events } from './../../interfaces';\n\n// D3 Imports\nimport { select, Selection } from 'd3-selection';\nimport { Tools } from '../../tools';\n\n// import the settings for the css prefix\nimport { carbonPrefix } from '../../configuration-non-customizable';\n\n// MISC\nimport ResizeObserver from 'resize-observer-polyfill';\n\nimport domToImage from './dom-to-image';\n\nconst CSS_VERIFIER_ELEMENT_CLASSNAME = 'DONT_STYLE_ME_css_styles_verifier';\n\ninterface getSVGElementSizeOptions {\n\tuseAttrs?: boolean;\n\tuseClientDimensions?: boolean;\n\tuseBBox?: boolean;\n\tuseBoundingRect?: boolean;\n}\n\nexport class DOMUtils extends Service {\n\t// Initialized in init\n\tprivate chartID;\n\n\tconstructor(model: any, services: any) {\n\t\tsuper(model, services);\n\t}\n\n\tstatic getHTMLElementSize(element: HTMLElement) {\n\t\treturn {\n\t\t\twidth: element.clientWidth,\n\t\t\theight: element.clientHeight,\n\t\t};\n\t}\n\n\tstatic getSVGElementSize(\n\t\tsvgSelector: Selection<any, any, any, any>,\n\t\toptions: getSVGElementSizeOptions = {\n\t\t\tuseAttrs: false,\n\t\t\tuseClientDimensions: false,\n\t\t\tuseBBox: false,\n\t\t\tuseBoundingRect: false,\n\t\t}\n\t) {\n\t\tif (!svgSelector.attr) {\n\t\t\tsvgSelector = select(svgSelector as any);\n\t\t}\n\n\t\tconst finalDimensions = {\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t};\n\n\t\tconst validateAndSetDimensions = (dimensions) => {\n\t\t\tif (dimensions) {\n\t\t\t\tObject.keys(finalDimensions).forEach((dimensionKey) => {\n\t\t\t\t\tif (dimensions[dimensionKey]) {\n\t\t\t\t\t\tconst dimension = dimensions[dimensionKey];\n\t\t\t\t\t\tconst dimensionNumber = parseFloat(dimension);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdimension &&\n\t\t\t\t\t\t\tdimensionNumber > finalDimensions[dimensionKey] &&\n\t\t\t\t\t\t\t('' + dimension).indexOf('%') === -1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tfinalDimensions[dimensionKey] = dimensionNumber;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tconst attrDimensions = {\n\t\t\twidth: svgSelector.attr('width'),\n\t\t\theight: svgSelector.attr('height'),\n\t\t};\n\n\t\tlet bbox, bboxDimensions, boundingRect, boundingRectDimensions;\n\t\t// In many versions of Firefox\n\t\t// getBBox will cause an \"NSFailure\" error\n\t\ttry {\n\t\t\tbbox = svgSelector.node().getBBox();\n\t\t\tbboxDimensions = {\n\t\t\t\twidth: bbox.width,\n\t\t\t\theight: bbox.height,\n\t\t\t};\n\t\t} catch (e) {}\n\n\t\ttry {\n\t\t\tboundingRect = svgSelector.node().getBoundingClientRect();\n\t\t\tboundingRectDimensions = {\n\t\t\t\twidth: boundingRect.width,\n\t\t\t\theight: boundingRect.height,\n\t\t\t};\n\t\t} catch (e) {}\n\n\t\tconst clientDimensions = {\n\t\t\twidth: svgSelector.node().clientWidth,\n\t\t\theight: svgSelector.node().clientHeight,\n\t\t};\n\n\t\t// If both attribute values are numbers\n\t\t// And not percentages or NaN\n\t\tif (options) {\n\t\t\tif (options.useAttrs) {\n\t\t\t\tvalidateAndSetDimensions(attrDimensions);\n\n\t\t\t\tif (finalDimensions.width > 0 && finalDimensions.height > 0) {\n\t\t\t\t\treturn finalDimensions;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options.useClientDimensions) {\n\t\t\t\tvalidateAndSetDimensions(clientDimensions);\n\n\t\t\t\tif (finalDimensions.width > 0 && finalDimensions.height > 0) {\n\t\t\t\t\treturn clientDimensions;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options.useBBox) {\n\t\t\t\tvalidateAndSetDimensions(bboxDimensions);\n\n\t\t\t\tif (finalDimensions.width > 0 && finalDimensions.height > 0) {\n\t\t\t\t\treturn bboxDimensions;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options.useBoundingRect) {\n\t\t\t\tvalidateAndSetDimensions(boundingRectDimensions);\n\n\t\t\t\tif (finalDimensions.width > 0 && finalDimensions.height > 0) {\n\t\t\t\t\treturn boundingRectDimensions;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst nativeDimensions = {\n\t\t\t\twidth: Tools.getProperty(\n\t\t\t\t\tsvgSelector.node(),\n\t\t\t\t\t'width',\n\t\t\t\t\t'baseVal',\n\t\t\t\t\t'value'\n\t\t\t\t),\n\t\t\t\theight: Tools.getProperty(\n\t\t\t\t\tsvgSelector.node(),\n\t\t\t\t\t'height',\n\t\t\t\t\t'baseVal',\n\t\t\t\t\t'value'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tvalidateAndSetDimensions(nativeDimensions);\n\t\t} catch (e) {\n\t\t\tvalidateAndSetDimensions(clientDimensions);\n\t\t\tvalidateAndSetDimensions(bboxDimensions);\n\t\t\tvalidateAndSetDimensions(attrDimensions);\n\t\t}\n\n\t\treturn finalDimensions;\n\t}\n\n\tstatic appendOrSelect(parent, query) {\n\t\tconst selection = parent.select(`${query}`);\n\n\t\tif (selection.empty()) {\n\t\t\t// see if there is an id\n\t\t\tlet querySections = query.split('#');\n\t\t\tlet elementToAppend;\n\t\t\tlet id;\n\t\t\t// if there is an id\n\t\t\tif (querySections.length === 2) {\n\t\t\t\t// take out the element to append\n\t\t\t\telementToAppend = querySections[0];\n\t\t\t\t// split it by classes\n\t\t\t\tquerySections = querySections[1].split('.');\n\t\t\t\t// the first string is the id\n\t\t\t\tid = querySections[0];\n\t\t\t} else {\n\t\t\t\tquerySections = query.split('.');\n\t\t\t\telementToAppend = querySections[0];\n\t\t\t}\n\n\t\t\treturn parent\n\t\t\t\t.append(elementToAppend)\n\t\t\t\t.attr('id', id)\n\t\t\t\t.attr('class', querySections.slice(1).join(' '));\n\t\t}\n\n\t\treturn selection;\n\t}\n\n\tprotected mainContainer: HTMLElement;\n\tprotected width: string;\n\tprotected height: string;\n\n\tinit() {\n\t\t// Add width & height to the chart holder if necessary, and add a classname\n\t\tthis.styleHolderElement();\n\n\t\t// Initialize chart ID\n\t\tthis.initializeID();\n\n\t\tthis.addMainContainer();\n\t\tthis.verifyCSSStylesBeingApplied();\n\n\t\tif (this.model.getOptions().resizable) {\n\t\t\tthis.addResizeListener();\n\t\t}\n\n\t\tthis.addHolderListeners();\n\n\t\tthis.handleFullscreenChange();\n\t}\n\n\tgetChartID() {\n\t\treturn this.chartID;\n\t}\n\n\tgenerateElementIDString(originalID) {\n\t\treturn `chart-${this.chartID}-${originalID}`;\n\t}\n\n\tprivate initializeID() {\n\t\tthis.chartID = Math.floor(\n\t\t\t(1 + Math.random()) * 0x1000000000000\n\t\t).toString(16);\n\t}\n\n\taddMainContainer() {\n\t\tconst options = this.model.getOptions();\n\t\tconst chartsprefix = Tools.getProperty(options, 'style', 'prefix');\n\n\t\tconst mainContainer = select(this.getHolder())\n\t\t\t.append('div')\n\t\t\t.classed(`${carbonPrefix}--${chartsprefix}--chart-wrapper`, true)\n\t\t\t.attr('id', `chart-${this.getChartID()}`)\n\t\t\t.style('height', '100%')\n\t\t\t.style('width', '100%');\n\n\t\tmainContainer.append('g').attr('class', CSS_VERIFIER_ELEMENT_CLASSNAME);\n\n\t\tthis.mainContainer = mainContainer.node();\n\t}\n\n\tupdate() {\n\t\tthis.styleHolderElement();\n\t}\n\n\tstyleHolderElement() {\n\t\tconst holderElement = this.getHolder() as HTMLElement;\n\n\t\t// In order for resize events to not clash with these updates\n\t\t// We'll check if the width & height values passed in options\n\t\t// Have changed, before setting them to the holder\n\t\tconst { width, height, theme } = this.model.getOptions();\n\t\tif (width !== this.width) {\n\t\t\t// Apply formatted width attribute to chart\n\t\t\tholderElement.style.width = width;\n\n\t\t\tthis.width = width;\n\t\t}\n\n\t\tif (height !== this.height) {\n\t\t\t// Apply formatted width attribute to chart\n\t\t\tholderElement.style.height = height;\n\n\t\t\tthis.height = height;\n\t\t}\n\n\t\t// Add class to chart holder\n\t\tselect(this.getHolder())\n\t\t\t.classed(`${carbonPrefix}--chart-holder`, true)\n\t\t\t.attr('data-carbon-theme', theme);\n\t}\n\n\tgetHolder() {\n\t\treturn this.model.get('holder');\n\t}\n\n\texportToJPG() {\n\t\tconst self = this;\n\n\t\tconst holder = this.getHolder();\n\t\tconst holderSelection = select(holder);\n\t\tholderSelection.classed('filled', true);\n\n\t\tdomToImage\n\t\t\t.toJpeg(this.getMainContainer(), {\n\t\t\t\tbgcolor:\n\t\t\t\t\ttypeof window !== 'undefined'\n\t\t\t\t\t\t? window\n\t\t\t\t\t\t\t\t.getComputedStyle(holder)\n\t\t\t\t\t\t\t\t.getPropertyValue('background-color')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tquality: 1,\n\t\t\t\t// Remove the toolbar\n\t\t\t\tfilter: (node) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.classList &&\n\t\t\t\t\t\tnode.classList.contains('cds--cc--toolbar')\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t})\n\t\t\t.then(function (dataUrl) {\n\t\t\t\tself.services.files.downloadImage(dataUrl, 'myChart.jpg');\n\t\t\t\tholderSelection.classed('filled', false);\n\t\t\t});\n\t}\n\n\texportToPNG() {\n\t\tconst self = this;\n\n\t\tconst holder = this.getHolder();\n\t\tconst holderSelection = select(holder);\n\t\tholderSelection.classed('filled', true);\n\n\t\tdomToImage\n\t\t\t.toPng(this.getMainContainer(), {\n\t\t\t\tbgcolor:\n\t\t\t\t\ttypeof window !== 'undefined'\n\t\t\t\t\t\t? window\n\t\t\t\t\t\t\t\t.getComputedStyle(holder)\n\t\t\t\t\t\t\t\t.getPropertyValue('background-color')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tquality: 1,\n\t\t\t\t// Remove the toolbar\n\t\t\t\tfilter: (node) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.classList &&\n\t\t\t\t\t\tnode.classList.contains('cds--cc--toolbar')\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t})\n\t\t\t.then(function (dataUrl) {\n\t\t\t\tself.services.files.downloadImage(dataUrl, 'myChart.png');\n\t\t\t\tholderSelection.classed('filled', false);\n\t\t\t})\n\t\t\t.catch(function (error) {\n\t\t\t\tconsole.error('oops, something went wrong!', error);\n\t\t\t});\n\t}\n\n\ttoggleFullscreen() {\n\t\tconst holder = this.getHolder();\n\t\tconst holderSelection = select(holder);\n\n\t\tconst isFullScreen = holderSelection.classed('fullscreen');\n\n\t\tif (\n\t\t\tisFullScreen &&\n\t\t\t(document.fullscreenElement ||\n\t\t\t\tdocument['webkitFullscreenElement'] ||\n\t\t\t\tdocument['mozFullScreenElement'] ||\n\t\t\t\tdocument['msFullscreenElement'])\n\t\t) {\n\t\t\t// Call the correct function depending on the browser\n\t\t\tif (document.exitFullscreen) {\n\t\t\t\tdocument.exitFullscreen();\n\t\t\t} else if (document['webkitExitFullscreen']) {\n\t\t\t\tdocument['webkitExitFullscreen']();\n\t\t\t} else if (document['mozCancelFullScreen']) {\n\t\t\t\tdocument['mozCancelFullScreen']();\n\t\t\t} else if (document['msExitFullscreen']) {\n\t\t\t\tdocument['msExitFullscreen']();\n\t\t\t}\n\t\t} else {\n\t\t\t// Call the correct function depending on the browser\n\t\t\tif (holder.requestFullscreen) {\n\t\t\t\tholder.requestFullscreen();\n\t\t\t} else if (holder.webkitRequestFullscreen) {\n\t\t\t\tholder.webkitRequestFullscreen();\n\t\t\t} else if (holder.mozRequestFullScreen) {\n\t\t\t\tholder.mozRequestFullScreen();\n\t\t\t} else if (holder.msRequestFullscreen) {\n\t\t\t\tholder.msRequestFullscreen();\n\t\t\t}\n\t\t}\n\t}\n\n\thandleFullscreenChange() {\n\t\tdocument.addEventListener('fullscreenchange', () => {\n\t\t\tconst holderSelection = select(this.getHolder());\n\t\t\tconst isFullScreen = holderSelection.classed('fullscreen');\n\n\t\t\t// Toggle the `fullscreen` classname\n\t\t\tholderSelection.classed('fullscreen', !isFullScreen);\n\t\t});\n\t}\n\n\tverifyCSSStylesBeingApplied() {\n\t\t// setTimeout is needed here since in `addSVGElement()` we're appending the\n\t\t// CSS verifier element, and need to allow some time for it to become available\n\t\t// in the DOM\n\t\tsetTimeout(() => {\n\t\t\tconst cssVerifierElement = select(this.mainContainer)\n\t\t\t\t.select(`g.${CSS_VERIFIER_ELEMENT_CLASSNAME}`)\n\t\t\t\t.node();\n\t\t\tconst computedStyles = getComputedStyle(cssVerifierElement as any);\n\t\t\tif (\n\t\t\t\tcomputedStyles.getPropertyValue('overflow') !== 'hidden' ||\n\t\t\t\tcomputedStyles.getPropertyValue('opacity') !== '0'\n\t\t\t) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Missing CSS styles for Carbon Charts. Please read the Carbon Charts getting started guide.'\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t}\n\n\tsetSVGMaxHeight() {\n\t\t// if there is a set height on the holder, leave the chart svg height at 100%\n\t\tif (!this.model.getOptions().height) {\n\t\t\tconst { height: chartHeight } = DOMUtils.getSVGElementSize(\n\t\t\t\tselect(this.mainContainer),\n\t\t\t\t{ useBBox: true }\n\t\t\t);\n\t\t\tconst chartSVGSelector = select(this.mainContainer).attr('class');\n\t\t\tconst children = select(this.mainContainer).selectAll(\n\t\t\t\t`.${chartSVGSelector} > svg`\n\t\t\t);\n\n\t\t\t// get the height of the children SVGs (spacers, titles, etc)\n\t\t\tlet childrenHeight = 0;\n\t\t\tchildren.nodes().forEach(function (childSVG) {\n\t\t\t\tchildrenHeight += Number(\n\t\t\t\t\tDOMUtils.getSVGElementSize(select(childSVG), {\n\t\t\t\t\t\tuseBBox: true,\n\t\t\t\t\t}).height\n\t\t\t\t);\n\t\t\t});\n\n\t\t\t// set the chart svg height to the children height\n\t\t\t// forcing the chart not to take up any more space than it requires\n\t\t\tchildrenHeight <= chartHeight\n\t\t\t\t? select(this.mainContainer).attr('height', childrenHeight)\n\t\t\t\t: select(this.mainContainer).attr('height', '100%');\n\t\t}\n\t}\n\n\tgetMainContainer() {\n\t\treturn this.mainContainer;\n\t}\n\n\taddHolderListeners() {\n\t\tconst holder = this.getHolder();\n\n\t\tif (!holder) {\n\t\t\treturn;\n\t\t}\n\n\t\tselect(holder)\n\t\t\t.on('mouseover', () => {\n\t\t\t\t// Dispatch event\n\t\t\t\tthis.services.events.dispatchEvent(Events.Chart.MOUSEOVER);\n\t\t\t})\n\t\t\t.on('mouseout', () => {\n\t\t\t\t// Dispatch event\n\t\t\t\tthis.services.events.dispatchEvent(Events.Chart.MOUSEOUT);\n\t\t\t});\n\t}\n\n\taddResizeListener() {\n\t\tconst holder = this.getHolder();\n\n\t\tif (!holder) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Grab current dimensions of the chart holder\n\t\tlet containerWidth = holder.clientWidth;\n\t\tlet containerHeight = holder.clientHeight;\n\n\t\t// The resize callback function\n\t\tconst resizeCallback = Tools.debounce((entries, observer) => {\n\t\t\tif (!holder) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tMath.abs(containerWidth - holder.clientWidth) > 1 ||\n\t\t\t\tMath.abs(containerHeight - holder.clientHeight) > 1\n\t\t\t) {\n\t\t\t\tcontainerWidth = holder.clientWidth;\n\t\t\t\tcontainerHeight = holder.clientHeight;\n\n\t\t\t\tthis.services.events.dispatchEvent(Events.Chart.RESIZE);\n\t\t\t}\n\t\t}, 12.5);\n\n\t\t// Observe the behaviour of resizing on the holder\n\t\tconst resizeObserver = new ResizeObserver(resizeCallback);\n\t\tresizeObserver.observe(holder);\n\t}\n}\n"]}
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -122,8 +122,8 @@
|
|
|
122
122
|
"signature": "dd3e8c4372ca80670fc59cced6978cbe766f8d7faa2c3a985ddf923f07787649"
|
|
123
123
|
},
|
|
124
124
|
"../src/interfaces/enums.ts": {
|
|
125
|
-
"version": "
|
|
126
|
-
"signature": "
|
|
125
|
+
"version": "b3a7906118d68af2b70d4688a99c17661f1893c5e216aeb595eaa21868590fb7",
|
|
126
|
+
"signature": "b3d8b9af4b5020a8c15b6f3674996603b0fb3c6af0d0030a3af4546aa17ed855"
|
|
127
127
|
},
|
|
128
128
|
"../../../node_modules/@types/d3-ease/index.d.ts": {
|
|
129
129
|
"version": "10967c128101cfdb8f70b9bc8d53c23919c8dfc0699753d22258262cf34f38d7",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"signature": "40479353a4fea9dd15e631f03b9bf3d724d627a49c7491ac3c3781275de9ba88"
|
|
155
155
|
},
|
|
156
156
|
"../src/configuration.ts": {
|
|
157
|
-
"version": "
|
|
157
|
+
"version": "7cc74cd6d4d790ec88ad3b3355a18b158c55c202756617239d05a2b671a8f5c9",
|
|
158
158
|
"signature": "bf067832dce54806fcbae20b3c812f4f4c87f362d322ede6f3bc416a92d9dbcd"
|
|
159
159
|
},
|
|
160
160
|
"../../../node_modules/@types/d3-time/index.d.ts": {
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"signature": "1d9a63e1a4536396484594c7290d407b4d9a5352593754b1a76979b6697f5af3"
|
|
191
191
|
},
|
|
192
192
|
"../src/services/essentials/dom-utils.ts": {
|
|
193
|
-
"version": "
|
|
193
|
+
"version": "86566ad0daf6bba03b9df8d00fbbe3b2a6202764e4d2b5c6e784d44633595533",
|
|
194
194
|
"signature": "7cfb6238b248b340dfc2ce88914f41f1af338e66379588012fab52cc7fdc2c6d"
|
|
195
195
|
},
|
|
196
196
|
"../src/services/essentials/events.ts": {
|
|
@@ -258,8 +258,8 @@
|
|
|
258
258
|
"signature": "c9e5b626cb6cc90b535dcaa930e64a4e033bfcb132abfd16a07edc4deeb1d99c"
|
|
259
259
|
},
|
|
260
260
|
"../src/interfaces/charts.ts": {
|
|
261
|
-
"version": "
|
|
262
|
-
"signature": "
|
|
261
|
+
"version": "a42174c6d89f4740aa38db8b6f5cb24aa44491207f2841664441726460c736d5",
|
|
262
|
+
"signature": "5af0c8ce745a2c28194ef7bef4e536a4de9aed35cac0100f075e355162da2968"
|
|
263
263
|
},
|
|
264
264
|
"../src/interfaces/layout.ts": {
|
|
265
265
|
"version": "684de2d7c612bd74a9d8e866b0b94cc53bd824422be4b3d216dc6682614e5fe8",
|
|
@@ -3792,10 +3792,10 @@
|
|
|
3792
3792
|
"../src/components/component.ts"
|
|
3793
3793
|
],
|
|
3794
3794
|
"../src/interfaces/charts.ts": [
|
|
3795
|
+
"../src/interfaces/enums.ts",
|
|
3795
3796
|
"../src/interfaces/index.ts",
|
|
3796
3797
|
"../src/interfaces/components.ts",
|
|
3797
|
-
"../src/interfaces/axis-scales.ts"
|
|
3798
|
-
"../src/interfaces/enums.ts"
|
|
3798
|
+
"../src/interfaces/axis-scales.ts"
|
|
3799
3799
|
],
|
|
3800
3800
|
"../src/interfaces/model.ts": [
|
|
3801
3801
|
"../src/interfaces/charts.ts"
|