@carbon/charts 0.32.9 → 0.33.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 +331 -145
- package/README.md +18 -8
- package/axis-chart.js +20 -20
- package/axis-chart.js.map +1 -1
- package/build/demo/data/area.d.ts +17 -0
- package/build/demo/data/bar.d.ts +71 -0
- package/build/demo/data/line.d.ts +55 -0
- package/build/demo/data/scatter.d.ts +18 -0
- package/build/src/components/essentials/tooltip-bar.d.ts +2 -2
- package/build/src/components/essentials/tooltip-radar.d.ts +2 -1
- package/build/src/components/essentials/tooltip.d.ts +2 -2
- package/build/src/interfaces/axis-scales.d.ts +2 -0
- package/build/src/interfaces/charts.d.ts +5 -0
- package/build/src/interfaces/components.d.ts +2 -0
- package/build/src/interfaces/enums.d.ts +12 -1
- package/build/src/interfaces/truncation.d.ts +17 -0
- package/build/src/model.d.ts +1 -0
- package/build/src/tools.d.ts +9 -0
- package/bundle.js +1 -1
- package/charts/area-stacked.js +3 -3
- package/charts/area-stacked.js.map +1 -1
- package/charts/area.js +3 -3
- package/charts/area.js.map +1 -1
- package/charts/bar-grouped.js +3 -3
- package/charts/bar-grouped.js.map +1 -1
- package/charts/bar-simple.js +3 -3
- package/charts/bar-simple.js.map +1 -1
- package/charts/bar-stacked.js +3 -3
- package/charts/bar-stacked.js.map +1 -1
- package/charts/bubble.js +3 -3
- package/charts/bubble.js.map +1 -1
- package/charts/donut.js +3 -3
- package/charts/donut.js.map +1 -1
- package/charts/gauge.js +2 -1
- package/charts/gauge.js.map +1 -1
- package/charts/line.js +3 -3
- package/charts/line.js.map +1 -1
- package/charts/pie.js +3 -3
- package/charts/pie.js.map +1 -1
- package/charts/radar.js +1 -1
- package/charts/radar.js.map +1 -1
- package/charts/scatter.js +3 -3
- package/charts/scatter.js.map +1 -1
- package/components/axes/axis.js +76 -14
- package/components/axes/axis.js.map +1 -1
- package/components/axes/grid.js +1 -1
- package/components/axes/grid.js.map +1 -1
- package/components/axes/ruler.js +2 -2
- package/components/axes/ruler.js.map +1 -1
- package/components/axes/two-dimensional-axes.js +3 -3
- package/components/axes/two-dimensional-axes.js.map +1 -1
- package/components/axes/zero-line.js +1 -1
- package/components/axes/zero-line.js.map +1 -1
- package/components/essentials/legend.js +53 -11
- package/components/essentials/legend.js.map +1 -1
- package/components/essentials/threshold.js +9 -9
- package/components/essentials/threshold.js.map +1 -1
- package/components/essentials/title.js +2 -2
- package/components/essentials/title.js.map +1 -1
- package/components/essentials/tooltip-bar.d.ts +2 -2
- package/components/essentials/tooltip-bar.js +24 -10
- package/components/essentials/tooltip-bar.js.map +1 -1
- package/components/essentials/tooltip-pie.js +3 -0
- package/components/essentials/tooltip-pie.js.map +1 -1
- package/components/essentials/tooltip-radar.d.ts +2 -1
- package/components/essentials/tooltip-radar.js +1 -1
- package/components/essentials/tooltip-radar.js.map +1 -1
- package/components/essentials/tooltip-scatter.js +6 -0
- package/components/essentials/tooltip-scatter.js.map +1 -1
- package/components/essentials/tooltip.d.ts +2 -2
- package/components/essentials/tooltip.js +16 -11
- package/components/essentials/tooltip.js.map +1 -1
- package/components/graphs/area-stacked.js +8 -7
- package/components/graphs/area-stacked.js.map +1 -1
- package/components/graphs/bar-grouped.js +7 -7
- package/components/graphs/bar-grouped.js.map +1 -1
- package/components/graphs/bar-simple.js +6 -6
- package/components/graphs/bar-simple.js.map +1 -1
- package/components/graphs/bar-stacked.js +6 -6
- package/components/graphs/bar-stacked.js.map +1 -1
- package/components/graphs/gauge.js +7 -5
- package/components/graphs/gauge.js.map +1 -1
- package/components/graphs/line.js +14 -10
- package/components/graphs/line.js.map +1 -1
- package/components/graphs/pie.js +12 -12
- package/components/graphs/pie.js.map +1 -1
- package/components/graphs/radar.js +11 -11
- package/components/graphs/radar.js.map +1 -1
- package/components/graphs/scatter-stacked.js +2 -4
- package/components/graphs/scatter-stacked.js.map +1 -1
- package/components/graphs/scatter.js +6 -8
- package/components/graphs/scatter.js.map +1 -1
- package/components/graphs/skeleton.js +3 -3
- package/components/graphs/skeleton.js.map +1 -1
- package/components/layout/layout.js +10 -4
- package/components/layout/layout.js.map +1 -1
- package/configuration.js +26 -8
- package/configuration.js.map +1 -1
- package/demo/create-codesandbox.js +19 -19
- package/demo/create-codesandbox.js.map +1 -1
- package/demo/data/area.d.ts +17 -0
- package/demo/data/area.js +26 -0
- package/demo/data/area.js.map +1 -1
- package/demo/data/bar.d.ts +71 -0
- package/demo/data/bar.js +176 -95
- package/demo/data/bar.js.map +1 -1
- package/demo/data/bubble.js +29 -29
- package/demo/data/bubble.js.map +1 -1
- package/demo/data/bundle.js +1 -1
- package/demo/data/index.js +39 -1
- package/demo/data/index.js.map +1 -1
- package/demo/data/line.d.ts +55 -0
- package/demo/data/line.js +149 -50
- package/demo/data/line.js.map +1 -1
- package/demo/data/pie.js +5 -5
- package/demo/data/pie.js.map +1 -1
- package/demo/data/radar.js +12 -12
- package/demo/data/radar.js.map +1 -1
- package/demo/data/scatter.d.ts +18 -0
- package/demo/data/scatter.js +73 -22
- package/demo/data/scatter.js.map +1 -1
- package/demo/data/step.js +6 -6
- package/demo/data/step.js.map +1 -1
- package/demo/data/time-series-axis.js +107 -107
- package/demo/data/time-series-axis.js.map +1 -1
- package/demo/styles.css +32 -0
- 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 +50 -27
- package/interfaces/a11y.js.map +1 -1
- package/interfaces/axis-scales.d.ts +2 -0
- package/interfaces/axis-scales.js.map +1 -1
- package/interfaces/charts.d.ts +5 -0
- package/interfaces/charts.js.map +1 -1
- package/interfaces/components.d.ts +2 -0
- package/interfaces/components.js.map +1 -1
- package/interfaces/enums.d.ts +12 -1
- package/interfaces/enums.js +12 -0
- package/interfaces/enums.js.map +1 -1
- package/interfaces/events.js.map +1 -1
- package/interfaces/truncation.d.ts +17 -0
- package/interfaces/truncation.js +1 -0
- package/interfaces/truncation.js.map +1 -0
- package/model.d.ts +1 -0
- package/model.js +61 -5
- package/model.js.map +1 -1
- package/package.json +1 -1
- package/polyfills.js +1 -1
- package/polyfills.js.map +1 -1
- package/services/angle-utils.js +8 -8
- package/services/angle-utils.js.map +1 -1
- package/services/colorPalettes.js +2 -2
- package/services/colorPalettes.js.map +1 -1
- package/services/colors.js +1 -1
- package/services/colors.js.map +1 -1
- package/services/curves.js +2 -2
- package/services/curves.js.map +1 -1
- package/services/essentials/dom-utils.js +6 -6
- package/services/essentials/dom-utils.js.map +1 -1
- package/services/essentials/events.js +1 -1
- package/services/essentials/events.js.map +1 -1
- package/services/scales-cartesian.js +17 -17
- package/services/scales-cartesian.js.map +1 -1
- package/services/time-series.js +2 -2
- package/services/time-series.js.map +1 -1
- package/styles/components/_tooltip.scss +2 -0
- package/styles-g10.css +8 -0
- package/styles-g10.css.map +1 -1
- package/styles-g10.min.css +1 -1
- package/styles-g10.min.css.map +1 -1
- package/styles-g100.css +8 -0
- package/styles-g100.css.map +1 -1
- package/styles-g100.min.css +1 -1
- package/styles-g100.min.css.map +1 -1
- package/styles-g90.css +8 -0
- package/styles-g90.css.map +1 -1
- package/styles-g90.min.css +1 -1
- package/styles-g90.min.css.map +1 -1
- package/styles.css +8 -0
- package/styles.css.map +1 -1
- package/styles.min.css +1 -1
- package/styles.min.css.map +1 -1
- package/tools.d.ts +9 -0
- package/tools.js +32 -7
- package/tools.js.map +1 -1
- package/tsconfig.tsbuildinfo +87 -69
package/model.js
CHANGED
|
@@ -19,11 +19,10 @@ var ChartModel = /** @class */ (function () {
|
|
|
19
19
|
this.colorScale = {};
|
|
20
20
|
this.services = services;
|
|
21
21
|
}
|
|
22
|
-
ChartModel.prototype.
|
|
22
|
+
ChartModel.prototype.getAllDataFromDomain = function () {
|
|
23
23
|
if (!this.get("data")) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
var ACTIVE = Configuration.legend.items.status.ACTIVE;
|
|
27
26
|
var dataGroups = this.getDataGroups();
|
|
28
27
|
// Remove datasets that have been disabled
|
|
29
28
|
var displayData = Tools.clone(this.get("data"));
|
|
@@ -42,12 +41,26 @@ var ChartModel = /** @class */ (function () {
|
|
|
42
41
|
else {
|
|
43
42
|
var _a = axesOptions[axis].domain, start_1 = _a[0], end_1 = _a[1];
|
|
44
43
|
// Filter out data outside domain
|
|
45
|
-
displayData = displayData.filter(function (datum) {
|
|
44
|
+
displayData = displayData.filter(function (datum) {
|
|
45
|
+
return datum[mapsTo_1] >= start_1 && datum[mapsTo_1] <= end_1;
|
|
46
|
+
});
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
return displayData.filter(function (datum) {
|
|
52
|
+
return dataGroups.find(function (group) { return group.name === datum[groupMapsTo]; });
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
ChartModel.prototype.getDisplayData = function () {
|
|
56
|
+
if (!this.get("data")) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
var ACTIVE = Configuration.legend.items.status.ACTIVE;
|
|
60
|
+
var dataGroups = this.getDataGroups();
|
|
61
|
+
var groupMapsTo = this.getOptions().data.groupMapsTo;
|
|
62
|
+
var allDataFromDomain = this.getAllDataFromDomain();
|
|
63
|
+
return allDataFromDomain.filter(function (datum) {
|
|
51
64
|
var group = dataGroups.find(function (group) { return group.name === datum[groupMapsTo]; });
|
|
52
65
|
return group.status === ACTIVE;
|
|
53
66
|
});
|
|
@@ -110,6 +123,20 @@ var ChartModel = /** @class */ (function () {
|
|
|
110
123
|
var domainIdentifier = this.services.cartesianScales.getDomainIdentifier();
|
|
111
124
|
var rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();
|
|
112
125
|
var stackKeys = map(displayData, function (datum) { return datum[domainIdentifier]; }).keys();
|
|
126
|
+
var axisPosition = this.services.cartesianScales.domainAxisPosition;
|
|
127
|
+
var scaleType = options.axes[axisPosition].scaleType;
|
|
128
|
+
// Sort keys
|
|
129
|
+
if (scaleType === ScaleTypes.TIME) {
|
|
130
|
+
stackKeys.sort(function (a, b) {
|
|
131
|
+
var dateA = new Date(a);
|
|
132
|
+
var dateB = new Date(b);
|
|
133
|
+
return dateA - dateB;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else if (scaleType === ScaleTypes.LOG ||
|
|
137
|
+
scaleType === ScaleTypes.LINEAR) {
|
|
138
|
+
stackKeys.sort(function (a, b) { return a - b; });
|
|
139
|
+
}
|
|
113
140
|
var dataGroupNames = this.getDataGroupNames();
|
|
114
141
|
return stackKeys.map(function (key) {
|
|
115
142
|
var correspondingValues = { sharedStackKey: key };
|
|
@@ -238,6 +265,19 @@ var ChartModel = /** @class */ (function () {
|
|
|
238
265
|
group.name === changedLabel ? ACTIVE : DISABLED;
|
|
239
266
|
});
|
|
240
267
|
}
|
|
268
|
+
// Updates selected groups
|
|
269
|
+
var updatedActiveItems = dataGroups.filter(function (group) { return group.status === ACTIVE; });
|
|
270
|
+
var options = this.getOptions();
|
|
271
|
+
var hasUpdatedDeactivatedItems = dataGroups.some(function (group) { return group.status === DISABLED; });
|
|
272
|
+
// If there are deactivated items, map the item name into selected groups
|
|
273
|
+
if (hasUpdatedDeactivatedItems) {
|
|
274
|
+
options.data.selectedGroups = updatedActiveItems.map(function (activeItem) { return activeItem.name; });
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
// If every item is active, clear array
|
|
278
|
+
options.data.selectedGroups = [];
|
|
279
|
+
}
|
|
280
|
+
;
|
|
241
281
|
// dispatch legend filtering event with the status of all the dataLabels
|
|
242
282
|
this.services.events.dispatchEvent(Events.Legend.ITEMS_UPDATE, {
|
|
243
283
|
dataGroups: dataGroups
|
|
@@ -365,11 +405,27 @@ var ChartModel = /** @class */ (function () {
|
|
|
365
405
|
};
|
|
366
406
|
ChartModel.prototype.generateDataGroups = function (data) {
|
|
367
407
|
var groupMapsTo = this.getOptions().data.groupMapsTo;
|
|
368
|
-
var
|
|
408
|
+
var _a = Configuration.legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
|
|
409
|
+
var options = this.getOptions();
|
|
369
410
|
var uniqueDataGroups = map(data, function (datum) { return datum[groupMapsTo]; }).keys();
|
|
411
|
+
// check if selectedGroups can be applied to chart with current data groups
|
|
412
|
+
if (options.data.selectedGroups.length) {
|
|
413
|
+
var hasAllSelectedGroups = options.data.selectedGroups
|
|
414
|
+
.every(function (groupName) { return uniqueDataGroups.includes(groupName); });
|
|
415
|
+
if (!hasAllSelectedGroups) {
|
|
416
|
+
options.data.selectedGroups = [];
|
|
417
|
+
}
|
|
418
|
+
;
|
|
419
|
+
}
|
|
420
|
+
// Get group status based on items in selected groups
|
|
421
|
+
var getStatus = function (groupName) {
|
|
422
|
+
return !options.data.selectedGroups.length || options.data.selectedGroups.includes(groupName)
|
|
423
|
+
? ACTIVE
|
|
424
|
+
: DISABLED;
|
|
425
|
+
};
|
|
370
426
|
return uniqueDataGroups.map(function (groupName) { return ({
|
|
371
427
|
name: groupName,
|
|
372
|
-
status:
|
|
428
|
+
status: getStatus(groupName)
|
|
373
429
|
}); });
|
|
374
430
|
};
|
|
375
431
|
/*
|
package/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["model.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAElD,KAAK;AACL,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;qEACqE;AACrE;IAwBC,oBAAY,QA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AI,CAAC,UAAU,EAAE,CAAC;QAClC,IAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAEvE,0EAA0E;QAC1E,IACC,iBAAiB,KAAK,IAAI;YAC1B,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,KAAK,CAAC,EAC1C;YACD,IAAI,CAAC,UAAU,GAAG,YAAY,EAAE;iBAC9B,KAAK,CAAC,aAAa,CAAC;iBACpB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAE7B,OAAO;SACP;QAED;;;;WAIG;QACH,IAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAC,SAAS;YACpC,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE;gBACjC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;aAC9C;iBAAM;gBACN,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;aAC3C;YAED,IAAI,UAAU,KAAK,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5C,UAAU,GAAG,CAAC,CAAC;aACf;iBAAM;gBACN,UAAU,EAAE,CAAC;aACb;QACF,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,YAAY,EAAE;aAC9B,KAAK,CAAC,UAAU,CAAC;aACjB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IACF,iBAAC;AAAD,CAAC,AA3fD,IA2fC","sourcesContent":["// Internal Imports\nimport * as Configuration from \"./configuration\";\nimport { Tools } from \"./tools\";\nimport * as colorPalettes from \"./services/colorPalettes\";\nimport { Events, ScaleTypes } from \"./interfaces\";\n\n// D3\nimport { scaleOrdinal } from \"d3-scale\";\nimport { map } from \"d3-collection\";\nimport { stack } from \"d3-shape\";\n\n/** The charting model layer which includes mainly the chart data and options,\n * as well as some misc. information to be shared among components */\nexport class ChartModel {\n\t// Callbacks\n\t/**\n\t * Function to be called when data or options update within the model\n\t * @type Function\n\t */\n\tprotected updateCallback: Function;\n\tprotected services: any;\n\n\t// Internal Model state\n\tprotected state: any = {\n\t\toptions: {}\n\t};\n\n\t// Data labels\n\t/**\n\t * A list of all the data groups that have existed within the lifetime of the chart\n\t * @type string[]\n\t */\n\tprotected allDataGroups: string[];\n\n\t// Fill scales & fill related objects\n\tprotected colorScale: any = {};\n\n\tconstructor(services: any) {\n\t\tthis.services = services;\n\t}\n\n\tgetDisplayData() {\n\t\tif (!this.get(\"data\")) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\t// Remove datasets that have been disabled\n\t\tlet displayData = Tools.clone(this.get(\"data\"));\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\tconst axesOptions = this.getOptions().axes;\n\n\t\t// Check for custom domain\n\t\tif (axesOptions) {\n\t\t\tObject.keys(axesOptions).forEach((axis) => {\n\t\t\t\tif (axesOptions[axis].mapsTo && axesOptions[axis].domain) {\n\t\t\t\t\tconst mapsTo = axesOptions[axis].mapsTo;\n\n\t\t\t\t\tif (axesOptions[axis].scaleType === ScaleTypes.LABELS) {\n\t\t\t\t\t\tdisplayData = displayData.filter((datum) =>\n\t\t\t\t\t\t\taxesOptions[axis].domain.includes(datum[mapsTo])\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [start, end] = axesOptions[axis].domain;\n\n\t\t\t\t\t\t// Filter out data outside domain\n\t\t\t\t\t\tdisplayData = displayData.filter(\n\t\t\t\t\t\t\t(datum) => datum[mapsTo] >= start && datum[mapsTo] <= end\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\treturn displayData.filter((datum) => {\n\t\t\tconst group = dataGroups.find(\n\t\t\t\t(group) => group.name === datum[groupMapsTo]\n\t\t\t);\n\n\t\t\treturn group.status === ACTIVE;\n\t\t});\n\t}\n\n\tgetData() {\n\t\treturn this.get(\"data\");\n\t}\n\n\tisDataEmpty() {\n\t\treturn !this.getData().length;\n\t}\n\n\t/**\n\t *\n\t * @param newData The new raw data to be set\n\t */\n\tsetData(newData) {\n\t\tconst sanitizedData = this.sanitize(Tools.clone(newData));\n\t\tconst dataGroups = this.generateDataGroups(sanitizedData);\n\n\t\tthis.set({\n\t\t\tdata: sanitizedData,\n\t\t\tdataGroups\n\t\t});\n\n\t\treturn sanitizedData;\n\t}\n\n\tgetDataGroups() {\n\t\treturn this.get(\"dataGroups\");\n\t}\n\n\tgetActiveDataGroups() {\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\treturn this.getDataGroups().filter(\n\t\t\t(dataGroup) => dataGroup.status === ACTIVE\n\t\t);\n\t}\n\n\tgetDataGroupNames() {\n\t\treturn this.getDataGroups().map((dataGroup) => dataGroup.name);\n\t}\n\n\tgetActiveDataGroupNames() {\n\t\treturn this.getActiveDataGroups().map((dataGroup) => dataGroup.name);\n\t}\n\n\tgetGroupedData() {\n\t\tconst displayData = this.getDisplayData();\n\t\tconst groupedData = {};\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\tdisplayData.map((datum) => {\n\t\t\tconst group = datum[groupMapsTo];\n\t\t\tif (\n\t\t\t\tgroupedData[group] !== null &&\n\t\t\t\tgroupedData[group] !== undefined\n\t\t\t) {\n\t\t\t\tgroupedData[group].push(datum);\n\t\t\t} else {\n\t\t\t\tgroupedData[group] = [datum];\n\t\t\t}\n\t\t});\n\n\t\treturn Object.keys(groupedData).map((groupName) => ({\n\t\t\tname: groupName,\n\t\t\tdata: groupedData[groupName]\n\t\t}));\n\t}\n\n\tgetDataValuesGroupedByKeys() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst displayData = this.getDisplayData();\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\tconst stackKeys = map(\n\t\t\tdisplayData,\n\t\t\t(datum) => datum[domainIdentifier]\n\t\t).keys();\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\n\t\treturn stackKeys.map((key) => {\n\t\t\tconst correspondingValues = { sharedStackKey: key };\n\t\t\tdataGroupNames.forEach((dataGroupName) => {\n\t\t\t\tconst correspondingDatum = displayData.find((datum) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdatum[groupMapsTo] === dataGroupName &&\n\t\t\t\t\t\tdatum[domainIdentifier].toString() === key\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tcorrespondingValues[dataGroupName] = correspondingDatum\n\t\t\t\t\t? correspondingDatum[rangeIdentifier]\n\t\t\t\t\t: null;\n\t\t\t});\n\t\t\treturn correspondingValues;\n\t\t}) as any;\n\t}\n\n\tgetStackedData({ percentage } = { percentage: false }) {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\t\tconst dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys();\n\n\t\tif (percentage) {\n\t\t\tconst maxByKey = Tools.fromPairs(\n\t\t\t\tdataValuesGroupedByKeys.map((d: any) => [d.sharedStackKey, 0])\n\t\t\t);\n\n\t\t\tdataValuesGroupedByKeys.forEach((d: any) => {\n\t\t\t\tdataGroupNames.forEach((name) => {\n\t\t\t\t\tmaxByKey[d.sharedStackKey] += d[name];\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// cycle through data values to get percentage\n\t\t\tdataValuesGroupedByKeys.forEach((d: any) => {\n\t\t\t\tdataGroupNames.forEach((name) => {\n\t\t\t\t\td[name] = (d[name] / maxByKey[d.sharedStackKey]) * 100;\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\treturn stack()\n\t\t\t.keys(dataGroupNames)(dataValuesGroupedByKeys)\n\t\t\t.map((series, i) => {\n\t\t\t\t// Add data group names to each series\n\t\t\t\treturn Object.keys(series)\n\t\t\t\t\t.filter((key: any) => !isNaN(key))\n\t\t\t\t\t.map((key) => {\n\t\t\t\t\t\tconst element = series[key];\n\t\t\t\t\t\telement[groupMapsTo] = dataGroupNames[i];\n\n\t\t\t\t\t\treturn element;\n\t\t\t\t\t});\n\t\t\t});\n\t}\n\n\t/**\n\t * @return {Object} The chart's options\n\t */\n\tgetOptions() {\n\t\treturn this.state.options;\n\t}\n\n\tset(newState: any, skipUpdate = false) {\n\t\tthis.state = Object.assign({}, this.state, newState);\n\n\t\tif (!skipUpdate) {\n\t\t\tthis.update();\n\t\t}\n\t}\n\n\tget(property?: string) {\n\t\tif (property) {\n\t\t\treturn this.state[property];\n\t\t} else {\n\t\t\treturn this.state;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * @param newOptions New options to be set\n\t */\n\tsetOptions(newOptions) {\n\t\tthis.set({\n\t\t\toptions: Tools.merge(this.getOptions(), newOptions)\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * Updates miscellanous information within the model\n\t * such as the color scales, or the legend data labels\n\t */\n\tupdate() {\n\t\tif (!this.getDisplayData()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updateAllDataGroups();\n\n\t\tthis.setColorScale();\n\t\tthis.services.events.dispatchEvent(Events.Model.UPDATE);\n\t}\n\n\tsetUpdateCallback(cb: Function) {\n\t\tthis.updateCallback = cb;\n\t}\n\n\t/*\n\t * Data labels\n\t */\n\ttoggleDataLabel(changedLabel: string) {\n\t\tconst { ACTIVE, DISABLED } = Configuration.legend.items.status;\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\tconst hasDeactivatedItems = dataGroups.some(\n\t\t\t(group) => group.status === DISABLED\n\t\t);\n\t\tconst activeItems = dataGroups.filter(\n\t\t\t(group) => group.status === ACTIVE\n\t\t);\n\n\t\t// If there are deactivated items, toggle \"changedLabel\"\n\t\tif (hasDeactivatedItems) {\n\t\t\t// If the only active item is being toggled\n\t\t\t// Activate all items\n\t\t\tif (\n\t\t\t\tactiveItems.length === 1 &&\n\t\t\t\tactiveItems[0].name === changedLabel\n\t\t\t) {\n\t\t\t\t// If every item is active, then enable \"changedLabel\" and disable all other items\n\t\t\t\tdataGroups.forEach((group, i) => {\n\t\t\t\t\tdataGroups[i].status = ACTIVE;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst indexToChange = dataGroups.findIndex(\n\t\t\t\t\t(group) => group.name === changedLabel\n\t\t\t\t);\n\t\t\t\tdataGroups[indexToChange].status =\n\t\t\t\t\tdataGroups[indexToChange].status === DISABLED\n\t\t\t\t\t\t? ACTIVE\n\t\t\t\t\t\t: DISABLED;\n\t\t\t}\n\t\t} else {\n\t\t\t// If every item is active, then enable \"changedLabel\" and disable all other items\n\t\t\tdataGroups.forEach((group, i) => {\n\t\t\t\tdataGroups[i].status =\n\t\t\t\t\tgroup.name === changedLabel ? ACTIVE : DISABLED;\n\t\t\t});\n\t\t}\n\n\t\t// dispatch legend filtering event with the status of all the dataLabels\n\t\tthis.services.events.dispatchEvent(Events.Legend.ITEMS_UPDATE, {\n\t\t\tdataGroups\n\t\t});\n\n\t\t// Update model\n\t\tthis.set({\n\t\t\tdataGroups\n\t\t});\n\t}\n\n\t/**\n\t * Should the data point be filled?\n\t * @param group\n\t * @param key\n\t * @param value\n\t * @param defaultFilled the default for this chart\n\t */\n\tgetIsFilled(group: any, key?: any, data?: any, defaultFilled?: boolean) {\n\t\tconst options = this.getOptions();\n\t\tif (options.getIsFilled) {\n\t\t\treturn options.getIsFilled(group, key, data, defaultFilled);\n\t\t} else {\n\t\t\treturn defaultFilled;\n\t\t}\n\t}\n\n\tgetFillColor(group: any, key?: any, data?: any) {\n\t\tconst options = this.getOptions();\n\t\tconst defaultFillColor = this.getFillScale()(group);\n\t\tif (options.getFillColor) {\n\t\t\treturn options.getFillColor(group, key, data, defaultFillColor);\n\t\t} else {\n\t\t\treturn defaultFillColor;\n\t\t}\n\t}\n\n\tgetStrokeColor(group: any, key?: any, data?: any) {\n\t\tconst options = this.getOptions();\n\t\tconst defaultStrokeColor = this.colorScale(group);\n\t\tif (options.getStrokeColor) {\n\t\t\treturn options.getStrokeColor(group, key, data, defaultStrokeColor);\n\t\t} else {\n\t\t\treturn defaultStrokeColor;\n\t\t}\n\t}\n\n\tgetFillScale() {\n\t\treturn this.colorScale;\n\t}\n\n\t/**\n\t * Converts data provided in the older format to tabular\n\t *\n\t */\n\tprotected transformToTabularData(data) {\n\t\tconsole.warn(\n\t\t\t\"We've updated the charting data format to be tabular by default. The current format you're using is deprecated and will be removed in v1.0, read more here https://carbon-design-system.github.io/carbon-charts/?path=/story/tutorials--tabular-data-format\"\n\t\t);\n\t\tconst tabularData = [];\n\t\tconst { datasets, labels } = data;\n\n\t\t// Loop through all datasets\n\t\tdatasets.forEach((dataset) => {\n\t\t\t// Update each data point to the new format\n\t\t\tdataset.data.forEach((datum, i) => {\n\t\t\t\tlet group;\n\n\t\t\t\tconst datasetLabel = Tools.getProperty(dataset, \"label\");\n\t\t\t\tif (datasetLabel === null) {\n\t\t\t\t\tconst correspondingLabel = Tools.getProperty(labels, i);\n\t\t\t\t\tif (correspondingLabel) {\n\t\t\t\t\t\tgroup = correspondingLabel;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgroup = \"Ungrouped\";\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tgroup = datasetLabel;\n\t\t\t\t}\n\n\t\t\t\tconst updatedDatum = {\n\t\t\t\t\tgroup,\n\t\t\t\t\tkey: labels[i]\n\t\t\t\t};\n\n\t\t\t\tif (isNaN(datum)) {\n\t\t\t\t\tupdatedDatum[\"value\"] = datum.value;\n\t\t\t\t\tupdatedDatum[\"date\"] = datum.date;\n\t\t\t\t} else {\n\t\t\t\t\tupdatedDatum[\"value\"] = datum;\n\t\t\t\t}\n\n\t\t\t\ttabularData.push(updatedDatum);\n\t\t\t});\n\t\t});\n\n\t\treturn tabularData;\n\t}\n\n\tprotected getTabularData(data) {\n\t\t// if data is not an array\n\t\tif (!Array.isArray(data)) {\n\t\t\treturn this.transformToTabularData(data);\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tprotected sanitize(data) {\n\t\treturn this.getTabularData(data);\n\t}\n\n\t/*\n\t * Data groups\n\t */\n\tprotected updateAllDataGroups() {\n\t\t// allDataGroups is used to generate a color scale that applies\n\t\t// to all the groups. Now when the data updates, you might remove a group,\n\t\t// and then bring it back in a newer data update, therefore\n\t\t// the order of the groups in allDataGroups matters so that you'd never\n\t\t// have an incorrect color assigned to a group.\n\n\t\t// Also, a new group should only be added to allDataGroups if\n\t\t// it doesn't currently exist\n\n\t\tif (!this.allDataGroups) {\n\t\t\tthis.allDataGroups = this.getDataGroupNames();\n\t\t} else {\n\t\t\t// Loop through current data groups\n\t\t\tthis.getDataGroupNames().forEach((dataGroupName) => {\n\t\t\t\t// If group name hasn't been stored yet, store it\n\t\t\t\tif (this.allDataGroups.indexOf(dataGroupName) === -1) {\n\t\t\t\t\tthis.allDataGroups.push(dataGroupName);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected generateDataGroups(data) {\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\tconst uniqueDataGroups = map(\n\t\t\tdata,\n\t\t\t(datum) => datum[groupMapsTo]\n\t\t).keys();\n\t\treturn uniqueDataGroups.map((groupName) => ({\n\t\t\tname: groupName,\n\t\t\tstatus: ACTIVE\n\t\t}));\n\t}\n\n\t/*\n\t * Fill scales\n\t */\n\tprotected setColorScale() {\n\t\tlet defaultColors = colorPalettes.DEFAULT;\n\n\t\tconst options = this.getOptions();\n\t\tconst userProvidedScale = Tools.getProperty(options, \"color\", \"scale\");\n\n\t\t// If there is no valid user provided scale, use the default set of colors\n\t\tif (\n\t\t\tuserProvidedScale === null ||\n\t\t\tObject.keys(userProvidedScale).length === 0\n\t\t) {\n\t\t\tthis.colorScale = scaleOrdinal()\n\t\t\t\t.range(defaultColors)\n\t\t\t\t.domain(this.allDataGroups);\n\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * Go through allDataGroups. If a data group has a color value provided\n\t\t * by the user, add that to the color range\n\t\t * If not, add a default color\n\t\t */\n\t\tconst colorRange = [];\n\t\tlet colorIndex = 0;\n\t\tthis.allDataGroups.forEach((dataGroup) => {\n\t\t\tif (userProvidedScale[dataGroup]) {\n\t\t\t\tcolorRange.push(userProvidedScale[dataGroup]);\n\t\t\t} else {\n\t\t\t\tcolorRange.push(defaultColors[colorIndex]);\n\t\t\t}\n\n\t\t\tif (colorIndex === defaultColors.length - 1) {\n\t\t\t\tcolorIndex = 0;\n\t\t\t} else {\n\t\t\t\tcolorIndex++;\n\t\t\t}\n\t\t});\n\n\t\tthis.colorScale = scaleOrdinal()\n\t\t\t.range(colorRange)\n\t\t\t.domain(this.allDataGroups);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["model.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAElD,KAAK;AACL,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;qEACqE;AACrE;IAwBC,oBAAY,QAAa;QAfzB,uBAAuB;QACb,UAAK,GAAQ;YACtB,OAAO,EAAE,EAAE;SACX,CAAC;QASF,qCAAqC;QAC3B,eAAU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,CAAC;QAEvE,0EAA0E;QAC1E,IACC,iBAAiB,KAAK,IAAI;YAC1B,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,KAAK,CAAC,EAC1C;YACD,IAAI,CAAC,UAAU,GAAG,YAAY,EAAE;iBAC9B,KAAK,CAAC,aAAa,CAAC;iBACpB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAE7B,OAAO;SACP;QAED;;;;WAIG;QACH,IAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAC,SAAS;YACpC,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE;gBACjC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;aAC9C;iBAAM;gBACN,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;aAC3C;YAED,IAAI,UAAU,KAAK,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5C,UAAU,GAAG,CAAC,CAAC;aACf;iBAAM;gBACN,UAAU,EAAE,CAAC;aACb;QACF,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,YAAY,EAAE;aAC9B,KAAK,CAAC,UAAU,CAAC;aACjB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IACF,iBAAC;AAAD,CAAC,AAhkBD,IAgkBC","sourcesContent":["// Internal Imports\nimport * as Configuration from \"./configuration\";\nimport { Tools } from \"./tools\";\nimport * as colorPalettes from \"./services/colorPalettes\";\nimport { Events, ScaleTypes } from \"./interfaces\";\n\n// D3\nimport { scaleOrdinal } from \"d3-scale\";\nimport { map } from \"d3-collection\";\nimport { stack } from \"d3-shape\";\n\n/** The charting model layer which includes mainly the chart data and options,\n * as well as some misc. information to be shared among components */\nexport class ChartModel {\n\t// Callbacks\n\t/**\n\t * Function to be called when data or options update within the model\n\t * @type Function\n\t */\n\tprotected updateCallback: Function;\n\tprotected services: any;\n\n\t// Internal Model state\n\tprotected state: any = {\n\t\toptions: {}\n\t};\n\n\t// Data labels\n\t/**\n\t * A list of all the data groups that have existed within the lifetime of the chart\n\t * @type string[]\n\t */\n\tprotected allDataGroups: string[];\n\n\t// Fill scales & fill related objects\n\tprotected colorScale: any = {};\n\n\tconstructor(services: any) {\n\t\tthis.services = services;\n\t}\n\n\tgetAllDataFromDomain() {\n\t\tif (!this.get(\"data\")) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\t// Remove datasets that have been disabled\n\t\tlet displayData = Tools.clone(this.get(\"data\"));\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\tconst axesOptions = this.getOptions().axes;\n\n\t\t// Check for custom domain\n\t\tif (axesOptions) {\n\t\t\tObject.keys(axesOptions).forEach((axis) => {\n\t\t\t\tif (axesOptions[axis].mapsTo && axesOptions[axis].domain) {\n\t\t\t\t\tconst mapsTo = axesOptions[axis].mapsTo;\n\n\t\t\t\t\tif (axesOptions[axis].scaleType === ScaleTypes.LABELS) {\n\t\t\t\t\t\tdisplayData = displayData.filter((datum) =>\n\t\t\t\t\t\t\taxesOptions[axis].domain.includes(datum[mapsTo])\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [start, end] = axesOptions[axis].domain;\n\n\t\t\t\t\t\t// Filter out data outside domain\n\t\t\t\t\t\tdisplayData = displayData.filter(\n\t\t\t\t\t\t\t(datum) =>\n\t\t\t\t\t\t\t\tdatum[mapsTo] >= start && datum[mapsTo] <= end\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\treturn displayData.filter((datum) => {\n\t\t\treturn dataGroups.find(\n\t\t\t\t(group) => group.name === datum[groupMapsTo]\n\t\t\t);\n\t\t});\n\t}\n\n\tgetDisplayData() {\n\t\tif (!this.get(\"data\")) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\t\tconst dataGroups = this.getDataGroups();\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\tconst allDataFromDomain = this.getAllDataFromDomain();\n\n\t\treturn allDataFromDomain.filter((datum) => {\n\t\t\tconst group = dataGroups.find(\n\t\t\t\t(group) => group.name === datum[groupMapsTo]\n\t\t\t);\n\n\t\t\treturn group.status === ACTIVE;\n\t\t});\n\t}\n\n\tgetData() {\n\t\treturn this.get(\"data\");\n\t}\n\n\tisDataEmpty() {\n\t\treturn !this.getData().length;\n\t}\n\n\t/**\n\t *\n\t * @param newData The new raw data to be set\n\t */\n\tsetData(newData) {\n\t\tconst sanitizedData = this.sanitize(Tools.clone(newData));\n\t\tconst dataGroups = this.generateDataGroups(sanitizedData);\n\n\t\tthis.set({\n\t\t\tdata: sanitizedData,\n\t\t\tdataGroups\n\t\t});\n\n\t\treturn sanitizedData;\n\t}\n\n\tgetDataGroups() {\n\t\treturn this.get(\"dataGroups\");\n\t}\n\n\tgetActiveDataGroups() {\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\treturn this.getDataGroups().filter(\n\t\t\t(dataGroup) => dataGroup.status === ACTIVE\n\t\t);\n\t}\n\n\tgetDataGroupNames() {\n\t\treturn this.getDataGroups().map((dataGroup) => dataGroup.name);\n\t}\n\n\tgetActiveDataGroupNames() {\n\t\treturn this.getActiveDataGroups().map((dataGroup) => dataGroup.name);\n\t}\n\n\tgetGroupedData() {\n\t\tconst displayData = this.getDisplayData();\n\t\tconst groupedData = {};\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\tdisplayData.map((datum) => {\n\t\t\tconst group = datum[groupMapsTo];\n\t\t\tif (\n\t\t\t\tgroupedData[group] !== null &&\n\t\t\t\tgroupedData[group] !== undefined\n\t\t\t) {\n\t\t\t\tgroupedData[group].push(datum);\n\t\t\t} else {\n\t\t\t\tgroupedData[group] = [datum];\n\t\t\t}\n\t\t});\n\n\t\treturn Object.keys(groupedData).map((groupName) => ({\n\t\t\tname: groupName,\n\t\t\tdata: groupedData[groupName]\n\t\t}));\n\t}\n\n\tgetDataValuesGroupedByKeys() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst displayData = this.getDisplayData();\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\tconst stackKeys = map(\n\t\t\tdisplayData,\n\t\t\t(datum) => datum[domainIdentifier]\n\t\t).keys();\n\n\t\tconst axisPosition = this.services.cartesianScales.domainAxisPosition;\n\t\tconst scaleType = options.axes[axisPosition].scaleType;\n\n\t\t// Sort keys\n\t\tif (scaleType === ScaleTypes.TIME) {\n\t\t\tstackKeys.sort((a: any, b: any) => {\n\t\t\t\tconst dateA: any = new Date(a);\n\t\t\t\tconst dateB: any = new Date(b);\n\t\t\t\treturn dateA - dateB;\n\t\t\t});\n\t\t} else if (\n\t\t\tscaleType === ScaleTypes.LOG ||\n\t\t\tscaleType === ScaleTypes.LINEAR\n\t\t) {\n\t\t\tstackKeys.sort((a: any, b: any) => a - b);\n\t\t}\n\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\n\t\treturn stackKeys.map((key) => {\n\t\t\tconst correspondingValues = { sharedStackKey: key };\n\t\t\tdataGroupNames.forEach((dataGroupName) => {\n\t\t\t\tconst correspondingDatum = displayData.find((datum) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdatum[groupMapsTo] === dataGroupName &&\n\t\t\t\t\t\tdatum[domainIdentifier].toString() === key\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tcorrespondingValues[dataGroupName] = correspondingDatum\n\t\t\t\t\t? correspondingDatum[rangeIdentifier]\n\t\t\t\t\t: null;\n\t\t\t});\n\t\t\treturn correspondingValues;\n\t\t}) as any;\n\t}\n\n\tgetStackedData({ percentage } = { percentage: false }) {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\t\tconst dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys();\n\n\t\tif (percentage) {\n\t\t\tconst maxByKey = Tools.fromPairs(\n\t\t\t\tdataValuesGroupedByKeys.map((d: any) => [d.sharedStackKey, 0])\n\t\t\t);\n\n\t\t\tdataValuesGroupedByKeys.forEach((d: any) => {\n\t\t\t\tdataGroupNames.forEach((name) => {\n\t\t\t\t\tmaxByKey[d.sharedStackKey] += d[name];\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// cycle through data values to get percentage\n\t\t\tdataValuesGroupedByKeys.forEach((d: any) => {\n\t\t\t\tdataGroupNames.forEach((name) => {\n\t\t\t\t\td[name] = (d[name] / maxByKey[d.sharedStackKey]) * 100;\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\treturn stack()\n\t\t\t.keys(dataGroupNames)(dataValuesGroupedByKeys)\n\t\t\t.map((series, i) => {\n\t\t\t\t// Add data group names to each series\n\t\t\t\treturn Object.keys(series)\n\t\t\t\t\t.filter((key: any) => !isNaN(key))\n\t\t\t\t\t.map((key) => {\n\t\t\t\t\t\tconst element = series[key];\n\t\t\t\t\t\telement[groupMapsTo] = dataGroupNames[i];\n\n\t\t\t\t\t\treturn element;\n\t\t\t\t\t});\n\t\t\t});\n\t}\n\n\t/**\n\t * @return {Object} The chart's options\n\t */\n\tgetOptions() {\n\t\treturn this.state.options;\n\t}\n\n\tset(newState: any, skipUpdate = false) {\n\t\tthis.state = Object.assign({}, this.state, newState);\n\n\t\tif (!skipUpdate) {\n\t\t\tthis.update();\n\t\t}\n\t}\n\n\tget(property?: string) {\n\t\tif (property) {\n\t\t\treturn this.state[property];\n\t\t} else {\n\t\t\treturn this.state;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * @param newOptions New options to be set\n\t */\n\tsetOptions(newOptions) {\n\t\tthis.set({\n\t\t\toptions: Tools.merge(this.getOptions(), newOptions)\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * Updates miscellanous information within the model\n\t * such as the color scales, or the legend data labels\n\t */\n\tupdate() {\n\t\tif (!this.getDisplayData()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updateAllDataGroups();\n\n\t\tthis.setColorScale();\n\t\tthis.services.events.dispatchEvent(Events.Model.UPDATE);\n\t}\n\n\tsetUpdateCallback(cb: Function) {\n\t\tthis.updateCallback = cb;\n\t}\n\n\t/*\n\t * Data labels\n\t */\n\ttoggleDataLabel(changedLabel: string) {\n\t\tconst { ACTIVE, DISABLED } = Configuration.legend.items.status;\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\tconst hasDeactivatedItems = dataGroups.some(\n\t\t\t(group) => group.status === DISABLED\n\t\t);\n\t\tconst activeItems = dataGroups.filter(\n\t\t\t(group) => group.status === ACTIVE\n\t\t);\n\n\t\t// If there are deactivated items, toggle \"changedLabel\"\n\t\tif (hasDeactivatedItems) {\n\t\t\t// If the only active item is being toggled\n\t\t\t// Activate all items\n\t\t\tif (\n\t\t\t\tactiveItems.length === 1 &&\n\t\t\t\tactiveItems[0].name === changedLabel\n\t\t\t) {\n\t\t\t\t// If every item is active, then enable \"changedLabel\" and disable all other items\n\t\t\t\tdataGroups.forEach((group, i) => {\n\t\t\t\t\tdataGroups[i].status = ACTIVE;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst indexToChange = dataGroups.findIndex(\n\t\t\t\t\t(group) => group.name === changedLabel\n\t\t\t\t);\n\t\t\t\tdataGroups[indexToChange].status =\n\t\t\t\t\tdataGroups[indexToChange].status === DISABLED\n\t\t\t\t\t\t? ACTIVE\n\t\t\t\t\t\t: DISABLED;\n\t\t\t}\n\t\t} else {\n\t\t\t// If every item is active, then enable \"changedLabel\" and disable all other items\n\t\t\tdataGroups.forEach((group, i) => {\n\t\t\t\tdataGroups[i].status =\n\t\t\t\t\tgroup.name === changedLabel ? ACTIVE : DISABLED;\n\t\t\t});\n\t\t}\n\n\t\t// Updates selected groups\n\t\tconst updatedActiveItems = dataGroups.filter(group => group.status === ACTIVE);\n\t\tconst options = this.getOptions();\n\n\t\tconst hasUpdatedDeactivatedItems = dataGroups.some(\n\t\t\tgroup => group.status === DISABLED\n\t\t);\n\n\t\t// If there are deactivated items, map the item name into selected groups\n\t\tif (hasUpdatedDeactivatedItems) {\n\t\t\toptions.data.selectedGroups = updatedActiveItems.map(activeItem => activeItem.name);\n\t\t} else {\n\t\t\t// If every item is active, clear array\n\t\t\toptions.data.selectedGroups = [];\n\t\t};\n\n\t\t// dispatch legend filtering event with the status of all the dataLabels\n\t\tthis.services.events.dispatchEvent(Events.Legend.ITEMS_UPDATE, {\n\t\t\tdataGroups\n\t\t});\n\n\t\t// Update model\n\t\tthis.set({\n\t\t\tdataGroups\n\t\t});\n\t}\n\n\t/**\n\t * Should the data point be filled?\n\t * @param group\n\t * @param key\n\t * @param value\n\t * @param defaultFilled the default for this chart\n\t */\n\tgetIsFilled(group: any, key?: any, data?: any, defaultFilled?: boolean) {\n\t\tconst options = this.getOptions();\n\t\tif (options.getIsFilled) {\n\t\t\treturn options.getIsFilled(group, key, data, defaultFilled);\n\t\t} else {\n\t\t\treturn defaultFilled;\n\t\t}\n\t}\n\n\tgetFillColor(group: any, key?: any, data?: any) {\n\t\tconst options = this.getOptions();\n\t\tconst defaultFillColor = this.getFillScale()(group);\n\t\tif (options.getFillColor) {\n\t\t\treturn options.getFillColor(group, key, data, defaultFillColor);\n\t\t} else {\n\t\t\treturn defaultFillColor;\n\t\t}\n\t}\n\n\tgetStrokeColor(group: any, key?: any, data?: any) {\n\t\tconst options = this.getOptions();\n\t\tconst defaultStrokeColor = this.colorScale(group);\n\t\tif (options.getStrokeColor) {\n\t\t\treturn options.getStrokeColor(group, key, data, defaultStrokeColor);\n\t\t} else {\n\t\t\treturn defaultStrokeColor;\n\t\t}\n\t}\n\n\tgetFillScale() {\n\t\treturn this.colorScale;\n\t}\n\n\t/**\n\t * Converts data provided in the older format to tabular\n\t *\n\t */\n\tprotected transformToTabularData(data) {\n\t\tconsole.warn(\n\t\t\t\"We've updated the charting data format to be tabular by default. The current format you're using is deprecated and will be removed in v1.0, read more here https://carbon-design-system.github.io/carbon-charts/?path=/story/tutorials--tabular-data-format\"\n\t\t);\n\t\tconst tabularData = [];\n\t\tconst { datasets, labels } = data;\n\n\t\t// Loop through all datasets\n\t\tdatasets.forEach((dataset) => {\n\t\t\t// Update each data point to the new format\n\t\t\tdataset.data.forEach((datum, i) => {\n\t\t\t\tlet group;\n\n\t\t\t\tconst datasetLabel = Tools.getProperty(dataset, \"label\");\n\t\t\t\tif (datasetLabel === null) {\n\t\t\t\t\tconst correspondingLabel = Tools.getProperty(labels, i);\n\t\t\t\t\tif (correspondingLabel) {\n\t\t\t\t\t\tgroup = correspondingLabel;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgroup = \"Ungrouped\";\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tgroup = datasetLabel;\n\t\t\t\t}\n\n\t\t\t\tconst updatedDatum = {\n\t\t\t\t\tgroup,\n\t\t\t\t\tkey: labels[i]\n\t\t\t\t};\n\n\t\t\t\tif (isNaN(datum)) {\n\t\t\t\t\tupdatedDatum[\"value\"] = datum.value;\n\t\t\t\t\tupdatedDatum[\"date\"] = datum.date;\n\t\t\t\t} else {\n\t\t\t\t\tupdatedDatum[\"value\"] = datum;\n\t\t\t\t}\n\n\t\t\t\ttabularData.push(updatedDatum);\n\t\t\t});\n\t\t});\n\n\t\treturn tabularData;\n\t}\n\n\tprotected getTabularData(data) {\n\t\t// if data is not an array\n\t\tif (!Array.isArray(data)) {\n\t\t\treturn this.transformToTabularData(data);\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tprotected sanitize(data) {\n\t\treturn this.getTabularData(data);\n\t}\n\n\t/*\n\t * Data groups\n\t */\n\tprotected updateAllDataGroups() {\n\t\t// allDataGroups is used to generate a color scale that applies\n\t\t// to all the groups. Now when the data updates, you might remove a group,\n\t\t// and then bring it back in a newer data update, therefore\n\t\t// the order of the groups in allDataGroups matters so that you'd never\n\t\t// have an incorrect color assigned to a group.\n\n\t\t// Also, a new group should only be added to allDataGroups if\n\t\t// it doesn't currently exist\n\n\t\tif (!this.allDataGroups) {\n\t\t\tthis.allDataGroups = this.getDataGroupNames();\n\t\t} else {\n\t\t\t// Loop through current data groups\n\t\t\tthis.getDataGroupNames().forEach((dataGroupName) => {\n\t\t\t\t// If group name hasn't been stored yet, store it\n\t\t\t\tif (this.allDataGroups.indexOf(dataGroupName) === -1) {\n\t\t\t\t\tthis.allDataGroups.push(dataGroupName);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected generateDataGroups(data) {\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\t\tconst { ACTIVE, DISABLED } = Configuration.legend.items.status;\n\t\tconst options = this.getOptions();\n\n\t\tconst uniqueDataGroups = map(\n\t\t\tdata,\n\t\t\t(datum) => datum[groupMapsTo]\n\t\t).keys();\n\n\t\t// check if selectedGroups can be applied to chart with current data groups\n\t\tif (options.data.selectedGroups.length) {\n\t\t\tconst hasAllSelectedGroups = options.data.selectedGroups\n\t\t\t\t.every(groupName => uniqueDataGroups.includes(groupName));\n\t\t\tif (!hasAllSelectedGroups) {\n\t\t\t\toptions.data.selectedGroups = [];\n\t\t\t};\n\t\t}\n\n\t\t// Get group status based on items in selected groups\n\t\tconst getStatus = (groupName) => \n\t\t\t!options.data.selectedGroups.length || options.data.selectedGroups.includes(groupName)\n\t\t\t\t? ACTIVE\n\t\t\t\t: DISABLED;\n\n\t\treturn uniqueDataGroups.map(groupName => ({\n\t\t\tname: groupName,\n\t\t\tstatus: getStatus(groupName)\n\t\t}));\n\t}\n\n\t/*\n\t * Fill scales\n\t */\n\tprotected setColorScale() {\n\t\tlet defaultColors = colorPalettes.DEFAULT;\n\n\t\tconst options = this.getOptions();\n\t\tconst userProvidedScale = Tools.getProperty(options, \"color\", \"scale\");\n\n\t\t// If there is no valid user provided scale, use the default set of colors\n\t\tif (\n\t\t\tuserProvidedScale === null ||\n\t\t\tObject.keys(userProvidedScale).length === 0\n\t\t) {\n\t\t\tthis.colorScale = scaleOrdinal()\n\t\t\t\t.range(defaultColors)\n\t\t\t\t.domain(this.allDataGroups);\n\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * Go through allDataGroups. If a data group has a color value provided\n\t\t * by the user, add that to the color range\n\t\t * If not, add a default color\n\t\t */\n\t\tconst colorRange = [];\n\t\tlet colorIndex = 0;\n\t\tthis.allDataGroups.forEach((dataGroup) => {\n\t\t\tif (userProvidedScale[dataGroup]) {\n\t\t\t\tcolorRange.push(userProvidedScale[dataGroup]);\n\t\t\t} else {\n\t\t\t\tcolorRange.push(defaultColors[colorIndex]);\n\t\t\t}\n\n\t\t\tif (colorIndex === defaultColors.length - 1) {\n\t\t\t\tcolorIndex = 0;\n\t\t\t} else {\n\t\t\t\tcolorIndex++;\n\t\t\t}\n\t\t});\n\n\t\tthis.colorScale = scaleOrdinal()\n\t\t\t.range(colorRange)\n\t\t\t.domain(this.allDataGroups);\n\t}\n}\n"]}
|
package/package.json
CHANGED
package/polyfills.js
CHANGED
|
@@ -7,7 +7,7 @@ if (typeof window !== "undefined") {
|
|
|
7
7
|
params = params || {
|
|
8
8
|
bubbles: false,
|
|
9
9
|
cancelable: false,
|
|
10
|
-
detail: undefined
|
|
10
|
+
detail: undefined
|
|
11
11
|
};
|
|
12
12
|
var evt = document.createEvent("CustomEvent");
|
|
13
13
|
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
package/polyfills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["polyfills.ts"],"names":[],"mappings":"AAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAClC,CAAC;QACA,IAAI,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,EAAE;YAChD,OAAO,KAAK,CAAC;SACb;QAED,SAAS,WAAW,CAAC,KAAK,EAAE,MAAM;YACjC,MAAM,GAAG,MAAM,IAAI;gBAClB,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,SAAS;aACjB,CAAC;YACF,IAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YAChD,GAAG,CAAC,eAAe,CAClB,KAAK,EACL,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,MAAM,CACb,CAAC;YACF,OAAO,GAAG,CAAC;QACZ,CAAC;QAED,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC;QAClD,MAAM,CAAC,aAAa,CAAC,GAAG,WAAkB,CAAC;IAC5C,CAAC,CAAC,EAAE,CAAC;IAEL,6CAA6C;IAC7C,SAAS,uBAAuB;QAC/B,IACC,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YAC5D,CAAC,MAAM,CAAC,gBAAgB,CAAC,EACxB;YACD,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC;SACjC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED,uBAAuB,EAAE,CAAC;CAC1B","sourcesContent":["if (typeof window !== \"undefined\") {\n\t(function () {\n\t\tif (typeof window[\"CustomEvent\"] === \"function\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction CustomEvent(event, params) {\n\t\t\tparams = params || {\n\t\t\t\tbubbles: false,\n\t\t\t\tcancelable: false,\n\t\t\t\tdetail: undefined
|
|
1
|
+
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["polyfills.ts"],"names":[],"mappings":"AAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAClC,CAAC;QACA,IAAI,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,EAAE;YAChD,OAAO,KAAK,CAAC;SACb;QAED,SAAS,WAAW,CAAC,KAAK,EAAE,MAAM;YACjC,MAAM,GAAG,MAAM,IAAI;gBAClB,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,SAAS;aACjB,CAAC;YACF,IAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YAChD,GAAG,CAAC,eAAe,CAClB,KAAK,EACL,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,MAAM,CACb,CAAC;YACF,OAAO,GAAG,CAAC;QACZ,CAAC;QAED,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC;QAClD,MAAM,CAAC,aAAa,CAAC,GAAG,WAAkB,CAAC;IAC5C,CAAC,CAAC,EAAE,CAAC;IAEL,6CAA6C;IAC7C,SAAS,uBAAuB;QAC/B,IACC,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YAC5D,CAAC,MAAM,CAAC,gBAAgB,CAAC,EACxB;YACD,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC;SACjC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED,uBAAuB,EAAE,CAAC;CAC1B","sourcesContent":["if (typeof window !== \"undefined\") {\n\t(function () {\n\t\tif (typeof window[\"CustomEvent\"] === \"function\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction CustomEvent(event, params) {\n\t\t\tparams = params || {\n\t\t\t\tbubbles: false,\n\t\t\t\tcancelable: false,\n\t\t\t\tdetail: undefined\n\t\t\t};\n\t\t\tconst evt = document.createEvent(\"CustomEvent\");\n\t\t\tevt.initCustomEvent(\n\t\t\t\tevent,\n\t\t\t\tparams.bubbles,\n\t\t\t\tparams.cancelable,\n\t\t\t\tparams.detail\n\t\t\t);\n\t\t\treturn evt;\n\t\t}\n\n\t\tCustomEvent.prototype = window[\"Event\"].prototype;\n\t\twindow[\"CustomEvent\"] = CustomEvent as any;\n\t})();\n\n\t// Avoid multiple instances of babel-polyfill\n\tfunction idempotentBabelPolyfill() {\n\t\tif (\n\t\t\t(typeof global !== \"undefined\" && !global[\"_babelPolyfill\"]) ||\n\t\t\t!window[\"_babelPolyfill\"]\n\t\t) {\n\t\t\treturn require(\"babel-polyfill\");\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tidempotentBabelPolyfill();\n}\n"]}
|
package/services/angle-utils.js
CHANGED
|
@@ -4,50 +4,50 @@ export function radialLabelPlacement(angleRadians) {
|
|
|
4
4
|
if (isInRange(angle, [0, 10]) || isInRange(angle, [350, 0])) {
|
|
5
5
|
return {
|
|
6
6
|
textAnchor: TextAnchor.START,
|
|
7
|
-
dominantBaseline: DominantBaseline.MIDDLE
|
|
7
|
+
dominantBaseline: DominantBaseline.MIDDLE
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
else if (isInRange(angle, [10, 80])) {
|
|
11
11
|
return {
|
|
12
12
|
textAnchor: TextAnchor.START,
|
|
13
|
-
dominantBaseline: DominantBaseline.HANGING
|
|
13
|
+
dominantBaseline: DominantBaseline.HANGING
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
else if (isInRange(angle, [80, 100])) {
|
|
17
17
|
return {
|
|
18
18
|
textAnchor: TextAnchor.MIDDLE,
|
|
19
|
-
dominantBaseline: DominantBaseline.HANGING
|
|
19
|
+
dominantBaseline: DominantBaseline.HANGING
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
else if (isInRange(angle, [100, 170])) {
|
|
23
23
|
return {
|
|
24
24
|
textAnchor: TextAnchor.END,
|
|
25
|
-
dominantBaseline: DominantBaseline.HANGING
|
|
25
|
+
dominantBaseline: DominantBaseline.HANGING
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
else if (isInRange(angle, [170, 190])) {
|
|
29
29
|
return {
|
|
30
30
|
textAnchor: TextAnchor.END,
|
|
31
|
-
dominantBaseline: DominantBaseline.MIDDLE
|
|
31
|
+
dominantBaseline: DominantBaseline.MIDDLE
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
else if (isInRange(angle, [190, 260])) {
|
|
35
35
|
return {
|
|
36
36
|
textAnchor: TextAnchor.END,
|
|
37
|
-
dominantBaseline: DominantBaseline.BASELINE
|
|
37
|
+
dominantBaseline: DominantBaseline.BASELINE
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
else if (isInRange(angle, [260, 280])) {
|
|
41
41
|
return {
|
|
42
42
|
textAnchor: TextAnchor.MIDDLE,
|
|
43
|
-
dominantBaseline: DominantBaseline.BASELINE
|
|
43
|
+
dominantBaseline: DominantBaseline.BASELINE
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
// 280 - 350
|
|
48
48
|
return {
|
|
49
49
|
textAnchor: TextAnchor.START,
|
|
50
|
-
dominantBaseline: DominantBaseline.BASELINE
|
|
50
|
+
dominantBaseline: DominantBaseline.BASELINE
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angle-utils.js","sourceRoot":"","sources":["angle-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAcnE,MAAM,UAAU,oBAAoB,CAAC,YAAmB;IACvD,IAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC;IAE/C,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE;QAC5D,OAAO;YACN,UAAU,EAAE,UAAU,CAAC,KAAK;YAC5B,gBAAgB,EA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chor, DominantBaseline } from \"../interfaces/enums\";\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport type Angle = number;\n\ninterface LabelAlignment {\n\ttextAnchor: TextAnchor;\n\tdominantBaseline: DominantBaseline;\n}\n\nexport function radialLabelPlacement(angleRadians: Angle): LabelAlignment {\n\tconst angle = mod(radToDeg(angleRadians), 360);\n\n\tif (isInRange(angle, [0, 10]) || isInRange(angle, [350, 0])) {\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.START,\n\t\t\tdominantBaseline: DominantBaseline.MIDDLE
|
|
1
|
+
{"version":3,"file":"angle-utils.js","sourceRoot":"","sources":["angle-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAcnE,MAAM,UAAU,oBAAoB,CAAC,YAAmB;IACvD,IAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC;IAE/C,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE;QAC5D,OAAO;YACN,UAAU,EAAE,UAAU,CAAC,KAAK;YAC5B,gBAAgB,EAAE,gBAAgB,CAAC,MAAM;SACzC,CAAC;KACF;SAAM,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;QACtC,OAAO;YACN,UAAU,EAAE,UAAU,CAAC,KAAK;YAC5B,gBAAgB,EAAE,gBAAgB,CAAC,OAAO;SAC1C,CAAC;KACF;SAAM,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE;QACvC,OAAO;YACN,UAAU,EAAE,UAAU,CAAC,MAAM;YAC7B,gBAAgB,EAAE,gBAAgB,CAAC,OAAO;SAC1C,CAAC;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G,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAU;IAClC,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,sBAAsB,CACrC,CAAQ,EACR,CAAS,EACT,CAAyB;IAAzB,kBAAA,EAAA,MAAa,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;IAEzB,IAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChC,IAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,EAAE,CAAC,GAAA,EAAE,CAAC,GAAA,EAAE,CAAC;AACjB,CAAC;AAED,yEAAyE;AACzE,gDAAgD;AAChD,yEAAyE;AACzE,mEAAmE;AACnE,MAAM,UAAU,6CAA6C,CAC5D,CAAQ,EACR,CAAS;IAET,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { TextAnchor, DominantBaseline } from \"../interfaces/enums\";\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport type Angle = number;\n\ninterface LabelAlignment {\n\ttextAnchor: TextAnchor;\n\tdominantBaseline: DominantBaseline;\n}\n\nexport function radialLabelPlacement(angleRadians: Angle): LabelAlignment {\n\tconst angle = mod(radToDeg(angleRadians), 360);\n\n\tif (isInRange(angle, [0, 10]) || isInRange(angle, [350, 0])) {\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.START,\n\t\t\tdominantBaseline: DominantBaseline.MIDDLE\n\t\t};\n\t} else if (isInRange(angle, [10, 80])) {\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.START,\n\t\t\tdominantBaseline: DominantBaseline.HANGING\n\t\t};\n\t} else if (isInRange(angle, [80, 100])) {\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.MIDDLE,\n\t\t\tdominantBaseline: DominantBaseline.HANGING\n\t\t};\n\t} else if (isInRange(angle, [100, 170])) {\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.END,\n\t\t\tdominantBaseline: DominantBaseline.HANGING\n\t\t};\n\t} else if (isInRange(angle, [170, 190])) {\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.END,\n\t\t\tdominantBaseline: DominantBaseline.MIDDLE\n\t\t};\n\t} else if (isInRange(angle, [190, 260])) {\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.END,\n\t\t\tdominantBaseline: DominantBaseline.BASELINE\n\t\t};\n\t} else if (isInRange(angle, [260, 280])) {\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.MIDDLE,\n\t\t\tdominantBaseline: DominantBaseline.BASELINE\n\t\t};\n\t} else {\n\t\t// 280 - 350\n\t\treturn {\n\t\t\ttextAnchor: TextAnchor.START,\n\t\t\tdominantBaseline: DominantBaseline.BASELINE\n\t\t};\n\t}\n}\n\nfunction mod(n: number, m: number) {\n\treturn ((n % m) + m) % m;\n}\n\nfunction isInRange(x: number, [min, max]: [number, number]) {\n\treturn x >= min && x <= max;\n}\n\nexport function radToDeg(rad: Angle): Angle {\n\treturn rad * (180 / Math.PI);\n}\n\nexport function degToRad(deg: Angle): Angle {\n\treturn deg * (Math.PI / 180);\n}\n\nexport function polarToCartesianCoords(\n\ta: Angle,\n\tr: number,\n\tt: Point = { x: 0, y: 0 }\n): Point {\n\tconst x = r * Math.cos(a) + t.x;\n\tconst y = r * Math.sin(a) + t.y;\n\treturn { x, y };\n}\n\n// Return the distance between a point (described with polar coordinates)\n// on a circumference and the vertical diameter.\n// If the point is on the left if the diameter, its distance is positive,\n// if it is on the right of the diameter, its distance is negative.\nexport function distanceBetweenPointOnCircAndVerticalDiameter(\n\ta: Angle,\n\tr: number\n) {\n\treturn r * Math.sin(a - Math.PI / 2);\n}\n"]}
|
|
@@ -16,7 +16,7 @@ export var WHITE = [
|
|
|
16
16
|
colors.teal(50),
|
|
17
17
|
colors.cyan(90),
|
|
18
18
|
"#8a3800",
|
|
19
|
-
colors.purple(50)
|
|
19
|
+
colors.purple(50)
|
|
20
20
|
];
|
|
21
21
|
export var DARK = [
|
|
22
22
|
colors.purple(60),
|
|
@@ -32,7 +32,7 @@ export var DARK = [
|
|
|
32
32
|
colors.teal(40),
|
|
33
33
|
colors.cyan(20),
|
|
34
34
|
"#ba4e00",
|
|
35
|
-
colors.purple(30)
|
|
35
|
+
colors.purple(30)
|
|
36
36
|
];
|
|
37
37
|
export var G10 = WHITE;
|
|
38
38
|
export var G90 = DARK;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorPalettes.js","sourceRoot":"","sources":["colorPalettes.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,gDAAgD;AAChD,wDAAwD;AACxD,SAAS;AACT,MAAM,CAAC,IAAM,KAAK,GAAG;IACpB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACjB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAClB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACd,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACd,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAChB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAClB,SAAS;IACT,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,SAAS;IACT,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,CAAC,IAAM,IAAI,GAAG;IACnB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACjB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAClB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACd,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACd,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAChB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAClB,SAAS;IACT,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACf,SAAS;IACT,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,CAAC,IAAM,GAAG,GAAG,KAAK,CAAC;AACzB,MAAM,CAAC,IAAM,GAAG,GAAG,IAAI,CAAC;AACxB,MAAM,CAAC,IAAM,IAAI,GAAG,IAAI,CAAC;AAEzB,MAAM,CAAC,IAAM,OAAO,GAAG,KAAK,CAAC","sourcesContent":["import colors from \"./colors\";\n\n// TODO - Some hardcoded values aren't available\n// in @carbon/colors yet. We should look at adding those\n// colors\nexport const WHITE = [\n\tcolors.purple(70),\n\tcolors.cyan(50),\n\tcolors.teal(70),\n\tcolors.magenta(70),\n\tcolors.red(50),\n\tcolors.red(90),\n\tcolors.green(60),\n\tcolors.blue(80),\n\tcolors.magenta(50),\n\t\"#b28600\", // Yellow 50\n\tcolors.teal(50),\n\tcolors.cyan(90),\n\t\"#8a3800\", // Orange 70\n\tcolors.purple(50)
|
|
1
|
+
{"version":3,"file":"colorPalettes.js","sourceRoot":"","sources":["colorPalettes.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,gDA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AM,GAAG,GAAG,IAAI,CAAC;AACxB,MAAM,CAAC,IAAM,IAAI,GAAG,IAAI,CAAC;AAEzB,MAAM,CAAC,IAAM,OAAO,GAAG,KAAK,CAAC","sourcesContent":["import colors from \"./colors\";\n\n// TODO - Some hardcoded values aren't available\n// in @carbon/colors yet. We should look at adding those\n// colors\nexport const WHITE = [\n\tcolors.purple(70),\n\tcolors.cyan(50),\n\tcolors.teal(70),\n\tcolors.magenta(70),\n\tcolors.red(50),\n\tcolors.red(90),\n\tcolors.green(60),\n\tcolors.blue(80),\n\tcolors.magenta(50),\n\t\"#b28600\", // Yellow 50\n\tcolors.teal(50),\n\tcolors.cyan(90),\n\t\"#8a3800\", // Orange 70\n\tcolors.purple(50)\n];\n\nexport const DARK = [\n\tcolors.purple(60),\n\tcolors.cyan(40),\n\tcolors.teal(60),\n\tcolors.magenta(40),\n\tcolors.red(50),\n\tcolors.red(10),\n\tcolors.green(30),\n\tcolors.blue(50),\n\tcolors.magenta(60),\n\t\"#d2a106\", // Yellow 40\n\tcolors.teal(40),\n\tcolors.cyan(20),\n\t\"#ba4e00\", // Orange 60\n\tcolors.purple(30)\n];\n\nexport const G10 = WHITE;\nexport const G90 = DARK;\nexport const G100 = DARK;\n\nexport const DEFAULT = WHITE;\n"]}
|
package/services/colors.js
CHANGED
|
@@ -7,6 +7,6 @@ export default {
|
|
|
7
7
|
magenta: function (shade) { return getColor(magenta, shade); },
|
|
8
8
|
purple: function (shade) { return getColor(purple, shade); },
|
|
9
9
|
red: function (shade) { return getColor(red, shade); },
|
|
10
|
-
teal: function (shade) { return getColor(teal, shade); }
|
|
10
|
+
teal: function (shade) { return getColor(teal, shade); }
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=../../src/services/colors.js.map
|
package/services/colors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sourceRoot":"","sources":["colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE/E,IAAM,QAAQ,GAAG,UAAC,GAAG,EAAE,KAAK,IAAK,OAAA,GAAG,CAAC,KAAK,CAAC,EAAV,CAAU,CAAC;AAE5C,eAAe;IACd,IAAI,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAArB,CAAqB;IACtC,IAAI,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAArB,CAAqB;IACtC,KAAK,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,EAAtB,CAAsB;IACxC,OAAO,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,EAAxB,CAAwB;IAC5C,MAAM,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,EAAvB,CAAuB;IAC1C,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,EAApB,CAAoB;IACpC,IAAI,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAArB,CAAqB;CACtC,CAAC","sourcesContent":["import { blue, cyan, green, magenta, purple, red, teal } from \"@carbon/colors\";\n\nconst getColor = (obj, shade) => obj[shade];\n\nexport default {\n\tblue: (shade) => getColor(blue, shade),\n\tcyan: (shade) => getColor(cyan, shade),\n\tgreen: (shade) => getColor(green, shade),\n\tmagenta: (shade) => getColor(magenta, shade),\n\tpurple: (shade) => getColor(purple, shade),\n\tred: (shade) => getColor(red, shade),\n\tteal: (shade) => getColor(teal, shade)
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE/E,IAAM,QAAQ,GAAG,UAAC,GAAG,EAAE,KAAK,IAAK,OAAA,GAAG,CAAC,KAAK,CAAC,EAAV,CAAU,CAAC;AAE5C,eAAe;IACd,IAAI,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAArB,CAAqB;IACtC,IAAI,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAArB,CAAqB;IACtC,KAAK,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,EAAtB,CAAsB;IACxC,OAAO,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,EAAxB,CAAwB;IAC5C,MAAM,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,EAAvB,CAAuB;IAC1C,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,EAApB,CAAoB;IACpC,IAAI,EAAE,UAAC,KAAK,IAAK,OAAA,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAArB,CAAqB;CACtC,CAAC","sourcesContent":["import { blue, cyan, green, magenta, purple, red, teal } from \"@carbon/colors\";\n\nconst getColor = (obj, shade) => obj[shade];\n\nexport default {\n\tblue: (shade) => getColor(blue, shade),\n\tcyan: (shade) => getColor(cyan, shade),\n\tgreen: (shade) => getColor(green, shade),\n\tmagenta: (shade) => getColor(magenta, shade),\n\tpurple: (shade) => getColor(purple, shade),\n\tred: (shade) => getColor(red, shade),\n\tteal: (shade) => getColor(teal, shade)\n};\n"]}
|
package/services/curves.js
CHANGED
|
@@ -11,7 +11,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
11
11
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
12
|
};
|
|
13
13
|
})();
|
|
14
|
-
import { curveBasis, curveBasisClosed, curveBasisOpen, curveBundle, curveCardinal, curveCardinalClosed, curveCardinalOpen, curveCatmullRom, curveCatmullRomClosed, curveCatmullRomOpen, curveLinear, curveLinearClosed, curveMonotoneX, curveMonotoneY, curveNatural, curveStep, curveStepAfter, curveStepBefore
|
|
14
|
+
import { curveBasis, curveBasisClosed, curveBasisOpen, curveBundle, curveCardinal, curveCardinalClosed, curveCardinalOpen, curveCatmullRom, curveCatmullRomClosed, curveCatmullRomOpen, curveLinear, curveLinearClosed, curveMonotoneX, curveMonotoneY, curveNatural, curveStep, curveStepAfter, curveStepBefore } from "d3-shape";
|
|
15
15
|
// Internal Imports
|
|
16
16
|
import { Service } from "./service";
|
|
17
17
|
var Curves = /** @class */ (function (_super) {
|
|
@@ -36,7 +36,7 @@ var Curves = /** @class */ (function (_super) {
|
|
|
36
36
|
curveNatural: curveNatural,
|
|
37
37
|
curveStep: curveStep,
|
|
38
38
|
curveStepAfter: curveStepAfter,
|
|
39
|
-
curveStepBefore: curveStepBefore
|
|
39
|
+
curveStepBefore: curveStepBefore
|
|
40
40
|
};
|
|
41
41
|
return _this;
|
|
42
42
|
}
|
package/services/curves.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curves.js","sourceRoot":"","sources":["curves.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,SAAS,EACT,cAAc,EACd,eAAe,
|
|
1
|
+
{"version":3,"file":"curves.js","sourceRoot":"","s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AAK,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAEvC,8CAA8C;YAC9C,IAAI,YAAY,EAAE;gBACjB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,UAAC,UAAU;oBAC5C,IAAI,OAAK,CAAC,UAAU,CAAC,EAAE;wBACtB,OAAK,GAAG,OAAK,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;qBACpD;gBACF,CAAC,CAAC,CAAC;aACH;YAED,OAAO,OAAK,CAAC;SACb;QAED,OAAO,CAAC,IAAI,CACX,qBAAmB,SAAS,8CAA2C,CACvE,CAAC;QACF,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IACF,aAAC;AAAD,CAAC,AA3DD,CAA4B,OAAO,GA2DlC","sourcesContent":["import {\n\tcurveBasis,\n\tcurveBasisClosed,\n\tcurveBasisOpen,\n\tcurveBundle,\n\tcurveCardinal,\n\tcurveCardinalClosed,\n\tcurveCardinalOpen,\n\tcurveCatmullRom,\n\tcurveCatmullRomClosed,\n\tcurveCatmullRomOpen,\n\tcurveLinear,\n\tcurveLinearClosed,\n\tcurveMonotoneX,\n\tcurveMonotoneY,\n\tcurveNatural,\n\tcurveStep,\n\tcurveStepAfter,\n\tcurveStepBefore,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tCurveBundleFactory,\n\tCurveCardinalFactory,\n\tCurveCatmullRomFactory,\n\tCurveGenerator\n} from \"d3-shape\";\n\n// this import is needed because of typescript bug (error TS4029)\nimport { Path } from \"d3-path\";\n\n// Internal Imports\nimport { Service } from \"./service\";\n\nexport class Curves extends Service {\n\tcurveTypes = {\n\t\tcurveLinear,\n\t\tcurveLinearClosed,\n\t\tcurveBasis,\n\t\tcurveBasisClosed,\n\t\tcurveBasisOpen,\n\t\tcurveBundle,\n\t\tcurveCardinal,\n\t\tcurveCardinalClosed,\n\t\tcurveCardinalOpen,\n\t\tcurveCatmullRom,\n\t\tcurveCatmullRomClosed,\n\t\tcurveCatmullRomOpen,\n\t\tcurveMonotoneX,\n\t\tcurveMonotoneY,\n\t\tcurveNatural,\n\t\tcurveStep,\n\t\tcurveStepAfter,\n\t\tcurveStepBefore\n\t};\n\n\tgetD3Curve() {\n\t\tlet curveName = \"curveLinear\";\n\t\tconst curveOptions = this.model.getOptions().curve;\n\n\t\t// Parse curve type whether the user provided a string\n\t\t// Or an object with more options\n\t\tif (curveOptions) {\n\t\t\tif (typeof curveOptions === \"string\") {\n\t\t\t\t// curve: 'string'\n\t\t\t\tcurveName = curveOptions;\n\t\t\t} else {\n\t\t\t\t// curve: { name: 'string' }\n\t\t\t\tcurveName = curveOptions.name;\n\t\t\t}\n\t\t}\n\n\t\tif (this.curveTypes[curveName]) {\n\t\t\t// Grab correct d3 curve function\n\t\t\tlet curve = this.curveTypes[curveName];\n\n\t\t\t// Apply user-provided options to the d3 curve\n\t\t\tif (curveOptions) {\n\t\t\t\tObject.keys(curveOptions).forEach((optionName) => {\n\t\t\t\t\tif (curve[optionName]) {\n\t\t\t\t\t\tcurve = curve[optionName](curveOptions[optionName]);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn curve;\n\t\t}\n\n\t\tconsole.warn(\n\t\t\t`The curve type '${curveName}' is invalid, using 'curveLinear' instead`\n\t\t);\n\t\treturn this.curveTypes[\"curveLinear\"];\n\t}\n}\n"]}
|
|
@@ -32,7 +32,7 @@ var DOMUtils = /** @class */ (function (_super) {
|
|
|
32
32
|
}
|
|
33
33
|
var finalDimensions = {
|
|
34
34
|
width: 0,
|
|
35
|
-
height: 0
|
|
35
|
+
height: 0
|
|
36
36
|
};
|
|
37
37
|
var validateAndSetDimensions = function (dimensions) {
|
|
38
38
|
if (dimensions) {
|
|
@@ -51,7 +51,7 @@ var DOMUtils = /** @class */ (function (_super) {
|
|
|
51
51
|
};
|
|
52
52
|
var attrDimensions = {
|
|
53
53
|
width: svgSelector.attr("width"),
|
|
54
|
-
height: svgSelector.attr("height")
|
|
54
|
+
height: svgSelector.attr("height")
|
|
55
55
|
};
|
|
56
56
|
var bbox, bboxDimensions, boundingRect, boundingRectDimensions;
|
|
57
57
|
// In many versions of Firefox
|
|
@@ -60,7 +60,7 @@ var DOMUtils = /** @class */ (function (_super) {
|
|
|
60
60
|
bbox = svgSelector.node().getBBox();
|
|
61
61
|
bboxDimensions = {
|
|
62
62
|
width: bbox.width,
|
|
63
|
-
height: bbox.height
|
|
63
|
+
height: bbox.height
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
catch (e) { }
|
|
@@ -68,13 +68,13 @@ var DOMUtils = /** @class */ (function (_super) {
|
|
|
68
68
|
boundingRect = svgSelector.node().getBoundingClientRect();
|
|
69
69
|
boundingRectDimensions = {
|
|
70
70
|
width: boundingRect.width,
|
|
71
|
-
height: boundingRect.height
|
|
71
|
+
height: boundingRect.height
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
catch (e) { }
|
|
75
75
|
var clientDimensions = {
|
|
76
76
|
width: svgSelector.node().clientWidth,
|
|
77
|
-
height: svgSelector.node().clientHeight
|
|
77
|
+
height: svgSelector.node().clientHeight
|
|
78
78
|
};
|
|
79
79
|
// If both attribute values are numbers
|
|
80
80
|
// And not percentages or NaN
|
|
@@ -107,7 +107,7 @@ var DOMUtils = /** @class */ (function (_super) {
|
|
|
107
107
|
try {
|
|
108
108
|
var nativeDimensions = {
|
|
109
109
|
width: Tools.getProperty(svgSelector.node(), "width", "baseVal", "value"),
|
|
110
|
-
height: Tools.getProperty(svgSelector.node(), "height", "baseVal", "value")
|
|
110
|
+
height: Tools.getProperty(svgSelector.node(), "height", "baseVal", "value")
|
|
111
111
|
};
|
|
112
112
|
validateAndSetDimensions(nativeDimensions);
|
|
113
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-utils.js","sourceRoot":"","sources":["dom-utils.ts"],"names":[],"mappings":";;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AAW,CAAC;QACxC,IAAI,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC;QAE1C,+BAA+B;QAC/B,IAAM,cAAc,GAAG,KAAK,CAAC,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,AApQD,CAA8B,OAAO,GAoQpC","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 settings from \"carbon-components/es/globals/js/settings\";\n\n// MISC\nimport ResizeObserver from \"resize-observer-polyfill\";\n\nexport class DOMUtils extends Service {\n\tstatic getSVGElementSize(\n\t\tsvgSelector: Selection<any, any, any, any>,\n\t\toptions?: any\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 querySections = query.split(\".\");\n\t\tconst elementToAppend = querySections[0];\n\n\t\tconst selection = parent.select(query);\n\t\tif (selection.empty()) {\n\t\t\treturn parent\n\t\t\t\t.append(elementToAppend)\n\t\t\t\t.attr(\"class\", querySections.slice(1).join(\" \"));\n\t\t}\n\n\t\treturn selection;\n\t}\n\n\tprotected svg: Element;\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// Add main SVG\n\t\tthis.addSVGElement();\n\n\t\tif (this.model.getOptions().resizable) {\n\t\t\tthis.addResizeListener();\n\t\t}\n\n\t\tthis.addHolderListeners();\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(\n\t\t\t`${settings.prefix}--chart-holder`,\n\t\t\ttrue\n\t\t);\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\taddSVGElement() {\n\t\tconst chartsprefix = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"style\",\n\t\t\t\"prefix\"\n\t\t);\n\t\tconst svg = select(this.getHolder())\n\t\t\t.append(\"svg\")\n\t\t\t.classed(`${settings.prefix}--${chartsprefix}--chart-svg`, true)\n\t\t\t.attr(\"height\", \"100%\")\n\t\t\t.attr(\"width\", \"100%\");\n\n\t\tthis.svg = svg.node();\n\t}\n\n\tgetMainSVG() {\n\t\treturn this.svg;\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,QAAQ,MAAM,0CAA0C,CAAC;AAEhE,OAAO;AACP,OAAO,cAAc,MAAM,0BAA0B,CAAC;AAEtD;IAA8B,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AAC,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,AApQD,CAA8B,OAAO,GAoQpC","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 settings from \"carbon-components/es/globals/js/settings\";\n\n// MISC\nimport ResizeObserver from \"resize-observer-polyfill\";\n\nexport class DOMUtils extends Service {\n\tstatic getSVGElementSize(\n\t\tsvgSelector: Selection<any, any, any, any>,\n\t\toptions?: any\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 querySections = query.split(\".\");\n\t\tconst elementToAppend = querySections[0];\n\n\t\tconst selection = parent.select(query);\n\t\tif (selection.empty()) {\n\t\t\treturn parent\n\t\t\t\t.append(elementToAppend)\n\t\t\t\t.attr(\"class\", querySections.slice(1).join(\" \"));\n\t\t}\n\n\t\treturn selection;\n\t}\n\n\tprotected svg: Element;\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// Add main SVG\n\t\tthis.addSVGElement();\n\n\t\tif (this.model.getOptions().resizable) {\n\t\t\tthis.addResizeListener();\n\t\t}\n\n\t\tthis.addHolderListeners();\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(\n\t\t\t`${settings.prefix}--chart-holder`,\n\t\t\ttrue\n\t\t);\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\taddSVGElement() {\n\t\tconst chartsprefix = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"style\",\n\t\t\t\"prefix\"\n\t\t);\n\t\tconst svg = select(this.getHolder())\n\t\t\t.append(\"svg\")\n\t\t\t.classed(`${settings.prefix}--${chartsprefix}--chart-svg`, true)\n\t\t\t.attr(\"height\", \"100%\")\n\t\t\t.attr(\"width\", \"100%\");\n\n\t\tthis.svg = svg.node();\n\t}\n\n\tgetMainSVG() {\n\t\treturn this.svg;\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["events.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;IAA4B,0BAAO;IAAnC;;IAoCA,CAAC;IAhCA,qBAAI,GAAJ;QACC,sCAAsC;QACtC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;IAC3D,CAAC;IAED,iCAAgB,GAAhB,UAAiB,IAAY,EAAE,QAAkB;QAChD,gDAAgD;QAChD,0EAA0E;QAC1E,2BAA2B;QAC3B,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAe,CAAC,CAAC;IAC/D,CAAC;IAED,oCAAmB,GAAnB,UAAoB,IAAY,EAAE,QAAkB;QACnD,gDAAgD;QAChD,0EAA0E;QAC1E,2BAA2B;QAC3B,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAe,CAAC,CAAC;IAClE,CAAC;IAED,8BAAa,GAAb,UAAc,SAAiB,EAAE,WAAoB;QACpD,IAAI,QAAQ,CAAC;QACb,IAAI,WAAW,EAAE;YAChB,QAAQ,GAAG,IAAI,WAAW,CAAC,SAAS,EAAE;gBACrC,MAAM,EAAE,WAAW;aACnB,CAAC,CAAC;SACH;aAAM;YACN,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACzC,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IACF,aAAC;AAAD,CAAC,AApCD,CAA4B,OAAO,GAoClC","sourcesContent":["// Internal Imports\nimport { Service } from \"../service\";\n\nexport class Events extends Service {\n\t// DOM Event target\n\tdocumentFragment: DocumentFragment;\n\n\tinit() {\n\t\t// Setup the event fragment on the DOM\n\t\tthis.documentFragment = document.createDocumentFragment();\n\t}\n\n\taddEventListener(type: string, listener: Function) {\n\t\t// Need the casting to any here since typescript\n\t\t// Is expecting a function of type EventListenerOrEventListenerObject here\n\t\t// Which seems unreasonable\n\t\tthis.documentFragment.addEventListener(type, listener as any);\n\t}\n\n\tremoveEventListener(type: string, listener: Function) {\n\t\t// Need the casting to any here since typescript\n\t\t// Is expecting a function of type EventListenerOrEventListenerObject here\n\t\t// Which seems unreasonable\n\t\tthis.documentFragment.removeEventListener(type, listener as any);\n\t}\n\n\tdispatchEvent(eventType: string, eventDetail?: object) {\n\t\tlet newEvent;\n\t\tif (eventDetail) {\n\t\t\tnewEvent = new CustomEvent(eventType, {\n\t\t\t\tdetail: eventDetail
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["events.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;IAA4B,0BAAO;IAAnC;;IAoCA,CAAC;IAhCA,qBAAI,GAAJ;QACC,sCAAsC;QACtC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;IAC3D,CAAC;IAED,iCAAgB,GAAhB,UAAiB,IAAY,EAAE,QAAkB;QAChD,gDAAgD;QAChD,0EAA0E;QAC1E,2BAA2B;QAC3B,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAe,CAAC,CAAC;IAC/D,CAAC;IAED,oCAAmB,GAAnB,UAAoB,IAAY,EAAE,QAAkB;QACnD,gDAAgD;QAChD,0EAA0E;QAC1E,2BAA2B;QAC3B,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAe,CAAC,CAAC;IAClE,CAAC;IAED,8BAAa,GAAb,UAAc,SAAiB,EAAE,WAAoB;QACpD,IAAI,QAAQ,CAAC;QACb,IAAI,WAAW,EAAE;YAChB,QAAQ,GAAG,IAAI,WAAW,CAAC,SAAS,EAAE;gBACrC,MAAM,EAAE,WAAW;aACnB,CAAC,CAAC;SACH;aAAM;YACN,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACzC,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IACF,aAAC;AAAD,CAAC,AApCD,CAA4B,OAAO,GAoClC","sourcesContent":["// Internal Imports\nimport { Service } from \"../service\";\n\nexport class Events extends Service {\n\t// DOM Event target\n\tdocumentFragment: DocumentFragment;\n\n\tinit() {\n\t\t// Setup the event fragment on the DOM\n\t\tthis.documentFragment = document.createDocumentFragment();\n\t}\n\n\taddEventListener(type: string, listener: Function) {\n\t\t// Need the casting to any here since typescript\n\t\t// Is expecting a function of type EventListenerOrEventListenerObject here\n\t\t// Which seems unreasonable\n\t\tthis.documentFragment.addEventListener(type, listener as any);\n\t}\n\n\tremoveEventListener(type: string, listener: Function) {\n\t\t// Need the casting to any here since typescript\n\t\t// Is expecting a function of type EventListenerOrEventListenerObject here\n\t\t// Which seems unreasonable\n\t\tthis.documentFragment.removeEventListener(type, listener as any);\n\t}\n\n\tdispatchEvent(eventType: string, eventDetail?: object) {\n\t\tlet newEvent;\n\t\tif (eventDetail) {\n\t\t\tnewEvent = new CustomEvent(eventType, {\n\t\t\t\tdetail: eventDetail\n\t\t\t});\n\t\t} else {\n\t\t\tnewEvent = document.createEvent(\"Event\");\n\t\t\tnewEvent.initEvent(eventType, false, true);\n\t\t}\n\n\t\tthis.documentFragment.dispatchEvent(newEvent);\n\t}\n}\n"]}
|