@oliasoft-open-source/charts-library 3.3.6-beta-1 → 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 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 = 12;
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
- const getData = () => {
37342
- return scalesKeys.reduce((acc, axeKey) => {
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 [first, second] = axes;
37357
- const reduceData = (arr, key) => arr.reduce((acc, { [key]: value }) => [...acc, value], []);
37358
- return datasets.reduce(
37359
- (acc, obj) => {
37360
- const include = Object.values(obj).some((val) => axes.includes(val));
37361
- const key = include ? second : first;
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
- const title = `${roundedValue} ${titleAxisLabel}`;
37562
- return truncateMiddle(title);
37508
+ return `${roundedValue} ${titleAxisLabel}`;
37563
37509
  };
37564
37510
  const labelCallback = (tooltipItem) => {
37565
37511
  const { showLabelsInTooltips, hideSimulationName } = options.tooltip;
@@ -37575,19 +37521,13 @@ const getLineChartToolTips = (options) => {
37575
37521
  const tooltipItemValue = getTooltipItemValue();
37576
37522
  const valAxisLabel = label === valueAxisLabel || valueAxisLabel.includes(label) ? "" : newValueAxisLabel;
37577
37523
  const tooltipLabel = getTooltipLabel(tooltipItem, showLabelsInTooltips);
37578
- const truncatedLabel = truncateMiddle(label);
37579
- const truncatedAxisLabel = truncateMiddle(valAxisLabel);
37580
- return `${truncatedLabel}: ${tooltipItemValue} ${truncatedAxisLabel}${tooltipLabel}`;
37524
+ return `${label}: ${tooltipItemValue} ${valAxisLabel}${tooltipLabel}`;
37581
37525
  };
37582
37526
  return {
37583
37527
  enabled: options.tooltip.tooltips,
37584
37528
  mode: ChartHoverMode.Nearest,
37585
37529
  intersect: true,
37586
- padding: TOOLTIP_PADDING,
37587
- usePointStyle: true,
37588
- boxWidth: LEGEND_LABEL_BOX_SIZE,
37589
- boxHeight: LEGEND_LABEL_BOX_SIZE,
37590
- boxPadding: TOOLTIP_BOX_PADDING,
37530
+ padding: 8,
37591
37531
  callbacks: {
37592
37532
  title: titleCallback,
37593
37533
  label: labelCallback,
@@ -38611,12 +38551,7 @@ const PieChart = (props) => {
38611
38551
  const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, { n: 3 }) : round$2(labelValue, 3);
38612
38552
  return `${dataLabel} ${formattedValue} ${unit}`;
38613
38553
  }
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
38554
+ }
38620
38555
  };
38621
38556
  };
38622
38557
  return /* @__PURE__ */ jsx(
@@ -39033,10 +38968,7 @@ const getBarChartToolTips = (options) => {
39033
38968
  enabled: options.tooltip.tooltips,
39034
38969
  mode: ChartHoverMode.Nearest,
39035
38970
  intersect: true,
39036
- padding: TOOLTIP_PADDING,
39037
- boxWidth: LEGEND_LABEL_BOX_SIZE,
39038
- boxHeight: LEGEND_LABEL_BOX_SIZE,
39039
- boxPadding: TOOLTIP_BOX_PADDING,
38971
+ padding: 8,
39040
38972
  callbacks: {
39041
38973
  title: titleCallback,
39042
38974
  label: labelCallback,