@oliasoft-open-source/charts-library 3.3.5 → 3.3.6-beta-1

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 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 = 6;
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
- return `${roundedValue} ${titleAxisLabel}`;
37561
+ const title = `${roundedValue} ${titleAxisLabel}`;
37562
+ return truncateMiddle(title);
37551
37563
  };
37552
37564
  const labelCallback = (tooltipItem) => {
37553
37565
  const { showLabelsInTooltips, hideSimulationName } = options.tooltip;
@@ -37563,13 +37575,19 @@ const getLineChartToolTips = (options) => {
37563
37575
  const tooltipItemValue = getTooltipItemValue();
37564
37576
  const valAxisLabel = label === valueAxisLabel || valueAxisLabel.includes(label) ? "" : newValueAxisLabel;
37565
37577
  const tooltipLabel = getTooltipLabel(tooltipItem, showLabelsInTooltips);
37566
- return `${label}: ${tooltipItemValue} ${valAxisLabel}${tooltipLabel}`;
37578
+ const truncatedLabel = truncateMiddle(label);
37579
+ const truncatedAxisLabel = truncateMiddle(valAxisLabel);
37580
+ return `${truncatedLabel}: ${tooltipItemValue} ${truncatedAxisLabel}${tooltipLabel}`;
37567
37581
  };
37568
37582
  return {
37569
37583
  enabled: options.tooltip.tooltips,
37570
37584
  mode: ChartHoverMode.Nearest,
37571
37585
  intersect: true,
37572
- padding: 8,
37586
+ padding: TOOLTIP_PADDING,
37587
+ usePointStyle: true,
37588
+ boxWidth: LEGEND_LABEL_BOX_SIZE,
37589
+ boxHeight: LEGEND_LABEL_BOX_SIZE,
37590
+ boxPadding: TOOLTIP_BOX_PADDING,
37573
37591
  callbacks: {
37574
37592
  title: titleCallback,
37575
37593
  label: labelCallback,
@@ -38593,7 +38611,12 @@ const PieChart = (props) => {
38593
38611
  const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, { n: 3 }) : round$2(labelValue, 3);
38594
38612
  return `${dataLabel} ${formattedValue} ${unit}`;
38595
38613
  }
38596
- }
38614
+ },
38615
+ padding: TOOLTIP_PADDING,
38616
+ boxWidth: LEGEND_LABEL_BOX_SIZE,
38617
+ boxHeight: LEGEND_LABEL_BOX_SIZE,
38618
+ boxPadding: TOOLTIP_BOX_PADDING,
38619
+ usePointStyle: true
38597
38620
  };
38598
38621
  };
38599
38622
  return /* @__PURE__ */ jsx(
@@ -39010,7 +39033,10 @@ const getBarChartToolTips = (options) => {
39010
39033
  enabled: options.tooltip.tooltips,
39011
39034
  mode: ChartHoverMode.Nearest,
39012
39035
  intersect: true,
39013
- padding: 8,
39036
+ padding: TOOLTIP_PADDING,
39037
+ boxWidth: LEGEND_LABEL_BOX_SIZE,
39038
+ boxHeight: LEGEND_LABEL_BOX_SIZE,
39039
+ boxPadding: TOOLTIP_BOX_PADDING,
39014
39040
  callbacks: {
39015
39041
  title: titleCallback,
39016
39042
  label: labelCallback,