@oliasoft-open-source/charts-library 3.4.5 → 3.4.7-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.
Files changed (63) hide show
  1. package/dist/declaration.d.ts +2 -0
  2. package/dist/index.js +677 -669
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/bar-chart/bar-chart-default-props.d.ts +30 -26
  5. package/dist/src/components/bar-chart/bar-chart.interface.d.ts +37 -70
  6. package/dist/src/components/bar-chart/get-bar-chart-data-labels.d.ts +11 -14
  7. package/dist/src/components/bar-chart/get-bar-chart-scales.d.ts +3 -2
  8. package/dist/src/components/bar-chart/get-bar-chart-tooltips.d.ts +3 -16
  9. package/dist/src/components/common/common.interface.d.ts +139 -0
  10. package/dist/src/components/common/helpers/chart-border-plugin.d.ts +8 -0
  11. package/dist/src/{helpers → components/common/helpers}/enums.d.ts +2 -1
  12. package/dist/src/components/common/helpers/get-chart-annotation.d.ts +27 -0
  13. package/dist/src/components/common/helpers/get-draggableData.d.ts +18 -0
  14. package/dist/src/{helpers → components/common/helpers}/range/range.d.ts +6 -6
  15. package/dist/src/components/line-chart/controls/axes-options/axes-options-form-state.d.ts +8 -3
  16. package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +52 -0
  17. package/dist/src/components/{controls → line-chart/controls}/axes-options/axes-options.d.ts +1 -1
  18. package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +18 -32
  19. package/dist/src/components/line-chart/controls/controls-portal.d.ts +6 -1
  20. package/dist/src/components/line-chart/controls/controls.d.ts +1 -1
  21. package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +5 -5
  22. package/dist/src/components/line-chart/controls/line-options.d.ts +9 -1
  23. package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +28 -6
  24. package/dist/src/components/line-chart/{state → hooks}/use-chart-state.d.ts +13 -1
  25. package/dist/src/components/line-chart/hooks/use-toggle-handler.d.ts +2 -1
  26. package/dist/src/components/line-chart/initialize/config.d.ts +2 -2
  27. package/dist/src/components/line-chart/legend/legend-interface.d.ts +24 -18
  28. package/dist/src/components/line-chart/legend/legend-panel.d.ts +2 -2
  29. package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +38 -30
  30. package/dist/src/components/line-chart/line-chart.interface.d.ts +48 -61
  31. package/dist/src/components/line-chart/plugins/chart-area-text-plugin.d.ts +14 -1
  32. package/dist/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.d.ts +5 -4
  33. package/dist/src/components/line-chart/plugins/plugins.interface.d.ts +2 -2
  34. package/dist/src/components/line-chart/state/initial-state.d.ts +20 -2
  35. package/dist/src/components/line-chart/state/line-chart-reducer.d.ts +2 -1
  36. package/dist/src/components/line-chart/state/manage-state-in-local-storage.d.ts +3 -2
  37. package/dist/src/components/line-chart/state/state.interfaces.d.ts +32 -7
  38. package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +1 -1
  39. package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts +1 -1
  40. package/dist/src/components/line-chart/utils/generate-line-chart-datasets.d.ts +3 -1
  41. package/dist/src/components/line-chart/utils/get-annotations-data.d.ts +1 -0
  42. package/dist/src/components/line-chart/utils/get-axes-data-from-metasets.d.ts +1 -0
  43. package/dist/src/components/line-chart/utils/get-axes-ranges-from-chart.d.ts +9 -2
  44. package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +3 -2
  45. package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +4 -4
  46. package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +2 -2
  47. package/dist/src/components/line-chart/utils/translations/get-translations.d.ts +2 -1
  48. package/dist/src/components/pie-chart/pie-chart-get-default-props.d.ts +12 -8
  49. package/dist/src/components/pie-chart/pie-chart.d.ts +1 -2
  50. package/dist/src/components/pie-chart/pie-chart.interface.d.ts +52 -51
  51. package/dist/src/components/scatter-chart/scatter-chart.d.ts +1 -1
  52. package/dist/src/components/scatter-chart/scatter-chart.intefrace.d.ts +6 -16
  53. package/package.json +1 -1
  54. package/dist/src/components/controls/axes-options/axes-options-interfaces.d.ts +0 -19
  55. package/dist/src/components/line-chart/hooks/hooks.interface.d.ts +0 -13
  56. package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +0 -37
  57. package/dist/src/components/pie-chart/pie-chart-utils.d.ts +0 -2
  58. package/dist/src/helpers/chart-border-plugin.d.ts +0 -7
  59. package/dist/src/helpers/chart-interface.d.ts +0 -85
  60. package/dist/src/helpers/get-chart-annotation.d.ts +0 -12
  61. package/dist/src/helpers/get-draggableData.d.ts +0 -18
  62. /package/dist/src/{helpers → components/common/helpers}/chart-consts.d.ts +0 -0
  63. /package/dist/src/{helpers → components/common/helpers}/range/estimate-data-series-have-close-values.d.ts +0 -0
package/dist/index.js CHANGED
@@ -576,7 +576,7 @@ let Color$1 = class Color {
576
576
  }
577
577
  };
578
578
  /*!
579
- * Chart.js v4.3.0
579
+ * Chart.js v4.3.2
580
580
  * https://www.chartjs.org
581
581
  * (c) 2023 Chart.js Contributors
582
582
  * Released under the MIT License
@@ -1048,7 +1048,7 @@ function _getStartAndCountOfVisiblePoints$1(meta, points, animationsDisabled) {
1048
1048
  if (minDefined) {
1049
1049
  start = _limitValue$1(Math.min(
1050
1050
  // @ts-expect-error Need to type _parsed
1051
- _lookupByKey$1(_parsed, iScale.axis, min).lo,
1051
+ _lookupByKey$1(_parsed, axis, min).lo,
1052
1052
  // @ts-expect-error Need to fix types on _lookupByKey
1053
1053
  animationsDisabled ? pointCount : _lookupByKey$1(points, axis, iScale.getPixelForValue(min)).lo
1054
1054
  ), 0, pointCount - 1);
@@ -1170,7 +1170,7 @@ const numbers$1 = [
1170
1170
  "radius",
1171
1171
  "tension"
1172
1172
  ];
1173
- const colors$2 = [
1173
+ const colors$1 = [
1174
1174
  "color",
1175
1175
  "borderColor",
1176
1176
  "backgroundColor"
@@ -1194,7 +1194,7 @@ function applyAnimationsDefaults(defaults2) {
1194
1194
  defaults2.set("animations", {
1195
1195
  colors: {
1196
1196
  type: "color",
1197
- properties: colors$2
1197
+ properties: colors$1
1198
1198
  },
1199
1199
  numbers: {
1200
1200
  type: "number",
@@ -2891,7 +2891,7 @@ function styleChanged$1(style, prevStyle) {
2891
2891
  return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
2892
2892
  }
2893
2893
  /*!
2894
- * Chart.js v4.3.0
2894
+ * Chart.js v4.3.2
2895
2895
  * https://www.chartjs.org
2896
2896
  * (c) 2023 Chart.js Contributors
2897
2897
  * Released under the MIT License
@@ -4825,7 +4825,7 @@ let LineController$1 = (_d = class extends DatasetController$1 {
4825
4825
  line._chart = this.chart;
4826
4826
  line._datasetIndex = this.index;
4827
4827
  line._decimated = !!_dataset._decimated;
4828
- line.points = points;
4828
+ line.points = points.slice(Math.max(this._drawStart - 1, 0), this._drawStart + this._drawCount);
4829
4829
  const options = this.resolveDatasetElementOptions(mode);
4830
4830
  if (!this.options.showLine) {
4831
4831
  options.borderWidth = 0;
@@ -4939,6 +4939,9 @@ let ScatterController$1 = (_f = class extends DatasetController$1 {
4939
4939
  count = points.length;
4940
4940
  }
4941
4941
  if (this.options.showLine) {
4942
+ if (!this.datasetElementType) {
4943
+ this.addElements();
4944
+ }
4942
4945
  const { dataset: line, _dataset } = meta;
4943
4946
  line._chart = this.chart;
4944
4947
  line._datasetIndex = this.index;
@@ -4950,6 +4953,9 @@ let ScatterController$1 = (_f = class extends DatasetController$1 {
4950
4953
  animated: !animationsDisabled,
4951
4954
  options
4952
4955
  }, mode);
4956
+ } else if (this.datasetElementType) {
4957
+ delete meta.dataset;
4958
+ this.datasetElementType = false;
4953
4959
  }
4954
4960
  this.updateElements(points, start, count, mode);
4955
4961
  }
@@ -7956,7 +7962,7 @@ function needContext$1(proxy, names2) {
7956
7962
  }
7957
7963
  return false;
7958
7964
  }
7959
- var version$3 = "4.3.0";
7965
+ var version$3 = "4.3.2";
7960
7966
  const KNOWN_POSITIONS$1 = [
7961
7967
  "top",
7962
7968
  "bottom",
@@ -10563,7 +10569,7 @@ let Legend$1 = class Legend extends Element$2 {
10563
10569
  cursor.x += width + padding;
10564
10570
  } else if (typeof legendItem2.text !== "string") {
10565
10571
  const fontLineHeight = labelFont.lineHeight;
10566
- cursor.y += calculateLegendItemHeight(legendItem2, fontLineHeight);
10572
+ cursor.y += calculateLegendItemHeight(legendItem2, fontLineHeight) + padding;
10567
10573
  } else {
10568
10574
  cursor.y += lineHeight;
10569
10575
  }
@@ -10677,7 +10683,7 @@ function calculateItemHeight(_itemHeight, legendItem2, fontLineHeight) {
10677
10683
  return itemHeight;
10678
10684
  }
10679
10685
  function calculateLegendItemHeight(legendItem2, fontLineHeight) {
10680
- const labelHeight = legendItem2.text ? legendItem2.text.length + 0.5 : 0;
10686
+ const labelHeight = legendItem2.text ? legendItem2.text.length : 0;
10681
10687
  return fontLineHeight * labelHeight;
10682
10688
  }
10683
10689
  function isListened(type, opts) {
@@ -12724,7 +12730,7 @@ let TimeScale$1 = (_q = class extends Scale$1 {
12724
12730
  if (time === max || options.bounds === "ticks" || count === 1) {
12725
12731
  addTick$1(ticks, time, timestamps);
12726
12732
  }
12727
- return Object.keys(ticks).sort((a2, b2) => a2 - b2).map((x2) => +x2);
12733
+ return Object.keys(ticks).sort(sorter$1).map((x2) => +x2);
12728
12734
  }
12729
12735
  getLabelForValue(value) {
12730
12736
  const adapter = this._adapter;
@@ -12922,6 +12928,18 @@ let TimeSeriesScale$1 = (_r = class extends TimeScale$1 {
12922
12928
  }
12923
12929
  return table2;
12924
12930
  }
12931
+ _generate() {
12932
+ const min = this.min;
12933
+ const max = this.max;
12934
+ let timestamps = super.getDataTimestamps();
12935
+ if (!timestamps.includes(min) || !timestamps.length) {
12936
+ timestamps.splice(0, 0, min);
12937
+ }
12938
+ if (!timestamps.includes(max) || timestamps.length === 1) {
12939
+ timestamps.push(max);
12940
+ }
12941
+ return timestamps.sort((a2, b2) => a2 - b2);
12942
+ }
12925
12943
  _getTimestampsForTable() {
12926
12944
  let timestamps = this._cache.all || [];
12927
12945
  if (timestamps.length) {
@@ -13086,12 +13104,15 @@ const Pie = /* @__PURE__ */ createTypedChart("pie", PieController$1);
13086
13104
  const Scatter = /* @__PURE__ */ createTypedChart("scatter", ScatterController$1);
13087
13105
  const MINOR_TICKS_PER_MAJOR = 10;
13088
13106
  const getLargestMajorTickWidth = (majorTickPositions) => {
13089
- return majorTickPositions.reduce((acc, curr, index2) => {
13090
- if (index2 === 0)
13091
- return acc;
13092
- const gap = Math.abs(curr - majorTickPositions[index2 - 1]);
13093
- return Math.max(gap, acc);
13094
- }, 0);
13107
+ return majorTickPositions.reduce(
13108
+ (acc, curr, index2) => {
13109
+ if (index2 === 0)
13110
+ return acc;
13111
+ const gap = Math.abs(curr - majorTickPositions[index2 - 1]);
13112
+ return Math.max(gap, acc);
13113
+ },
13114
+ 0
13115
+ );
13095
13116
  };
13096
13117
  const isValidPosition = (minorTickPosition, majorTickPositions, scale) => {
13097
13118
  const { axis, left: left2, top: top2, right: right2, bottom: bottom2 } = scale;
@@ -13119,16 +13140,18 @@ const getMinorTickPositions = (majorTickPositions, scale) => {
13119
13140
  return positions2;
13120
13141
  };
13121
13142
  const drawMinorTicksForScale = (scale) => {
13143
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
13122
13144
  const { chart: chart2, ctx } = scale;
13123
- if (!chart2.config._config.options.scales[scale.id].grid.drawOnChartArea)
13145
+ const config2 = chart2.config;
13146
+ if (!((_d2 = (_c2 = (_b2 = (_a2 = config2 == null ? void 0 : config2.options) == null ? void 0 : _a2.scales) == null ? void 0 : _b2[scale.id]) == null ? void 0 : _c2.grid) == null ? void 0 : _d2.drawOnChartArea))
13124
13147
  return;
13125
- if (chart2.config._config.options.indexAxis === scale.axis)
13148
+ if (config2.options.indexAxis === scale.axis)
13126
13149
  return;
13127
13150
  const isHorizontal = scale.axis === "x";
13128
13151
  const majorTickPositions = scale.ticks.map((_2, index2) => scale.getPixelForTick(index2)).sort((a2, b2) => a2 - b2);
13129
13152
  const minorTickPositions = getMinorTickPositions(majorTickPositions, scale);
13130
13153
  ctx.save();
13131
- ctx.strokeStyle = chart2.config._config.options.scales[scale.id].grid.color || "rgba(0,0,0,0.06)";
13154
+ ctx.strokeStyle = ((_i2 = (_h2 = (_g2 = (_f2 = (_e2 = config2 == null ? void 0 : config2._config) == null ? void 0 : _e2.options) == null ? void 0 : _f2.scales) == null ? void 0 : _g2[scale.id]) == null ? void 0 : _h2.grid) == null ? void 0 : _i2.color) || "rgba(0,0,0,0.06)";
13132
13155
  ctx.lineWidth = 0.5;
13133
13156
  minorTickPositions.forEach((minorTickPosition) => {
13134
13157
  ctx.beginPath();
@@ -13267,6 +13290,7 @@ var PanZoomMode = /* @__PURE__ */ ((PanZoomMode2) => {
13267
13290
  PanZoomMode2["X"] = "x";
13268
13291
  PanZoomMode2["Y"] = "y";
13269
13292
  PanZoomMode2["XY"] = "xy";
13293
+ PanZoomMode2["Z"] = "z";
13270
13294
  return PanZoomMode2;
13271
13295
  })(PanZoomMode || {});
13272
13296
  var Key = /* @__PURE__ */ ((Key2) => {
@@ -13284,7 +13308,7 @@ var Events = /* @__PURE__ */ ((Events2) => {
13284
13308
  })(Events || {});
13285
13309
  const chartAreaBorderPlugin = {
13286
13310
  id: "chartAreaBorder",
13287
- beforeDraw(chart2, args, options) {
13311
+ beforeDraw(chart2, _args, options) {
13288
13312
  const {
13289
13313
  ctx,
13290
13314
  chartArea: { left: left2, top: top2, width, height }
@@ -13299,6 +13323,7 @@ const chartAreaBorderPlugin = {
13299
13323
  }
13300
13324
  };
13301
13325
  const getPlugins = (graph, legend2) => {
13326
+ var _a2;
13302
13327
  let plugins = [];
13303
13328
  if (graph.showMinorGridlines) {
13304
13329
  plugins.push(chartMinorGridlinesPlugin);
@@ -13307,25 +13332,25 @@ const getPlugins = (graph, legend2) => {
13307
13332
  if ((customLegend == null ? void 0 : customLegend.customLegendPlugin) && (customLegend == null ? void 0 : customLegend.customLegendContainerID)) {
13308
13333
  plugins.push({
13309
13334
  id: CUSTOM_LEGEND_PLUGIN_NAME,
13310
- ...legend2.customLegend.customLegendPlugin
13335
+ ...(_a2 = legend2 == null ? void 0 : legend2.customLegend) == null ? void 0 : _a2.customLegendPlugin
13311
13336
  });
13312
13337
  }
13313
13338
  plugins.push(chartAreaBorderPlugin);
13314
13339
  return plugins;
13315
13340
  };
13316
- const generateRandomColor$1 = (colors2) => {
13341
+ const generateRandomColor = (colors2) => {
13317
13342
  const color2 = `#${Math.floor(Math.random() * WHITE_COLOR_AS_DECIMAL).toString(
13318
13343
  16
13319
13344
  )}`;
13320
13345
  if (colors2.includes(color2)) {
13321
- return generateRandomColor$1(colors2);
13346
+ return generateRandomColor(colors2);
13322
13347
  } else {
13323
13348
  colors2.push(color2);
13324
- return color2;
13349
+ return colors2;
13325
13350
  }
13326
13351
  };
13327
13352
  const setAnnotations = (annotationsData) => {
13328
- return (annotationsData == null ? void 0 : annotationsData.length) ? annotationsData.map((v2, i2) => i2) : [];
13353
+ return (annotationsData == null ? void 0 : annotationsData.length) ? annotationsData.map((_v, i2) => i2) : [];
13329
13354
  };
13330
13355
  const getTitle = (options) => {
13331
13356
  return options.title !== "" ? {
@@ -13351,16 +13376,16 @@ const getClassName = (chartStyling, styles2) => {
13351
13376
  }
13352
13377
  return cx(styles2.chart, heightStyles, squareAspectRatioStyle);
13353
13378
  };
13354
- const getLegend = (options, clickHandler, state = null) => {
13355
- const { legend: legend2 } = options;
13379
+ const getLegend = (options, clickHandler) => {
13380
+ const { legend: legend2 } = options || {};
13356
13381
  return {
13357
- position: legend2.position || Position.Top,
13358
- display: legend2.display,
13359
- align: legend2.align,
13382
+ position: (legend2 == null ? void 0 : legend2.position) || Position.Top,
13383
+ display: legend2 == null ? void 0 : legend2.display,
13384
+ align: legend2 == null ? void 0 : legend2.align,
13360
13385
  labels: {
13361
13386
  boxHeight: LEGEND_LABEL_BOX_SIZE,
13362
- boxWidth: legend2.usePointStyle ? LEGEND_LABEL_BOX_SIZE : void 0,
13363
- usePointStyle: legend2.usePointStyle
13387
+ boxWidth: (legend2 == null ? void 0 : legend2.usePointStyle) ? LEGEND_LABEL_BOX_SIZE : void 0,
13388
+ usePointStyle: legend2 == null ? void 0 : legend2.usePointStyle
13364
13389
  },
13365
13390
  onClick: clickHandler
13366
13391
  };
@@ -13381,7 +13406,7 @@ const getChartFileName = (axes) => {
13381
13406
  }
13382
13407
  const axesLabels = axes.reduce((acc, cur, index2) => {
13383
13408
  var _a2;
13384
- const labelWithNoSpace = ((_a2 = cur.label) == null ? void 0 : _a2.replace(/\s/g, "_")) || index2;
13409
+ const labelWithNoSpace = ((_a2 = cur.label) == null ? void 0 : _a2.replace(/\s/g, "_")) || String(index2);
13385
13410
  return [...acc, labelWithNoSpace];
13386
13411
  }, []);
13387
13412
  return axesLabels.join("_");
@@ -13398,7 +13423,7 @@ const styles$5 = {
13398
13423
  };
13399
13424
  const ScatterChart = (props) => {
13400
13425
  setDefaultTheme();
13401
- const { data, options, testId = null } = props.chart;
13426
+ const { data = { datasets: [] }, options, testId = null } = props.chart;
13402
13427
  return /* @__PURE__ */ jsx("div", { className: styles$5.chart, children: /* @__PURE__ */ jsx(Scatter, { options, data, "data-testid": testId }) });
13403
13428
  };
13404
13429
  function getDefaultExportFromCjs(x2) {
@@ -22073,6 +22098,7 @@ const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
22073
22098
  const DISABLE_DRAG_OPTIONS = "DISABLE_DRAG_OPTIONS";
22074
22099
  const reducer$1 = (state, action) => {
22075
22100
  return produce(state, (draft) => {
22101
+ var _a2;
22076
22102
  switch (action.type) {
22077
22103
  case TOGGLE_ZOOM: {
22078
22104
  draft.zoomEnabled = !draft.zoomEnabled;
@@ -22130,11 +22156,11 @@ const reducer$1 = (state, action) => {
22130
22156
  }
22131
22157
  case TOGGLE_ANNOTATION: {
22132
22158
  const { annotationIndex } = action.payload;
22133
- const updatedIndexes = draft.showAnnotationLineIndex.includes(
22159
+ const updatedIndexes = ((_a2 = draft == null ? void 0 : draft.showAnnotationLineIndex) == null ? void 0 : _a2.includes(
22134
22160
  annotationIndex
22135
- ) ? draft.showAnnotationLineIndex.filter(
22161
+ )) ? draft.showAnnotationLineIndex.filter(
22136
22162
  (v2) => v2 !== annotationIndex
22137
- ) : [...draft.showAnnotationLineIndex, annotationIndex];
22163
+ ) : [...(draft == null ? void 0 : draft.showAnnotationLineIndex) ?? [], annotationIndex];
22138
22164
  draft.showAnnotationLineIndex = updatedIndexes;
22139
22165
  break;
22140
22166
  }
@@ -22170,7 +22196,8 @@ const generateAxisId = (axisType, index2 = 0, hasMultiAxes = false) => {
22170
22196
  return `${axisType}${i2}`;
22171
22197
  };
22172
22198
  const getAxisTypeFromKey = (string) => {
22173
- return string.match(/[^0-9/]+/gi)[0];
22199
+ var _a2;
22200
+ return ((_a2 = string == null ? void 0 : string.match(/[^0-9/]+/gi)) == null ? void 0 : _a2[0]) ?? "";
22174
22201
  };
22175
22202
  const generateKey = (values) => {
22176
22203
  const key = values.join("");
@@ -22193,7 +22220,7 @@ const removeExpiredChartStates = (maxAgeInHours = 72) => {
22193
22220
  const maxAgeInMilliseconds = maxAgeInHours * 60 * 60 * 1e3;
22194
22221
  for (let i2 = 0; i2 < localStorage.length; i2++) {
22195
22222
  const key = localStorage.key(i2);
22196
- if (key.includes("line-chart-state-")) {
22223
+ if (key == null ? void 0 : key.includes("line-chart-state-")) {
22197
22224
  const chartStateObjectJSON = localStorage.getItem(key);
22198
22225
  if (chartStateObjectJSON) {
22199
22226
  const chartStateObject = JSON.parse(chartStateObjectJSON);
@@ -22222,38 +22249,40 @@ const storeChartStateInStorage = (state, persistenceId) => {
22222
22249
  };
22223
22250
  const initialState = ({ options, persistenceId }) => {
22224
22251
  const {
22225
- additionalAxesOptions: { range: customAxesRange },
22226
- annotations: { annotationsData },
22252
+ additionalAxesOptions: { range: customAxesRange = {} },
22253
+ annotations: { annotationsData = [] },
22227
22254
  axes,
22228
22255
  chartOptions: { enableZoom, enablePan, showPoints, showLine },
22229
22256
  legend: { display },
22230
22257
  dragData
22231
22258
  } = options;
22232
22259
  const getStateAxesByType = (axisType, customAxesRange2) => {
22233
- var _a2, _b2, _c2;
22260
+ var _a2, _b2, _c2, _d2, _e2;
22234
22261
  if (!axes[axisType]) {
22235
22262
  return [];
22236
22263
  }
22237
22264
  if (((_a2 = axes[axisType]) == null ? void 0 : _a2.length) > 1) {
22238
- return axes[axisType].map((axisObj, index2) => {
22239
- var _a3, _b3;
22240
- const id = generateAxisId(axisType, index2, axes[axisType].length > 1);
22241
- const customMin = (_a3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _a3.min;
22242
- const customMax = (_b3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b3.max;
22243
- const { unit } = axisObj;
22244
- return {
22245
- id,
22246
- //only add custom axis ranges if defined:
22247
- ...customMin ? { min: customMin } : {},
22248
- ...customMax ? { max: customMax } : {},
22249
- ...unit ? { unit } : {}
22250
- };
22251
- });
22265
+ return axes[axisType].map(
22266
+ (axisObj, index2) => {
22267
+ var _a3, _b3;
22268
+ const id = generateAxisId(axisType, index2, axes[axisType].length > 1);
22269
+ const customMin = (_a3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _a3.min;
22270
+ const customMax = (_b3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b3.max;
22271
+ const { unit } = axisObj;
22272
+ return {
22273
+ id,
22274
+ //only add custom axis ranges if defined:
22275
+ ...customMin ? { min: customMin } : {},
22276
+ ...customMax ? { max: customMax } : {},
22277
+ ...unit ? { unit } : {}
22278
+ };
22279
+ }
22280
+ );
22252
22281
  } else {
22253
22282
  const id = generateAxisId(axisType);
22254
22283
  const customMin = (_b2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b2.min;
22255
22284
  const customMax = (_c2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _c2.max;
22256
- const unit = axes == null ? void 0 : axes[id][0].unit;
22285
+ const unit = (_e2 = (_d2 = axes == null ? void 0 : axes[id]) == null ? void 0 : _d2[0]) == null ? void 0 : _e2.unit;
22257
22286
  return [
22258
22287
  {
22259
22288
  id,
@@ -22420,15 +22449,15 @@ const LineOptions = ({
22420
22449
  }
22421
22450
  ];
22422
22451
  const selectedOption = options.find((option) => option.selected);
22423
- return /* @__PURE__ */ jsx(Tooltip$2, { text: selectedOption.label, placement: "bottom", children: /* @__PURE__ */ jsx(
22452
+ return /* @__PURE__ */ jsx(Tooltip$2, { text: selectedOption == null ? void 0 : selectedOption.label, placement: "bottom", children: /* @__PURE__ */ jsx(
22424
22453
  Button,
22425
22454
  {
22426
22455
  small: true,
22427
22456
  basic: true,
22428
22457
  colored: "muted",
22429
22458
  round: true,
22430
- icon: selectedOption.icon,
22431
- onClick: selectedOption.onClick
22459
+ icon: selectedOption == null ? void 0 : selectedOption.icon,
22460
+ onClick: selectedOption == null ? void 0 : selectedOption.onClick
22432
22461
  }
22433
22462
  ) });
22434
22463
  };
@@ -22521,8 +22550,8 @@ const DragOptions = ({
22521
22550
  colored: "muted",
22522
22551
  basic: true,
22523
22552
  small: true,
22524
- label: selectedOption.buttonLabel || selectedOption.label,
22525
- icon: selectedOption.icon
22553
+ label: (selectedOption == null ? void 0 : selectedOption.buttonLabel) || (selectedOption == null ? void 0 : selectedOption.label),
22554
+ icon: selectedOption == null ? void 0 : selectedOption.icon
22526
22555
  }
22527
22556
  )
22528
22557
  }
@@ -23502,15 +23531,19 @@ const useChartFunctions = ({
23502
23531
  }) => {
23503
23532
  const {
23504
23533
  annotations,
23505
- interactions: { onLegendClick, onPointHover, onPointUnhover },
23534
+ interactions: {
23535
+ onLegendClick,
23536
+ onHover: onPointHover,
23537
+ onUnhover: onPointUnhover
23538
+ },
23506
23539
  additionalAxesOptions,
23507
23540
  axes
23508
23541
  } = options;
23509
23542
  const legendClick = useCallback(
23510
- (e2, legendItem2) => {
23543
+ (_e2, legendItem2) => {
23511
23544
  const { datasetIndex } = legendItem2;
23512
- const chartInstance = chartRef.current;
23513
- const { datasets } = chartInstance.data;
23545
+ const chartInstance = chartRef == null ? void 0 : chartRef.current;
23546
+ const { datasets } = (chartInstance == null ? void 0 : chartInstance.data) || {};
23514
23547
  const dataset = datasets[datasetIndex];
23515
23548
  const meta = chartInstance.getDatasetMeta(datasetIndex);
23516
23549
  meta.hidden = meta.hidden === null ? !dataset.hidden : null;
@@ -23519,7 +23552,7 @@ const useChartFunctions = ({
23519
23552
  dispatch({ type: "TOGGLE_ANNOTATION", payload: { annotationIndex } });
23520
23553
  }
23521
23554
  if (dataset.displayGroup) {
23522
- datasets.forEach((ds, ix) => {
23555
+ datasets == null ? void 0 : datasets.forEach((ds, ix) => {
23523
23556
  if (ds.displayGroup !== dataset.displayGroup)
23524
23557
  return;
23525
23558
  chartInstance.getDatasetMeta(ix).hidden = meta.hidden;
@@ -23528,13 +23561,13 @@ const useChartFunctions = ({
23528
23561
  if (onLegendClick) {
23529
23562
  onLegendClick(legendItem2 == null ? void 0 : legendItem2.text, legendItem2.hidden);
23530
23563
  }
23531
- chartInstance.update();
23564
+ chartInstance == null ? void 0 : chartInstance.update();
23532
23565
  },
23533
23566
  [onLegendClick, annotations]
23534
23567
  );
23535
23568
  const resetZoom2 = useCallback(() => {
23536
- const chartInstance = chartRef.current;
23537
- chartInstance.resetZoom();
23569
+ const chartInstance = chartRef == null ? void 0 : chartRef.current;
23570
+ chartInstance == null ? void 0 : chartInstance.resetZoom();
23538
23571
  dispatch({ type: "RESET_AXES_RANGES" });
23539
23572
  }, [chartRef]);
23540
23573
  const onHover = useCallback((hoveredPoint, setHoveredPoint) => {
@@ -23574,22 +23607,30 @@ const useChartFunctions = ({
23574
23607
  }, [chartRef, state.axes]);
23575
23608
  const handleKeyDown = useCallback(
23576
23609
  (evt) => {
23610
+ var _a2, _b2, _c2, _d2, _e2;
23577
23611
  if (evt.key === Key.Shift) {
23578
23612
  const chart2 = chartRef.current;
23579
- chart2.config.options.plugins.zoom.zoom.mode = PanZoomMode.Y;
23580
- chart2.config.options.plugins.zoom.pan.mode = PanZoomMode.Y;
23581
- chart2.update();
23613
+ const zoom2 = (_c2 = (_b2 = (_a2 = chart2 == null ? void 0 : chart2.config) == null ? void 0 : _a2.options) == null ? void 0 : _b2.plugins) == null ? void 0 : _c2.zoom;
23614
+ if (((_d2 = zoom2 == null ? void 0 : zoom2.zoom) == null ? void 0 : _d2.mode) && ((_e2 = zoom2 == null ? void 0 : zoom2.pan) == null ? void 0 : _e2.mode)) {
23615
+ zoom2.zoom.mode = PanZoomMode.Y;
23616
+ zoom2.pan.mode = PanZoomMode.Y;
23617
+ chart2 == null ? void 0 : chart2.update();
23618
+ }
23582
23619
  }
23583
23620
  },
23584
23621
  [chartRef]
23585
23622
  );
23586
23623
  const handleKeyUp = useCallback(
23587
23624
  (evt) => {
23625
+ var _a2, _b2, _c2, _d2, _e2;
23588
23626
  if (evt.key === Key.Shift) {
23589
23627
  const chart2 = chartRef.current;
23590
- chart2.config.options.plugins.zoom.zoom.mode = PanZoomMode.Z;
23591
- chart2.config.options.plugins.zoom.pan.mode = PanZoomMode.Z;
23592
- chart2.update();
23628
+ const zoom2 = (_c2 = (_b2 = (_a2 = chart2 == null ? void 0 : chart2.config) == null ? void 0 : _a2.options) == null ? void 0 : _b2.plugins) == null ? void 0 : _c2.zoom;
23629
+ if (((_d2 = zoom2 == null ? void 0 : zoom2.zoom) == null ? void 0 : _d2.mode) && ((_e2 = zoom2 == null ? void 0 : zoom2.pan) == null ? void 0 : _e2.mode)) {
23630
+ zoom2.zoom.mode = PanZoomMode.XY;
23631
+ zoom2.pan.mode = PanZoomMode.XY;
23632
+ chart2 == null ? void 0 : chart2.update();
23633
+ }
23593
23634
  }
23594
23635
  },
23595
23636
  [chartRef]
@@ -23635,13 +23676,15 @@ const useChartFunctions = ({
23635
23676
  );
23636
23677
  const updateAxesRangesFromChart = useCallback(() => {
23637
23678
  const { scales = {} } = (chartRef == null ? void 0 : chartRef.current) || {};
23638
- const axes2 = Object.entries(scales).map(([key, { min, max }]) => {
23639
- return {
23640
- id: key,
23641
- min: min ?? 0,
23642
- max: max ?? 0
23643
- };
23644
- });
23679
+ const axes2 = Object.entries(scales).map(
23680
+ ([key, { min, max }]) => {
23681
+ return {
23682
+ id: key,
23683
+ min: min ?? 0,
23684
+ max: max ?? 0
23685
+ };
23686
+ }
23687
+ );
23645
23688
  dispatch({
23646
23689
  type: UPDATE_AXES_RANGES,
23647
23690
  payload: { axes: axes2 }
@@ -23673,8 +23716,11 @@ var actionTypes = /* @__PURE__ */ ((actionTypes2) => {
23673
23716
  actionTypes2["UnitUpdated"] = "unitUpdated";
23674
23717
  return actionTypes2;
23675
23718
  })(actionTypes || {});
23676
- const initializeFormState = ({ initialAxesRanges, axes = [] }) => {
23677
- return initialAxesRanges.map((initialAxisRange) => {
23719
+ const initializeFormState = ({
23720
+ initialAxesRanges,
23721
+ axes = []
23722
+ }) => {
23723
+ return (initialAxesRanges == null ? void 0 : initialAxesRanges.map((initialAxisRange) => {
23678
23724
  const currentAxisRange = axes.find((a2) => a2.id === initialAxisRange.id);
23679
23725
  return {
23680
23726
  id: initialAxisRange.id,
@@ -23682,7 +23728,7 @@ const initializeFormState = ({ initialAxesRanges, axes = [] }) => {
23682
23728
  max: (currentAxisRange == null ? void 0 : currentAxisRange.max) ?? (initialAxisRange == null ? void 0 : initialAxisRange.max),
23683
23729
  unit: currentAxisRange == null ? void 0 : currentAxisRange.unit
23684
23730
  };
23685
- });
23731
+ })) || [];
23686
23732
  };
23687
23733
  const isEmptyString = (value) => value === "";
23688
23734
  const createErrorMessages = (value, compareTo, type) => {
@@ -23700,11 +23746,12 @@ const validateAxes = (formState) => {
23700
23746
  return formState.reduce(
23701
23747
  (acc, { id, min, max }) => {
23702
23748
  return produce(acc, (draft) => {
23749
+ var _a2;
23703
23750
  const errors = {
23704
- min: createErrorMessages(min, max, "min"),
23705
- max: createErrorMessages(max, min, "max")
23751
+ min: createErrorMessages(String(min), String(max), "min"),
23752
+ max: createErrorMessages(String(max), String(min), "max")
23706
23753
  };
23707
- draft.errors.push({
23754
+ (_a2 = draft == null ? void 0 : draft.errors) == null ? void 0 : _a2.push({
23708
23755
  id,
23709
23756
  ...errors
23710
23757
  });
@@ -23724,13 +23771,17 @@ const reducer = (state, action) => {
23724
23771
  return produce(state, (draft) => {
23725
23772
  const { name: name2, value, id } = action.payload;
23726
23773
  const axis = draft.find((a2) => a2.id === id);
23727
- axis[name2] = value;
23774
+ if (axis) {
23775
+ axis[name2] = value;
23776
+ }
23728
23777
  });
23729
23778
  case actionTypes.UnitUpdated:
23730
23779
  return produce(state, (draft) => {
23731
23780
  const { name: name2, value, id } = action.payload;
23732
23781
  const axis = draft.find((a2) => a2.id === id);
23733
- axis.unit[name2] = value;
23782
+ if (axis) {
23783
+ axis.unit[name2] = value;
23784
+ }
23734
23785
  });
23735
23786
  default:
23736
23787
  return state;
@@ -23783,54 +23834,55 @@ const AxesOptionsPopover = (optionsPopover) => {
23783
23834
  onUpdateAxes({
23784
23835
  axes: sanitizedFormState
23785
23836
  });
23786
- sanitizedFormState.forEach((el, i2) => {
23837
+ sanitizedFormState.map((el, i2) => {
23787
23838
  var _a3, _b2, _c2;
23788
23839
  const selectedUnit = (_a3 = el.unit) == null ? void 0 : _a3.selectedUnit;
23789
23840
  if (selectedUnit) {
23790
23841
  (_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
23791
23842
  }
23792
23843
  });
23793
- if (depthType) {
23794
- depthType.setSelectedDepthType(depthTypeState);
23844
+ if (depthType && (depthType == null ? void 0 : depthType.setSelectedDepthType)) {
23845
+ depthType == null ? void 0 : depthType.setSelectedDepthType(depthTypeState);
23795
23846
  }
23796
23847
  }
23797
- close();
23848
+ close == null ? void 0 : close();
23798
23849
  };
23799
23850
  const onReset = () => {
23800
23851
  dispatch({
23801
23852
  type: actionTypes.Reset,
23802
23853
  payload: { axes, initialAxesRanges }
23803
23854
  });
23804
- initialAxesRanges.forEach((el, i2) => {
23855
+ initialAxesRanges.map((el, i2) => {
23805
23856
  var _a3, _b2, _c2;
23806
- const selectedUnit = (_a3 = el == null ? void 0 : el.unit) == null ? void 0 : _a3.selectedUnit;
23857
+ const selectedUnit = (_a3 = el.unit) == null ? void 0 : _a3.selectedUnit;
23807
23858
  if (selectedUnit) {
23808
23859
  (_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
23809
23860
  }
23810
23861
  });
23811
23862
  onResetAxes();
23812
- close();
23863
+ close == null ? void 0 : close();
23813
23864
  };
23814
23865
  const isCustomValue = axes.filter((axis) => axis.max || axis.min).length > 0;
23815
23866
  const handleInputFocus = (e2) => e2.target.select();
23816
23867
  return /* @__PURE__ */ jsxs("form", { onSubmit: onDone, children: [
23817
23868
  axes.map((axis, i2) => {
23818
- var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
23819
- const axisLabel = (_a3 = controlsAxesLabels.find(
23869
+ var _a3, _b2, _c2;
23870
+ const axisControl = controlsAxesLabels.find(
23820
23871
  (el) => el.id === axis.id
23821
- )) == null ? void 0 : _a3.label;
23822
- const min = (_b2 = formState.find((a2) => a2.id === axis.id)) == null ? void 0 : _b2.min;
23823
- const max = (_c2 = formState.find((a2) => a2.id === axis.id)) == null ? void 0 : _c2.max;
23824
- const minError = (_e2 = (_d2 = errors == null ? void 0 : errors.find((a2) => a2.id === axis.id)) == null ? void 0 : _d2.min) == null ? void 0 : _e2[0];
23825
- const maxError = (_g2 = (_f2 = errors == null ? void 0 : errors.find((a2) => a2.id === axis.id)) == null ? void 0 : _f2.max) == null ? void 0 : _g2[0];
23826
- const unit = (_h2 = formState.find((a2) => a2.id === axis.id)) == null ? void 0 : _h2.unit;
23872
+ );
23873
+ const axisLabel = axisControl == null ? void 0 : axisControl.label;
23874
+ const axisState = formState.find((a2) => a2.id === axis.id);
23875
+ const axisErrors = errors == null ? void 0 : errors.find((a2) => a2.id === axis.id);
23876
+ const { min, max, unit } = axisState || {};
23877
+ const minErrorMsg = ((_a3 = axisErrors == null ? void 0 : axisErrors.min) == null ? void 0 : _a3[0]) ? translations[axisErrors.min[0]] : null;
23878
+ const maxErrorMsg = ((_b2 = axisErrors == null ? void 0 : axisErrors.max) == null ? void 0 : _b2[0]) ? translations[axisErrors.max[0]] : null;
23827
23879
  return /* @__PURE__ */ jsx(Field, { label: axisLabel || axis.id || "", children: /* @__PURE__ */ jsxs(InputGroup, { small: true, width: "300px", children: [
23828
23880
  /* @__PURE__ */ jsx(
23829
23881
  NumberInput,
23830
23882
  {
23831
23883
  name: "min",
23832
23884
  value: min,
23833
- error: translations[minError],
23885
+ error: minErrorMsg,
23834
23886
  size: 5,
23835
23887
  width: "100%",
23836
23888
  onChange: (evt) => onEditValue({
@@ -23847,7 +23899,7 @@ const AxesOptionsPopover = (optionsPopover) => {
23847
23899
  {
23848
23900
  name: "max",
23849
23901
  value: max,
23850
- error: translations[maxError],
23902
+ error: maxErrorMsg,
23851
23903
  size: 5,
23852
23904
  width: "100%",
23853
23905
  onChange: (evt) => onEditValue({
@@ -23862,7 +23914,7 @@ const AxesOptionsPopover = (optionsPopover) => {
23862
23914
  Select,
23863
23915
  {
23864
23916
  name: "selectedUnit",
23865
- options: (_i2 = axis == null ? void 0 : axis.unit) == null ? void 0 : _i2.options,
23917
+ options: (_c2 = axis == null ? void 0 : axis.unit) == null ? void 0 : _c2.options,
23866
23918
  value: unit == null ? void 0 : unit.selectedUnit,
23867
23919
  onChange: (e2) => {
23868
23920
  onEditUnit({
@@ -23958,14 +24010,19 @@ const AxesOptions = (optionsPopover) => {
23958
24010
  }
23959
24011
  );
23960
24012
  };
23961
- const ControlsPortal = ({ children, controlsPortalId }) => {
24013
+ const ControlsPortal = ({
24014
+ children,
24015
+ controlsPortalId
24016
+ }) => {
23962
24017
  if (controlsPortalId && document.getElementById(controlsPortalId)) {
23963
24018
  return /* @__PURE__ */ jsx(Portal, { id: controlsPortalId, children });
23964
24019
  }
23965
24020
  return children;
23966
24021
  };
23967
24022
  const Controls = ({
23968
- props: { headerComponent, subheaderComponent, table: table2 },
24023
+ headerComponent,
24024
+ subheaderComponent,
24025
+ table: table2,
23969
24026
  chartRef,
23970
24027
  state,
23971
24028
  options,
@@ -23983,7 +24040,7 @@ const Controls = ({
23983
24040
  showTable,
23984
24041
  zoomEnabled
23985
24042
  } = state;
23986
- const { dragData } = options;
24043
+ const { dragData, depthType } = options;
23987
24044
  const {
23988
24045
  onToggleLine,
23989
24046
  onTogglePan,
@@ -24010,7 +24067,7 @@ const Controls = ({
24010
24067
  /* @__PURE__ */ jsxs("div", { className: styles$3.controls, children: [
24011
24068
  !!options.title && /* @__PURE__ */ jsx(Text, { bold: true, children: options.title }),
24012
24069
  headerComponent,
24013
- /* @__PURE__ */ jsx(ControlsPortal, { controlsPortalId, children: /* @__PURE__ */ jsxs("div", { className: styles$3.buttons, children: [
24070
+ /* @__PURE__ */ jsx(ControlsPortal, { controlsPortalId: controlsPortalId ?? "", children: /* @__PURE__ */ jsxs("div", { className: styles$3.buttons, children: [
24014
24071
  !showTable && /* @__PURE__ */ jsxs(Fragment, { children: [
24015
24072
  /* @__PURE__ */ jsx(
24016
24073
  AxesOptions,
@@ -24020,7 +24077,7 @@ const Controls = ({
24020
24077
  controlsAxesLabels,
24021
24078
  onUpdateAxes,
24022
24079
  onResetAxes,
24023
- depthType: options.depthType,
24080
+ depthType,
24024
24081
  translations
24025
24082
  }
24026
24083
  ),
@@ -24203,7 +24260,7 @@ const LegendItemLine = ({ dataset }) => {
24203
24260
  ) });
24204
24261
  };
24205
24262
  const LegendItemPoint = ({ dataset }) => {
24206
- const { pointBackgroundColor, pointRadius, pointStyle } = dataset;
24263
+ const { pointBackgroundColor, pointRadius, pointStyle = "" } = dataset;
24207
24264
  if (!pointRadius)
24208
24265
  return null;
24209
24266
  const size = pointRadius * 2;
@@ -24290,12 +24347,12 @@ const LegendPanel = forwardRef((props, ref) => {
24290
24347
  const { data, chartArea, height = 0, width = 0 } = chart2;
24291
24348
  const { datasets } = data;
24292
24349
  const { top: top2, left: left2, bottom: bottom2, right: right2 } = chartArea;
24293
- const items = ((_d2 = (_c2 = (_b2 = (_a2 = chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.legend) == null ? void 0 : _c2.labels) == null ? void 0 : _d2.generateLabels(chart2)) ?? [];
24350
+ const items = ((_d2 = (_c2 = (_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.legend) == null ? void 0 : _c2.labels) == null ? void 0 : _d2.generateLabels(chart2)) ?? [];
24294
24351
  const style = {
24295
- left: legendPosition.includes("left") ? left2 : null,
24296
- right: legendPosition.includes("right") ? width - right2 : null,
24297
- top: legendPosition.includes("top") ? top2 : null,
24298
- bottom: legendPosition.includes("bottom") ? height - bottom2 : null,
24352
+ left: legendPosition.includes("left") ? left2 : void 0,
24353
+ right: legendPosition.includes("right") ? width - right2 : void 0,
24354
+ top: legendPosition.includes("top") ? top2 : void 0,
24355
+ bottom: legendPosition.includes("bottom") ? height - bottom2 : void 0,
24299
24356
  maxHeight: 0.5 * (bottom2 - top2 - LEGEND_MARGIN * 2),
24300
24357
  maxWidth: 0.5 * (right2 - left2 - LEGEND_MARGIN * 2),
24301
24358
  margin: LEGEND_MARGIN
@@ -24446,7 +24503,7 @@ const Legend2 = ({
24446
24503
  LegendDropZones,
24447
24504
  {
24448
24505
  chartArea,
24449
- setLegendPosition,
24506
+ setLegendPosition: (position) => setLegendPosition(position),
24450
24507
  isDragging: isDragging2,
24451
24508
  placeholderSize: panelSize
24452
24509
  }
@@ -24464,116 +24521,122 @@ const TextLabelPosition = {
24464
24521
  BOTTOM_CENTER: "bottom-center",
24465
24522
  BOTTOM_RIGHT: "bottom-right"
24466
24523
  };
24467
- const getDefaultProps$2 = (props) => {
24524
+ const defaultAxes$1 = (axes) => ({
24525
+ x: (axes == null ? void 0 : axes.x) || [],
24526
+ y: (axes == null ? void 0 : axes.y) || []
24527
+ });
24528
+ const defaultAdditionalAxesOptions$1 = (options) => ({
24529
+ chartScaleType: (options == null ? void 0 : options.chartScaleType) || "linear",
24530
+ reverse: (options == null ? void 0 : options.reverse) || false,
24531
+ beginAtZero: (options == null ? void 0 : options.beginAtZero) ?? false,
24532
+ stepSize: options == null ? void 0 : options.stepSize,
24533
+ suggestedMin: options == null ? void 0 : options.suggestedMin,
24534
+ suggestedMax: options == null ? void 0 : options.suggestedMax,
24535
+ range: (options == null ? void 0 : options.range) || {},
24536
+ autoAxisPadding: (options == null ? void 0 : options.autoAxisPadding) ?? false
24537
+ });
24538
+ const defaultChartStyling$2 = (options) => ({
24539
+ width: options == null ? void 0 : options.width,
24540
+ height: options == null ? void 0 : options.height,
24541
+ maintainAspectRatio: (options == null ? void 0 : options.maintainAspectRatio) ?? false,
24542
+ staticChartHeight: (options == null ? void 0 : options.staticChartHeight) ?? false,
24543
+ performanceMode: (options == null ? void 0 : options.performanceMode) ?? true,
24544
+ squareAspectRatio: options == null ? void 0 : options.squareAspectRatio,
24545
+ layoutPadding: (options == null ? void 0 : options.layoutPadding) || {
24546
+ top: 0,
24547
+ bottom: 20,
24548
+ left: 0,
24549
+ right: 0
24550
+ }
24551
+ });
24552
+ const defaultTooltip$2 = (tooltip) => ({
24553
+ tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
24554
+ showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) ?? false,
24555
+ hideSimulationName: (tooltip == null ? void 0 : tooltip.hideSimulationName) ?? false
24556
+ });
24557
+ const defaultGraph$2 = (graph) => ({
24558
+ lineTension: (graph == null ? void 0 : graph.lineTension) ?? 0.01,
24559
+ spanGaps: (graph == null ? void 0 : graph.spanGaps) ?? false,
24560
+ showDataLabels: (graph == null ? void 0 : graph.showDataLabels) ?? false,
24561
+ showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) ?? false
24562
+ });
24563
+ const defaultAnnotations$1 = (annotations) => {
24468
24564
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
24469
- props.chart.options = props.chart.options || {};
24470
- props.chart.options.axes = props.chart.options.axes || {};
24471
- props.chart.options.additionalAxesOptions = props.chart.options.additionalAxesOptions || {};
24472
- props.chart.options.chartStyling = props.chart.options.chartStyling || {};
24473
- props.chart.options.tooltip = props.chart.options.tooltip || {};
24474
- props.chart.options.graph = props.chart.options.graph || {};
24475
- props.chart.options.annotations = props.chart.options.annotations || {};
24476
- props.chart.options.legend = props.chart.options.legend || {};
24477
- props.chart.options.legend.customLegend = props.chart.options.legend.customLegend || { customLegendPlugin: null, customLegendContainerID: "" };
24478
- props.chart.options.chartOptions = props.chart.options.chartOptions || {};
24479
- props.chart.options.interactions = props.chart.options.interactions || {};
24480
- props.chart.options.dragData = props.chart.options.dragData || {};
24481
- const chart2 = {
24482
- persistenceId: props.chart.persistenceId ?? "",
24483
- controlsPortalId: props.chart.controlsPortalId ?? null,
24484
- testId: props.chart.testId ?? null,
24485
- data: props.chart.data,
24565
+ return {
24566
+ labelAnnotation: {
24567
+ showLabel: ((_a2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _a2.showLabel) ?? false,
24568
+ text: ((_b2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _b2.text) ?? "",
24569
+ position: ((_c2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _c2.position) ?? TextLabelPosition.BOTTOM_RIGHT,
24570
+ fontSize: ((_d2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _d2.fontSize) ?? 12,
24571
+ xOffset: ((_e2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _e2.xOffset) ?? 5,
24572
+ yOffset: ((_f2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _f2.yOffset) ?? 5,
24573
+ maxWidth: ((_g2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _g2.maxWidth) ?? 300,
24574
+ lineHeight: ((_h2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _h2.lineHeight) ?? 12
24575
+ },
24576
+ showAnnotations: (annotations == null ? void 0 : annotations.showAnnotations) ?? false,
24577
+ controlAnnotation: (annotations == null ? void 0 : annotations.controlAnnotation) ?? false,
24578
+ annotationsData: (annotations == null ? void 0 : annotations.annotationsData) ?? []
24579
+ };
24580
+ };
24581
+ const defaultLegend$2 = (legend2) => ({
24582
+ display: (legend2 == null ? void 0 : legend2.display) ?? true,
24583
+ position: (legend2 == null ? void 0 : legend2.position) ?? Position.BottomLeft,
24584
+ align: (legend2 == null ? void 0 : legend2.align) ?? AlignOptions.Center,
24585
+ customLegend: (legend2 == null ? void 0 : legend2.customLegend) ?? {
24586
+ customLegendPlugin: null,
24587
+ customLegendContainerID: ""
24588
+ },
24589
+ usePointStyle: (legend2 == null ? void 0 : legend2.usePointStyle) ?? true
24590
+ });
24591
+ const defaultChartOptions$2 = (options) => ({
24592
+ showPoints: (options == null ? void 0 : options.showPoints) ?? true,
24593
+ enableZoom: (options == null ? void 0 : options.enableZoom) ?? true,
24594
+ enablePan: (options == null ? void 0 : options.enablePan) ?? false,
24595
+ showLine: (options == null ? void 0 : options.showLine) ?? true,
24596
+ closeOnOutsideClick: (options == null ? void 0 : options.closeOnOutsideClick) ?? false
24597
+ });
24598
+ const defaultInteractions$2 = (interactions) => ({
24599
+ onLegendClick: interactions == null ? void 0 : interactions.onLegendClick,
24600
+ onHover: interactions == null ? void 0 : interactions.onHover,
24601
+ onUnhover: interactions == null ? void 0 : interactions.onUnhover,
24602
+ onAnimationComplete: interactions == null ? void 0 : interactions.onAnimationComplete
24603
+ });
24604
+ const defaultDragData$1 = (dragData) => ({
24605
+ enableDragData: (dragData == null ? void 0 : dragData.enableDragData) ?? false,
24606
+ showTooltip: (dragData == null ? void 0 : dragData.showTooltip) ?? true,
24607
+ roundPoints: (dragData == null ? void 0 : dragData.roundPoints) ?? true,
24608
+ dragX: (dragData == null ? void 0 : dragData.dragX) ?? true,
24609
+ dragY: (dragData == null ? void 0 : dragData.dragY) ?? true,
24610
+ onDragStart: dragData == null ? void 0 : dragData.onDragStart,
24611
+ onDrag: dragData == null ? void 0 : dragData.onDrag,
24612
+ onDragEnd: dragData == null ? void 0 : dragData.onDragEnd
24613
+ });
24614
+ const getDefaultProps$2 = (props) => {
24615
+ const chart2 = (props == null ? void 0 : props.chart) || {};
24616
+ const options = (chart2 == null ? void 0 : chart2.options) || {};
24617
+ return {
24618
+ persistenceId: (chart2 == null ? void 0 : chart2.persistenceId) ?? "",
24619
+ controlsPortalId: (chart2 == null ? void 0 : chart2.controlsPortalId) ?? "",
24620
+ testId: (chart2 == null ? void 0 : chart2.testId) ?? null,
24621
+ data: chart2 == null ? void 0 : chart2.data,
24486
24622
  options: {
24487
- title: props.chart.options.title || "",
24488
- scales: props.chart.options.scales || {},
24489
- axes: {
24490
- x: props.chart.options.axes.x || [{}],
24491
- y: props.chart.options.axes.y || [{}]
24492
- },
24493
- additionalAxesOptions: {
24494
- chartScaleType: props.chart.options.additionalAxesOptions.chartScaleType || "linear",
24495
- reverse: props.chart.options.additionalAxesOptions.reverse || false,
24496
- beginAtZero: props.chart.options.additionalAxesOptions.beginAtZero || false,
24497
- stepSize: props.chart.options.additionalAxesOptions.stepSize,
24498
- suggestedMin: props.chart.options.additionalAxesOptions.suggestedMin,
24499
- suggestedMax: props.chart.options.additionalAxesOptions.suggestedMax,
24500
- range: props.chart.options.additionalAxesOptions.range,
24501
- autoAxisPadding: props.chart.options.additionalAxesOptions.autoAxisPadding ?? false
24502
- },
24503
- chartStyling: {
24504
- width: props.chart.options.chartStyling.width,
24505
- height: props.chart.options.chartStyling.height,
24506
- maintainAspectRatio: props.chart.options.chartStyling.maintainAspectRatio || false,
24507
- staticChartHeight: props.chart.options.chartStyling.staticChartHeight || false,
24508
- performanceMode: props.chart.options.chartStyling.performanceMode ?? true,
24509
- squareAspectRatio: props.chart.options.chartStyling.squareAspectRatio || false,
24510
- layoutPadding: props.chart.options.chartStyling.layoutPadding || {
24511
- top: 0,
24512
- bottom: 20,
24513
- left: 0,
24514
- right: 0
24515
- }
24516
- },
24517
- tooltip: {
24518
- tooltips: props.chart.options.tooltip.tooltips ?? true,
24519
- showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false,
24520
- hideSimulationName: props.chart.options.tooltip.hideSimulationName || false
24521
- },
24522
- graph: {
24523
- lineTension: props.chart.options.graph.lineTension || 0.01,
24524
- spanGaps: props.chart.options.graph.spanGaps || false,
24525
- showDataLabels: props.chart.options.graph.showDataLabels || false,
24526
- showMinorGridlines: props.chart.options.graph.showMinorGridlines || false
24527
- },
24528
- annotations: {
24529
- labelAnnotation: {
24530
- showLabel: ((_a2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _a2.showLabel) ?? false,
24531
- text: ((_b2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _b2.text) ?? "",
24532
- position: ((_c2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _c2.position) ?? TextLabelPosition.BOTTOM_RIGHT,
24533
- fontSize: ((_d2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _d2.fontSize) ?? 12,
24534
- xOffset: ((_e2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _e2.xOffset) ?? 5,
24535
- yOffset: ((_f2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _f2.yOffset) ?? 5,
24536
- maxWidth: ((_g2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _g2.maxWidth) ?? 300,
24537
- lineHeight: ((_h2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _h2.lineHeight) ?? 12
24538
- },
24539
- showAnnotations: props.chart.options.annotations.showAnnotations ?? false,
24540
- controlAnnotation: props.chart.options.annotations.controlAnnotation || false,
24541
- annotationsData: props.chart.options.annotations.annotationsData || []
24542
- },
24543
- legend: {
24544
- display: props.chart.options.legend.display ?? true,
24545
- position: props.chart.options.legend.position || "bottom-left",
24546
- align: props.chart.options.legend.align || "center",
24547
- customLegend: props.chart.options.legend.customLegend,
24548
- usePointStyle: props.chart.options.legend.usePointStyle ?? true
24549
- },
24550
- chartOptions: {
24551
- showPoints: props.chart.options.chartOptions.showPoints ?? true,
24552
- enableZoom: props.chart.options.chartOptions.enableZoom || true,
24553
- enablePan: props.chart.options.chartOptions.enablePan || false,
24554
- showLine: props.chart.options.chartOptions.showLine ?? true,
24555
- closeOnOutsideClick: props.chart.options.chartOptions.closeOnOutsideClick || false
24556
- },
24557
- interactions: {
24558
- onLegendClick: props.chart.options.interactions.onLegendClick,
24559
- onPointHover: props.chart.options.interactions.onPointHover,
24560
- onPointUnhover: props.chart.options.interactions.onPointUnhover,
24561
- onAnimationComplete: props.chart.options.interactions.onAnimationComplete
24562
- },
24563
- depthType: props.chart.options.depthType,
24564
- dragData: {
24565
- enableDragData: props.chart.options.dragData.enableDragData ?? false,
24566
- showTooltip: props.chart.options.dragData.showTooltip ?? true,
24567
- roundPoints: props.chart.options.dragData.roundPoints ?? true,
24568
- dragX: props.chart.options.dragData.dragX ?? true,
24569
- dragY: props.chart.options.dragData.dragY ?? true,
24570
- onDragStart: props.chart.options.dragData.onDragStart,
24571
- onDrag: props.chart.options.dragData.onDrag,
24572
- onDragEnd: props.chart.options.dragData.onDragEnd
24573
- }
24623
+ title: (options == null ? void 0 : options.title) ?? "",
24624
+ scales: (options == null ? void 0 : options.scales) ?? {},
24625
+ axes: defaultAxes$1(options == null ? void 0 : options.axes),
24626
+ additionalAxesOptions: defaultAdditionalAxesOptions$1(
24627
+ options == null ? void 0 : options.additionalAxesOptions
24628
+ ),
24629
+ chartStyling: defaultChartStyling$2(options == null ? void 0 : options.chartStyling),
24630
+ tooltip: defaultTooltip$2(options == null ? void 0 : options.tooltip),
24631
+ graph: defaultGraph$2(options == null ? void 0 : options.graph),
24632
+ annotations: defaultAnnotations$1(options == null ? void 0 : options.annotations),
24633
+ legend: defaultLegend$2(options == null ? void 0 : options.legend),
24634
+ chartOptions: defaultChartOptions$2(options == null ? void 0 : options.chartOptions),
24635
+ interactions: defaultInteractions$2(options == null ? void 0 : options.interactions),
24636
+ dragData: defaultDragData$1(options == null ? void 0 : options.dragData),
24637
+ depthType: (options == null ? void 0 : options.depthType) ?? {}
24574
24638
  }
24575
24639
  };
24576
- return chart2;
24577
24640
  };
24578
24641
  const DEFAULT_POINT_RADIUS = 2;
24579
24642
  const DEFAULT_HOVER_RADIUS = 5;
@@ -24635,7 +24698,7 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
24635
24698
  if (formation) {
24636
24699
  const axesMin = (_a2 = axes[0]) == null ? void 0 : _a2.min;
24637
24700
  const axesMax = (_b2 = axes[0]) == null ? void 0 : _b2.max;
24638
- const [startPoint, midPointWithLabel, endPoint] = data;
24701
+ const [startPoint, endPoint] = data;
24639
24702
  if (axesMin && (startPoint == null ? void 0 : startPoint.x)) {
24640
24703
  data[0].x = Math.max(axesMin, startPoint.x);
24641
24704
  }
@@ -24657,9 +24720,9 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
24657
24720
  borderWidth: parseFloat(borderWidth) || DEFAULT_BORDER_WIDTH,
24658
24721
  borderDash: borderDash || [],
24659
24722
  borderJoinStyle: BORDER_JOIN_STYLE,
24660
- borderColor: borderColor ?? indexedColor ?? generateRandomColor$1(COLORS),
24723
+ borderColor: borderColor ?? indexedColor ?? generateRandomColor(COLORS),
24661
24724
  backgroundColor: backgroundColor ?? DEFAULT_BACKGROUND_COLOR,
24662
- pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor$1(COLORS),
24725
+ pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor(COLORS),
24663
24726
  pointRadius: pointsEnabled ? linePointRadius : DEFAULT_LINE_POINT_RADIUS,
24664
24727
  pointHoverRadius: hoverRadius,
24665
24728
  pointHitRadius: line.pointHitRadius ?? hoverRadius
@@ -24699,8 +24762,8 @@ const formatAxisLabelNumbers = (tickValue, ticks, locale = "en-gb") => {
24699
24762
  };
24700
24763
  const getLineChartAxis = (options, axisType, state, currentScales, i2 = 0) => {
24701
24764
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
24702
- const axisData = currentScales || options.axes[axisType][0];
24703
- const stateAxis = state.axes.filter(
24765
+ const axisData = currentScales || options.axes[axisType][0] || {};
24766
+ const stateAxis = state == null ? void 0 : state.axes.filter(
24704
24767
  (axis) => axis.id.startsWith(axisType)
24705
24768
  )[i2];
24706
24769
  const ticksConfigFromProps = (_b2 = (_a2 = options == null ? void 0 : options.scales) == null ? void 0 : _a2[`${i2 === 0 ? axisType : axisType + i2}`]) == null ? void 0 : _b2.ticks;
@@ -24747,14 +24810,17 @@ const getLineChartAxis = (options, axisType, state, currentScales, i2 = 0) => {
24747
24810
  };
24748
24811
  const getLineChartAxes = (options, axisType, state) => {
24749
24812
  const axesData = options.axes[axisType];
24750
- const axes = axesData.reduce((acc, curr, i2) => {
24751
- const axisData = curr;
24752
- axisData.color = curr.color || COLORS[i2] || generateRandomColor$1(COLORS);
24753
- axisData.position = curr.position || getAxisPosition(axisType, i2);
24754
- const axis = getLineChartAxis(options, axisType, state, axisData, i2);
24755
- const axisId = generateAxisId(axisType, i2, true);
24756
- return { ...acc, [axisId]: axis };
24757
- }, {});
24813
+ const axes = axesData.reduce(
24814
+ (acc, curr, i2) => {
24815
+ const axisData = curr;
24816
+ axisData.color = curr.color || COLORS[i2] || generateRandomColor(COLORS);
24817
+ axisData.position = curr.position || getAxisPosition(axisType, i2);
24818
+ const axis = getLineChartAxis(options, axisType, state, axisData, i2);
24819
+ const axisId = generateAxisId(axisType, i2, true);
24820
+ return { ...acc, [axisId]: axis };
24821
+ },
24822
+ {}
24823
+ );
24758
24824
  return axes;
24759
24825
  };
24760
24826
  const getLineChartScales = (options, state) => {
@@ -24803,11 +24869,9 @@ const estimateDataSeriesHaveCloseValues = (generatedDatasets) => {
24803
24869
  }
24804
24870
  return acc;
24805
24871
  }, {});
24806
- return Object.values(axesFirstLast).some(
24807
- ({ xFirst, xLast, yFirst, yLast }) => {
24808
- return isCloseTo(xFirst, xLast, { absoluteDiff: MAX_DECIMAL_DIFF }) || isCloseTo(yFirst, yLast, { absoluteDiff: MAX_DECIMAL_DIFF });
24809
- }
24810
- );
24872
+ return Object.values(axesFirstLast).some(({ xFirst, xLast, yFirst, yLast }) => {
24873
+ return isCloseTo(xFirst, xLast, { absoluteDiff: MAX_DECIMAL_DIFF }) || isCloseTo(yFirst, yLast, { absoluteDiff: MAX_DECIMAL_DIFF });
24874
+ });
24811
24875
  };
24812
24876
  const whiteSpacePercentage = 0.05;
24813
24877
  const defaultRange = { min: -1, max: 1 };
@@ -24856,77 +24920,44 @@ const getSuggestedAxisRange = ({
24856
24920
  max: round$2(maxAxisValue, DECIMAL_POINT_TOLERANCE)
24857
24921
  };
24858
24922
  };
24859
- const checkMultiAxis = (scalesKeys) => {
24860
- let counts = {
24861
- x: 0,
24862
- y: 0
24863
- };
24864
- scalesKeys.forEach((axeKey) => {
24865
- const key = getAxisTypeFromKey(axeKey);
24866
- counts[key]++;
24867
- });
24868
- const res = counts.x > counts.y && AxisType.X || counts.y > counts.x && AxisType.Y || counts.x === counts.y && null;
24869
- return res;
24870
- };
24871
24923
  const getAnnotationsData = (data) => {
24872
- return data.reduce((acc, obj) => {
24924
+ return data == null ? void 0 : data.reduce((acc, obj) => {
24873
24925
  return {
24874
24926
  ...acc,
24875
24927
  [obj.annotationAxis]: [...acc[obj.annotationAxis] || [], +obj.value]
24876
24928
  };
24877
24929
  }, {});
24878
24930
  };
24879
- const getAxesData = (scalesKeys, datasets, annotationsData) => {
24880
- const allData = (datasets == null ? void 0 : datasets.reduce((acc, item) => [...acc, ...item.data], [])) ?? [];
24881
- const getData = () => {
24882
- return scalesKeys.reduce((acc, axeKey) => {
24883
- const key = getAxisTypeFromKey(axeKey);
24884
- const data = getAnnotationsData(annotationsData);
24885
- const formData = allData == null ? void 0 : allData.map((val) => val == null ? void 0 : val[key]).concat(data[key] || []);
24886
- return {
24887
- ...acc,
24888
- [axeKey]: [...new Set(formData)]
24889
- };
24890
- }, {});
24891
- };
24892
- const getDataForMultiAxes = () => {
24893
- const multiAxesKey = checkMultiAxis(scalesKeys);
24894
- const axes = (scalesKeys == null ? void 0 : scalesKeys.filter((key) => key == null ? void 0 : key.includes(multiAxesKey))) ?? [];
24895
- const data = getAnnotationsData(annotationsData);
24896
- const [first, second] = axes;
24897
- const reduceData = (arr, key) => arr.reduce((acc, { [key]: value }) => [...acc, value], []);
24898
- return datasets.reduce(
24899
- (acc, obj) => {
24900
- const key = Object.values(obj).find((val) => axes.includes(val)) ?? multiAxesKey;
24901
- return key ? {
24902
- ...acc,
24903
- [key]: [
24904
- .../* @__PURE__ */ new Set([
24905
- ...acc[key],
24906
- ...reduceData(obj == null ? void 0 : obj.data, multiAxesKey),
24907
- ...key === multiAxesKey && (data == null ? void 0 : data[multiAxesKey]) || []
24908
- ])
24909
- ]
24910
- } : acc;
24911
- },
24912
- { [first]: [], [second]: [] }
24913
- );
24914
- };
24915
- return {
24916
- ...getData(),
24917
- ...getDataForMultiAxes()
24918
- };
24931
+ const getAxesDataFromMetasets = (chartRef, scalesKeys, annotationsData) => {
24932
+ var _a2;
24933
+ if (!chartRef || !scalesKeys)
24934
+ return {};
24935
+ const metasets = ((_a2 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _a2.getSortedVisibleDatasetMetas()) ?? [];
24936
+ const annotData = getAnnotationsData(annotationsData);
24937
+ return metasets && (scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
24938
+ const data = metasets.filter((dataset) => Object.values(dataset).includes(key)).flatMap((dataset) => dataset._parsed).map((parsedData) => parsedData[getAxisTypeFromKey(key)]).concat((annotData == null ? void 0 : annotData[key]) ?? []);
24939
+ return {
24940
+ ...acc,
24941
+ [key]: [...new Set(data)]
24942
+ };
24943
+ }, {}));
24919
24944
  };
24920
- const autoScale = (options, state, generatedDatasets) => {
24921
- const { additionalAxesOptions = {}, annotations = {} } = options || {};
24922
- const { annotationsData = [] } = annotations || {};
24945
+ const autoScale = (options, state, generatedDatasets, chartRef) => {
24946
+ const {
24947
+ additionalAxesOptions = {},
24948
+ annotations: { annotationsData = [] } = {}
24949
+ } = options || {};
24923
24950
  const scales = getLineChartScales(options, state) || {};
24924
24951
  if (!(additionalAxesOptions == null ? void 0 : additionalAxesOptions.autoAxisPadding) && !estimateDataSeriesHaveCloseValues(generatedDatasets)) {
24925
24952
  return scales;
24926
24953
  }
24927
24954
  const scalesKeys = Object.keys(scales) ?? [];
24928
- const data = getAxesData(scalesKeys, generatedDatasets, annotationsData) ?? {};
24929
- const adjustedScales = scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
24955
+ const data = getAxesDataFromMetasets(
24956
+ chartRef,
24957
+ scalesKeys,
24958
+ annotationsData
24959
+ );
24960
+ const adjustedScales = data && (scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
24930
24961
  const { min: propMin = void 0, max: propMax = void 0 } = scales[key];
24931
24962
  const { min, max } = getSuggestedAxisRange({
24932
24963
  data: data[key],
@@ -24941,7 +24972,7 @@ const autoScale = (options, state, generatedDatasets) => {
24941
24972
  }
24942
24973
  };
24943
24974
  return { ...acc, ...res };
24944
- }, {});
24975
+ }, {}));
24945
24976
  return adjustedScales ?? scales;
24946
24977
  };
24947
24978
  const getCondition = (x2, y2, left2, right2, bottom2) => {
@@ -25003,7 +25034,7 @@ const annotationLeave = ({ element }, { chart: chart2 }) => {
25003
25034
  chart2.canvas.style.cursor = CursorStyle.Initial;
25004
25035
  };
25005
25036
  const generateAnnotations = (options, state) => {
25006
- const { annotationsData } = options.annotations;
25037
+ const { annotationsData } = (options == null ? void 0 : options.annotations) || {};
25007
25038
  const annotations = annotationsData == null ? void 0 : annotationsData.reduce((acc, curr, i2) => {
25008
25039
  var _a2;
25009
25040
  if (!((_a2 = state == null ? void 0 : state.showAnnotationLineIndex) == null ? void 0 : _a2.includes(i2))) {
@@ -25055,9 +25086,9 @@ const generateAnnotations = (options, state) => {
25055
25086
  return annotations;
25056
25087
  };
25057
25088
  const getAnnotation = (options, state) => {
25058
- const { showAnnotations, annotationsData } = options.annotations || {};
25089
+ const { showAnnotations, annotationsData } = (options == null ? void 0 : options.annotations) || {};
25059
25090
  const shouldGenerateAnnotations = showAnnotations && (annotationsData == null ? void 0 : annotationsData.length);
25060
- const annotations = shouldGenerateAnnotations ? generateAnnotations(options, state) : null;
25091
+ const annotations = shouldGenerateAnnotations ? generateAnnotations(options, state) : {};
25061
25092
  return { annotations };
25062
25093
  };
25063
25094
  const getUnitsFromLabel = (label) => {
@@ -25067,12 +25098,12 @@ const getUnitsFromLabel = (label) => {
25067
25098
  };
25068
25099
  const getLineChartToolTips = (options) => {
25069
25100
  const getTooltipLabels = (dataset) => {
25070
- var _a2, _b2;
25101
+ var _a2, _b2, _c2, _d2, _e2;
25071
25102
  const xIndex = ((_a2 = dataset.xAxisID) == null ? void 0 : _a2.length) > 1 ? dataset.xAxisID[1] - 1 : 0;
25072
25103
  const yIndex = ((_b2 = dataset.yAxisID) == null ? void 0 : _b2.length) > 1 ? dataset.yAxisID[1] - 1 : 0;
25073
25104
  const xAxis = options.axes.x[xIndex];
25074
25105
  const yAxis = options.axes.y[yIndex];
25075
- if (options.axes.x[0].position === Position.Top) {
25106
+ if (((_e2 = (_d2 = (_c2 = options == null ? void 0 : options.axes) == null ? void 0 : _c2.x) == null ? void 0 : _d2[0]) == null ? void 0 : _e2.position) === Position.Top) {
25076
25107
  return {
25077
25108
  titleAxisLabel: (yAxis == null ? void 0 : yAxis.label) || "",
25078
25109
  valueAxisLabel: (xAxis == null ? void 0 : xAxis.label) || "",
@@ -25165,6 +25196,7 @@ const useChartOptions = ({
25165
25196
  dispatch,
25166
25197
  generatedDatasets
25167
25198
  }) => {
25199
+ var _a2, _b2;
25168
25200
  const {
25169
25201
  interactions: { onAnimationComplete },
25170
25202
  annotations: {
@@ -25177,7 +25209,7 @@ const useChartOptions = ({
25177
25209
  yOffset,
25178
25210
  maxWidth,
25179
25211
  lineHeight
25180
- }
25212
+ } = {}
25181
25213
  },
25182
25214
  chartStyling: { layoutPadding }
25183
25215
  } = options;
@@ -25206,11 +25238,11 @@ const useChartOptions = ({
25206
25238
  [showAnnotationLineIndex, legendClick]
25207
25239
  );
25208
25240
  const legend2 = useMemo(
25209
- () => getLegend(options, legendClick, state),
25241
+ () => getLegend(options, legendClick),
25210
25242
  [legendEnabled]
25211
25243
  );
25212
25244
  const scales = useMemo(
25213
- () => autoScale(options, state, generatedDatasets),
25245
+ () => autoScale(options, state, generatedDatasets, chartRef),
25214
25246
  [options, state, generatedDatasets]
25215
25247
  );
25216
25248
  const dragData = useMemo(
@@ -25221,8 +25253,8 @@ const useChartOptions = ({
25221
25253
  () => ({
25222
25254
  enabled: panEnabled,
25223
25255
  mode: PanZoomMode.XY,
25224
- onPanComplete({ chart: chart2 }) {
25225
- updateAxesRangesFromChart(chart2);
25256
+ onPanComplete() {
25257
+ updateAxesRangesFromChart();
25226
25258
  }
25227
25259
  }),
25228
25260
  [panEnabled]
@@ -25237,8 +25269,8 @@ const useChartOptions = ({
25237
25269
  borderColor: BORDER_COLOR,
25238
25270
  borderWidth: 1
25239
25271
  },
25240
- onZoomComplete({ chart: chart2 }) {
25241
- updateAxesRangesFromChart(chart2);
25272
+ onZoomComplete() {
25273
+ updateAxesRangesFromChart();
25242
25274
  }
25243
25275
  }),
25244
25276
  [zoomEnabled]
@@ -25250,8 +25282,8 @@ const useChartOptions = ({
25250
25282
  tooltip,
25251
25283
  legend: { ...legend2, display: false },
25252
25284
  // hide default legend for line chart only
25253
- [CUSTOM_LEGEND_PLUGIN_NAME]: options.legend.customLegend.customLegendPlugin && {
25254
- containerID: options.legend.customLegend.customLegendContainerID
25285
+ [CUSTOM_LEGEND_PLUGIN_NAME]: ((_a2 = options.legend.customLegend) == null ? void 0 : _a2.customLegendPlugin) && {
25286
+ containerID: (_b2 = options.legend.customLegend) == null ? void 0 : _b2.customLegendContainerID
25255
25287
  },
25256
25288
  chartAreaBorder: {
25257
25289
  borderColor: BORDER_COLOR
@@ -25275,7 +25307,7 @@ const useChartOptions = ({
25275
25307
  },
25276
25308
  onHover: onHover(hoveredPoint, setHoveredPoint),
25277
25309
  maintainAspectRatio: options.chartStyling.maintainAspectRatio,
25278
- aspectRatio: options.chartStyling.squareAspectRatio ? 1 : null,
25310
+ aspectRatio: options.chartStyling.squareAspectRatio ? 1 : 0,
25279
25311
  animation: options.chartStyling.performanceMode ? false : {
25280
25312
  duration: ANIMATION_DURATION.FAST,
25281
25313
  onComplete: onAnimationComplete
@@ -25297,10 +25329,7 @@ const useChartOptions = ({
25297
25329
  [state, options]
25298
25330
  );
25299
25331
  };
25300
- const useChartPlugins = ({
25301
- options,
25302
- resetZoom: resetZoom2
25303
- }) => {
25332
+ const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
25304
25333
  const { graph, legend: legend2 } = options;
25305
25334
  const debouncedResetZoom = useCallback(
25306
25335
  debounce$3(() => {
@@ -25310,7 +25339,7 @@ const useChartPlugins = ({
25310
25339
  [resetZoom2]
25311
25340
  );
25312
25341
  const handleDoubleClick = useCallback(
25313
- (chart2, args) => {
25342
+ (_chart, args) => {
25314
25343
  const { event } = args;
25315
25344
  if (event.type === DOUBLE_CLICK) {
25316
25345
  debouncedResetZoom();
@@ -25343,15 +25372,19 @@ const getAxesRangesFromChart = (chartRef, axes) => {
25343
25372
  });
25344
25373
  };
25345
25374
  const useToggleCustomLegendVisibility = (memoState, memoOptions) => {
25375
+ var _a2, _b2;
25346
25376
  useEffect(() => {
25347
- if (memoOptions.legend.customLegend.customLegendPlugin) {
25377
+ var _a3, _b3;
25378
+ if ((_b3 = (_a3 = memoOptions == null ? void 0 : memoOptions.legend) == null ? void 0 : _a3.customLegend) == null ? void 0 : _b3.customLegendPlugin) {
25348
25379
  const parent = document.getElementById(
25349
25380
  memoOptions.legend.customLegend.customLegendContainerID
25350
25381
  );
25351
- parent.style.visibility = memoState.legendEnabled ? "visible" : "hidden";
25382
+ if (parent !== null) {
25383
+ parent.style.visibility = memoState.legendEnabled ? "visible" : "hidden";
25384
+ }
25352
25385
  }
25353
25386
  }, [
25354
- memoOptions.legend.customLegend.customLegendPlugin,
25387
+ (_b2 = (_a2 = memoOptions == null ? void 0 : memoOptions.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendPlugin,
25355
25388
  memoState.legendEnabled
25356
25389
  ]);
25357
25390
  };
@@ -25368,7 +25401,7 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
25368
25401
  ]);
25369
25402
  };
25370
25403
  const useUpdateAxesRanges = (range, dispatch) => {
25371
- const prevRange = useRef();
25404
+ const prevRange = useRef(null);
25372
25405
  const updateAxesRanges = useCallback(() => {
25373
25406
  if (range && range.x && range.y && !isEqual(range, prevRange.current)) {
25374
25407
  const axes = Object.entries(range).map(([key, { min, max }]) => ({
@@ -25552,9 +25585,9 @@ const chartAreaTextPlugin = {
25552
25585
  maxWidth: initialMaxWidth,
25553
25586
  position
25554
25587
  } = options;
25555
- const { ctx, chartArea } = chart2;
25556
25588
  if (!showLabel || !text)
25557
25589
  return;
25590
+ const { ctx, chartArea } = chart2;
25558
25591
  const maxWidth = calculateMaxWidth(initialMaxWidth, chartArea.width);
25559
25592
  const [x2, y2] = getPositionCoordinates(position, chart2, xOffset, yOffset);
25560
25593
  renderWrappedText(ctx, {
@@ -25632,7 +25665,7 @@ const LineChart = (props) => {
25632
25665
  const { translations, languageKey } = getConfig();
25633
25666
  const chart2 = getDefaultProps$2(props);
25634
25667
  const {
25635
- data: { datasets },
25668
+ data: { datasets } = { datasets: [] },
25636
25669
  options,
25637
25670
  testId,
25638
25671
  persistenceId,
@@ -25690,7 +25723,7 @@ const LineChart = (props) => {
25690
25723
  /* @__PURE__ */ jsx(
25691
25724
  Controls,
25692
25725
  {
25693
- props,
25726
+ ...props,
25694
25727
  chartRef,
25695
25728
  state,
25696
25729
  options,
@@ -25715,7 +25748,6 @@ const LineChart = (props) => {
25715
25748
  showCustomLegend && /* @__PURE__ */ jsx(
25716
25749
  Legend2,
25717
25750
  {
25718
- props,
25719
25751
  chartRef,
25720
25752
  state,
25721
25753
  options,
@@ -25762,84 +25794,59 @@ const styles$1 = {
25762
25794
  help: help$1,
25763
25795
  autoWeight: autoWeight$1
25764
25796
  };
25765
- const colors$1 = [
25766
- "#3366cc",
25767
- "#dc3912",
25768
- "#ff9900",
25769
- "#109618",
25770
- "#990099",
25771
- "#0099c6",
25772
- "#dd4477",
25773
- "#66aa00",
25774
- "#b82e2e",
25775
- "#316395",
25776
- "#994499",
25777
- "#22aa99",
25778
- "#aaaa11",
25779
- "#6633cc",
25780
- "#e67300",
25781
- "#8b0707",
25782
- "#651067",
25783
- "#329262",
25784
- "#5574a6",
25785
- "#3b3eac"
25786
- ];
25787
- const generateRandomColor = () => {
25788
- const color2 = `#${Math.floor(Math.random() * 16777215).toString(16)}`;
25789
- if (colors$1.includes(color2)) {
25790
- return generateRandomColor();
25791
- } else {
25792
- colors$1.push(color2);
25793
- return color2;
25794
- }
25797
+ const defaultChartStyling$1 = (styling) => ({
25798
+ width: styling == null ? void 0 : styling.width,
25799
+ height: styling == null ? void 0 : styling.height,
25800
+ maintainAspectRatio: (styling == null ? void 0 : styling.maintainAspectRatio) || false,
25801
+ staticChartHeight: (styling == null ? void 0 : styling.staticChartHeight) || false,
25802
+ performanceMode: (styling == null ? void 0 : styling.performanceMode) ?? true
25803
+ });
25804
+ const defaultTooltip$1 = (tooltip) => ({
25805
+ tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
25806
+ showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
25807
+ });
25808
+ const defaultGraph$1 = (graph) => ({
25809
+ showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
25810
+ stacked: (graph == null ? void 0 : graph.stacked) || false,
25811
+ cutout: (graph == null ? void 0 : graph.cutout) || 0
25812
+ });
25813
+ const defaultLegend$1 = (legend2) => ({
25814
+ display: (legend2 == null ? void 0 : legend2.display) ?? true,
25815
+ useDataset: (legend2 == null ? void 0 : legend2.useDataset) || false,
25816
+ position: (legend2 == null ? void 0 : legend2.position) || Position.Bottom,
25817
+ align: (legend2 == null ? void 0 : legend2.align) || AlignOptions.Center
25818
+ });
25819
+ const defaultChartOptions$1 = (options) => ({
25820
+ enableZoom: (options == null ? void 0 : options.enableZoom) || false,
25821
+ enablePan: (options == null ? void 0 : options.enablePan) || false
25822
+ });
25823
+ const defaultInteractions$1 = (interactions) => ({
25824
+ onLegendClick: interactions == null ? void 0 : interactions.onLegendClick,
25825
+ onHover: interactions == null ? void 0 : interactions.onHover,
25826
+ onUnhover: interactions == null ? void 0 : interactions.onUnhover
25827
+ });
25828
+ const defaultChartData = (data) => {
25829
+ return {
25830
+ labels: (data == null ? void 0 : data.labels) || [],
25831
+ datasets: (data == null ? void 0 : data.datasets) || []
25832
+ };
25795
25833
  };
25796
25834
  const getDefaultProps$1 = (props) => {
25797
- props.chart.options = props.chart.options || {};
25798
- props.chart.options.chartStyling = props.chart.options.chartStyling || {};
25799
- props.chart.options.tooltip = props.chart.options.tooltip || {};
25800
- props.chart.options.graph = props.chart.options.graph || {};
25801
- props.chart.options.legend = props.chart.options.legend || {};
25802
- props.chart.options.chartOptions = props.chart.options.chartOptions || {};
25803
- props.chart.options.interactions = props.chart.options.interactions || {};
25804
- const chart2 = {
25805
- testId: props.chart.testId ?? null,
25806
- data: props.chart.data,
25835
+ const chart2 = (props == null ? void 0 : props.chart) || {};
25836
+ const options = (chart2 == null ? void 0 : chart2.options) || {};
25837
+ return {
25838
+ testId: (chart2 == null ? void 0 : chart2.testId) ?? null,
25839
+ data: defaultChartData(chart2 == null ? void 0 : chart2.data),
25807
25840
  options: {
25808
- title: props.chart.options.title || "",
25809
- chartStyling: {
25810
- width: props.chart.options.chartStyling.width,
25811
- height: props.chart.options.chartStyling.height,
25812
- maintainAspectRatio: props.chart.options.chartStyling.maintainAspectRatio || false,
25813
- staticChartHeight: props.chart.options.chartStyling.staticChartHeight || false,
25814
- performanceMode: props.chart.options.chartStyling.performanceMode != null ? props.chart.options.chartStyling.performanceMode : true
25815
- },
25816
- tooltip: {
25817
- tooltips: props.chart.options.tooltip.tooltips != null ? props.chart.options.tooltip.tooltips : true,
25818
- showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false
25819
- },
25820
- graph: {
25821
- showDataLabels: props.chart.options.graph.showDataLabels || false,
25822
- stacked: props.chart.options.graph.stacked || false,
25823
- cutout: props.chart.options.graph.cutout || 0
25824
- },
25825
- legend: {
25826
- display: props.chart.options.legend.display != null ? props.chart.options.legend.display : true,
25827
- useDataset: props.chart.options.legend.useDataset || false,
25828
- position: props.chart.options.legend.position || "bottom",
25829
- align: props.chart.options.legend.align || "center"
25830
- },
25831
- chartOptions: {
25832
- enableZoom: props.chart.options.chartOptions.enableZoom || false,
25833
- enablePan: props.chart.options.chartOptions.enablePan || false
25834
- },
25835
- interactions: {
25836
- onLegendClick: props.chart.options.interactions.onLegendClick,
25837
- onPieHover: props.chart.options.interactions.onPieHover,
25838
- onPieUnhover: props.chart.options.interactions.onPieUnhover
25839
- }
25841
+ title: (options == null ? void 0 : options.title) || "",
25842
+ chartStyling: defaultChartStyling$1(options == null ? void 0 : options.chartStyling),
25843
+ tooltip: defaultTooltip$1(options == null ? void 0 : options.tooltip),
25844
+ graph: defaultGraph$1(options == null ? void 0 : options.graph),
25845
+ legend: defaultLegend$1(options == null ? void 0 : options.legend),
25846
+ chartOptions: defaultChartOptions$1(options == null ? void 0 : options.chartOptions),
25847
+ interactions: defaultInteractions$1(options == null ? void 0 : options.interactions)
25840
25848
  }
25841
25849
  };
25842
- return chart2;
25843
25850
  };
25844
25851
  Chart$2.register(
25845
25852
  LinearScale$1,
@@ -25860,25 +25867,25 @@ const PieChart = (props) => {
25860
25867
  const [pointHover, setPointHover] = useState(false);
25861
25868
  const { data, options, testId } = chart2;
25862
25869
  const generateDatasets = (datasets) => {
25863
- const copyDataset = JSON.parse(JSON.stringify(datasets));
25870
+ const copyDataset = [...datasets];
25864
25871
  if (options.graph.stacked) {
25865
25872
  const generatedDataset = {
25866
25873
  label: copyDataset[0].label,
25867
25874
  backgroundColor: [],
25868
25875
  borderColor: [],
25869
- borderWidth: parseFloat(copyDataset[0].borderWidth) || "1",
25876
+ borderWidth: Number(copyDataset[0].borderWidth) || 1,
25870
25877
  data: []
25871
25878
  };
25872
- data.labels.map((label, labelIndex) => {
25879
+ data.labels.map((_label, labelIndex) => {
25873
25880
  copyDataset.map((arc, arcIndex) => {
25874
25881
  generatedDataset.data.push(arc.data[labelIndex]);
25875
25882
  const { backgroundColor } = arc;
25876
25883
  const { borderColor } = arc;
25877
25884
  generatedDataset.backgroundColor.push(
25878
- (Array.isArray(backgroundColor) ? backgroundColor[labelIndex % borderColor.length] : backgroundColor) || colors$1[labelIndex] + `${99 - 10 * arcIndex}`
25885
+ (Array.isArray(backgroundColor) ? backgroundColor[labelIndex % ((borderColor == null ? void 0 : borderColor.length) || 1)] : backgroundColor) || COLORS[labelIndex] + `${99 - 10 * arcIndex}`
25879
25886
  );
25880
25887
  generatedDataset.borderColor.push(
25881
- (Array.isArray(borderColor) ? borderColor[labelIndex % borderColor.length] : borderColor) || colors$1[labelIndex]
25888
+ (Array.isArray(borderColor) ? borderColor[labelIndex % borderColor.length] : borderColor) || COLORS[labelIndex]
25882
25889
  );
25883
25890
  });
25884
25891
  });
@@ -25887,9 +25894,7 @@ const PieChart = (props) => {
25887
25894
  const generatedDatasets2 = copyDataset.map(
25888
25895
  (pieDataset, index2) => {
25889
25896
  const borderWidth = parseFloat(pieDataset.borderWidth) || "1";
25890
- const color2 = pieDataset.data.map(
25891
- (_pie, i2) => colors$1[i2] || generateRandomColor()
25892
- );
25897
+ const color2 = pieDataset.data.map((_pie, i2) => COLORS[i2]) || generateRandomColor(COLORS);
25893
25898
  const borderColor = pieDataset.borderColor || color2;
25894
25899
  const backgroundColor = pieDataset.backgroundColor || color2.map((col) => col + `${99 - 11 * index2}`);
25895
25900
  return {
@@ -25909,10 +25914,10 @@ const PieChart = (props) => {
25909
25914
  text: chart2.options.title
25910
25915
  } : {};
25911
25916
  };
25912
- const legendClick = (e2, legendItem2, legend2) => {
25917
+ const legendClick = (_e2, legendItem2, legend2) => {
25913
25918
  const chartInstance = legend2.chart;
25914
25919
  const { datasets } = chartInstance.data;
25915
- const { index: index2 } = legendItem2;
25920
+ const { index: index2 = 0, text = "", hidden = false } = legendItem2 || {};
25916
25921
  if (options.graph.stacked) {
25917
25922
  if (options.legend.useDataset) {
25918
25923
  for (let i2 = 0; i2 < chartInstance.config._config.data.datasets[0].data.length; i2++) {
@@ -25924,7 +25929,7 @@ const PieChart = (props) => {
25924
25929
  }
25925
25930
  } else {
25926
25931
  for (let i2 = 0; i2 < chartInstance.config._config.data.datasets[0].data.length; i2++) {
25927
- if (parseInt(i2 / data.datasets.length) === index2) {
25932
+ if (parseInt(String(i2 / data.datasets.length)) === index2) {
25928
25933
  const meta = chartInstance.getDatasetMeta(0);
25929
25934
  const arc = meta.data[i2];
25930
25935
  arc.hidden = !arc.hidden;
@@ -25950,25 +25955,25 @@ const PieChart = (props) => {
25950
25955
  }
25951
25956
  }
25952
25957
  if (options.interactions.onLegendClick)
25953
- options.interactions.onLegendClick(legendItem2 == null ? void 0 : legendItem2.text, legendItem2.hidden);
25958
+ options.interactions.onLegendClick(text, hidden);
25954
25959
  chartInstance.update();
25955
25960
  };
25956
- const onClick = (evt, elements, chartInstance) => {
25961
+ const onClick = (_evt, _elements, chartInstance) => {
25957
25962
  chartInstance.resetZoom();
25958
25963
  };
25959
25964
  const onHover = (evt, hoveredItems) => {
25960
25965
  if (pointHover && !(hoveredItems == null ? void 0 : hoveredItems.length)) {
25961
25966
  setPointHover(false);
25962
- if (options.interactions.onPieUnhover) {
25963
- options.interactions.onPieUnhover(evt);
25967
+ if (options.interactions.onUnhover) {
25968
+ options.interactions.onUnhover(evt);
25964
25969
  }
25965
25970
  }
25966
25971
  if (!pointHover && (hoveredItems == null ? void 0 : hoveredItems.length)) {
25967
25972
  setPointHover(true);
25968
- if (options.interactions.onPieHover) {
25973
+ if (options.interactions.onHover) {
25969
25974
  const { index: index2, datasetIndex } = hoveredItems[0];
25970
25975
  const generatedDataset = generatedDatasets;
25971
- options.interactions.onPieHover(
25976
+ options.interactions.onHover(
25972
25977
  evt,
25973
25978
  datasetIndex,
25974
25979
  index2,
@@ -25982,7 +25987,7 @@ const PieChart = (props) => {
25982
25987
  display: "auto",
25983
25988
  align: "center",
25984
25989
  anchor: "center",
25985
- formatter: (value, context) => {
25990
+ formatter: (_value, context) => {
25986
25991
  if (context.chart.getDatasetMeta(
25987
25992
  options.graph.stacked ? 0 : context.datasetIndex
25988
25993
  ).data[context.dataIndex].hidden)
@@ -26001,85 +26006,74 @@ const PieChart = (props) => {
26001
26006
  };
26002
26007
  };
26003
26008
  const getLegend2 = () => {
26009
+ const generateLabels = (chartInstance) => {
26010
+ const meta = chartInstance.getDatasetMeta(0);
26011
+ const getStyles = (dataset, i2) => {
26012
+ const dataPoint = dataset.data[i2 % dataset.data.length];
26013
+ const { label } = dataPoint;
26014
+ const arc = meta.data[i2];
26015
+ const text = arc.hidden ? "-".repeat(label.length) : label;
26016
+ const backgroundColor = dataPoint == null ? void 0 : dataPoint.backgroundColor;
26017
+ const borderColor = dataPoint == null ? void 0 : dataPoint.borderColor;
26018
+ return {
26019
+ text,
26020
+ fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[0] : backgroundColor) || COLORS[0] + `${99 - 20 * i2}`,
26021
+ strokeStyle: (Array.isArray(borderColor) ? borderColor[0] : borderColor) || COLORS[0],
26022
+ index: i2
26023
+ };
26024
+ };
26025
+ let mappedData;
26026
+ if (options.graph.stacked) {
26027
+ if (options.legend.useDataset) {
26028
+ mappedData = data.datasets.map(getStyles);
26029
+ } else {
26030
+ mappedData = data.labels.map((label, i2) => {
26031
+ var _a2, _b2;
26032
+ const arc = meta.data[parseInt(String(i2 * data.datasets.length))];
26033
+ const text = arc.hidden ? "-".repeat(label.length) : label;
26034
+ const backgroundColor = (_a2 = data.datasets[0]) == null ? void 0 : _a2.backgroundColor;
26035
+ const borderColor = (_b2 = data.datasets[0]) == null ? void 0 : _b2.borderColor;
26036
+ return {
26037
+ text,
26038
+ fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || COLORS[i2] + "99",
26039
+ strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % ((backgroundColor == null ? void 0 : backgroundColor.length) ?? 0)] : borderColor) || COLORS[i2],
26040
+ index: i2
26041
+ };
26042
+ });
26043
+ }
26044
+ } else if (options.legend.useDataset) {
26045
+ mappedData = data.datasets.map(getStyles);
26046
+ } else {
26047
+ mappedData = data.labels.map((label, i2) => {
26048
+ var _a2, _b2;
26049
+ const arc = meta.data[i2];
26050
+ const text = arc.hidden ? "-".repeat(label.length) : label;
26051
+ const backgroundColor = (_a2 = data.datasets[0]) == null ? void 0 : _a2.backgroundColor;
26052
+ const borderColor = (_b2 = data.datasets[0]) == null ? void 0 : _b2.borderColor;
26053
+ return {
26054
+ text,
26055
+ fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || COLORS[i2] + "99",
26056
+ strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % ((backgroundColor == null ? void 0 : backgroundColor.length) ?? 0)] : borderColor) || COLORS[i2],
26057
+ index: i2
26058
+ };
26059
+ });
26060
+ }
26061
+ return mappedData;
26062
+ };
26004
26063
  return {
26005
26064
  position: options.legend.position,
26006
26065
  display: options.legend.display,
26007
26066
  align: options.legend.align,
26008
26067
  labels: {
26009
- generateLabels(chartInstance) {
26010
- if (options.graph.stacked) {
26011
- const meta = chartInstance.getDatasetMeta(0);
26012
- if (options.legend.useDataset) {
26013
- return data.datasets.map((data2, i2) => {
26014
- var _a2, _b2;
26015
- const { label } = data2.datasets[i2 % data2.datasets.length];
26016
- const arc = meta.data[i2];
26017
- const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
26018
- const backgroundColor = (_a2 = data2.datasets[i2]) == null ? void 0 : _a2.backgroundColor;
26019
- const borderColor = (_b2 = data2.datasets[i2]) == null ? void 0 : _b2.borderColor;
26020
- return {
26021
- text,
26022
- fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[0] : backgroundColor) || colors$1[0] + `${99 - 20 * i2}`,
26023
- strokeStyle: (Array.isArray(borderColor) ? borderColor[0] : borderColor) || colors$1[0],
26024
- index: i2
26025
- };
26026
- });
26027
- } else {
26028
- return data.labels.map((data2, i2) => {
26029
- var _a2, _b2;
26030
- const label = data2.labels[i2];
26031
- const arc = meta.data[parseInt(i2 * data2.datasets.length)];
26032
- const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
26033
- const backgroundColor = (_a2 = data2.datasets[0]) == null ? void 0 : _a2.backgroundColor;
26034
- const borderColor = (_b2 = data2.datasets[0]) == null ? void 0 : _b2.borderColor;
26035
- return {
26036
- text,
26037
- fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || colors$1[i2] + "99",
26038
- strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % backgroundColor.length] : borderColor) || colors$1[i2],
26039
- index: i2
26040
- };
26041
- });
26042
- }
26043
- }
26044
- if (options.legend.useDataset) {
26045
- return data.datasets.map((dataset, i2) => {
26046
- var _a2, _b2;
26047
- const meta = chartInstance.getDatasetMeta(i2);
26048
- const text = meta.hidden ? dataset.label.split("").reduce((acc, curr) => acc + "-", "") : dataset.label;
26049
- const backgroundColor = (_a2 = data.datasets[i2]) == null ? void 0 : _a2.backgroundColor;
26050
- const borderColor = (_b2 = data.datasets[i2]) == null ? void 0 : _b2.borderColor;
26051
- return {
26052
- text,
26053
- fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[0] : backgroundColor) || colors$1[0] + `${99 - 20 * i2}`,
26054
- strokeStyle: (Array.isArray(borderColor) ? borderColor[0] : borderColor) || colors$1[0],
26055
- index: i2
26056
- };
26057
- });
26058
- } else {
26059
- return data.labels.map((label, i2) => {
26060
- var _a2, _b2;
26061
- const meta = chartInstance.getDatasetMeta(0);
26062
- const arc = meta.data[i2];
26063
- const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
26064
- const backgroundColor = (_a2 = data.datasets[0]) == null ? void 0 : _a2.backgroundColor;
26065
- const borderColor = (_b2 = data.datasets[0]) == null ? void 0 : _b2.borderColor;
26066
- return {
26067
- text,
26068
- fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || colors$1[i2] + "99",
26069
- strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % backgroundColor.length] : borderColor) || colors$1[i2],
26070
- index: i2
26071
- };
26072
- });
26073
- }
26074
- },
26068
+ generateLabels,
26075
26069
  boxHeight: 6,
26076
26070
  boxWidth: 6,
26077
26071
  usePointStyle: true,
26078
- filter: (item, data2) => {
26072
+ filter: (item) => {
26079
26073
  var _a2;
26080
26074
  if (!options.legend.useDataset)
26081
26075
  return true;
26082
- return !((_a2 = data2.datasets[item.index]) == null ? void 0 : _a2.hideLegend);
26076
+ return !((_a2 = data.datasets[item.index]) == null ? void 0 : _a2.hideLegend);
26083
26077
  }
26084
26078
  },
26085
26079
  onClick: legendClick
@@ -26090,7 +26084,7 @@ const PieChart = (props) => {
26090
26084
  callbacks: {
26091
26085
  title: (tooltipItem) => {
26092
26086
  const { dataIndex } = tooltipItem[0];
26093
- const index2 = options.graph.stacked ? parseInt(dataIndex / data.labels.length) : dataIndex;
26087
+ const index2 = options.graph.stacked ? parseInt(String(dataIndex / data.labels.length)) : dataIndex;
26094
26088
  const label = data.labels[index2];
26095
26089
  return `${label}`;
26096
26090
  },
@@ -26102,7 +26096,7 @@ const PieChart = (props) => {
26102
26096
  const value = tooltipItem.dataset.data[dataIndex];
26103
26097
  const labelValue = typeof value === "object" ? `${value.value || ""} ${options.tooltip.showLabelsInTooltips && value.label ? "(" + value.label + ")" : ""}` : value;
26104
26098
  const unit = (data == null ? void 0 : data.yUnit) ? `[${data == null ? void 0 : data.yUnit}]` : "";
26105
- const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, { n: 3 }) : round$2(labelValue, 3);
26099
+ const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, 3) : round$2(labelValue, 3);
26106
26100
  return `${dataLabel} ${formattedValue} ${unit}`;
26107
26101
  }
26108
26102
  },
@@ -26144,32 +26138,14 @@ const PieChart = (props) => {
26144
26138
  },
26145
26139
  hover: {
26146
26140
  mode: "nearest",
26147
- intersect: "true"
26141
+ intersect: true
26148
26142
  },
26149
26143
  onHover,
26150
- elements: {
26151
- pie: {
26152
- pointStyle: "circle"
26153
- }
26154
- },
26155
26144
  plugins: {
26156
26145
  annotation: false,
26157
26146
  // Disable globally-registered annotation plugin
26158
26147
  title: getTitle2(),
26159
26148
  datalabels: getDatalabels(),
26160
- // zoom: {
26161
- // pan: {
26162
- // enabled: ,
26163
- // mode: ,
26164
- // },
26165
- // zoom: {
26166
- // drag: {
26167
- // enabled:,
26168
- // },
26169
- // mode: ,
26170
- // speed: ,
26171
- // },
26172
- // },
26173
26149
  tooltip: getToolTips(),
26174
26150
  legend: getLegend2()
26175
26151
  }
@@ -38555,93 +38531,102 @@ const styles = {
38555
38531
  help,
38556
38532
  autoWeight
38557
38533
  };
38534
+ const defaultAxes = (axes) => ({
38535
+ x: (axes == null ? void 0 : axes.x) || [{}],
38536
+ y: (axes == null ? void 0 : axes.y) || [{}]
38537
+ });
38538
+ const defaultAdditionalAxesOptions = (options) => ({
38539
+ chartScaleType: (options == null ? void 0 : options.chartScaleType) || "linear",
38540
+ reverse: (options == null ? void 0 : options.reverse) || false,
38541
+ stacked: (options == null ? void 0 : options.stacked) || false,
38542
+ beginAtZero: (options == null ? void 0 : options.beginAtZero) ?? true,
38543
+ stepSize: options == null ? void 0 : options.stepSize,
38544
+ suggestedMin: options == null ? void 0 : options.suggestedMin,
38545
+ suggestedMax: options == null ? void 0 : options.suggestedMax,
38546
+ min: options == null ? void 0 : options.min,
38547
+ max: options == null ? void 0 : options.max
38548
+ });
38549
+ const defaultChartStyling = (styling) => ({
38550
+ width: styling == null ? void 0 : styling.width,
38551
+ height: styling == null ? void 0 : styling.height,
38552
+ maintainAspectRatio: (styling == null ? void 0 : styling.maintainAspectRatio) || false,
38553
+ staticChartHeight: (styling == null ? void 0 : styling.staticChartHeight) || false,
38554
+ performanceMode: (styling == null ? void 0 : styling.performanceMode) ?? true
38555
+ });
38556
+ const defaultTooltip = (tooltip) => ({
38557
+ tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
38558
+ showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
38559
+ });
38560
+ const defaultGraph = (graph) => ({
38561
+ showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
38562
+ showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) || false
38563
+ });
38564
+ const defaultAnnotations = (annotations) => ({
38565
+ showAnnotations: (annotations == null ? void 0 : annotations.showAnnotations) ?? true,
38566
+ controlAnnotation: (annotations == null ? void 0 : annotations.controlAnnotation) || false,
38567
+ annotationsData: (annotations == null ? void 0 : annotations.annotationsData) || []
38568
+ });
38569
+ const defaultLegend = (legend2) => ({
38570
+ display: (legend2 == null ? void 0 : legend2.display) ?? true,
38571
+ position: (legend2 == null ? void 0 : legend2.position) || Position.Bottom,
38572
+ align: (legend2 == null ? void 0 : legend2.align) || AlignOptions.Center,
38573
+ customLegend: (legend2 == null ? void 0 : legend2.customLegend) || {
38574
+ customLegendPlugin: null,
38575
+ customLegendContainerID: ""
38576
+ }
38577
+ });
38578
+ const defaultChartOptions = (options) => ({
38579
+ enableZoom: (options == null ? void 0 : options.enableZoom) || false,
38580
+ enablePan: (options == null ? void 0 : options.enablePan) || false
38581
+ });
38582
+ const defaultInteractions = (interactions) => ({
38583
+ onLegendClick: interactions == null ? void 0 : interactions.onLegendClick,
38584
+ onHover: interactions == null ? void 0 : interactions.onHover,
38585
+ onUnhover: interactions == null ? void 0 : interactions.onUnhover
38586
+ });
38587
+ const defaultDragData = (dragData) => ({
38588
+ enableDragData: (dragData == null ? void 0 : dragData.enableDragData) || false,
38589
+ showTooltip: (dragData == null ? void 0 : dragData.showTooltip) ?? true,
38590
+ roundPoints: (dragData == null ? void 0 : dragData.roundPoints) ?? true,
38591
+ dragX: (dragData == null ? void 0 : dragData.dragX) ?? true,
38592
+ dragY: (dragData == null ? void 0 : dragData.dragY) ?? true,
38593
+ onDragStart: dragData == null ? void 0 : dragData.onDragStart,
38594
+ onDrag: dragData == null ? void 0 : dragData.onDrag,
38595
+ onDragEnd: dragData == null ? void 0 : dragData.onDragEnd
38596
+ });
38558
38597
  const getDefaultProps = (props) => {
38559
- props.chart.options = props.chart.options || {};
38560
- props.chart.options.axes = props.chart.options.axes || {};
38561
- props.chart.options.additionalAxesOptions = props.chart.options.additionalAxesOptions || {};
38562
- props.chart.options.chartStyling = props.chart.options.chartStyling || {};
38563
- props.chart.options.tooltip = props.chart.options.tooltip || {};
38564
- props.chart.options.graph = props.chart.options.graph || {};
38565
- props.chart.options.annotations = props.chart.options.annotations || {};
38566
- props.chart.options.legend = props.chart.options.legend || {};
38567
- props.chart.options.legend.customLegend = props.chart.options.legend.customLegend || { customLegendPlugin: null, customLegendContainerID: "" };
38568
- props.chart.options.chartOptions = props.chart.options.chartOptions || {};
38569
- props.chart.options.interactions = props.chart.options.interactions || {};
38570
- props.chart.options.dragData = props.chart.options.dragData || {};
38571
- const chart2 = {
38572
- testId: props.chart.testId ?? null,
38573
- data: props.chart.data,
38598
+ const chart2 = (props == null ? void 0 : props.chart) || {};
38599
+ const options = (chart2 == null ? void 0 : chart2.options) || {};
38600
+ return {
38601
+ testId: (chart2 == null ? void 0 : chart2.testId) ?? "",
38602
+ data: chart2 == null ? void 0 : chart2.data,
38574
38603
  options: {
38575
- title: props.chart.options.title || "",
38576
- direction: props.chart.options.direction || "vertical",
38577
- axes: {
38578
- x: props.chart.options.axes.x || [{}],
38579
- y: props.chart.options.axes.y || [{}]
38580
- },
38581
- additionalAxesOptions: {
38582
- chartScaleType: props.chart.options.additionalAxesOptions.chartScaleType || "linear",
38583
- reverse: props.chart.options.additionalAxesOptions.reverse || false,
38584
- stacked: props.chart.options.additionalAxesOptions.stacked || false,
38585
- beginAtZero: props.chart.options.additionalAxesOptions.beginAtZero != null ? props.chart.options.additionalAxesOptions.beginAtZero : true,
38586
- stepSize: props.chart.options.additionalAxesOptions.stepSize,
38587
- suggestedMin: props.chart.options.additionalAxesOptions.suggestedMin,
38588
- suggestedMax: props.chart.options.additionalAxesOptions.suggestedMax,
38589
- min: props.chart.options.additionalAxesOptions.min,
38590
- max: props.chart.options.additionalAxesOptions.max
38591
- },
38592
- chartStyling: {
38593
- width: props.chart.options.chartStyling.width,
38594
- height: props.chart.options.chartStyling.height,
38595
- maintainAspectRatio: props.chart.options.chartStyling.maintainAspectRatio || false,
38596
- staticChartHeight: props.chart.options.chartStyling.staticChartHeight || false,
38597
- performanceMode: props.chart.options.chartStyling.performanceMode != null ? props.chart.options.chartStyling.performanceMode : true
38598
- },
38599
- tooltip: {
38600
- tooltips: props.chart.options.tooltip.tooltips != null ? props.chart.options.tooltip.tooltips : true,
38601
- showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false
38602
- },
38603
- graph: {
38604
- showDataLabels: props.chart.options.graph.showDataLabels || false,
38605
- showMinorGridlines: props.chart.options.graph.showMinorGridlines || false
38606
- },
38607
- annotations: {
38608
- showAnnotations: props.chart.options.annotations.showAnnotations != null ? props.chart.options.annotations.showAnnotations : true,
38609
- controlAnnotation: props.chart.options.annotations.controlAnnotation || false,
38610
- annotationsData: props.chart.options.annotations.annotationsData || []
38611
- },
38612
- legend: {
38613
- display: props.chart.options.legend.display != null ? props.chart.options.legend.display : true,
38614
- position: props.chart.options.legend.position || "bottom",
38615
- align: props.chart.options.legend.align || "center",
38616
- customLegend: props.chart.options.legend.customLegend
38617
- },
38618
- chartOptions: {
38619
- enableZoom: props.chart.options.chartOptions.enableZoom || false,
38620
- enablePan: props.chart.options.chartOptions.enablePan || false
38621
- },
38622
- interactions: {
38623
- onLegendClick: props.chart.options.interactions.onLegendClick,
38624
- onBarHover: props.chart.options.interactions.onBarHover,
38625
- onBarUnhover: props.chart.options.interactions.onBarUnhover
38626
- },
38627
- dragData: {
38628
- enableDragData: props.chart.options.dragData.enableDragData || false,
38629
- showTooltip: props.chart.options.dragData.showTooltip || true,
38630
- roundPoints: props.chart.options.dragData.roundPoints || true,
38631
- dragX: props.chart.options.dragData.dragX || true,
38632
- dragY: props.chart.options.dragData.dragY || true,
38633
- onDragStart: props.chart.options.dragData.onDragStart,
38634
- onDrag: props.chart.options.dragData.onDrag,
38635
- onDragEnd: props.chart.options.dragData.onDragEnd
38636
- }
38637
- }
38638
- };
38639
- return chart2;
38640
- };
38641
- const getBarChartAxis = (chart2, axisType, currentScales, i2) => {
38642
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
38604
+ title: (options == null ? void 0 : options.title) || "",
38605
+ direction: (options == null ? void 0 : options.direction) || "vertical",
38606
+ axes: defaultAxes(options == null ? void 0 : options.axes),
38607
+ additionalAxesOptions: defaultAdditionalAxesOptions(
38608
+ options == null ? void 0 : options.additionalAxesOptions
38609
+ ),
38610
+ chartStyling: defaultChartStyling(options == null ? void 0 : options.chartStyling),
38611
+ tooltip: defaultTooltip(options == null ? void 0 : options.tooltip),
38612
+ graph: defaultGraph(options == null ? void 0 : options.graph),
38613
+ annotations: defaultAnnotations(options == null ? void 0 : options.annotations),
38614
+ legend: defaultLegend(options == null ? void 0 : options.legend),
38615
+ chartOptions: defaultChartOptions(options == null ? void 0 : options.chartOptions),
38616
+ interactions: defaultInteractions(options == null ? void 0 : options.interactions),
38617
+ dragData: defaultDragData(options == null ? void 0 : options.dragData)
38618
+ }
38619
+ };
38620
+ };
38621
+ const getBarChartAxis = ({
38622
+ chart: chart2,
38623
+ axisType = AxisType.X,
38624
+ currentScale,
38625
+ i: i2
38626
+ }) => {
38627
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
38643
38628
  const isDirectionVertical = isVertical(chart2.options.direction);
38644
- const axisData = currentScales || chart2.options.axes[axisType][0];
38629
+ const axisData = currentScale || chart2.options.axes[axisType][0];
38645
38630
  const isDirectionCompatibleWithAxisType = isDirectionVertical && axisType === AxisType.Y || !isDirectionVertical && axisType === AxisType.X;
38646
38631
  const grid = (axisData == null ? void 0 : axisData.gridLines) || {};
38647
38632
  const getScaleType = () => {
@@ -38662,7 +38647,7 @@ const getBarChartAxis = (chart2, axisType, currentScales, i2) => {
38662
38647
  return isLogarithmic ? LOGARITHMIC_STEPS.includes(tick) ? formatAxisLabelNumbers(tick, ticks2) : "" : formatAxisLabelNumbers(tick, ticks2);
38663
38648
  };
38664
38649
  const stepSize = !isLogarithmic ? {
38665
- stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions.stepSize : null)
38650
+ stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions == null ? void 0 : additionalAxesOptions.stepSize : null)
38666
38651
  } : {};
38667
38652
  const ticks = {
38668
38653
  ...stepSize,
@@ -38678,56 +38663,68 @@ const getBarChartAxis = (chart2, axisType, currentScales, i2) => {
38678
38663
  };
38679
38664
  return {
38680
38665
  type: getScaleType(),
38681
- position: axisData.position,
38682
- beginAtZero: chart2.options.additionalAxesOptions.beginAtZero,
38666
+ position: axisData == null ? void 0 : axisData.position,
38667
+ beginAtZero: (_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.additionalAxesOptions) == null ? void 0 : _b2.beginAtZero,
38683
38668
  reverse: getReverse(),
38684
- suggestedMax: (_b2 = (_a2 = chart2.options) == null ? void 0 : _a2.additionalAxesOptions) == null ? void 0 : _b2.suggestedMax,
38685
- suggestedMin: (_d2 = (_c2 = chart2.options) == null ? void 0 : _c2.additionalAxesOptions) == null ? void 0 : _d2.suggestedMin,
38686
- min: isDirectionCompatibleWithAxisType ? (_f2 = (_e2 = chart2.options) == null ? void 0 : _e2.additionalAxesOptions) == null ? void 0 : _f2.min : void 0,
38687
- max: isDirectionCompatibleWithAxisType ? (_h2 = (_g2 = chart2.options) == null ? void 0 : _g2.additionalAxesOptions) == null ? void 0 : _h2.max : void 0,
38669
+ suggestedMax: (_d2 = (_c2 = chart2.options) == null ? void 0 : _c2.additionalAxesOptions) == null ? void 0 : _d2.suggestedMax,
38670
+ suggestedMin: (_f2 = (_e2 = chart2.options) == null ? void 0 : _e2.additionalAxesOptions) == null ? void 0 : _f2.suggestedMin,
38671
+ min: isDirectionCompatibleWithAxisType ? (_h2 = (_g2 = chart2.options) == null ? void 0 : _g2.additionalAxesOptions) == null ? void 0 : _h2.min : void 0,
38672
+ max: isDirectionCompatibleWithAxisType ? (_j2 = (_i2 = chart2.options) == null ? void 0 : _i2.additionalAxesOptions) == null ? void 0 : _j2.max : void 0,
38688
38673
  title: {
38689
- display: ((_i2 = axisData.label) == null ? void 0 : _i2.length) || ((_j2 = axisData.unit) == null ? void 0 : _j2.length),
38690
- text: axisData.label || axisData.unit,
38674
+ display: ((_k2 = axisData == null ? void 0 : axisData.label) == null ? void 0 : _k2.length) || ((_l2 = axisData == null ? void 0 : axisData.unit) == null ? void 0 : _l2.length),
38675
+ text: (axisData == null ? void 0 : axisData.label) || (axisData == null ? void 0 : axisData.unit),
38691
38676
  padding: 0
38692
38677
  },
38693
38678
  ticks: getTicks(),
38694
38679
  grid: {
38695
38680
  ...grid
38696
38681
  },
38697
- stacked: chart2.options.additionalAxesOptions.stacked
38682
+ stacked: (_n2 = (_m2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _m2.additionalAxesOptions) == null ? void 0 : _n2.stacked
38698
38683
  };
38699
38684
  };
38700
38685
  const getBarChartAxes = (chart2, axisType) => {
38701
- const axesData = chart2.options.axes[axisType];
38702
- const axes = axesData.reduce((acc, curr, i2) => {
38703
- const axisData = curr;
38704
- const color2 = curr.color || COLORS[i2] || generateRandomColor$1(COLORS);
38705
- axisData.color = color2;
38706
- axisData.position = curr.position || getAxisPosition(axisType, i2);
38707
- const axis = getBarChartAxis(chart2, axisType, axisData);
38708
- const axisId = i2 === 0 ? axisType : `${axisType}${i2 + 1}`;
38709
- return { ...acc, [axisId]: axis };
38710
- }, {});
38686
+ var _a2, _b2;
38687
+ const axesData = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.axes) == null ? void 0 : _b2[axisType]) || [];
38688
+ const axes = axesData.reduce(
38689
+ (acc, curr, i2) => {
38690
+ const axisData = curr;
38691
+ const color2 = curr.color || COLORS[i2] || generateRandomColor(COLORS);
38692
+ axisData.color = color2;
38693
+ axisData.position = curr.position || getAxisPosition(axisType, i2);
38694
+ const axis = getBarChartAxis({ chart: chart2, axisType, currentScale: axisData });
38695
+ const axisId = i2 === 0 ? axisType : `${axisType}${i2 + 1}`;
38696
+ return { ...acc, [axisId]: axis };
38697
+ },
38698
+ {}
38699
+ );
38711
38700
  return axes;
38712
38701
  };
38713
38702
  const getBarChartScales = (chart2) => {
38714
38703
  var _a2, _b2;
38715
38704
  const hasMultipleXAxes = ((_a2 = chart2.options.axes.x) == null ? void 0 : _a2.length) > 1;
38716
38705
  const hasMultipleYAxes = ((_b2 = chart2.options.axes.y) == null ? void 0 : _b2.length) > 1;
38717
- const xAxesScales = hasMultipleXAxes ? getBarChartAxes(chart2, AxisType.X) : { x: getBarChartAxis(chart2, AxisType.X) };
38718
- const yAxesScales = hasMultipleYAxes ? getBarChartAxes(chart2, AxisType.Y) : { y: getBarChartAxis(chart2, AxisType.Y) };
38706
+ const xAxesScales = hasMultipleXAxes ? getBarChartAxes(chart2, AxisType.X) : { x: getBarChartAxis({ chart: chart2, axisType: AxisType.X }) };
38707
+ const yAxesScales = hasMultipleYAxes ? getBarChartAxes(chart2, AxisType.Y) : { y: getBarChartAxis({ chart: chart2, axisType: AxisType.Y }) };
38719
38708
  return {
38720
38709
  ...xAxesScales,
38721
38710
  ...yAxesScales
38722
38711
  };
38723
38712
  };
38724
38713
  const getBarChartToolTips = (options) => {
38714
+ var _a2;
38725
38715
  const getTooltipLabels = (dataset) => {
38726
- var _a2, _b2;
38716
+ var _a3, _b2;
38727
38717
  const isDirectionVertical = isVertical(options.direction);
38728
- const { x: x2, y: y2 } = options.axes;
38729
- const xIndex = ((_a2 = dataset.xAxisID) == null ? void 0 : _a2.length) > 1 ? dataset.xAxisID[1] - 1 : 0;
38730
- const yIndex = ((_b2 = dataset.yAxisID) == null ? void 0 : _b2.length) > 1 ? dataset.yAxisID[1] - 1 : 0;
38718
+ const x2 = ((_a3 = options.axes) == null ? void 0 : _a3.x) || [];
38719
+ const y2 = ((_b2 = options.axes) == null ? void 0 : _b2.y) || [];
38720
+ const getAxisIndex = (axisID) => {
38721
+ if (!axisID)
38722
+ return 0;
38723
+ const match = axisID.match(/\d+$/);
38724
+ return match ? parseInt(match[0], 10) - 1 : 0;
38725
+ };
38726
+ const xIndex = getAxisIndex(dataset == null ? void 0 : dataset.xAxisID);
38727
+ const yIndex = getAxisIndex(dataset == null ? void 0 : dataset.yAxisID);
38731
38728
  const xAxis = isDirectionVertical ? x2[xIndex] : y2[yIndex];
38732
38729
  const yAxis = isDirectionVertical ? y2[yIndex] : x2[xIndex];
38733
38730
  return {
@@ -38739,18 +38736,18 @@ const getBarChartToolTips = (options) => {
38739
38736
  valueUnit: (yAxis == null ? void 0 : yAxis.unit) || ""
38740
38737
  };
38741
38738
  };
38742
- const titleCallback = (tooltipItem, data) => {
38743
- var _a2;
38744
- const barLabel = ((_a2 = tooltipItem[0]) == null ? void 0 : _a2.label) || "";
38745
- const labels = getTooltipLabels(tooltipItem[0].dataset);
38739
+ const titleCallback = (tooltipItems, _data) => {
38740
+ var _a3, _b2;
38741
+ const barLabel = ((_a3 = tooltipItems == null ? void 0 : tooltipItems[0]) == null ? void 0 : _a3.label) || "";
38742
+ const labels = getTooltipLabels((_b2 = tooltipItems == null ? void 0 : tooltipItems[0]) == null ? void 0 : _b2.dataset);
38746
38743
  const { titleAxisLabel, titleUnit } = labels;
38747
38744
  const axisLabel = !titleAxisLabel && !titleUnit ? "" : `${titleAxisLabel || titleUnit}: `;
38748
38745
  return axisLabel + barLabel;
38749
38746
  };
38750
38747
  const labelCallback = (tooltipItem) => {
38751
- var _a2;
38752
- const { showLabelsInTooltips } = options.tooltip;
38753
- let label = ((_a2 = tooltipItem.dataset) == null ? void 0 : _a2.label) || "";
38748
+ var _a3;
38749
+ const { showLabelsInTooltips = false } = (options == null ? void 0 : options.tooltip) || {};
38750
+ let label = ((_a3 = tooltipItem.dataset) == null ? void 0 : _a3.label) || "";
38754
38751
  const labels = getTooltipLabels(tooltipItem.dataset);
38755
38752
  const { valueUnit, valueAxisLabel } = labels;
38756
38753
  const getTooltipItemValue = () => {
@@ -38768,9 +38765,12 @@ const getBarChartToolTips = (options) => {
38768
38765
  tooltipItemValue2 = labelNumberFormatted;
38769
38766
  }
38770
38767
  if (Array.isArray(tooltipItem.raw)) {
38771
- tooltipItemValue2 = tooltipItem.raw.reduce((acc, curr, i2) => {
38772
- return i2 === 0 ? `${acc} ${curr}` : `${acc}, ${curr}`;
38773
- }, "");
38768
+ tooltipItemValue2 = tooltipItem.raw.reduce(
38769
+ (acc, curr, i2) => {
38770
+ return i2 === 0 ? `${acc} ${curr}` : `${acc}, ${curr}`;
38771
+ },
38772
+ ""
38773
+ );
38774
38774
  }
38775
38775
  if (typeof tooltipItem.raw === "object") {
38776
38776
  tooltipItemValue2 = formattedValue;
@@ -38785,7 +38785,7 @@ const getBarChartToolTips = (options) => {
38785
38785
  return `${label}: ${tooltipItemValue} ${unit}${valAxisLabel}${tooltipLabel}`;
38786
38786
  };
38787
38787
  return {
38788
- enabled: options.tooltip.tooltips,
38788
+ enabled: (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.tooltips,
38789
38789
  mode: ChartHoverMode.Nearest,
38790
38790
  intersect: true,
38791
38791
  padding: TOOLTIP_PADDING,
@@ -38800,9 +38800,11 @@ const getBarChartToolTips = (options) => {
38800
38800
  };
38801
38801
  };
38802
38802
  const getBarChartDataLabels = (options) => {
38803
- const { beginAtZero, reverse } = options.additionalAxesOptions;
38804
- const formatterCallback = (value, context) => {
38805
- const { dataset, dataIndex } = context;
38803
+ var _a2;
38804
+ const { beginAtZero, reverse } = (options == null ? void 0 : options.additionalAxesOptions) || {};
38805
+ const formatterCallback = (_value, context) => {
38806
+ const { datasetIndex, dataIndex } = context;
38807
+ const dataset = context.chart.data.datasets[datasetIndex];
38806
38808
  const dataElement = dataset.data[dataIndex];
38807
38809
  let dataLabel = "";
38808
38810
  if (typeof dataElement === "number") {
@@ -38817,7 +38819,7 @@ const getBarChartDataLabels = (options) => {
38817
38819
  };
38818
38820
  const beginAtNotZeroAlign = reverse ? AlignOptions.End : AlignOptions.Start;
38819
38821
  const beginAtNotZeroAnchor = reverse ? AlignOptions.Start : AlignOptions.End;
38820
- return options.graph.showDataLabels ? {
38822
+ return ((_a2 = options == null ? void 0 : options.graph) == null ? void 0 : _a2.showDataLabels) ? {
38821
38823
  display: AUTO,
38822
38824
  align: beginAtZero ? AlignOptions.Center : beginAtNotZeroAlign,
38823
38825
  anchor: beginAtZero ? AlignOptions.Center : beginAtNotZeroAnchor,
@@ -38839,6 +38841,7 @@ Chart$2.register(
38839
38841
  Ht
38840
38842
  );
38841
38843
  const BarChart = (props) => {
38844
+ var _a2, _b2, _c2;
38842
38845
  setDefaultTheme();
38843
38846
  const chartRef = useRef(null);
38844
38847
  const [pointHover, setPointHover] = useState(false);
@@ -38849,42 +38852,44 @@ const BarChart = (props) => {
38849
38852
  setAnnotations(annotations.annotationsData)
38850
38853
  );
38851
38854
  const generateBarChartDatasets = (datasets) => {
38852
- var _a2;
38855
+ var _a3;
38853
38856
  const barDatasetsCopy = [...datasets];
38854
- if (annotations.controlAnnotation && annotations.showAnnotations && ((_a2 = annotations.annotationsData) == null ? void 0 : _a2.length)) {
38855
- annotations.annotationsData.forEach((annotation2, index2) => {
38856
- barDatasetsCopy.push({
38857
- isAnnotation: true,
38858
- label: annotation2.label,
38859
- annotationIndex: index2,
38860
- backgroundColor: annotation2.color || COLORS[index2],
38861
- borderColor: annotation2.color || COLORS[index2],
38862
- data: [],
38863
- type: ChartType.Bar
38864
- });
38865
- });
38857
+ if (annotations.controlAnnotation && annotations.showAnnotations && ((_a3 = annotations.annotationsData) == null ? void 0 : _a3.length)) {
38858
+ annotations.annotationsData.forEach(
38859
+ (annotation2, index2) => {
38860
+ barDatasetsCopy.push({
38861
+ isAnnotation: true,
38862
+ label: annotation2.label,
38863
+ annotationIndex: index2,
38864
+ backgroundColor: annotation2.color || COLORS[index2],
38865
+ borderColor: annotation2.color || COLORS[index2],
38866
+ data: [],
38867
+ type: ChartType.Bar
38868
+ });
38869
+ }
38870
+ );
38866
38871
  }
38867
38872
  const generatedDatasets2 = barDatasetsCopy.map((barDataset, index2) => {
38868
38873
  const colorSchema = COLORS;
38869
38874
  const colors2 = barDataset.data.map((_2, i2) => {
38870
38875
  const colorSelectionIndex = datasets.length > 1 ? index2 : i2;
38871
- return colorSchema[colorSelectionIndex] || generateRandomColor$1(COLORS);
38876
+ return colorSchema[colorSelectionIndex] || generateRandomColor(COLORS);
38872
38877
  });
38873
38878
  const backgroundColors = barDataset.backgroundColor || colors2.map((color2) => color2 + ALPHA_CHANEL);
38874
38879
  return {
38875
38880
  ...barDataset,
38876
- borderWidth: parseFloat(barDataset.borderWidth) || "1",
38877
- borderColor: barDataset.borderColor || colors2,
38881
+ borderWidth: parseFloat(String(barDataset.borderWidth)) ?? 1,
38882
+ borderColor: barDataset.borderColor || colors2[index2],
38878
38883
  backgroundColor: backgroundColors
38879
38884
  };
38880
38885
  });
38881
- return generatedDatasets2;
38886
+ return generatedDatasets2 || [];
38882
38887
  };
38883
- const generatedDatasets = generateBarChartDatasets(chart2.data.datasets);
38884
- const legendClick = (e2, legendItem2) => {
38885
- const index2 = legendItem2.datasetIndex;
38888
+ const generatedDatasets = generateBarChartDatasets((_a2 = chart2 == null ? void 0 : chart2.data) == null ? void 0 : _a2.datasets);
38889
+ const legendClick = (_e2, legendItem2) => {
38890
+ const index2 = (legendItem2 == null ? void 0 : legendItem2.datasetIndex) ?? null;
38886
38891
  const chartInstance = chartRef.current;
38887
- if (chartInstance) {
38892
+ if (chartInstance && index2 !== null) {
38888
38893
  const { datasets } = chartInstance.data;
38889
38894
  const dataset = datasets[index2];
38890
38895
  const meta = chartInstance.getDatasetMeta(index2);
@@ -38911,27 +38916,30 @@ const BarChart = (props) => {
38911
38916
  });
38912
38917
  }
38913
38918
  if (interactions.onLegendClick) {
38914
- interactions.onLegendClick(legendItem2 == null ? void 0 : legendItem2.text, legendItem2.hidden);
38919
+ interactions.onLegendClick(
38920
+ legendItem2 == null ? void 0 : legendItem2.text,
38921
+ (legendItem2 == null ? void 0 : legendItem2.hidden) ?? false
38922
+ );
38915
38923
  }
38916
38924
  chartInstance.update();
38917
38925
  }
38918
38926
  };
38919
- const onClick = (evt, elements, chartInstance) => {
38927
+ const onClick = (_evt, _elements, chartInstance) => {
38920
38928
  chartInstance.resetZoom();
38921
38929
  };
38922
- const onHover = (evt, hoveredItems, chartInstance) => {
38930
+ const onHover = (evt, hoveredItems) => {
38923
38931
  if (pointHover && !(hoveredItems == null ? void 0 : hoveredItems.length)) {
38924
38932
  setPointHover(false);
38925
- if (interactions.onBarUnhover) {
38926
- interactions.onBarUnhover(evt);
38933
+ if (interactions.onUnhover) {
38934
+ interactions.onUnhover(evt);
38927
38935
  }
38928
38936
  }
38929
38937
  if (!pointHover && (hoveredItems == null ? void 0 : hoveredItems.length)) {
38930
38938
  setPointHover(true);
38931
- if (interactions.onBarHover) {
38939
+ if (interactions.onHover) {
38932
38940
  const { index: index2, datasetIndex } = hoveredItems[0];
38933
38941
  const generatedDataset = generatedDatasets;
38934
- interactions.onBarHover(evt, datasetIndex, index2, generatedDataset);
38942
+ interactions.onHover(evt, datasetIndex, index2, generatedDataset);
38935
38943
  }
38936
38944
  }
38937
38945
  };
@@ -38949,7 +38957,7 @@ const BarChart = (props) => {
38949
38957
  {
38950
38958
  ref: chartRef,
38951
38959
  data: {
38952
- labels: chart2.data.labels.length ? chart2.data.labels : [""],
38960
+ labels: ((_c2 = (_b2 = chart2 == null ? void 0 : chart2.data) == null ? void 0 : _b2.labels) == null ? void 0 : _c2.length) ? chart2.data.labels : [""],
38953
38961
  datasets: generatedDatasets
38954
38962
  },
38955
38963
  options: {
@@ -38964,9 +38972,9 @@ const BarChart = (props) => {
38964
38972
  mode: ChartHoverMode.Nearest,
38965
38973
  intersect: true
38966
38974
  },
38967
- elements: {
38968
- bar: { pointStyle: PointStyle.Circle }
38969
- },
38975
+ // elements: {
38976
+ // bar: { pointStyle: PointStyle.Circle },
38977
+ // },
38970
38978
  scales: getBarChartScales(chart2),
38971
38979
  plugins: {
38972
38980
  title: getTitle(options),