@oliasoft-open-source/charts-library 3.3.5 → 3.3.6-beta-2
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 +33 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13059,7 +13059,9 @@ 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 =
|
|
13062
|
+
const LEGEND_LABEL_BOX_SIZE = 12;
|
|
13063
|
+
const TOOLTIP_PADDING = 8;
|
|
13064
|
+
const TOOLTIP_BOX_PADDING = 4;
|
|
13063
13065
|
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
13064
13066
|
const COLORS = [
|
|
13065
13067
|
"#3366cc",
|
|
@@ -37542,12 +37544,22 @@ const getLineChartToolTips = (options) => {
|
|
|
37542
37544
|
};
|
|
37543
37545
|
}
|
|
37544
37546
|
};
|
|
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
|
+
};
|
|
37545
37556
|
const titleCallback = (tooltipItem, data) => {
|
|
37546
37557
|
const labels = getTooltipLabels(tooltipItem[0].dataset);
|
|
37547
37558
|
const { titleLabel, titleAxisLabel } = labels;
|
|
37548
37559
|
const formattedValue = titleLabel === TooltipLabel.Y ? tooltipItem[0].parsed.y : tooltipItem[0].parsed.x;
|
|
37549
37560
|
const roundedValue = Math.abs(formattedValue) < 1 ? formattedValue.toPrecision(3) : formattedValue.toFixed(2);
|
|
37550
|
-
|
|
37561
|
+
const title = `${roundedValue} ${titleAxisLabel}`;
|
|
37562
|
+
return truncateMiddle(title);
|
|
37551
37563
|
};
|
|
37552
37564
|
const labelCallback = (tooltipItem) => {
|
|
37553
37565
|
const { showLabelsInTooltips, hideSimulationName } = options.tooltip;
|
|
@@ -37558,18 +37570,22 @@ const getLineChartToolTips = (options) => {
|
|
|
37558
37570
|
const labelNumber = valueLabel === TooltipLabel.X ? tooltipItem.parsed.x : tooltipItem.parsed.y;
|
|
37559
37571
|
return Math.abs(labelNumber) < 1 ? labelNumber.toPrecision(3) : labelNumber.toFixed(3);
|
|
37560
37572
|
};
|
|
37561
|
-
const splitValueAxisLabel = valueAxisLabel.split(" ");
|
|
37562
|
-
const newValueAxisLabel = hideSimulationName ? splitValueAxisLabel[splitValueAxisLabel.length - 1] : valueAxisLabel;
|
|
37563
37573
|
const tooltipItemValue = getTooltipItemValue();
|
|
37564
|
-
const valAxisLabel = label === valueAxisLabel || valueAxisLabel.includes(label) ? "" : newValueAxisLabel;
|
|
37565
37574
|
const tooltipLabel = getTooltipLabel(tooltipItem, showLabelsInTooltips);
|
|
37566
|
-
|
|
37575
|
+
const matches = valueAxisLabel.match(/\[(.*?)\]/g);
|
|
37576
|
+
const units = matches && matches.length > 0 ? matches[0] : "";
|
|
37577
|
+
const truncatedLabel = truncateMiddle(label);
|
|
37578
|
+
return `${truncatedLabel}: ${tooltipItemValue} ${units} ${tooltipLabel}`;
|
|
37567
37579
|
};
|
|
37568
37580
|
return {
|
|
37569
37581
|
enabled: options.tooltip.tooltips,
|
|
37570
37582
|
mode: ChartHoverMode.Nearest,
|
|
37571
37583
|
intersect: true,
|
|
37572
|
-
padding:
|
|
37584
|
+
padding: TOOLTIP_PADDING,
|
|
37585
|
+
usePointStyle: true,
|
|
37586
|
+
boxWidth: LEGEND_LABEL_BOX_SIZE,
|
|
37587
|
+
boxHeight: LEGEND_LABEL_BOX_SIZE,
|
|
37588
|
+
boxPadding: TOOLTIP_BOX_PADDING,
|
|
37573
37589
|
callbacks: {
|
|
37574
37590
|
title: titleCallback,
|
|
37575
37591
|
label: labelCallback,
|
|
@@ -38593,7 +38609,12 @@ const PieChart = (props) => {
|
|
|
38593
38609
|
const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, { n: 3 }) : round$2(labelValue, 3);
|
|
38594
38610
|
return `${dataLabel} ${formattedValue} ${unit}`;
|
|
38595
38611
|
}
|
|
38596
|
-
}
|
|
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
|
|
38597
38618
|
};
|
|
38598
38619
|
};
|
|
38599
38620
|
return /* @__PURE__ */ jsx(
|
|
@@ -39010,7 +39031,10 @@ const getBarChartToolTips = (options) => {
|
|
|
39010
39031
|
enabled: options.tooltip.tooltips,
|
|
39011
39032
|
mode: ChartHoverMode.Nearest,
|
|
39012
39033
|
intersect: true,
|
|
39013
|
-
padding:
|
|
39034
|
+
padding: TOOLTIP_PADDING,
|
|
39035
|
+
boxWidth: LEGEND_LABEL_BOX_SIZE,
|
|
39036
|
+
boxHeight: LEGEND_LABEL_BOX_SIZE,
|
|
39037
|
+
boxPadding: TOOLTIP_BOX_PADDING,
|
|
39014
39038
|
callbacks: {
|
|
39015
39039
|
title: titleCallback,
|
|
39016
39040
|
label: labelCallback,
|