@oliasoft-open-source/charts-library 3.3.6-beta-2 → 3.3.6-beta-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/dist/index.js +17 -83
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13059,9 +13059,7 @@ const ANNOTATION_DASH = [10, 2];
|
|
|
13059
13059
|
const DEFAULT_FONT_SIZE = 13;
|
|
13060
13060
|
const DEFAULT_FONT_FAMILY = '"Lato", sans-serif';
|
|
13061
13061
|
const DEFAULT_COLOR = "rgba(0,0,0,.87)";
|
|
13062
|
-
const LEGEND_LABEL_BOX_SIZE =
|
|
13063
|
-
const TOOLTIP_PADDING = 8;
|
|
13064
|
-
const TOOLTIP_BOX_PADDING = 4;
|
|
13062
|
+
const LEGEND_LABEL_BOX_SIZE = 6;
|
|
13065
13063
|
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
13066
13064
|
const COLORS = [
|
|
13067
13065
|
"#3366cc",
|
|
@@ -37316,18 +37314,6 @@ const getSuggestedAxisRange = ({
|
|
|
37316
37314
|
max: round$2(maxAxisValue, DECIMAL_POINT_TOLERANCE)
|
|
37317
37315
|
};
|
|
37318
37316
|
};
|
|
37319
|
-
const checkMultiAxis = (scalesKeys) => {
|
|
37320
|
-
let counts = {
|
|
37321
|
-
x: 0,
|
|
37322
|
-
y: 0
|
|
37323
|
-
};
|
|
37324
|
-
scalesKeys.forEach((axeKey) => {
|
|
37325
|
-
const key = getAxisTypeFromKey(axeKey);
|
|
37326
|
-
counts[key]++;
|
|
37327
|
-
});
|
|
37328
|
-
const res = counts.x > counts.y && AxisType.X || counts.y > counts.x && AxisType.Y || counts.x === counts.y && null;
|
|
37329
|
-
return res;
|
|
37330
|
-
};
|
|
37331
37317
|
const getAnnotationsData = (data) => {
|
|
37332
37318
|
return data.reduce((acc, obj) => {
|
|
37333
37319
|
return {
|
|
@@ -37338,45 +37324,15 @@ const getAnnotationsData = (data) => {
|
|
|
37338
37324
|
};
|
|
37339
37325
|
const getAxesData = (scalesKeys, datasets, annotationsData) => {
|
|
37340
37326
|
const allData = (datasets == null ? void 0 : datasets.reduce((acc, item) => [...acc, ...item.data], [])) ?? [];
|
|
37341
|
-
|
|
37342
|
-
|
|
37343
|
-
const key = getAxisTypeFromKey(axeKey);
|
|
37344
|
-
const data = getAnnotationsData(annotationsData);
|
|
37345
|
-
const formData = allData == null ? void 0 : allData.map((val) => val == null ? void 0 : val[key]).concat(data[key] || []);
|
|
37346
|
-
return {
|
|
37347
|
-
...acc,
|
|
37348
|
-
[axeKey]: [...new Set(formData)]
|
|
37349
|
-
};
|
|
37350
|
-
}, {});
|
|
37351
|
-
};
|
|
37352
|
-
const getDataForMultiAxes = () => {
|
|
37353
|
-
const multiAxesKey = checkMultiAxis(scalesKeys);
|
|
37354
|
-
const axes = (scalesKeys == null ? void 0 : scalesKeys.filter((key) => key == null ? void 0 : key.includes(multiAxesKey))) ?? [];
|
|
37327
|
+
return scalesKeys.reduce((acc, axeKey) => {
|
|
37328
|
+
const key = getAxisTypeFromKey(axeKey);
|
|
37355
37329
|
const data = getAnnotationsData(annotationsData);
|
|
37356
|
-
const [
|
|
37357
|
-
|
|
37358
|
-
|
|
37359
|
-
(
|
|
37360
|
-
|
|
37361
|
-
|
|
37362
|
-
return {
|
|
37363
|
-
...acc,
|
|
37364
|
-
[key]: [
|
|
37365
|
-
.../* @__PURE__ */ new Set([
|
|
37366
|
-
...acc[key],
|
|
37367
|
-
...reduceData(obj == null ? void 0 : obj.data, multiAxesKey),
|
|
37368
|
-
...!include && (data == null ? void 0 : data[multiAxesKey]) || []
|
|
37369
|
-
])
|
|
37370
|
-
]
|
|
37371
|
-
};
|
|
37372
|
-
},
|
|
37373
|
-
{ [first]: [], [second]: [] }
|
|
37374
|
-
);
|
|
37375
|
-
};
|
|
37376
|
-
return {
|
|
37377
|
-
...getData(),
|
|
37378
|
-
...getDataForMultiAxes()
|
|
37379
|
-
};
|
|
37330
|
+
const formData = allData == null ? void 0 : allData.map((val) => val == null ? void 0 : val[key]).concat(data[key] || []);
|
|
37331
|
+
return {
|
|
37332
|
+
...acc,
|
|
37333
|
+
[axeKey]: [...new Set(formData)]
|
|
37334
|
+
};
|
|
37335
|
+
}, {});
|
|
37380
37336
|
};
|
|
37381
37337
|
const autoScale = (options, state, generatedDatasets) => {
|
|
37382
37338
|
const { additionalAxesOptions = {}, annotations = {} } = options || {};
|
|
@@ -37544,22 +37500,12 @@ const getLineChartToolTips = (options) => {
|
|
|
37544
37500
|
};
|
|
37545
37501
|
}
|
|
37546
37502
|
};
|
|
37547
|
-
const truncateMiddle = (string) => {
|
|
37548
|
-
const STRING_MAX_LENGTH = 30;
|
|
37549
|
-
if (string.length <= STRING_MAX_LENGTH) {
|
|
37550
|
-
return string;
|
|
37551
|
-
}
|
|
37552
|
-
const start = string.substring(0, STRING_MAX_LENGTH / 2).trim();
|
|
37553
|
-
const end = string.substring(string.length - STRING_MAX_LENGTH / 2).trim();
|
|
37554
|
-
return `${start}…${end}`;
|
|
37555
|
-
};
|
|
37556
37503
|
const titleCallback = (tooltipItem, data) => {
|
|
37557
37504
|
const labels = getTooltipLabels(tooltipItem[0].dataset);
|
|
37558
37505
|
const { titleLabel, titleAxisLabel } = labels;
|
|
37559
37506
|
const formattedValue = titleLabel === TooltipLabel.Y ? tooltipItem[0].parsed.y : tooltipItem[0].parsed.x;
|
|
37560
37507
|
const roundedValue = Math.abs(formattedValue) < 1 ? formattedValue.toPrecision(3) : formattedValue.toFixed(2);
|
|
37561
|
-
|
|
37562
|
-
return truncateMiddle(title);
|
|
37508
|
+
return `${roundedValue} ${titleAxisLabel}`;
|
|
37563
37509
|
};
|
|
37564
37510
|
const labelCallback = (tooltipItem) => {
|
|
37565
37511
|
const { showLabelsInTooltips, hideSimulationName } = options.tooltip;
|
|
@@ -37570,22 +37516,18 @@ const getLineChartToolTips = (options) => {
|
|
|
37570
37516
|
const labelNumber = valueLabel === TooltipLabel.X ? tooltipItem.parsed.x : tooltipItem.parsed.y;
|
|
37571
37517
|
return Math.abs(labelNumber) < 1 ? labelNumber.toPrecision(3) : labelNumber.toFixed(3);
|
|
37572
37518
|
};
|
|
37519
|
+
const splitValueAxisLabel = valueAxisLabel.split(" ");
|
|
37520
|
+
const newValueAxisLabel = hideSimulationName ? splitValueAxisLabel[splitValueAxisLabel.length - 1] : valueAxisLabel;
|
|
37573
37521
|
const tooltipItemValue = getTooltipItemValue();
|
|
37522
|
+
const valAxisLabel = label === valueAxisLabel || valueAxisLabel.includes(label) ? "" : newValueAxisLabel;
|
|
37574
37523
|
const tooltipLabel = getTooltipLabel(tooltipItem, showLabelsInTooltips);
|
|
37575
|
-
|
|
37576
|
-
const units = matches && matches.length > 0 ? matches[0] : "";
|
|
37577
|
-
const truncatedLabel = truncateMiddle(label);
|
|
37578
|
-
return `${truncatedLabel}: ${tooltipItemValue} ${units} ${tooltipLabel}`;
|
|
37524
|
+
return `${label}: ${tooltipItemValue} ${valAxisLabel}${tooltipLabel}`;
|
|
37579
37525
|
};
|
|
37580
37526
|
return {
|
|
37581
37527
|
enabled: options.tooltip.tooltips,
|
|
37582
37528
|
mode: ChartHoverMode.Nearest,
|
|
37583
37529
|
intersect: true,
|
|
37584
|
-
padding:
|
|
37585
|
-
usePointStyle: true,
|
|
37586
|
-
boxWidth: LEGEND_LABEL_BOX_SIZE,
|
|
37587
|
-
boxHeight: LEGEND_LABEL_BOX_SIZE,
|
|
37588
|
-
boxPadding: TOOLTIP_BOX_PADDING,
|
|
37530
|
+
padding: 8,
|
|
37589
37531
|
callbacks: {
|
|
37590
37532
|
title: titleCallback,
|
|
37591
37533
|
label: labelCallback,
|
|
@@ -38609,12 +38551,7 @@ const PieChart = (props) => {
|
|
|
38609
38551
|
const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, { n: 3 }) : round$2(labelValue, 3);
|
|
38610
38552
|
return `${dataLabel} ${formattedValue} ${unit}`;
|
|
38611
38553
|
}
|
|
38612
|
-
}
|
|
38613
|
-
padding: TOOLTIP_PADDING,
|
|
38614
|
-
boxWidth: LEGEND_LABEL_BOX_SIZE,
|
|
38615
|
-
boxHeight: LEGEND_LABEL_BOX_SIZE,
|
|
38616
|
-
boxPadding: TOOLTIP_BOX_PADDING,
|
|
38617
|
-
usePointStyle: true
|
|
38554
|
+
}
|
|
38618
38555
|
};
|
|
38619
38556
|
};
|
|
38620
38557
|
return /* @__PURE__ */ jsx(
|
|
@@ -39031,10 +38968,7 @@ const getBarChartToolTips = (options) => {
|
|
|
39031
38968
|
enabled: options.tooltip.tooltips,
|
|
39032
38969
|
mode: ChartHoverMode.Nearest,
|
|
39033
38970
|
intersect: true,
|
|
39034
|
-
padding:
|
|
39035
|
-
boxWidth: LEGEND_LABEL_BOX_SIZE,
|
|
39036
|
-
boxHeight: LEGEND_LABEL_BOX_SIZE,
|
|
39037
|
-
boxPadding: TOOLTIP_BOX_PADDING,
|
|
38971
|
+
padding: 8,
|
|
39038
38972
|
callbacks: {
|
|
39039
38973
|
title: titleCallback,
|
|
39040
38974
|
label: labelCallback,
|