@carbon/charts 0.53.5 → 0.54.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/build/demo/data/CHART_TYPES.d.ts +5 -0
- package/build/demo/data/heatmap.d.ts +96 -0
- package/build/demo/data/index.d.ts +1 -0
- package/build/src/charts/heatmap.d.ts +10 -0
- package/build/src/charts/index.d.ts +1 -0
- package/build/src/components/axes/axis.d.ts +7 -1
- package/build/src/components/axes/hover-axis.d.ts +10 -0
- package/build/src/components/essentials/color-scale-legend.d.ts +11 -0
- package/build/src/components/graphs/bar-stacked.d.ts +1 -0
- package/build/src/components/graphs/heatmap.d.ts +25 -0
- package/build/src/components/index.d.ts +2 -0
- package/build/src/configuration-non-customizable.d.ts +12 -0
- package/build/src/configuration.d.ts +2 -1
- package/build/src/interfaces/charts.d.ts +35 -2
- package/build/src/interfaces/enums.d.ts +22 -0
- package/build/src/interfaces/events.d.ts +13 -1
- package/build/src/model/cartesian-charts.d.ts +8 -1
- package/build/src/model/heatmap.d.ts +57 -0
- package/build/src/model/model.d.ts +1 -1
- package/build/src/services/scales-cartesian.d.ts +1 -0
- package/bundle.js +1 -1
- package/charts/heatmap.d.ts +10 -0
- package/charts/heatmap.js +138 -0
- package/charts/heatmap.js.map +1 -0
- package/charts/index.d.ts +1 -0
- package/charts/index.js +1 -0
- package/charts/index.js.map +1 -1
- package/components/axes/axis.d.ts +7 -1
- package/components/axes/axis.js +9 -2
- package/components/axes/axis.js.map +1 -1
- package/components/axes/hover-axis.d.ts +10 -0
- package/components/axes/hover-axis.js +235 -0
- package/components/axes/hover-axis.js.map +1 -0
- package/components/axes/two-dimensional-axes.js +8 -3
- package/components/axes/two-dimensional-axes.js.map +1 -1
- package/components/essentials/color-scale-legend.d.ts +11 -0
- package/components/essentials/color-scale-legend.js +236 -0
- package/components/essentials/color-scale-legend.js.map +1 -0
- package/components/graphs/bar-stacked.d.ts +1 -0
- package/components/graphs/bar-stacked.js +16 -0
- package/components/graphs/bar-stacked.js.map +1 -1
- package/components/graphs/heatmap.d.ts +25 -0
- package/components/graphs/heatmap.js +369 -0
- package/components/graphs/heatmap.js.map +1 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -0
- package/components/index.js.map +1 -1
- package/configuration-non-customizable.d.ts +12 -0
- package/configuration-non-customizable.js +13 -0
- package/configuration-non-customizable.js.map +1 -1
- package/configuration.d.ts +2 -1
- package/configuration.js +13 -1
- package/configuration.js.map +1 -1
- package/demo/data/CHART_TYPES.d.ts +5 -0
- package/demo/data/CHART_TYPES.js +5 -0
- package/demo/data/CHART_TYPES.js.map +1 -1
- package/demo/data/bundle.js +1 -1
- package/demo/data/heatmap.d.ts +96 -0
- package/demo/data/heatmap.js +1135 -0
- package/demo/data/heatmap.js.map +1 -0
- package/demo/data/index.d.ts +1 -0
- package/demo/data/index.js +30 -0
- package/demo/data/index.js.map +1 -1
- package/demo/styles.css +16458 -9179
- 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 +18 -4
- package/interfaces/charts.d.ts +35 -2
- package/interfaces/charts.js.map +1 -1
- package/interfaces/components.js.map +1 -1
- package/interfaces/enums.d.ts +22 -0
- package/interfaces/enums.js +25 -0
- package/interfaces/enums.js.map +1 -1
- package/interfaces/events.d.ts +13 -1
- package/interfaces/events.js +13 -0
- package/interfaces/events.js.map +1 -1
- package/model/cartesian-charts.d.ts +8 -1
- package/model/cartesian-charts.js +4 -2
- package/model/cartesian-charts.js.map +1 -1
- package/model/heatmap.d.ts +57 -0
- package/model/heatmap.js +289 -0
- package/model/heatmap.js.map +1 -0
- package/model/model.d.ts +1 -1
- package/model/model.js +1 -1
- package/model/model.js.map +1 -1
- package/package.json +1 -1
- package/services/canvas-zoom.js +1 -1
- package/services/canvas-zoom.js.map +1 -1
- package/services/scales-cartesian.d.ts +1 -0
- package/services/scales-cartesian.js +16 -0
- package/services/scales-cartesian.js.map +1 -1
- package/styles/_chart-holder.scss +1 -1
- package/styles/color-palatte.scss +96 -0
- package/styles/colors.scss +35 -1
- package/styles/components/_axis.scss +41 -0
- package/styles/components/_color-legend.scss +24 -0
- package/styles/components/index.scss +1 -0
- package/styles/graphs/_heatmap.scss +70 -0
- package/styles/graphs/index.scss +1 -0
- package/styles-g10.css +2002 -181
- 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 +2005 -184
- 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 +2006 -182
- 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 +2002 -181
- package/styles.css.map +1 -1
- package/styles.min.css +1 -1
- package/styles.min.css.map +1 -1
- package/tsconfig.tsbuildinfo +188 -65
package/model/heatmap.js
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
15
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
16
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
17
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
18
|
+
r[k] = a[j];
|
|
19
|
+
return r;
|
|
20
|
+
};
|
|
21
|
+
// Internal Imports
|
|
22
|
+
import { AxisFlavor, ScaleTypes } from '../interfaces';
|
|
23
|
+
import { ChartModelCartesian } from './cartesian-charts';
|
|
24
|
+
import { Tools } from '../tools';
|
|
25
|
+
// d3 imports
|
|
26
|
+
import { extent } from 'd3-array';
|
|
27
|
+
import { scaleQuantize } from 'd3-scale';
|
|
28
|
+
/** The gauge chart model layer */
|
|
29
|
+
var HeatmapModel = /** @class */ (function (_super) {
|
|
30
|
+
__extends(HeatmapModel, _super);
|
|
31
|
+
function HeatmapModel(services) {
|
|
32
|
+
var _this = _super.call(this, services) || this;
|
|
33
|
+
_this.axisFlavor = AxisFlavor.HOVERABLE;
|
|
34
|
+
_this._colorScale = undefined;
|
|
35
|
+
// List of unique ranges and domains
|
|
36
|
+
_this._domains = [];
|
|
37
|
+
_this._ranges = [];
|
|
38
|
+
_this._matrix = {};
|
|
39
|
+
// Check which scale types are being used
|
|
40
|
+
var axis = Tools.getProperty(_this.getOptions(), 'axes');
|
|
41
|
+
// Need to check options since scale service hasn't been instantiated
|
|
42
|
+
if ((!!Tools.getProperty(axis, 'left', 'scaleType') &&
|
|
43
|
+
Tools.getProperty(axis, 'left', 'scaleType') !==
|
|
44
|
+
ScaleTypes.LABELS) ||
|
|
45
|
+
(!!Tools.getProperty(axis, 'right', 'scaleType') &&
|
|
46
|
+
Tools.getProperty(axis, 'right', 'scaleType') !==
|
|
47
|
+
ScaleTypes.LABELS) ||
|
|
48
|
+
(!!Tools.getProperty(axis, 'top', 'scaleType') &&
|
|
49
|
+
Tools.getProperty(axis, 'top', 'scaleType') !==
|
|
50
|
+
ScaleTypes.LABELS) ||
|
|
51
|
+
(!!Tools.getProperty(axis, 'bottom', 'scaleType') &&
|
|
52
|
+
Tools.getProperty(axis, 'bottom', 'scaleType') !==
|
|
53
|
+
ScaleTypes.LABELS)) {
|
|
54
|
+
throw Error('Heatmap only supports label scaletypes.');
|
|
55
|
+
}
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get min and maximum value of the display data
|
|
60
|
+
* @returns Array consisting of smallest and largest values in data
|
|
61
|
+
*/
|
|
62
|
+
HeatmapModel.prototype.getValueDomain = function () {
|
|
63
|
+
var data = this.getDisplayData().map(function (element) { return element.value; });
|
|
64
|
+
var limits = extent(data);
|
|
65
|
+
var domain = [];
|
|
66
|
+
// Round extent values to the nearest multiple of 10
|
|
67
|
+
// Axis rounds values to multiples of 2, 5, and 10s.
|
|
68
|
+
limits.forEach(function (number, index) {
|
|
69
|
+
var value = Number(number);
|
|
70
|
+
if (index === 0 && value >= 0) {
|
|
71
|
+
value = 0;
|
|
72
|
+
}
|
|
73
|
+
else if (value % 10 === 0 || value === 0) {
|
|
74
|
+
value;
|
|
75
|
+
}
|
|
76
|
+
else if (value < 0) {
|
|
77
|
+
value = Math.floor(value / 10) * 10;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
value = Math.ceil(value / 10) * 10;
|
|
81
|
+
}
|
|
82
|
+
domain.push(value);
|
|
83
|
+
});
|
|
84
|
+
// Ensure the median of the range is 0
|
|
85
|
+
if (domain[0] < 0 && domain[1] > 0) {
|
|
86
|
+
if (Math.abs(domain[0]) > domain[1]) {
|
|
87
|
+
domain[1] = Math.abs(domain[0]);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
domain[0] = -domain[1];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return domain;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* @override
|
|
97
|
+
* @param value
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
HeatmapModel.prototype.getFillColor = function (value) {
|
|
101
|
+
return this._colorScale(value);
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Generate a list of all unique domains
|
|
105
|
+
* @returns String[]
|
|
106
|
+
*/
|
|
107
|
+
HeatmapModel.prototype.getUniqueDomain = function () {
|
|
108
|
+
if (Tools.isEmpty(this._domains)) {
|
|
109
|
+
var displayData = this.getDisplayData();
|
|
110
|
+
var cartesianScales = this.services.cartesianScales;
|
|
111
|
+
var domainIdentifier_1 = cartesianScales.getDomainIdentifier();
|
|
112
|
+
var mainXAxisPosition = cartesianScales.getMainXAxisPosition();
|
|
113
|
+
var customDomain = cartesianScales.getCustomDomainValuesByposition(mainXAxisPosition);
|
|
114
|
+
// Use user defined domain if specified
|
|
115
|
+
if (!!customDomain) {
|
|
116
|
+
return customDomain;
|
|
117
|
+
}
|
|
118
|
+
// Get unique axis values & create a matrix
|
|
119
|
+
this._domains = Array.from(new Set(displayData.map(function (d) {
|
|
120
|
+
return d[domainIdentifier_1];
|
|
121
|
+
})));
|
|
122
|
+
}
|
|
123
|
+
return this._domains;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Generates a list of all unique ranges
|
|
127
|
+
* @returns String[]
|
|
128
|
+
*/
|
|
129
|
+
HeatmapModel.prototype.getUniqueRanges = function () {
|
|
130
|
+
if (Tools.isEmpty(this._ranges)) {
|
|
131
|
+
var displayData = this.getDisplayData();
|
|
132
|
+
var cartesianScales = this.services.cartesianScales;
|
|
133
|
+
var rangeIdentifier_1 = cartesianScales.getRangeIdentifier();
|
|
134
|
+
var mainYAxisPosition = cartesianScales.getMainYAxisPosition();
|
|
135
|
+
var customDomain = cartesianScales.getCustomDomainValuesByposition(mainYAxisPosition);
|
|
136
|
+
// Use user defined domain if specified
|
|
137
|
+
if (!!customDomain) {
|
|
138
|
+
return customDomain;
|
|
139
|
+
}
|
|
140
|
+
// Get unique axis values & create a matrix
|
|
141
|
+
this._ranges = Array.from(new Set(displayData.map(function (d) {
|
|
142
|
+
return d[rangeIdentifier_1];
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
145
|
+
return this._ranges;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Generates a matrix (If doesn't exist) and returns it
|
|
149
|
+
* @returns Object
|
|
150
|
+
*/
|
|
151
|
+
HeatmapModel.prototype.getMatrix = function () {
|
|
152
|
+
var _this = this;
|
|
153
|
+
if (Tools.isEmpty(this._matrix)) {
|
|
154
|
+
var uniqueDomain = this.getUniqueDomain();
|
|
155
|
+
var uniqueRange = this.getUniqueRanges();
|
|
156
|
+
var domainIdentifier_2 = this.services.cartesianScales.getDomainIdentifier();
|
|
157
|
+
var rangeIdentifier_2 = this.services.cartesianScales.getRangeIdentifier();
|
|
158
|
+
// Create a column
|
|
159
|
+
var range_1 = {};
|
|
160
|
+
uniqueRange.forEach(function (ran) {
|
|
161
|
+
// Initialize matrix to empty state
|
|
162
|
+
range_1[ran] = {
|
|
163
|
+
value: null,
|
|
164
|
+
index: -1,
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
// Complete the matrix by cloning the column to all domains
|
|
168
|
+
uniqueDomain.forEach(function (dom) {
|
|
169
|
+
_this._matrix[dom] = Tools.clone(range_1);
|
|
170
|
+
});
|
|
171
|
+
// Fill in user passed data
|
|
172
|
+
this.getDisplayData().forEach(function (d, i) {
|
|
173
|
+
_this._matrix[d[domainIdentifier_2]][d[rangeIdentifier_2]] = {
|
|
174
|
+
value: d['value'],
|
|
175
|
+
index: i,
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return this._matrix;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
* @param newData The new raw data to be set
|
|
184
|
+
*/
|
|
185
|
+
HeatmapModel.prototype.setData = function (newData) {
|
|
186
|
+
var sanitizedData = this.sanitize(Tools.clone(newData));
|
|
187
|
+
var dataGroups = this.generateDataGroups(sanitizedData);
|
|
188
|
+
this.set({
|
|
189
|
+
data: sanitizedData,
|
|
190
|
+
dataGroups: dataGroups,
|
|
191
|
+
});
|
|
192
|
+
// Set attributes to empty
|
|
193
|
+
this._domains = [];
|
|
194
|
+
this._ranges = [];
|
|
195
|
+
this._matrix = {};
|
|
196
|
+
return sanitizedData;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Converts Object matrix into a single array
|
|
200
|
+
* @returns Object[]
|
|
201
|
+
*/
|
|
202
|
+
HeatmapModel.prototype.getMatrixAsArray = function () {
|
|
203
|
+
var _this = this;
|
|
204
|
+
if (Tools.isEmpty(this._matrix)) {
|
|
205
|
+
this.getMatrix();
|
|
206
|
+
}
|
|
207
|
+
var uniqueDomain = this.getUniqueDomain();
|
|
208
|
+
var uniqueRange = this.getUniqueRanges();
|
|
209
|
+
var domainIdentifier = this.services.cartesianScales.getDomainIdentifier();
|
|
210
|
+
var rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();
|
|
211
|
+
var arr = [];
|
|
212
|
+
uniqueDomain.forEach(function (domain) {
|
|
213
|
+
uniqueRange.forEach(function (range) {
|
|
214
|
+
var element = {
|
|
215
|
+
value: _this._matrix[domain][range].value,
|
|
216
|
+
index: _this._matrix[domain][range].index,
|
|
217
|
+
};
|
|
218
|
+
element[domainIdentifier] = domain;
|
|
219
|
+
element[rangeIdentifier] = range;
|
|
220
|
+
arr.push(element);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
return arr;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Generate tabular data from display data
|
|
227
|
+
* @returns Array<Object>
|
|
228
|
+
*/
|
|
229
|
+
HeatmapModel.prototype.getTabularDataArray = function () {
|
|
230
|
+
var displayData = this.getDisplayData();
|
|
231
|
+
var _a = this.assignRangeAndDomains(), primaryDomain = _a.primaryDomain, primaryRange = _a.primaryRange, secondaryDomain = _a.secondaryDomain, secondaryRange = _a.secondaryRange;
|
|
232
|
+
var domainValueFormatter;
|
|
233
|
+
var result = __spreadArrays([
|
|
234
|
+
[primaryDomain.label, primaryRange.label, 'Value']
|
|
235
|
+
], displayData.map(function (datum) { return [
|
|
236
|
+
datum[primaryDomain.identifier] === null
|
|
237
|
+
? '–'
|
|
238
|
+
: domainValueFormatter
|
|
239
|
+
? domainValueFormatter(datum[primaryDomain.identifier])
|
|
240
|
+
: datum[primaryDomain.identifier],
|
|
241
|
+
datum[primaryRange.identifier] === null
|
|
242
|
+
? '–'
|
|
243
|
+
: datum[primaryRange.identifier].toLocaleString(),
|
|
244
|
+
datum['value'],
|
|
245
|
+
]; }));
|
|
246
|
+
return result;
|
|
247
|
+
};
|
|
248
|
+
// Uses quantize scale to return class names
|
|
249
|
+
HeatmapModel.prototype.getColorClassName = function (configs) {
|
|
250
|
+
return configs.originalClassName + " " + this._colorScale(configs.value);
|
|
251
|
+
};
|
|
252
|
+
HeatmapModel.prototype.setColorClassNames = function () {
|
|
253
|
+
var options = this.getOptions();
|
|
254
|
+
var customColors = Tools.getProperty(options, 'color', 'gradient', 'colors');
|
|
255
|
+
var customColorsEnabled = !Tools.isEmpty(customColors);
|
|
256
|
+
var colorPairingOption = Tools.getProperty(options, 'color', 'pairing', 'option');
|
|
257
|
+
// If domain consists of negative and positive values, use diverging palettes
|
|
258
|
+
var domain = this.getValueDomain();
|
|
259
|
+
var colorScheme = domain[0] < 0 && domain[1] > 0 ? 'diverge' : 'mono';
|
|
260
|
+
// Use default color pairing options if not in defined range
|
|
261
|
+
if (colorPairingOption < 1 &&
|
|
262
|
+
colorPairingOption > 4 &&
|
|
263
|
+
colorScheme === 'mono') {
|
|
264
|
+
colorPairingOption = 1;
|
|
265
|
+
}
|
|
266
|
+
else if (colorPairingOption < 1 &&
|
|
267
|
+
colorPairingOption > 2 &&
|
|
268
|
+
colorScheme === 'diverge') {
|
|
269
|
+
colorPairingOption = 1;
|
|
270
|
+
}
|
|
271
|
+
// Uses css classes for fill
|
|
272
|
+
var colorPairing = customColorsEnabled ? customColors : [];
|
|
273
|
+
if (!customColorsEnabled) {
|
|
274
|
+
// Add class names to list and the amount based on the color scheme
|
|
275
|
+
// Carbon charts has 11 colors for a single monochromatic palette & 17 for a divergent palette
|
|
276
|
+
var colorGroupingLength = colorScheme === 'diverge' ? 17 : 11;
|
|
277
|
+
for (var i = 1; i < colorGroupingLength + 1; i++) {
|
|
278
|
+
colorPairing.push("fill-" + colorScheme + "-" + colorPairingOption + "-" + i);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Save scale type
|
|
282
|
+
this._colorScale = scaleQuantize()
|
|
283
|
+
.domain(this.getValueDomain())
|
|
284
|
+
.range(colorPairing);
|
|
285
|
+
};
|
|
286
|
+
return HeatmapModel;
|
|
287
|
+
}(ChartModelCartesian));
|
|
288
|
+
export { HeatmapModel };
|
|
289
|
+
//# sourceMappingURL=../../src/model/heatmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heatmap.js","sourceRoot":"","sources":["heatmap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,kCAAkC;AAClC;IAAkC,gCAAmB;IAUpD,sBAAY,QAAa;QAAzB,YACC,kBAAM,QAAQ,CAAC,SAsBf;QAhCS,gBAAU,GAAG,UAAU,CAAC,SAAS,CAAC;QACpC,iBAAW,GAAQ,SAAS,CAAC;QAErC,oCAAoC;QAC5B,cAAQ,GAAG,EAAE,CAAC;QACd,aAAO,GAAG,EAAE,CAAC;QAEb,aAAO,GAAG,EAAE,CAAC;QAKpB,yCAAyC;QACzC,IAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,KAAI,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAAC;QAE1D,qEAAqE;QACrE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E;aAChC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAsB,CAAC;aACjD,KAAK,CAAC,YAAY,CAAC,CAAC;IACvB,CAAC;IACF,mBAAC;AAAD,CAAC,AAjVD,CAAkC,mBAAmB,GAiVpD","sourcesContent":["// Internal Imports\nimport { AxisFlavor, ScaleTypes } from '../interfaces';\nimport { ChartModelCartesian } from './cartesian-charts';\nimport { Tools } from '../tools';\n\n// d3 imports\nimport { extent } from 'd3-array';\nimport { scaleQuantize } from 'd3-scale';\n\n/** The gauge chart model layer */\nexport class HeatmapModel extends ChartModelCartesian {\n\tprotected axisFlavor = AxisFlavor.HOVERABLE;\n\tprivate _colorScale: any = undefined;\n\n\t// List of unique ranges and domains\n\tprivate _domains = [];\n\tprivate _ranges = [];\n\n\tprivate _matrix = {};\n\n\tconstructor(services: any) {\n\t\tsuper(services);\n\n\t\t// Check which scale types are being used\n\t\tconst axis = Tools.getProperty(this.getOptions(), 'axes');\n\n\t\t// Need to check options since scale service hasn't been instantiated\n\t\tif (\n\t\t\t(!!Tools.getProperty(axis, 'left', 'scaleType') &&\n\t\t\t\tTools.getProperty(axis, 'left', 'scaleType') !==\n\t\t\t\t\tScaleTypes.LABELS) ||\n\t\t\t(!!Tools.getProperty(axis, 'right', 'scaleType') &&\n\t\t\t\tTools.getProperty(axis, 'right', 'scaleType') !==\n\t\t\t\t\tScaleTypes.LABELS) ||\n\t\t\t(!!Tools.getProperty(axis, 'top', 'scaleType') &&\n\t\t\t\tTools.getProperty(axis, 'top', 'scaleType') !==\n\t\t\t\t\tScaleTypes.LABELS) ||\n\t\t\t(!!Tools.getProperty(axis, 'bottom', 'scaleType') &&\n\t\t\t\tTools.getProperty(axis, 'bottom', 'scaleType') !==\n\t\t\t\t\tScaleTypes.LABELS)\n\t\t) {\n\t\t\tthrow Error('Heatmap only supports label scaletypes.');\n\t\t}\n\t}\n\n\t/**\n\t * Get min and maximum value of the display data\n\t * @returns Array consisting of smallest and largest values in data\n\t */\n\tgetValueDomain() {\n\t\tconst data = this.getDisplayData().map((element) => element.value);\n\t\tconst limits = extent(data);\n\t\tconst domain = [];\n\n\t\t// Round extent values to the nearest multiple of 10\n\t\t// Axis rounds values to multiples of 2, 5, and 10s.\n\t\tlimits.forEach((number, index) => {\n\t\t\tlet value = Number(number);\n\n\t\t\tif (index === 0 && value >= 0) {\n\t\t\t\tvalue = 0;\n\t\t\t} else if (value % 10 === 0 || value === 0) {\n\t\t\t\tvalue;\n\t\t\t} else if (value < 0) {\n\t\t\t\tvalue = Math.floor(value / 10) * 10;\n\t\t\t} else {\n\t\t\t\tvalue = Math.ceil(value / 10) * 10;\n\t\t\t}\n\n\t\t\tdomain.push(value);\n\t\t});\n\n\t\t// Ensure the median of the range is 0\n\t\tif (domain[0] < 0 && domain[1] > 0) {\n\t\t\tif (Math.abs(domain[0]) > domain[1]) {\n\t\t\t\tdomain[1] = Math.abs(domain[0]);\n\t\t\t} else {\n\t\t\t\tdomain[0] = -domain[1];\n\t\t\t}\n\t\t}\n\n\t\treturn domain;\n\t}\n\n\t/**\n\t * @override\n\t * @param value\n\t * @returns\n\t */\n\tgetFillColor(value: number) {\n\t\treturn this._colorScale(value);\n\t}\n\n\t/**\n\t * Generate a list of all unique domains\n\t * @returns String[]\n\t */\n\tgetUniqueDomain(): string[] {\n\t\tif (Tools.isEmpty(this._domains)) {\n\t\t\tconst displayData = this.getDisplayData();\n\t\t\tconst { cartesianScales } = this.services;\n\n\t\t\tconst domainIdentifier = cartesianScales.getDomainIdentifier();\n\t\t\tconst mainXAxisPosition = cartesianScales.getMainXAxisPosition();\n\t\t\tconst customDomain = cartesianScales.getCustomDomainValuesByposition(\n\t\t\t\tmainXAxisPosition\n\t\t\t);\n\n\t\t\t// Use user defined domain if specified\n\t\t\tif (!!customDomain) {\n\t\t\t\treturn customDomain;\n\t\t\t}\n\n\t\t\t// Get unique axis values & create a matrix\n\t\t\tthis._domains = Array.from(\n\t\t\t\tnew Set(\n\t\t\t\t\tdisplayData.map((d) => {\n\t\t\t\t\t\treturn d[domainIdentifier];\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn this._domains;\n\t}\n\n\t/**\n\t * Generates a list of all unique ranges\n\t * @returns String[]\n\t */\n\tgetUniqueRanges(): string[] {\n\t\tif (Tools.isEmpty(this._ranges)) {\n\t\t\tconst displayData = this.getDisplayData();\n\t\t\tconst { cartesianScales } = this.services;\n\n\t\t\tconst rangeIdentifier = cartesianScales.getRangeIdentifier();\n\t\t\tconst mainYAxisPosition = cartesianScales.getMainYAxisPosition();\n\t\t\tconst customDomain = cartesianScales.getCustomDomainValuesByposition(\n\t\t\t\tmainYAxisPosition\n\t\t\t);\n\n\t\t\t// Use user defined domain if specified\n\t\t\tif (!!customDomain) {\n\t\t\t\treturn customDomain;\n\t\t\t}\n\n\t\t\t// Get unique axis values & create a matrix\n\t\t\tthis._ranges = Array.from(\n\t\t\t\tnew Set(\n\t\t\t\t\tdisplayData.map((d) => {\n\t\t\t\t\t\treturn d[rangeIdentifier];\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn this._ranges;\n\t}\n\n\t/**\n\t * Generates a matrix (If doesn't exist) and returns it\n\t * @returns Object\n\t */\n\tgetMatrix() {\n\t\tif (Tools.isEmpty(this._matrix)) {\n\t\t\tconst uniqueDomain = this.getUniqueDomain();\n\t\t\tconst uniqueRange = this.getUniqueRanges();\n\n\t\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\t\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\t\t// Create a column\n\t\t\tconst range = {};\n\t\t\tuniqueRange.forEach((ran: any) => {\n\t\t\t\t// Initialize matrix to empty state\n\t\t\t\trange[ran] = {\n\t\t\t\t\tvalue: null,\n\t\t\t\t\tindex: -1,\n\t\t\t\t};\n\t\t\t});\n\n\t\t\t// Complete the matrix by cloning the column to all domains\n\t\t\tuniqueDomain.forEach((dom: any) => {\n\t\t\t\tthis._matrix[dom] = Tools.clone(range);\n\t\t\t});\n\n\t\t\t// Fill in user passed data\n\t\t\tthis.getDisplayData().forEach((d, i) => {\n\t\t\t\tthis._matrix[d[domainIdentifier]][d[rangeIdentifier]] = {\n\t\t\t\t\tvalue: d['value'],\n\t\t\t\t\tindex: i,\n\t\t\t\t};\n\t\t\t});\n\t\t}\n\n\t\treturn this._matrix;\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\t// Set attributes to empty\n\t\tthis._domains = [];\n\t\tthis._ranges = [];\n\t\tthis._matrix = {};\n\n\t\treturn sanitizedData;\n\t}\n\n\t/**\n\t * Converts Object matrix into a single array\n\t * @returns Object[]\n\t */\n\tgetMatrixAsArray(): Object[] {\n\t\tif (Tools.isEmpty(this._matrix)) {\n\t\t\tthis.getMatrix();\n\t\t}\n\n\t\tconst uniqueDomain = this.getUniqueDomain();\n\t\tconst uniqueRange = this.getUniqueRanges();\n\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\tconst arr = [];\n\t\tuniqueDomain.forEach((domain) => {\n\t\t\tuniqueRange.forEach((range) => {\n\t\t\t\tconst element = {\n\t\t\t\t\tvalue: this._matrix[domain][range].value,\n\t\t\t\t\tindex: this._matrix[domain][range].index,\n\t\t\t\t};\n\t\t\t\telement[domainIdentifier] = domain;\n\t\t\t\telement[rangeIdentifier] = range;\n\t\t\t\tarr.push(element);\n\t\t\t});\n\t\t});\n\n\t\treturn arr;\n\t}\n\n\t/**\n\t * Generate tabular data from display data\n\t * @returns Array<Object>\n\t */\n\tgetTabularDataArray() {\n\t\tconst displayData = this.getDisplayData();\n\n\t\tconst {\n\t\t\tprimaryDomain,\n\t\t\tprimaryRange,\n\t\t\tsecondaryDomain,\n\t\t\tsecondaryRange,\n\t\t} = this.assignRangeAndDomains();\n\n\t\tlet domainValueFormatter;\n\n\t\tconst result = [\n\t\t\t[primaryDomain.label, primaryRange.label, 'Value'],\n\t\t\t...displayData.map((datum) => [\n\t\t\t\tdatum[primaryDomain.identifier] === null\n\t\t\t\t\t? '–'\n\t\t\t\t\t: domainValueFormatter\n\t\t\t\t\t? domainValueFormatter(datum[primaryDomain.identifier])\n\t\t\t\t\t: datum[primaryDomain.identifier],\n\t\t\t\tdatum[primaryRange.identifier] === null\n\t\t\t\t\t? '–'\n\t\t\t\t\t: datum[primaryRange.identifier].toLocaleString(),\n\t\t\t\tdatum['value'],\n\t\t\t]),\n\t\t];\n\n\t\treturn result;\n\t}\n\n\t// Uses quantize scale to return class names\n\tgetColorClassName(configs: { value?: number; originalClassName?: string }) {\n\t\treturn `${configs.originalClassName} ${this._colorScale(\n\t\t\tconfigs.value as number\n\t\t)}`;\n\t}\n\n\tprotected setColorClassNames() {\n\t\tconst options = this.getOptions();\n\n\t\tconst customColors = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'gradient',\n\t\t\t'colors'\n\t\t);\n\t\tconst customColorsEnabled = !Tools.isEmpty(customColors);\n\n\t\tlet colorPairingOption = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'pairing',\n\t\t\t'option'\n\t\t);\n\n\t\t// If domain consists of negative and positive values, use diverging palettes\n\t\tconst domain = this.getValueDomain();\n\t\tconst colorScheme = domain[0] < 0 && domain[1] > 0 ? 'diverge' : 'mono';\n\n\t\t// Use default color pairing options if not in defined range\n\t\tif (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 4 &&\n\t\t\tcolorScheme === 'mono'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t} else if (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 2 &&\n\t\t\tcolorScheme === 'diverge'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t}\n\n\t\t// Uses css classes for fill\n\t\tconst colorPairing = customColorsEnabled ? customColors : [];\n\n\t\tif (!customColorsEnabled) {\n\t\t\t// Add class names to list and the amount based on the color scheme\n\t\t\t// Carbon charts has 11 colors for a single monochromatic palette & 17 for a divergent palette\n\t\t\tconst colorGroupingLength = colorScheme === 'diverge' ? 17 : 11;\n\t\t\tfor (let i = 1; i < colorGroupingLength + 1; i++) {\n\t\t\t\tcolorPairing.push(\n\t\t\t\t\t`fill-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Save scale type\n\t\tthis._colorScale = scaleQuantize()\n\t\t\t.domain(this.getValueDomain() as [number, number])\n\t\t\t.range(colorPairing);\n\t}\n}\n"]}
|
package/model/model.d.ts
CHANGED
package/model/model.js
CHANGED
|
@@ -243,7 +243,7 @@ var ChartModel = /** @class */ (function () {
|
|
|
243
243
|
};
|
|
244
244
|
ChartModel.prototype.getStackKeys = function (_a) {
|
|
245
245
|
var _this = this;
|
|
246
|
-
var _b = _a.bins, bins =
|
|
246
|
+
var _b = _a === void 0 ? { bins: null, groups: null } : _a, _c = _b.bins, bins = _c === void 0 ? null : _c, _d = _b.groups, groups = _d === void 0 ? null : _d;
|
|
247
247
|
var options = this.getOptions();
|
|
248
248
|
var displayData = this.getDisplayData(groups);
|
|
249
249
|
var stackKeys;
|
package/model/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,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAElF,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,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Aa,CAAC,MAAM,EAAE;YACtE,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;SAC7C;QAED,IAAI,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACrE,IAAM,kBAAkB,GAAG,aAAa,CAAC,KAAK,CAAC,cAAc,CAAC;QAE9D,mEAAmE;QACnE,IAAM,cAAc,GAAG,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAEpE,qDAAqD;QACrD,aAAa;YACZ,aAAa,IAAI,kBAAkB,CAAI,cAAc,WAAQ,CAAC;gBAC7D,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,CAAC,CAAC;QAEN,yDAAyD;QACzD,IAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAC1C,UAAC,SAAS,EAAE,KAAK;YAChB,OAAG,cAAc,SAAI,aAAa,UAAI,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC,CAAE;QAAxD,CAAwD,CACzD,CAAC;QAEF,kCAAkC;QAClC,IAAI,CAAC,eAAe,GAAG,YAAY,EAAE;aACnC,KAAK,CAAC,YAAY,CAAC;aACnB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IACF,iBAAC;AAAD,CAAC,AAr2BD,IAq2BC","sourcesContent":["// Internal Imports\nimport * as Configuration from '../configuration';\nimport { histogram as histogramConfigs } from '../configuration-non-customizable';\n\nimport { Tools } from '../tools';\nimport { Events, ScaleTypes, ColorClassNameTypes } from '../interfaces';\n\n// D3\nimport { scaleOrdinal } from 'd3-scale';\nimport { stack, stackOffsetDiverging } from 'd3-shape';\nimport { histogram } from 'd3-array';\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\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\tprotected colorClassNames: any = {};\n\n\tconstructor(services: any) {\n\t\tthis.services = services;\n\t}\n\n\tgetAllDataFromDomain(groups?) {\n\t\tif (!this.getData()) {\n\t\t\treturn null;\n\t\t}\n\t\tconst options = this.getOptions();\n\t\t// Remove datasets that have been disabled\n\t\tlet allData = this.getData();\n\t\tconst dataGroups = this.getDataGroups();\n\t\tconst { groupMapsTo } = Tools.getProperty(options, 'data');\n\t\tconst axesOptions = Tools.getProperty(options, 'axes');\n\n\t\t// filter out the groups that are irrelevant to the component\n\t\tif (groups) {\n\t\t\tallData = allData.filter((item) =>\n\t\t\t\tgroups.includes(item[groupMapsTo])\n\t\t\t);\n\t\t}\n\n\t\tif (axesOptions) {\n\t\t\tObject.keys(axesOptions).forEach((axis) => {\n\t\t\t\tconst mapsTo = axesOptions[axis].mapsTo;\n\t\t\t\tconst scaleType = axesOptions[axis].scaleType;\n\t\t\t\t// make sure linear/log values are numbers\n\t\t\t\tif (\n\t\t\t\t\tscaleType === ScaleTypes.LINEAR ||\n\t\t\t\t\tscaleType === ScaleTypes.LOG\n\t\t\t\t) {\n\t\t\t\t\tallData = allData.map((datum) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...datum,\n\t\t\t\t\t\t\t[mapsTo]:\n\t\t\t\t\t\t\t\tdatum[mapsTo] === null\n\t\t\t\t\t\t\t\t\t? datum[mapsTo]\n\t\t\t\t\t\t\t\t\t: Number(datum[mapsTo]),\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Check for custom domain\n\t\t\t\tif (mapsTo && axesOptions[axis].domain) {\n\t\t\t\t\tif (scaleType === ScaleTypes.LABELS) {\n\t\t\t\t\t\tallData = allData.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\t\t\t\t\t\t// Filter out data outside domain if that datapoint is using that axis (has mapsTo property)\n\t\t\t\t\t\tallData = allData.filter(\n\t\t\t\t\t\t\t(datum) =>\n\t\t\t\t\t\t\t\t!(mapsTo in datum) ||\n\t\t\t\t\t\t\t\t(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 allData.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\t/**\n\t * Charts that have group configs passed into them, only want to retrieve the display data relevant to that chart\n\t * @param groups the included datasets for the particular chart\n\t */\n\tgetDisplayData(groups?) {\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(groups);\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\t\tconst allDataFromDomain = this.getAllDataFromDomain(groups);\n\n\t\treturn allDataFromDomain.filter((datum) => {\n\t\t\treturn dataGroups.find(\n\t\t\t\t(dataGroup) =>\n\t\t\t\t\tdataGroup.name === datum[groupMapsTo] &&\n\t\t\t\t\tdataGroup.status === ACTIVE\n\t\t\t);\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(groups?) {\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\t// No data should be displayed while data is still loading\n\t\tif (isDataLoading) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// if its a combo chart, the specific chart will pass the model the groups it needs\n\t\tif (groups) {\n\t\t\treturn this.get('dataGroups').filter((dataGroup) =>\n\t\t\t\tgroups.includes(dataGroup.name)\n\t\t\t);\n\t\t}\n\t\treturn this.get('dataGroups');\n\t}\n\n\tgetActiveDataGroups(groups?) {\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\treturn this.getDataGroups(groups).filter(\n\t\t\t(dataGroup) => dataGroup.status === ACTIVE\n\t\t);\n\t}\n\n\tgetDataGroupNames(groups?) {\n\t\tconst dataGroups = this.getDataGroups(groups);\n\t\treturn dataGroups.map((dataGroup) => dataGroup.name);\n\t}\n\n\tgetActiveDataGroupNames(groups?) {\n\t\tconst activeDataGroups = this.getActiveDataGroups(groups);\n\t\treturn activeDataGroups.map((dataGroup) => dataGroup.name);\n\t}\n\n\tprivate aggregateBinDataByGroup(bin) {\n\t\treturn Tools.groupBy(bin, 'group');\n\t}\n\n\tgetBinConfigurations() {\n\t\t// Manipulate data and options for Histogram\n\t\tconst data = this.getDisplayData();\n\t\tconst options = this.getOptions();\n\n\t\tconst mainXPos = this.services.cartesianScales.getMainXAxisPosition();\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\n\t\tconst axisOptions = options.axes[mainXPos];\n\t\tconst { groupMapsTo } = options.data;\n\t\tconst { bins: axisBins = histogramConfigs.defaultBins } = axisOptions;\n\t\tconst areBinsDefined = Array.isArray(axisBins);\n\n\t\t// Get Histogram bins\n\t\tconst bins = histogram()\n\t\t\t.value((d) => d[domainIdentifier])\n\t\t\t.thresholds(axisBins)(data);\n\n\t\tif (!areBinsDefined) {\n\t\t\t// If bins are not defined by user\n\t\t\tconst binsWidth = bins[0].x1 - bins[0].x0;\n\t\t\t// Set last bin width as the others\n\t\t\tbins[bins.length - 1].x1 = +bins[bins.length - 1].x0 + binsWidth;\n\t\t} else {\n\t\t\t// Set last bin end as the last user defined one\n\t\t\tbins[bins.length - 1].x1 = axisBins[axisBins.length - 1];\n\t\t}\n\n\t\tconst binsDomain = areBinsDefined\n\t\t\t? [axisBins[0], axisBins[axisBins.length - 1]]\n\t\t\t: [bins[0].x0, bins[bins.length - 1].x1];\n\n\t\t// Get all groups\n\t\tconst groupsKeys = Array.from(new Set(data.map((d) => d[groupMapsTo])));\n\n\t\tconst histogramData = [];\n\n\t\t// Group data by bin\n\t\tbins.forEach((bin) => {\n\t\t\tconst key = `${bin.x0}-${bin.x1}`;\n\t\t\tconst aggregateDataByGroup = this.aggregateBinDataByGroup(bin);\n\n\t\t\tgroupsKeys.forEach((group: string) => {\n\t\t\t\t// For each dataset put a bin with value 0 if not exist\n\t\t\t\t// (Scale X won't change when changing showed datasets)\n\t\t\t\thistogramData.push({\n\t\t\t\t\tgroup,\n\t\t\t\t\tkey,\n\t\t\t\t\tvalue: aggregateDataByGroup[group] || 0,\n\t\t\t\t\tbin: bin.x0,\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\treturn {\n\t\t\tbins,\n\t\t\tbinsDomain,\n\t\t};\n\t}\n\n\tgetBinnedStackedData() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst dataGroupNames = this.getActiveDataGroupNames();\n\n\t\tconst { bins } = this.getBinConfigurations();\n\t\tconst dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys({\n\t\t\tbins,\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\tgetGroupedData(groups?) {\n\t\tconst displayData = this.getDisplayData(groups);\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\tgetStackKeys({ bins = null, groups = null }) {\n\t\tconst options = this.getOptions();\n\n\t\tconst displayData = this.getDisplayData(groups);\n\n\t\tlet stackKeys;\n\t\tif (bins) {\n\t\t\tstackKeys = bins.map((bin) => `${bin.x0}-${bin.x1}`);\n\t\t} else {\n\t\t\tstackKeys = Tools.removeArrayDuplicates(\n\t\t\t\tdisplayData.map((datum) => {\n\t\t\t\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier(\n\t\t\t\t\t\tdatum\n\t\t\t\t\t);\n\n\t\t\t\t\treturn datum[domainIdentifier] &&\n\t\t\t\t\t\ttypeof datum[domainIdentifier].toString === 'function'\n\t\t\t\t\t\t? datum[domainIdentifier].toString()\n\t\t\t\t\t\t: datum[domainIdentifier];\n\t\t\t\t})\n\t\t\t);\n\t\t}\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\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\treturn stackKeys;\n\t}\n\n\tgetDataValuesGroupedByKeys({ bins = null, groups = null }) {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\t\tconst displayData = this.getDisplayData(groups);\n\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\n\t\tconst stackKeys = this.getStackKeys({ bins, groups });\n\t\tif (bins) {\n\t\t\treturn stackKeys.map((key) => {\n\t\t\t\tconst [binStart, binEnd] = key.split('-');\n\n\t\t\t\tconst correspondingValues = { x0: binStart, x1: binEnd };\n\t\t\t\tconst correspondingBin = bins.find(\n\t\t\t\t\t(bin) => bin.x0.toString() === binStart.toString()\n\t\t\t\t);\n\n\t\t\t\tdataGroupNames.forEach((dataGroupName) => {\n\t\t\t\t\tcorrespondingValues[\n\t\t\t\t\t\tdataGroupName\n\t\t\t\t\t] = correspondingBin.filter(\n\t\t\t\t\t\t(binItem) => binItem[groupMapsTo] === dataGroupName\n\t\t\t\t\t).length;\n\t\t\t\t});\n\n\t\t\t\treturn correspondingValues;\n\t\t\t}) as any;\n\t\t}\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\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier(\n\t\t\t\t\t\tdatum\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdatum[groupMapsTo] === dataGroupName &&\n\t\t\t\t\t\tdatum.hasOwnProperty(domainIdentifier) &&\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\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier(\n\t\t\t\t\tcorrespondingValues\n\t\t\t\t);\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\n\t\t\treturn correspondingValues;\n\t\t}) as any;\n\t}\n\n\tgetStackedData({ percentage = false, groups = null, divergent = false }) {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\t// Get only active data groups so non-active data groups are not rendered\n\t\t// on legend item click\n\t\tconst dataGroupNames = this.getActiveDataGroupNames(groups);\n\t\tconst dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys({\n\t\t\tgroups,\n\t\t});\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\tif (maxByKey[d.sharedStackKey]) {\n\t\t\t\t\t\td[name] = (d[name] / maxByKey[d.sharedStackKey]) * 100;\n\t\t\t\t\t} else {\n\t\t\t\t\t\td[name] = 0;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tconst stackToUse = divergent\n\t\t\t? stack().offset(stackOffsetDiverging)\n\t\t\t: stack();\n\n\t\treturn stackToUse\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, configs?: any) {\n\t\tthis.state = Object.assign({}, this.state, newState);\n\t\tconst newConfig = Object.assign(\n\t\t\t{ skipUpdate: false, animate: true }, // default configs\n\t\t\tconfigs\n\t\t);\n\t\tif (!newConfig.skipUpdate) {\n\t\t\tthis.update(newConfig.animate);\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\tconst options = this.getOptions();\n\t\tTools.updateLegendAdditionalItems(options, newOptions);\n\n\t\tthis.set({\n\t\t\toptions: Tools.merge(options, 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(animate = true) {\n\t\tif (!this.getDisplayData()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updateAllDataGroups();\n\n\t\tthis.setCustomColorScale();\n\t\tthis.setColorClassNames();\n\t\tthis.services.events.dispatchEvent(Events.Model.UPDATE, { animate });\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(\n\t\t\t(group) => group.status === ACTIVE\n\t\t);\n\t\tconst options = this.getOptions();\n\n\t\tconst hasUpdatedDeactivatedItems = dataGroups.some(\n\t\t\t(group) => 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(\n\t\t\t\t(activeItem) => activeItem.name\n\t\t\t);\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 = Tools.getProperty(this.colorScale, group);\n\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 = Tools.getProperty(this.colorScale, group);\n\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\tisUserProvidedColorScaleValid() {\n\t\tconst userProvidedScale = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'color',\n\t\t\t'scale'\n\t\t);\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\tif (\n\t\t\tuserProvidedScale == null ||\n\t\t\tObject.keys(userProvidedScale).length == 0\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn dataGroups.some((dataGroup) =>\n\t\t\tObject.keys(userProvidedScale).includes(dataGroup.name)\n\t\t);\n\t}\n\n\tgetColorClassName(configs: {\n\t\tclassNameTypes: ColorClassNameTypes[];\n\t\tdataGroupName?: string;\n\t\toriginalClassName?: string;\n\t}) {\n\t\tconst colorPairingTag = this.colorClassNames(configs.dataGroupName);\n\t\tlet className = configs.originalClassName;\n\t\tconfigs.classNameTypes.forEach(\n\t\t\t(type) =>\n\t\t\t\t(className = configs.originalClassName\n\t\t\t\t\t? `${className} ${type}-${colorPairingTag}`\n\t\t\t\t\t: `${type}-${colorPairingTag}`)\n\t\t);\n\n\t\treturn className;\n\t}\n\n\t/**\n\t * For charts that might hold an associated status for their dataset\n\t */\n\tgetStatus() {\n\t\treturn null;\n\t}\n\n\tgetAllDataGroupsNames() {\n\t\treturn this.allDataGroups;\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/docs-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\tgetTabularDataArray() {\n\t\treturn [];\n\t}\n\n\texportToCSV() {\n\t\tlet data = this.getTabularDataArray().map((row) =>\n\t\t\trow.map((column) => `\\\"${column}\\\"`)\n\t\t);\n\n\t\tlet csvString = '',\n\t\t\tcsvData = '';\n\t\tdata.forEach(function (d, i) {\n\t\t\tcsvData = d.join(',');\n\t\t\tcsvString += i < data.length ? csvData + '\\n' : csvData;\n\t\t});\n\n\t\tthis.services.files.downloadCSV(csvString, 'myChart.csv');\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\tdata = this.getTabularData(data);\n\n\t\treturn 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 = Tools.removeArrayDuplicates(\n\t\t\tdata.map((datum) => datum[groupMapsTo])\n\t\t);\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.every(\n\t\t\t\t(groupName) => uniqueDataGroups.includes(groupName)\n\t\t\t);\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 ||\n\t\t\toptions.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 setCustomColorScale() {\n\t\tif (!this.isUserProvidedColorScaleValid()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst options = this.getOptions();\n\t\tconst userProvidedScale = Tools.getProperty(options, 'color', 'scale');\n\n\t\tObject.keys(userProvidedScale).forEach((dataGroup) => {\n\t\t\tif (!this.allDataGroups.includes(dataGroup)) {\n\t\t\t\tconsole.warn(`\"${dataGroup}\" does not exist in data groups.`);\n\t\t\t}\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 */\n\t\tconst providedDataGroups = this.allDataGroups.filter(\n\t\t\t(dataGroup) => userProvidedScale[dataGroup]\n\t\t);\n\n\t\tprovidedDataGroups.forEach(\n\t\t\t(dataGroup) =>\n\t\t\t\t(this.colorScale[dataGroup] = userProvidedScale[dataGroup])\n\t\t);\n\t}\n\n\t/*\n\t * Color palette\n\t */\n\tprotected setColorClassNames() {\n\t\tconst colorPairingOptions = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'color',\n\t\t\t'pairing'\n\t\t);\n\n\t\t// Check if user has defined numberOfVariants (differ from given data)\n\t\tlet numberOfVariants = Tools.getProperty(\n\t\t\tcolorPairingOptions,\n\t\t\t'numberOfVariants'\n\t\t);\n\t\tif (!numberOfVariants || numberOfVariants < this.allDataGroups.length) {\n\t\t\tnumberOfVariants = this.allDataGroups.length;\n\t\t}\n\n\t\tlet pairingOption = Tools.getProperty(colorPairingOptions, 'option');\n\t\tconst colorPairingCounts = Configuration.color.pairingOptions;\n\n\t\t// If number of dataGroups is greater than 5, user 14-color palette\n\t\tconst numberOfColors = numberOfVariants > 5 ? 14 : numberOfVariants;\n\n\t\t// Use default palette if user choice is not in range\n\t\tpairingOption =\n\t\t\tpairingOption <= colorPairingCounts[`${numberOfColors}-color`]\n\t\t\t\t? pairingOption\n\t\t\t\t: 1;\n\n\t\t// Create color classes for graph, tooltip and stroke use\n\t\tconst colorPairing = this.allDataGroups.map(\n\t\t\t(dataGroup, index) =>\n\t\t\t\t`${numberOfColors}-${pairingOption}-${(index % 14) + 1}`\n\t\t);\n\n\t\t// Create default color classnames\n\t\tthis.colorClassNames = scaleOrdinal()\n\t\t\t.range(colorPairing)\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,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAElF,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAuB,MAAM,eAAe,CAAC;AAExE,KAAK;AACL,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;qEACqE;AACrE;IAoBC,oBAAY,QAAa;QAjBzB,uBAAuB;QACb,UAAK,GAAQ;Y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C,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAEpE,qDAAqD;QACrD,aAAa;YACZ,aAAa,IAAI,kBAAkB,CAAI,cAAc,WAAQ,CAAC;gBAC7D,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,CAAC,CAAC;QAEN,yDAAyD;QACzD,IAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAC1C,UAAC,SAAS,EAAE,KAAK;YAChB,OAAG,cAAc,SAAI,aAAa,UAAI,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC,CAAE;QAAxD,CAAwD,CACzD,CAAC;QAEF,kCAAkC;QAClC,IAAI,CAAC,eAAe,GAAG,YAAY,EAAE;aACnC,KAAK,CAAC,YAAY,CAAC;aACnB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IACF,iBAAC;AAAD,CAAC,AAv2BD,IAu2BC","sourcesContent":["// Internal Imports\nimport * as Configuration from '../configuration';\nimport { histogram as histogramConfigs } from '../configuration-non-customizable';\n\nimport { Tools } from '../tools';\nimport { Events, ScaleTypes, ColorClassNameTypes } from '../interfaces';\n\n// D3\nimport { scaleOrdinal } from 'd3-scale';\nimport { stack, stackOffsetDiverging } from 'd3-shape';\nimport { histogram } from 'd3-array';\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\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\tprotected colorClassNames: any = {};\n\n\tconstructor(services: any) {\n\t\tthis.services = services;\n\t}\n\n\tgetAllDataFromDomain(groups?) {\n\t\tif (!this.getData()) {\n\t\t\treturn null;\n\t\t}\n\t\tconst options = this.getOptions();\n\t\t// Remove datasets that have been disabled\n\t\tlet allData = this.getData();\n\t\tconst dataGroups = this.getDataGroups();\n\t\tconst { groupMapsTo } = Tools.getProperty(options, 'data');\n\t\tconst axesOptions = Tools.getProperty(options, 'axes');\n\n\t\t// filter out the groups that are irrelevant to the component\n\t\tif (groups) {\n\t\t\tallData = allData.filter((item) =>\n\t\t\t\tgroups.includes(item[groupMapsTo])\n\t\t\t);\n\t\t}\n\n\t\tif (axesOptions) {\n\t\t\tObject.keys(axesOptions).forEach((axis) => {\n\t\t\t\tconst mapsTo = axesOptions[axis].mapsTo;\n\t\t\t\tconst scaleType = axesOptions[axis].scaleType;\n\t\t\t\t// make sure linear/log values are numbers\n\t\t\t\tif (\n\t\t\t\t\tscaleType === ScaleTypes.LINEAR ||\n\t\t\t\t\tscaleType === ScaleTypes.LOG\n\t\t\t\t) {\n\t\t\t\t\tallData = allData.map((datum) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...datum,\n\t\t\t\t\t\t\t[mapsTo]:\n\t\t\t\t\t\t\t\tdatum[mapsTo] === null\n\t\t\t\t\t\t\t\t\t? datum[mapsTo]\n\t\t\t\t\t\t\t\t\t: Number(datum[mapsTo]),\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Check for custom domain\n\t\t\t\tif (mapsTo && axesOptions[axis].domain) {\n\t\t\t\t\tif (scaleType === ScaleTypes.LABELS) {\n\t\t\t\t\t\tallData = allData.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\t\t\t\t\t\t// Filter out data outside domain if that datapoint is using that axis (has mapsTo property)\n\t\t\t\t\t\tallData = allData.filter(\n\t\t\t\t\t\t\t(datum) =>\n\t\t\t\t\t\t\t\t!(mapsTo in datum) ||\n\t\t\t\t\t\t\t\t(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 allData.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\t/**\n\t * Charts that have group configs passed into them, only want to retrieve the display data relevant to that chart\n\t * @param groups the included datasets for the particular chart\n\t */\n\tgetDisplayData(groups?) {\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(groups);\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\t\tconst allDataFromDomain = this.getAllDataFromDomain(groups);\n\n\t\treturn allDataFromDomain.filter((datum) => {\n\t\t\treturn dataGroups.find(\n\t\t\t\t(dataGroup) =>\n\t\t\t\t\tdataGroup.name === datum[groupMapsTo] &&\n\t\t\t\t\tdataGroup.status === ACTIVE\n\t\t\t);\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(groups?) {\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\t// No data should be displayed while data is still loading\n\t\tif (isDataLoading) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// if its a combo chart, the specific chart will pass the model the groups it needs\n\t\tif (groups) {\n\t\t\treturn this.get('dataGroups').filter((dataGroup) =>\n\t\t\t\tgroups.includes(dataGroup.name)\n\t\t\t);\n\t\t}\n\t\treturn this.get('dataGroups');\n\t}\n\n\tgetActiveDataGroups(groups?) {\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\treturn this.getDataGroups(groups).filter(\n\t\t\t(dataGroup) => dataGroup.status === ACTIVE\n\t\t);\n\t}\n\n\tgetDataGroupNames(groups?) {\n\t\tconst dataGroups = this.getDataGroups(groups);\n\t\treturn dataGroups.map((dataGroup) => dataGroup.name);\n\t}\n\n\tgetActiveDataGroupNames(groups?) {\n\t\tconst activeDataGroups = this.getActiveDataGroups(groups);\n\t\treturn activeDataGroups.map((dataGroup) => dataGroup.name);\n\t}\n\n\tprivate aggregateBinDataByGroup(bin) {\n\t\treturn Tools.groupBy(bin, 'group');\n\t}\n\n\tgetBinConfigurations() {\n\t\t// Manipulate data and options for Histogram\n\t\tconst data = this.getDisplayData();\n\t\tconst options = this.getOptions();\n\n\t\tconst mainXPos = this.services.cartesianScales.getMainXAxisPosition();\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\n\t\tconst axisOptions = options.axes[mainXPos];\n\t\tconst { groupMapsTo } = options.data;\n\t\tconst { bins: axisBins = histogramConfigs.defaultBins } = axisOptions;\n\t\tconst areBinsDefined = Array.isArray(axisBins);\n\n\t\t// Get Histogram bins\n\t\tconst bins = histogram()\n\t\t\t.value((d) => d[domainIdentifier])\n\t\t\t.thresholds(axisBins)(data);\n\n\t\tif (!areBinsDefined) {\n\t\t\t// If bins are not defined by user\n\t\t\tconst binsWidth = bins[0].x1 - bins[0].x0;\n\t\t\t// Set last bin width as the others\n\t\t\tbins[bins.length - 1].x1 = +bins[bins.length - 1].x0 + binsWidth;\n\t\t} else {\n\t\t\t// Set last bin end as the last user defined one\n\t\t\tbins[bins.length - 1].x1 = axisBins[axisBins.length - 1];\n\t\t}\n\n\t\tconst binsDomain = areBinsDefined\n\t\t\t? [axisBins[0], axisBins[axisBins.length - 1]]\n\t\t\t: [bins[0].x0, bins[bins.length - 1].x1];\n\n\t\t// Get all groups\n\t\tconst groupsKeys = Array.from(new Set(data.map((d) => d[groupMapsTo])));\n\n\t\tconst histogramData = [];\n\n\t\t// Group data by bin\n\t\tbins.forEach((bin) => {\n\t\t\tconst key = `${bin.x0}-${bin.x1}`;\n\t\t\tconst aggregateDataByGroup = this.aggregateBinDataByGroup(bin);\n\n\t\t\tgroupsKeys.forEach((group: string) => {\n\t\t\t\t// For each dataset put a bin with value 0 if not exist\n\t\t\t\t// (Scale X won't change when changing showed datasets)\n\t\t\t\thistogramData.push({\n\t\t\t\t\tgroup,\n\t\t\t\t\tkey,\n\t\t\t\t\tvalue: aggregateDataByGroup[group] || 0,\n\t\t\t\t\tbin: bin.x0,\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\treturn {\n\t\t\tbins,\n\t\t\tbinsDomain,\n\t\t};\n\t}\n\n\tgetBinnedStackedData() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst dataGroupNames = this.getActiveDataGroupNames();\n\n\t\tconst { bins } = this.getBinConfigurations();\n\t\tconst dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys({\n\t\t\tbins,\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\tgetGroupedData(groups?) {\n\t\tconst displayData = this.getDisplayData(groups);\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\tgetStackKeys(\n\t\t{ bins = null, groups = null } = { bins: null, groups: null }\n\t) {\n\t\tconst options = this.getOptions();\n\n\t\tconst displayData = this.getDisplayData(groups);\n\n\t\tlet stackKeys;\n\t\tif (bins) {\n\t\t\tstackKeys = bins.map((bin) => `${bin.x0}-${bin.x1}`);\n\t\t} else {\n\t\t\tstackKeys = Tools.removeArrayDuplicates(\n\t\t\t\tdisplayData.map((datum) => {\n\t\t\t\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier(\n\t\t\t\t\t\tdatum\n\t\t\t\t\t);\n\n\t\t\t\t\treturn datum[domainIdentifier] &&\n\t\t\t\t\t\ttypeof datum[domainIdentifier].toString === 'function'\n\t\t\t\t\t\t? datum[domainIdentifier].toString()\n\t\t\t\t\t\t: datum[domainIdentifier];\n\t\t\t\t})\n\t\t\t);\n\t\t}\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\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\treturn stackKeys;\n\t}\n\n\tgetDataValuesGroupedByKeys({ bins = null, groups = null }) {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\t\tconst displayData = this.getDisplayData(groups);\n\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\n\t\tconst stackKeys = this.getStackKeys({ bins, groups });\n\t\tif (bins) {\n\t\t\treturn stackKeys.map((key) => {\n\t\t\t\tconst [binStart, binEnd] = key.split('-');\n\n\t\t\t\tconst correspondingValues = { x0: binStart, x1: binEnd };\n\t\t\t\tconst correspondingBin = bins.find(\n\t\t\t\t\t(bin) => bin.x0.toString() === binStart.toString()\n\t\t\t\t);\n\n\t\t\t\tdataGroupNames.forEach((dataGroupName) => {\n\t\t\t\t\tcorrespondingValues[\n\t\t\t\t\t\tdataGroupName\n\t\t\t\t\t] = correspondingBin.filter(\n\t\t\t\t\t\t(binItem) => binItem[groupMapsTo] === dataGroupName\n\t\t\t\t\t).length;\n\t\t\t\t});\n\n\t\t\t\treturn correspondingValues;\n\t\t\t}) as any;\n\t\t}\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\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier(\n\t\t\t\t\t\tdatum\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdatum[groupMapsTo] === dataGroupName &&\n\t\t\t\t\t\tdatum.hasOwnProperty(domainIdentifier) &&\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\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier(\n\t\t\t\t\tcorrespondingValues\n\t\t\t\t);\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\n\t\t\treturn correspondingValues;\n\t\t}) as any;\n\t}\n\n\tgetStackedData({ percentage = false, groups = null, divergent = false }) {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\t// Get only active data groups so non-active data groups are not rendered\n\t\t// on legend item click\n\t\tconst dataGroupNames = this.getActiveDataGroupNames(groups);\n\t\tconst dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys({\n\t\t\tgroups,\n\t\t});\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\tif (maxByKey[d.sharedStackKey]) {\n\t\t\t\t\t\td[name] = (d[name] / maxByKey[d.sharedStackKey]) * 100;\n\t\t\t\t\t} else {\n\t\t\t\t\t\td[name] = 0;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tconst stackToUse = divergent\n\t\t\t? stack().offset(stackOffsetDiverging)\n\t\t\t: stack();\n\n\t\treturn stackToUse\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, configs?: any) {\n\t\tthis.state = Object.assign({}, this.state, newState);\n\t\tconst newConfig = Object.assign(\n\t\t\t{ skipUpdate: false, animate: true }, // default configs\n\t\t\tconfigs\n\t\t);\n\t\tif (!newConfig.skipUpdate) {\n\t\t\tthis.update(newConfig.animate);\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\tconst options = this.getOptions();\n\t\tTools.updateLegendAdditionalItems(options, newOptions);\n\n\t\tthis.set({\n\t\t\toptions: Tools.merge(options, 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(animate = true) {\n\t\tif (!this.getDisplayData()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updateAllDataGroups();\n\n\t\tthis.setCustomColorScale();\n\t\tthis.setColorClassNames();\n\t\tthis.services.events.dispatchEvent(Events.Model.UPDATE, { animate });\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(\n\t\t\t(group) => group.status === ACTIVE\n\t\t);\n\t\tconst options = this.getOptions();\n\n\t\tconst hasUpdatedDeactivatedItems = dataGroups.some(\n\t\t\t(group) => 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(\n\t\t\t\t(activeItem) => activeItem.name\n\t\t\t);\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 = Tools.getProperty(this.colorScale, group);\n\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 = Tools.getProperty(this.colorScale, group);\n\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\tisUserProvidedColorScaleValid() {\n\t\tconst userProvidedScale = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'color',\n\t\t\t'scale'\n\t\t);\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\tif (\n\t\t\tuserProvidedScale == null ||\n\t\t\tObject.keys(userProvidedScale).length == 0\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn dataGroups.some((dataGroup) =>\n\t\t\tObject.keys(userProvidedScale).includes(dataGroup.name)\n\t\t);\n\t}\n\n\tgetColorClassName(configs: {\n\t\tclassNameTypes: ColorClassNameTypes[];\n\t\tdataGroupName?: string;\n\t\toriginalClassName?: string;\n\t}) {\n\t\tconst colorPairingTag = this.colorClassNames(configs.dataGroupName);\n\t\tlet className = configs.originalClassName;\n\t\tconfigs.classNameTypes.forEach(\n\t\t\t(type) =>\n\t\t\t\t(className = configs.originalClassName\n\t\t\t\t\t? `${className} ${type}-${colorPairingTag}`\n\t\t\t\t\t: `${type}-${colorPairingTag}`)\n\t\t);\n\n\t\treturn className;\n\t}\n\n\t/**\n\t * For charts that might hold an associated status for their dataset\n\t */\n\tgetStatus() {\n\t\treturn null;\n\t}\n\n\tgetAllDataGroupsNames() {\n\t\treturn this.allDataGroups;\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/docs-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\tgetTabularDataArray() {\n\t\treturn [];\n\t}\n\n\texportToCSV() {\n\t\tlet data = this.getTabularDataArray().map((row) =>\n\t\t\trow.map((column) => `\\\"${column}\\\"`)\n\t\t);\n\n\t\tlet csvString = '',\n\t\t\tcsvData = '';\n\t\tdata.forEach(function (d, i) {\n\t\t\tcsvData = d.join(',');\n\t\t\tcsvString += i < data.length ? csvData + '\\n' : csvData;\n\t\t});\n\n\t\tthis.services.files.downloadCSV(csvString, 'myChart.csv');\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\tdata = this.getTabularData(data);\n\n\t\treturn 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 = Tools.removeArrayDuplicates(\n\t\t\tdata.map((datum) => datum[groupMapsTo])\n\t\t);\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.every(\n\t\t\t\t(groupName) => uniqueDataGroups.includes(groupName)\n\t\t\t);\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 ||\n\t\t\toptions.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 setCustomColorScale() {\n\t\tif (!this.isUserProvidedColorScaleValid()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst options = this.getOptions();\n\t\tconst userProvidedScale = Tools.getProperty(options, 'color', 'scale');\n\n\t\tObject.keys(userProvidedScale).forEach((dataGroup) => {\n\t\t\tif (!this.allDataGroups.includes(dataGroup)) {\n\t\t\t\tconsole.warn(`\"${dataGroup}\" does not exist in data groups.`);\n\t\t\t}\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 */\n\t\tconst providedDataGroups = this.allDataGroups.filter(\n\t\t\t(dataGroup) => userProvidedScale[dataGroup]\n\t\t);\n\n\t\tprovidedDataGroups.forEach(\n\t\t\t(dataGroup) =>\n\t\t\t\t(this.colorScale[dataGroup] = userProvidedScale[dataGroup])\n\t\t);\n\t}\n\n\t/*\n\t * Color palette\n\t */\n\tprotected setColorClassNames() {\n\t\tconst colorPairingOptions = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'color',\n\t\t\t'pairing'\n\t\t);\n\n\t\t// Check if user has defined numberOfVariants (differ from given data)\n\t\tlet numberOfVariants = Tools.getProperty(\n\t\t\tcolorPairingOptions,\n\t\t\t'numberOfVariants'\n\t\t);\n\t\tif (!numberOfVariants || numberOfVariants < this.allDataGroups.length) {\n\t\t\tnumberOfVariants = this.allDataGroups.length;\n\t\t}\n\n\t\tlet pairingOption = Tools.getProperty(colorPairingOptions, 'option');\n\t\tconst colorPairingCounts = Configuration.color.pairingOptions;\n\n\t\t// If number of dataGroups is greater than 5, user 14-color palette\n\t\tconst numberOfColors = numberOfVariants > 5 ? 14 : numberOfVariants;\n\n\t\t// Use default palette if user choice is not in range\n\t\tpairingOption =\n\t\t\tpairingOption <= colorPairingCounts[`${numberOfColors}-color`]\n\t\t\t\t? pairingOption\n\t\t\t\t: 1;\n\n\t\t// Create color classes for graph, tooltip and stroke use\n\t\tconst colorPairing = this.allDataGroups.map(\n\t\t\t(dataGroup, index) =>\n\t\t\t\t`${numberOfColors}-${pairingOption}-${(index % 14) + 1}`\n\t\t);\n\n\t\t// Create default color classnames\n\t\tthis.colorClassNames = scaleOrdinal()\n\t\t\t.range(colorPairing)\n\t\t\t.domain(this.allDataGroups);\n\t}\n}\n"]}
|
package/package.json
CHANGED
package/services/canvas-zoom.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Service } from './service';
|
|
|
16
16
|
import { Events } from './../interfaces/enums';
|
|
17
17
|
import * as Configuration from '../configuration';
|
|
18
18
|
// Services
|
|
19
|
-
import { DOMUtils } from './
|
|
19
|
+
import { DOMUtils } from './essentials/dom-utils';
|
|
20
20
|
import { select } from 'd3-selection';
|
|
21
21
|
var CanvasZoom = /** @class */ (function (_super) {
|
|
22
22
|
__extends(CanvasZoom, _super);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-zoom.js","sourceRoot":"","sources":["canvas-zoom.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas-zoom.js","sourceRoot":"","sources":["canvas-zoom.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,WAAW;AACX,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC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AAC,IAAI,CAAC;aACnB,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAExB,iCAAiC;QACjC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IACvE,CAAC;IACF,iBAAC;AAAD,CAAC,AA5DD,CAAgC,OAAO,GA4DtC","sourcesContent":["// Internal Imports\nimport { Service } from './service';\nimport { Events } from './../interfaces/enums';\nimport * as Configuration from '../configuration';\n// Services\nimport { DOMUtils } from './essentials/dom-utils';\nimport { select } from 'd3-selection';\n\nexport class CanvasZoom extends Service {\n\tprotected model: any;\n\n\t/**\n\t * focal: object to zoom into\n\t * canvasElements: all the elements to translate and zoom on the chart area\n\t * zoomSettings: object containing duration, easing and zoomlevel for the zoom behaviours\n\t * */\n\tzoomIn(focal, canvasElements, zoomSettings?) {\n\t\tlet x;\n\t\tlet y;\n\t\tlet zoomLevel;\n\t\tconst settings = zoomSettings\n\t\t\t? zoomSettings\n\t\t\t: Configuration.canvasZoomSettings;\n\n\t\tif (focal) {\n\t\t\tx = focal.x;\n\t\t\ty = focal.y;\n\t\t\tzoomLevel = 2;\n\t\t}\n\n\t\t// the 'viewport' size of the chart\n\t\tconst { width, height } = DOMUtils.getSVGElementSize(\n\t\t\tthis.services.domUtils.getHolder(),\n\t\t\t{\n\t\t\t\tuseClientDimensions: true,\n\t\t\t}\n\t\t);\n\n\t\tcanvasElements\n\t\t\t.transition()\n\t\t\t.duration(settings.duration)\n\t\t\t.ease(settings.ease)\n\t\t\t.attr(\n\t\t\t\t'transform',\n\t\t\t\t`translate(${width / 2}, ${\n\t\t\t\t\theight / 2\n\t\t\t\t}) scale(${zoomLevel}) translate(${-x},${-y})`\n\t\t\t);\n\n\t\t// Dispatch canvas zoom in event\n\t\tthis.services.events.dispatchEvent(Events.CanvasZoom.CANVAS_ZOOM_IN, {\n\t\t\telement: select(focal),\n\t\t});\n\t}\n\n\tzoomOut(canvasElements, zoomSettings?) {\n\t\tconst settings = zoomSettings\n\t\t\t? zoomSettings\n\t\t\t: Configuration.canvasZoomSettings;\n\t\tcanvasElements\n\t\t\t.transition()\n\t\t\t.duration(settings.duration)\n\t\t\t.ease(settings.ease)\n\t\t\t.attr('transform', '');\n\n\t\t// Dispatch canvas zoom out event\n\t\tthis.services.events.dispatchEvent(Events.CanvasZoom.CANVAS_ZOOM_OUT);\n\t}\n}\n"]}
|
|
@@ -37,6 +37,7 @@ export declare class CartesianScales extends Service {
|
|
|
37
37
|
determineOrientation(): void;
|
|
38
38
|
isDualAxes(): Boolean;
|
|
39
39
|
determineAxisDuality(): void;
|
|
40
|
+
getCustomDomainValuesByposition(axisPosition: AxisPositions): any;
|
|
40
41
|
getOrientation(): CartesianOrientations;
|
|
41
42
|
getScaleByPosition(axisPosition: AxisPositions): any;
|
|
42
43
|
getScaleTypeByPosition(axisPosition: AxisPositions): any;
|