@oliasoft-open-source/charts-library 3.3.6-beta-3 → 3.3.6-beta-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +50 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37314,25 +37314,66 @@ const getSuggestedAxisRange = ({
|
|
|
37314
37314
|
max: round$2(maxAxisValue, DECIMAL_POINT_TOLERANCE)
|
|
37315
37315
|
};
|
|
37316
37316
|
};
|
|
37317
|
+
const checkMultiAxis = (scalesKeys) => {
|
|
37318
|
+
let counts = {
|
|
37319
|
+
x: 0,
|
|
37320
|
+
y: 0
|
|
37321
|
+
};
|
|
37322
|
+
scalesKeys.forEach((axeKey) => {
|
|
37323
|
+
const key = getAxisTypeFromKey(axeKey);
|
|
37324
|
+
counts[key]++;
|
|
37325
|
+
});
|
|
37326
|
+
const res = counts.x > counts.y && AxisType.X || counts.y > counts.x && AxisType.Y || counts.x === counts.y && null;
|
|
37327
|
+
return res;
|
|
37328
|
+
};
|
|
37317
37329
|
const getAnnotationsData = (data) => {
|
|
37318
37330
|
return data.reduce((acc, obj) => {
|
|
37319
37331
|
return {
|
|
37320
37332
|
...acc,
|
|
37321
|
-
[obj.annotationAxis]: [...acc[obj.annotationAxis] || [], obj.value]
|
|
37333
|
+
[obj.annotationAxis]: [...acc[obj.annotationAxis] || [], +obj.value]
|
|
37322
37334
|
};
|
|
37323
37335
|
}, {});
|
|
37324
37336
|
};
|
|
37325
37337
|
const getAxesData = (scalesKeys, datasets, annotationsData) => {
|
|
37326
37338
|
const allData = (datasets == null ? void 0 : datasets.reduce((acc, item) => [...acc, ...item.data], [])) ?? [];
|
|
37327
|
-
|
|
37328
|
-
|
|
37339
|
+
const getData = () => {
|
|
37340
|
+
return scalesKeys.reduce((acc, axeKey) => {
|
|
37341
|
+
const key = getAxisTypeFromKey(axeKey);
|
|
37342
|
+
const data = getAnnotationsData(annotationsData);
|
|
37343
|
+
const formData = allData == null ? void 0 : allData.map((val) => val == null ? void 0 : val[key]).concat(data[key] || []);
|
|
37344
|
+
return {
|
|
37345
|
+
...acc,
|
|
37346
|
+
[axeKey]: [...new Set(formData)]
|
|
37347
|
+
};
|
|
37348
|
+
}, {});
|
|
37349
|
+
};
|
|
37350
|
+
const getDataForMultiAxes = () => {
|
|
37351
|
+
const multiAxesKey = checkMultiAxis(scalesKeys);
|
|
37352
|
+
const axes = (scalesKeys == null ? void 0 : scalesKeys.filter((key) => key == null ? void 0 : key.includes(multiAxesKey))) ?? [];
|
|
37329
37353
|
const data = getAnnotationsData(annotationsData);
|
|
37330
|
-
const
|
|
37331
|
-
|
|
37332
|
-
|
|
37333
|
-
|
|
37334
|
-
|
|
37335
|
-
|
|
37354
|
+
const [first, second] = axes;
|
|
37355
|
+
const reduceData = (arr, key) => arr.reduce((acc, { [key]: value }) => [...acc, value], []);
|
|
37356
|
+
return datasets.reduce(
|
|
37357
|
+
(acc, obj) => {
|
|
37358
|
+
const key = Object.values(obj).find((val) => axes.includes(val));
|
|
37359
|
+
return {
|
|
37360
|
+
...acc,
|
|
37361
|
+
[key]: [
|
|
37362
|
+
.../* @__PURE__ */ new Set([
|
|
37363
|
+
...acc[key],
|
|
37364
|
+
...reduceData(obj == null ? void 0 : obj.data, multiAxesKey),
|
|
37365
|
+
...key === multiAxesKey && (data == null ? void 0 : data[multiAxesKey]) || []
|
|
37366
|
+
])
|
|
37367
|
+
]
|
|
37368
|
+
};
|
|
37369
|
+
},
|
|
37370
|
+
{ [first]: [], [second]: [] }
|
|
37371
|
+
);
|
|
37372
|
+
};
|
|
37373
|
+
return {
|
|
37374
|
+
...getData(),
|
|
37375
|
+
...getDataForMultiAxes()
|
|
37376
|
+
};
|
|
37336
37377
|
};
|
|
37337
37378
|
const autoScale = (options, state, generatedDatasets) => {
|
|
37338
37379
|
const { additionalAxesOptions = {}, annotations = {} } = options || {};
|