@oliasoft-open-source/charts-library 3.4.7-beta-1 → 3.4.8-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 (60) hide show
  1. package/dist/declaration.d.ts +0 -2
  2. package/dist/index.js +612 -659
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/bar-chart/bar-chart-default-props.d.ts +26 -30
  5. package/dist/src/components/bar-chart/bar-chart.interface.d.ts +70 -37
  6. package/dist/src/components/bar-chart/get-bar-chart-data-labels.d.ts +14 -11
  7. package/dist/src/components/bar-chart/get-bar-chart-scales.d.ts +2 -3
  8. package/dist/src/components/bar-chart/get-bar-chart-tooltips.d.ts +16 -3
  9. package/dist/src/components/controls/axes-options/axes-options-interfaces.d.ts +19 -0
  10. package/dist/src/components/{line-chart/controls → controls}/axes-options/axes-options.d.ts +1 -1
  11. package/dist/src/components/line-chart/controls/axes-options/axes-options-form-state.d.ts +3 -8
  12. package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +32 -18
  13. package/dist/src/components/line-chart/controls/controls-portal.d.ts +1 -6
  14. package/dist/src/components/line-chart/controls/controls.d.ts +1 -1
  15. package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +5 -5
  16. package/dist/src/components/line-chart/controls/line-options.d.ts +1 -9
  17. package/dist/src/components/line-chart/hooks/hooks.interface.d.ts +13 -0
  18. package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +6 -28
  19. package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +37 -0
  20. package/dist/src/components/line-chart/hooks/use-toggle-handler.d.ts +1 -2
  21. package/dist/src/components/line-chart/initialize/config.d.ts +2 -2
  22. package/dist/src/components/line-chart/legend/legend-interface.d.ts +18 -24
  23. package/dist/src/components/line-chart/legend/legend-panel.d.ts +2 -2
  24. package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +30 -38
  25. package/dist/src/components/line-chart/line-chart.interface.d.ts +61 -48
  26. package/dist/src/components/line-chart/plugins/chart-area-text-plugin.d.ts +1 -14
  27. package/dist/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.d.ts +4 -5
  28. package/dist/src/components/line-chart/plugins/plugins.interface.d.ts +2 -2
  29. package/dist/src/components/line-chart/state/initial-state.d.ts +2 -20
  30. package/dist/src/components/line-chart/state/line-chart-reducer.d.ts +1 -2
  31. package/dist/src/components/line-chart/state/manage-state-in-local-storage.d.ts +2 -3
  32. package/dist/src/components/line-chart/state/state.interfaces.d.ts +7 -32
  33. package/dist/src/components/line-chart/{hooks → state}/use-chart-state.d.ts +1 -13
  34. package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts +1 -1
  35. package/dist/src/components/line-chart/utils/generate-line-chart-datasets.d.ts +1 -3
  36. package/dist/src/components/line-chart/utils/get-axes-ranges-from-chart.d.ts +2 -9
  37. package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +2 -3
  38. package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +4 -4
  39. package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +2 -2
  40. package/dist/src/components/line-chart/utils/translations/get-translations.d.ts +1 -2
  41. package/dist/src/components/pie-chart/pie-chart-get-default-props.d.ts +8 -12
  42. package/dist/src/components/pie-chart/pie-chart-utils.d.ts +2 -0
  43. package/dist/src/components/pie-chart/pie-chart.d.ts +2 -1
  44. package/dist/src/components/pie-chart/pie-chart.interface.d.ts +51 -52
  45. package/dist/src/components/scatter-chart/scatter-chart.d.ts +1 -1
  46. package/dist/src/components/scatter-chart/scatter-chart.intefrace.d.ts +16 -6
  47. package/dist/src/helpers/chart-border-plugin.d.ts +7 -0
  48. package/dist/src/helpers/chart-interface.d.ts +85 -0
  49. package/dist/src/{components/common/helpers → helpers}/enums.d.ts +1 -2
  50. package/dist/src/helpers/get-chart-annotation.d.ts +12 -0
  51. package/dist/src/helpers/get-draggableData.d.ts +18 -0
  52. package/dist/src/{components/common/helpers → helpers}/range/range.d.ts +6 -6
  53. package/package.json +1 -1
  54. package/dist/src/components/common/common.interface.d.ts +0 -139
  55. package/dist/src/components/common/helpers/chart-border-plugin.d.ts +0 -8
  56. package/dist/src/components/common/helpers/get-chart-annotation.d.ts +0 -27
  57. package/dist/src/components/common/helpers/get-draggableData.d.ts +0 -18
  58. package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +0 -52
  59. /package/dist/src/{components/common/helpers → helpers}/chart-consts.d.ts +0 -0
  60. /package/dist/src/{components/common/helpers → 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.2
579
+ * Chart.js v4.3.0
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, axis, min).lo,
1051
+ _lookupByKey$1(_parsed, iScale.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$1 = [
1173
+ const colors$2 = [
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$1
1197
+ properties: colors$2
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.2
2894
+ * Chart.js v4.3.0
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.slice(Math.max(this._drawStart - 1, 0), this._drawStart + this._drawCount);
4828
+ line.points = points;
4829
4829
  const options = this.resolveDatasetElementOptions(mode);
4830
4830
  if (!this.options.showLine) {
4831
4831
  options.borderWidth = 0;
@@ -4939,9 +4939,6 @@ 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
- }
4945
4942
  const { dataset: line, _dataset } = meta;
4946
4943
  line._chart = this.chart;
4947
4944
  line._datasetIndex = this.index;
@@ -4953,9 +4950,6 @@ let ScatterController$1 = (_f = class extends DatasetController$1 {
4953
4950
  animated: !animationsDisabled,
4954
4951
  options
4955
4952
  }, mode);
4956
- } else if (this.datasetElementType) {
4957
- delete meta.dataset;
4958
- this.datasetElementType = false;
4959
4953
  }
4960
4954
  this.updateElements(points, start, count, mode);
4961
4955
  }
@@ -7962,7 +7956,7 @@ function needContext$1(proxy, names2) {
7962
7956
  }
7963
7957
  return false;
7964
7958
  }
7965
- var version$3 = "4.3.2";
7959
+ var version$3 = "4.3.0";
7966
7960
  const KNOWN_POSITIONS$1 = [
7967
7961
  "top",
7968
7962
  "bottom",
@@ -10569,7 +10563,7 @@ let Legend$1 = class Legend extends Element$2 {
10569
10563
  cursor.x += width + padding;
10570
10564
  } else if (typeof legendItem2.text !== "string") {
10571
10565
  const fontLineHeight = labelFont.lineHeight;
10572
- cursor.y += calculateLegendItemHeight(legendItem2, fontLineHeight) + padding;
10566
+ cursor.y += calculateLegendItemHeight(legendItem2, fontLineHeight);
10573
10567
  } else {
10574
10568
  cursor.y += lineHeight;
10575
10569
  }
@@ -10683,7 +10677,7 @@ function calculateItemHeight(_itemHeight, legendItem2, fontLineHeight) {
10683
10677
  return itemHeight;
10684
10678
  }
10685
10679
  function calculateLegendItemHeight(legendItem2, fontLineHeight) {
10686
- const labelHeight = legendItem2.text ? legendItem2.text.length : 0;
10680
+ const labelHeight = legendItem2.text ? legendItem2.text.length + 0.5 : 0;
10687
10681
  return fontLineHeight * labelHeight;
10688
10682
  }
10689
10683
  function isListened(type, opts) {
@@ -12730,7 +12724,7 @@ let TimeScale$1 = (_q = class extends Scale$1 {
12730
12724
  if (time === max || options.bounds === "ticks" || count === 1) {
12731
12725
  addTick$1(ticks, time, timestamps);
12732
12726
  }
12733
- return Object.keys(ticks).sort(sorter$1).map((x2) => +x2);
12727
+ return Object.keys(ticks).sort((a2, b2) => a2 - b2).map((x2) => +x2);
12734
12728
  }
12735
12729
  getLabelForValue(value) {
12736
12730
  const adapter = this._adapter;
@@ -12928,18 +12922,6 @@ let TimeSeriesScale$1 = (_r = class extends TimeScale$1 {
12928
12922
  }
12929
12923
  return table2;
12930
12924
  }
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
- }
12943
12925
  _getTimestampsForTable() {
12944
12926
  let timestamps = this._cache.all || [];
12945
12927
  if (timestamps.length) {
@@ -13104,15 +13086,12 @@ const Pie = /* @__PURE__ */ createTypedChart("pie", PieController$1);
13104
13086
  const Scatter = /* @__PURE__ */ createTypedChart("scatter", ScatterController$1);
13105
13087
  const MINOR_TICKS_PER_MAJOR = 10;
13106
13088
  const getLargestMajorTickWidth = (majorTickPositions) => {
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
- );
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);
13116
13095
  };
13117
13096
  const isValidPosition = (minorTickPosition, majorTickPositions, scale) => {
13118
13097
  const { axis, left: left2, top: top2, right: right2, bottom: bottom2 } = scale;
@@ -13140,18 +13119,16 @@ const getMinorTickPositions = (majorTickPositions, scale) => {
13140
13119
  return positions2;
13141
13120
  };
13142
13121
  const drawMinorTicksForScale = (scale) => {
13143
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
13144
13122
  const { chart: chart2, ctx } = scale;
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))
13123
+ if (!chart2.config._config.options.scales[scale.id].grid.drawOnChartArea)
13147
13124
  return;
13148
- if (config2.options.indexAxis === scale.axis)
13125
+ if (chart2.config._config.options.indexAxis === scale.axis)
13149
13126
  return;
13150
13127
  const isHorizontal = scale.axis === "x";
13151
13128
  const majorTickPositions = scale.ticks.map((_2, index2) => scale.getPixelForTick(index2)).sort((a2, b2) => a2 - b2);
13152
13129
  const minorTickPositions = getMinorTickPositions(majorTickPositions, scale);
13153
13130
  ctx.save();
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)";
13131
+ ctx.strokeStyle = chart2.config._config.options.scales[scale.id].grid.color || "rgba(0,0,0,0.06)";
13155
13132
  ctx.lineWidth = 0.5;
13156
13133
  minorTickPositions.forEach((minorTickPosition) => {
13157
13134
  ctx.beginPath();
@@ -13290,7 +13267,6 @@ var PanZoomMode = /* @__PURE__ */ ((PanZoomMode2) => {
13290
13267
  PanZoomMode2["X"] = "x";
13291
13268
  PanZoomMode2["Y"] = "y";
13292
13269
  PanZoomMode2["XY"] = "xy";
13293
- PanZoomMode2["Z"] = "z";
13294
13270
  return PanZoomMode2;
13295
13271
  })(PanZoomMode || {});
13296
13272
  var Key = /* @__PURE__ */ ((Key2) => {
@@ -13308,7 +13284,7 @@ var Events = /* @__PURE__ */ ((Events2) => {
13308
13284
  })(Events || {});
13309
13285
  const chartAreaBorderPlugin = {
13310
13286
  id: "chartAreaBorder",
13311
- beforeDraw(chart2, _args, options) {
13287
+ beforeDraw(chart2, args, options) {
13312
13288
  const {
13313
13289
  ctx,
13314
13290
  chartArea: { left: left2, top: top2, width, height }
@@ -13323,7 +13299,6 @@ const chartAreaBorderPlugin = {
13323
13299
  }
13324
13300
  };
13325
13301
  const getPlugins = (graph, legend2) => {
13326
- var _a2;
13327
13302
  let plugins = [];
13328
13303
  if (graph.showMinorGridlines) {
13329
13304
  plugins.push(chartMinorGridlinesPlugin);
@@ -13332,25 +13307,25 @@ const getPlugins = (graph, legend2) => {
13332
13307
  if ((customLegend == null ? void 0 : customLegend.customLegendPlugin) && (customLegend == null ? void 0 : customLegend.customLegendContainerID)) {
13333
13308
  plugins.push({
13334
13309
  id: CUSTOM_LEGEND_PLUGIN_NAME,
13335
- ...(_a2 = legend2 == null ? void 0 : legend2.customLegend) == null ? void 0 : _a2.customLegendPlugin
13310
+ ...legend2.customLegend.customLegendPlugin
13336
13311
  });
13337
13312
  }
13338
13313
  plugins.push(chartAreaBorderPlugin);
13339
13314
  return plugins;
13340
13315
  };
13341
- const generateRandomColor = (colors2) => {
13316
+ const generateRandomColor$1 = (colors2) => {
13342
13317
  const color2 = `#${Math.floor(Math.random() * WHITE_COLOR_AS_DECIMAL).toString(
13343
13318
  16
13344
13319
  )}`;
13345
13320
  if (colors2.includes(color2)) {
13346
- return generateRandomColor(colors2);
13321
+ return generateRandomColor$1(colors2);
13347
13322
  } else {
13348
13323
  colors2.push(color2);
13349
- return colors2;
13324
+ return color2;
13350
13325
  }
13351
13326
  };
13352
13327
  const setAnnotations = (annotationsData) => {
13353
- return (annotationsData == null ? void 0 : annotationsData.length) ? annotationsData.map((_v, i2) => i2) : [];
13328
+ return (annotationsData == null ? void 0 : annotationsData.length) ? annotationsData.map((v2, i2) => i2) : [];
13354
13329
  };
13355
13330
  const getTitle = (options) => {
13356
13331
  return options.title !== "" ? {
@@ -13376,16 +13351,16 @@ const getClassName = (chartStyling, styles2) => {
13376
13351
  }
13377
13352
  return cx(styles2.chart, heightStyles, squareAspectRatioStyle);
13378
13353
  };
13379
- const getLegend = (options, clickHandler) => {
13380
- const { legend: legend2 } = options || {};
13354
+ const getLegend = (options, clickHandler, state = null) => {
13355
+ const { legend: legend2 } = options;
13381
13356
  return {
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,
13357
+ position: legend2.position || Position.Top,
13358
+ display: legend2.display,
13359
+ align: legend2.align,
13385
13360
  labels: {
13386
13361
  boxHeight: LEGEND_LABEL_BOX_SIZE,
13387
- boxWidth: (legend2 == null ? void 0 : legend2.usePointStyle) ? LEGEND_LABEL_BOX_SIZE : void 0,
13388
- usePointStyle: legend2 == null ? void 0 : legend2.usePointStyle
13362
+ boxWidth: legend2.usePointStyle ? LEGEND_LABEL_BOX_SIZE : void 0,
13363
+ usePointStyle: legend2.usePointStyle
13389
13364
  },
13390
13365
  onClick: clickHandler
13391
13366
  };
@@ -13406,7 +13381,7 @@ const getChartFileName = (axes) => {
13406
13381
  }
13407
13382
  const axesLabels = axes.reduce((acc, cur, index2) => {
13408
13383
  var _a2;
13409
- const labelWithNoSpace = ((_a2 = cur.label) == null ? void 0 : _a2.replace(/\s/g, "_")) || String(index2);
13384
+ const labelWithNoSpace = ((_a2 = cur.label) == null ? void 0 : _a2.replace(/\s/g, "_")) || index2;
13410
13385
  return [...acc, labelWithNoSpace];
13411
13386
  }, []);
13412
13387
  return axesLabels.join("_");
@@ -13423,7 +13398,7 @@ const styles$5 = {
13423
13398
  };
13424
13399
  const ScatterChart = (props) => {
13425
13400
  setDefaultTheme();
13426
- const { data = { datasets: [] }, options, testId = null } = props.chart;
13401
+ const { data, options, testId = null } = props.chart;
13427
13402
  return /* @__PURE__ */ jsx("div", { className: styles$5.chart, children: /* @__PURE__ */ jsx(Scatter, { options, data, "data-testid": testId }) });
13428
13403
  };
13429
13404
  function getDefaultExportFromCjs(x2) {
@@ -22098,7 +22073,6 @@ const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
22098
22073
  const DISABLE_DRAG_OPTIONS = "DISABLE_DRAG_OPTIONS";
22099
22074
  const reducer$1 = (state, action) => {
22100
22075
  return produce(state, (draft) => {
22101
- var _a2;
22102
22076
  switch (action.type) {
22103
22077
  case TOGGLE_ZOOM: {
22104
22078
  draft.zoomEnabled = !draft.zoomEnabled;
@@ -22156,11 +22130,11 @@ const reducer$1 = (state, action) => {
22156
22130
  }
22157
22131
  case TOGGLE_ANNOTATION: {
22158
22132
  const { annotationIndex } = action.payload;
22159
- const updatedIndexes = ((_a2 = draft == null ? void 0 : draft.showAnnotationLineIndex) == null ? void 0 : _a2.includes(
22133
+ const updatedIndexes = draft.showAnnotationLineIndex.includes(
22160
22134
  annotationIndex
22161
- )) ? draft.showAnnotationLineIndex.filter(
22135
+ ) ? draft.showAnnotationLineIndex.filter(
22162
22136
  (v2) => v2 !== annotationIndex
22163
- ) : [...(draft == null ? void 0 : draft.showAnnotationLineIndex) ?? [], annotationIndex];
22137
+ ) : [...draft.showAnnotationLineIndex, annotationIndex];
22164
22138
  draft.showAnnotationLineIndex = updatedIndexes;
22165
22139
  break;
22166
22140
  }
@@ -22197,7 +22171,7 @@ const generateAxisId = (axisType, index2 = 0, hasMultiAxes = false) => {
22197
22171
  };
22198
22172
  const getAxisTypeFromKey = (string) => {
22199
22173
  var _a2;
22200
- return ((_a2 = string == null ? void 0 : string.match(/[^0-9/]+/gi)) == null ? void 0 : _a2[0]) ?? "";
22174
+ return ((_a2 = string.match(/[^0-9/]+/gi)) == null ? void 0 : _a2[0]) || "";
22201
22175
  };
22202
22176
  const generateKey = (values) => {
22203
22177
  const key = values.join("");
@@ -22220,7 +22194,7 @@ const removeExpiredChartStates = (maxAgeInHours = 72) => {
22220
22194
  const maxAgeInMilliseconds = maxAgeInHours * 60 * 60 * 1e3;
22221
22195
  for (let i2 = 0; i2 < localStorage.length; i2++) {
22222
22196
  const key = localStorage.key(i2);
22223
- if (key == null ? void 0 : key.includes("line-chart-state-")) {
22197
+ if (key.includes("line-chart-state-")) {
22224
22198
  const chartStateObjectJSON = localStorage.getItem(key);
22225
22199
  if (chartStateObjectJSON) {
22226
22200
  const chartStateObject = JSON.parse(chartStateObjectJSON);
@@ -22249,40 +22223,38 @@ const storeChartStateInStorage = (state, persistenceId) => {
22249
22223
  };
22250
22224
  const initialState = ({ options, persistenceId }) => {
22251
22225
  const {
22252
- additionalAxesOptions: { range: customAxesRange = {} },
22253
- annotations: { annotationsData = [] },
22226
+ additionalAxesOptions: { range: customAxesRange },
22227
+ annotations: { annotationsData },
22254
22228
  axes,
22255
22229
  chartOptions: { enableZoom, enablePan, showPoints, showLine },
22256
22230
  legend: { display },
22257
22231
  dragData
22258
22232
  } = options;
22259
22233
  const getStateAxesByType = (axisType, customAxesRange2) => {
22260
- var _a2, _b2, _c2, _d2, _e2;
22234
+ var _a2, _b2, _c2;
22261
22235
  if (!axes[axisType]) {
22262
22236
  return [];
22263
22237
  }
22264
22238
  if (((_a2 = axes[axisType]) == null ? void 0 : _a2.length) > 1) {
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
- );
22239
+ return axes[axisType].map((axisObj, index2) => {
22240
+ var _a3, _b3;
22241
+ const id = generateAxisId(axisType, index2, axes[axisType].length > 1);
22242
+ const customMin = (_a3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _a3.min;
22243
+ const customMax = (_b3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b3.max;
22244
+ const { unit } = axisObj;
22245
+ return {
22246
+ id,
22247
+ //only add custom axis ranges if defined:
22248
+ ...customMin ? { min: customMin } : {},
22249
+ ...customMax ? { max: customMax } : {},
22250
+ ...unit ? { unit } : {}
22251
+ };
22252
+ });
22281
22253
  } else {
22282
22254
  const id = generateAxisId(axisType);
22283
22255
  const customMin = (_b2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b2.min;
22284
22256
  const customMax = (_c2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _c2.max;
22285
- const unit = (_e2 = (_d2 = axes == null ? void 0 : axes[id]) == null ? void 0 : _d2[0]) == null ? void 0 : _e2.unit;
22257
+ const unit = axes == null ? void 0 : axes[id][0].unit;
22286
22258
  return [
22287
22259
  {
22288
22260
  id,
@@ -22449,15 +22421,15 @@ const LineOptions = ({
22449
22421
  }
22450
22422
  ];
22451
22423
  const selectedOption = options.find((option) => option.selected);
22452
- return /* @__PURE__ */ jsx(Tooltip$2, { text: selectedOption == null ? void 0 : selectedOption.label, placement: "bottom", children: /* @__PURE__ */ jsx(
22424
+ return /* @__PURE__ */ jsx(Tooltip$2, { text: selectedOption.label, placement: "bottom", children: /* @__PURE__ */ jsx(
22453
22425
  Button,
22454
22426
  {
22455
22427
  small: true,
22456
22428
  basic: true,
22457
22429
  colored: "muted",
22458
22430
  round: true,
22459
- icon: selectedOption == null ? void 0 : selectedOption.icon,
22460
- onClick: selectedOption == null ? void 0 : selectedOption.onClick
22431
+ icon: selectedOption.icon,
22432
+ onClick: selectedOption.onClick
22461
22433
  }
22462
22434
  ) });
22463
22435
  };
@@ -22550,8 +22522,8 @@ const DragOptions = ({
22550
22522
  colored: "muted",
22551
22523
  basic: true,
22552
22524
  small: true,
22553
- label: (selectedOption == null ? void 0 : selectedOption.buttonLabel) || (selectedOption == null ? void 0 : selectedOption.label),
22554
- icon: selectedOption == null ? void 0 : selectedOption.icon
22525
+ label: selectedOption.buttonLabel || selectedOption.label,
22526
+ icon: selectedOption.icon
22555
22527
  }
22556
22528
  )
22557
22529
  }
@@ -23531,19 +23503,15 @@ const useChartFunctions = ({
23531
23503
  }) => {
23532
23504
  const {
23533
23505
  annotations,
23534
- interactions: {
23535
- onLegendClick,
23536
- onHover: onPointHover,
23537
- onUnhover: onPointUnhover
23538
- },
23506
+ interactions: { onLegendClick, onPointHover, onPointUnhover },
23539
23507
  additionalAxesOptions,
23540
23508
  axes
23541
23509
  } = options;
23542
23510
  const legendClick = useCallback(
23543
- (_e2, legendItem2) => {
23511
+ (e2, legendItem2) => {
23544
23512
  const { datasetIndex } = legendItem2;
23545
- const chartInstance = chartRef == null ? void 0 : chartRef.current;
23546
- const { datasets } = (chartInstance == null ? void 0 : chartInstance.data) || {};
23513
+ const chartInstance = chartRef.current;
23514
+ const { datasets } = chartInstance.data;
23547
23515
  const dataset = datasets[datasetIndex];
23548
23516
  const meta = chartInstance.getDatasetMeta(datasetIndex);
23549
23517
  meta.hidden = meta.hidden === null ? !dataset.hidden : null;
@@ -23552,7 +23520,7 @@ const useChartFunctions = ({
23552
23520
  dispatch({ type: "TOGGLE_ANNOTATION", payload: { annotationIndex } });
23553
23521
  }
23554
23522
  if (dataset.displayGroup) {
23555
- datasets == null ? void 0 : datasets.forEach((ds, ix) => {
23523
+ datasets.forEach((ds, ix) => {
23556
23524
  if (ds.displayGroup !== dataset.displayGroup)
23557
23525
  return;
23558
23526
  chartInstance.getDatasetMeta(ix).hidden = meta.hidden;
@@ -23561,13 +23529,13 @@ const useChartFunctions = ({
23561
23529
  if (onLegendClick) {
23562
23530
  onLegendClick(legendItem2 == null ? void 0 : legendItem2.text, legendItem2.hidden);
23563
23531
  }
23564
- chartInstance == null ? void 0 : chartInstance.update();
23532
+ chartInstance.update();
23565
23533
  },
23566
23534
  [onLegendClick, annotations]
23567
23535
  );
23568
23536
  const resetZoom2 = useCallback(() => {
23569
- const chartInstance = chartRef == null ? void 0 : chartRef.current;
23570
- chartInstance == null ? void 0 : chartInstance.resetZoom();
23537
+ const chartInstance = chartRef.current;
23538
+ chartInstance.resetZoom();
23571
23539
  dispatch({ type: "RESET_AXES_RANGES" });
23572
23540
  }, [chartRef]);
23573
23541
  const onHover = useCallback((hoveredPoint, setHoveredPoint) => {
@@ -23607,30 +23575,22 @@ const useChartFunctions = ({
23607
23575
  }, [chartRef, state.axes]);
23608
23576
  const handleKeyDown = useCallback(
23609
23577
  (evt) => {
23610
- var _a2, _b2, _c2, _d2, _e2;
23611
23578
  if (evt.key === Key.Shift) {
23612
23579
  const chart2 = chartRef.current;
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
- }
23580
+ chart2.config.options.plugins.zoom.zoom.mode = PanZoomMode.Y;
23581
+ chart2.config.options.plugins.zoom.pan.mode = PanZoomMode.Y;
23582
+ chart2.update();
23619
23583
  }
23620
23584
  },
23621
23585
  [chartRef]
23622
23586
  );
23623
23587
  const handleKeyUp = useCallback(
23624
23588
  (evt) => {
23625
- var _a2, _b2, _c2, _d2, _e2;
23626
23589
  if (evt.key === Key.Shift) {
23627
23590
  const chart2 = chartRef.current;
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
- }
23591
+ chart2.config.options.plugins.zoom.zoom.mode = PanZoomMode.Z;
23592
+ chart2.config.options.plugins.zoom.pan.mode = PanZoomMode.Z;
23593
+ chart2.update();
23634
23594
  }
23635
23595
  },
23636
23596
  [chartRef]
@@ -23676,15 +23636,13 @@ const useChartFunctions = ({
23676
23636
  );
23677
23637
  const updateAxesRangesFromChart = useCallback(() => {
23678
23638
  const { scales = {} } = (chartRef == null ? void 0 : chartRef.current) || {};
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
- );
23639
+ const axes2 = Object.entries(scales).map(([key, { min, max }]) => {
23640
+ return {
23641
+ id: key,
23642
+ min: min ?? 0,
23643
+ max: max ?? 0
23644
+ };
23645
+ });
23688
23646
  dispatch({
23689
23647
  type: UPDATE_AXES_RANGES,
23690
23648
  payload: { axes: axes2 }
@@ -23716,11 +23674,8 @@ var actionTypes = /* @__PURE__ */ ((actionTypes2) => {
23716
23674
  actionTypes2["UnitUpdated"] = "unitUpdated";
23717
23675
  return actionTypes2;
23718
23676
  })(actionTypes || {});
23719
- const initializeFormState = ({
23720
- initialAxesRanges,
23721
- axes = []
23722
- }) => {
23723
- return (initialAxesRanges == null ? void 0 : initialAxesRanges.map((initialAxisRange) => {
23677
+ const initializeFormState = ({ initialAxesRanges, axes = [] }) => {
23678
+ return initialAxesRanges.map((initialAxisRange) => {
23724
23679
  const currentAxisRange = axes.find((a2) => a2.id === initialAxisRange.id);
23725
23680
  return {
23726
23681
  id: initialAxisRange.id,
@@ -23728,7 +23683,7 @@ const initializeFormState = ({
23728
23683
  max: (currentAxisRange == null ? void 0 : currentAxisRange.max) ?? (initialAxisRange == null ? void 0 : initialAxisRange.max),
23729
23684
  unit: currentAxisRange == null ? void 0 : currentAxisRange.unit
23730
23685
  };
23731
- })) || [];
23686
+ });
23732
23687
  };
23733
23688
  const isEmptyString = (value) => value === "";
23734
23689
  const createErrorMessages = (value, compareTo, type) => {
@@ -23746,12 +23701,11 @@ const validateAxes = (formState) => {
23746
23701
  return formState.reduce(
23747
23702
  (acc, { id, min, max }) => {
23748
23703
  return produce(acc, (draft) => {
23749
- var _a2;
23750
23704
  const errors = {
23751
- min: createErrorMessages(String(min), String(max), "min"),
23752
- max: createErrorMessages(String(max), String(min), "max")
23705
+ min: createErrorMessages(min, max, "min"),
23706
+ max: createErrorMessages(max, min, "max")
23753
23707
  };
23754
- (_a2 = draft == null ? void 0 : draft.errors) == null ? void 0 : _a2.push({
23708
+ draft.errors.push({
23755
23709
  id,
23756
23710
  ...errors
23757
23711
  });
@@ -23771,17 +23725,13 @@ const reducer = (state, action) => {
23771
23725
  return produce(state, (draft) => {
23772
23726
  const { name: name2, value, id } = action.payload;
23773
23727
  const axis = draft.find((a2) => a2.id === id);
23774
- if (axis) {
23775
- axis[name2] = value;
23776
- }
23728
+ axis[name2] = value;
23777
23729
  });
23778
23730
  case actionTypes.UnitUpdated:
23779
23731
  return produce(state, (draft) => {
23780
23732
  const { name: name2, value, id } = action.payload;
23781
23733
  const axis = draft.find((a2) => a2.id === id);
23782
- if (axis) {
23783
- axis.unit[name2] = value;
23784
- }
23734
+ axis.unit[name2] = value;
23785
23735
  });
23786
23736
  default:
23787
23737
  return state;
@@ -23834,55 +23784,54 @@ const AxesOptionsPopover = (optionsPopover) => {
23834
23784
  onUpdateAxes({
23835
23785
  axes: sanitizedFormState
23836
23786
  });
23837
- sanitizedFormState.map((el, i2) => {
23787
+ sanitizedFormState.forEach((el, i2) => {
23838
23788
  var _a3, _b2, _c2;
23839
23789
  const selectedUnit = (_a3 = el.unit) == null ? void 0 : _a3.selectedUnit;
23840
23790
  if (selectedUnit) {
23841
23791
  (_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
23842
23792
  }
23843
23793
  });
23844
- if (depthType && (depthType == null ? void 0 : depthType.setSelectedDepthType)) {
23845
- depthType == null ? void 0 : depthType.setSelectedDepthType(depthTypeState);
23794
+ if (depthType) {
23795
+ depthType.setSelectedDepthType(depthTypeState);
23846
23796
  }
23847
23797
  }
23848
- close == null ? void 0 : close();
23798
+ close();
23849
23799
  };
23850
23800
  const onReset = () => {
23851
23801
  dispatch({
23852
23802
  type: actionTypes.Reset,
23853
23803
  payload: { axes, initialAxesRanges }
23854
23804
  });
23855
- initialAxesRanges.map((el, i2) => {
23805
+ initialAxesRanges.forEach((el, i2) => {
23856
23806
  var _a3, _b2, _c2;
23857
- const selectedUnit = (_a3 = el.unit) == null ? void 0 : _a3.selectedUnit;
23807
+ const selectedUnit = (_a3 = el == null ? void 0 : el.unit) == null ? void 0 : _a3.selectedUnit;
23858
23808
  if (selectedUnit) {
23859
23809
  (_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
23860
23810
  }
23861
23811
  });
23862
23812
  onResetAxes();
23863
- close == null ? void 0 : close();
23813
+ close();
23864
23814
  };
23865
23815
  const isCustomValue = axes.filter((axis) => axis.max || axis.min).length > 0;
23866
23816
  const handleInputFocus = (e2) => e2.target.select();
23867
23817
  return /* @__PURE__ */ jsxs("form", { onSubmit: onDone, children: [
23868
23818
  axes.map((axis, i2) => {
23869
- var _a3, _b2, _c2;
23870
- const axisControl = controlsAxesLabels.find(
23819
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
23820
+ const axisLabel = (_a3 = controlsAxesLabels.find(
23871
23821
  (el) => el.id === axis.id
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;
23822
+ )) == null ? void 0 : _a3.label;
23823
+ const min = (_b2 = formState.find((a2) => a2.id === axis.id)) == null ? void 0 : _b2.min;
23824
+ const max = (_c2 = formState.find((a2) => a2.id === axis.id)) == null ? void 0 : _c2.max;
23825
+ 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];
23826
+ 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];
23827
+ const unit = (_h2 = formState.find((a2) => a2.id === axis.id)) == null ? void 0 : _h2.unit;
23879
23828
  return /* @__PURE__ */ jsx(Field, { label: axisLabel || axis.id || "", children: /* @__PURE__ */ jsxs(InputGroup, { small: true, width: "300px", children: [
23880
23829
  /* @__PURE__ */ jsx(
23881
23830
  NumberInput,
23882
23831
  {
23883
23832
  name: "min",
23884
23833
  value: min,
23885
- error: minErrorMsg,
23834
+ error: translations[minError],
23886
23835
  size: 5,
23887
23836
  width: "100%",
23888
23837
  onChange: (evt) => onEditValue({
@@ -23899,7 +23848,7 @@ const AxesOptionsPopover = (optionsPopover) => {
23899
23848
  {
23900
23849
  name: "max",
23901
23850
  value: max,
23902
- error: maxErrorMsg,
23851
+ error: translations[maxError],
23903
23852
  size: 5,
23904
23853
  width: "100%",
23905
23854
  onChange: (evt) => onEditValue({
@@ -23914,7 +23863,7 @@ const AxesOptionsPopover = (optionsPopover) => {
23914
23863
  Select,
23915
23864
  {
23916
23865
  name: "selectedUnit",
23917
- options: (_c2 = axis == null ? void 0 : axis.unit) == null ? void 0 : _c2.options,
23866
+ options: (_i2 = axis == null ? void 0 : axis.unit) == null ? void 0 : _i2.options,
23918
23867
  value: unit == null ? void 0 : unit.selectedUnit,
23919
23868
  onChange: (e2) => {
23920
23869
  onEditUnit({
@@ -24010,19 +23959,14 @@ const AxesOptions = (optionsPopover) => {
24010
23959
  }
24011
23960
  );
24012
23961
  };
24013
- const ControlsPortal = ({
24014
- children,
24015
- controlsPortalId
24016
- }) => {
23962
+ const ControlsPortal = ({ children, controlsPortalId }) => {
24017
23963
  if (controlsPortalId && document.getElementById(controlsPortalId)) {
24018
23964
  return /* @__PURE__ */ jsx(Portal, { id: controlsPortalId, children });
24019
23965
  }
24020
23966
  return children;
24021
23967
  };
24022
23968
  const Controls = ({
24023
- headerComponent,
24024
- subheaderComponent,
24025
- table: table2,
23969
+ props: { headerComponent, subheaderComponent, table: table2 },
24026
23970
  chartRef,
24027
23971
  state,
24028
23972
  options,
@@ -24040,7 +23984,7 @@ const Controls = ({
24040
23984
  showTable,
24041
23985
  zoomEnabled
24042
23986
  } = state;
24043
- const { dragData, depthType } = options;
23987
+ const { dragData } = options;
24044
23988
  const {
24045
23989
  onToggleLine,
24046
23990
  onTogglePan,
@@ -24067,7 +24011,7 @@ const Controls = ({
24067
24011
  /* @__PURE__ */ jsxs("div", { className: styles$3.controls, children: [
24068
24012
  !!options.title && /* @__PURE__ */ jsx(Text, { bold: true, children: options.title }),
24069
24013
  headerComponent,
24070
- /* @__PURE__ */ jsx(ControlsPortal, { controlsPortalId: controlsPortalId ?? "", children: /* @__PURE__ */ jsxs("div", { className: styles$3.buttons, children: [
24014
+ /* @__PURE__ */ jsx(ControlsPortal, { controlsPortalId, children: /* @__PURE__ */ jsxs("div", { className: styles$3.buttons, children: [
24071
24015
  !showTable && /* @__PURE__ */ jsxs(Fragment, { children: [
24072
24016
  /* @__PURE__ */ jsx(
24073
24017
  AxesOptions,
@@ -24077,7 +24021,7 @@ const Controls = ({
24077
24021
  controlsAxesLabels,
24078
24022
  onUpdateAxes,
24079
24023
  onResetAxes,
24080
- depthType,
24024
+ depthType: options.depthType,
24081
24025
  translations
24082
24026
  }
24083
24027
  ),
@@ -24260,7 +24204,7 @@ const LegendItemLine = ({ dataset }) => {
24260
24204
  ) });
24261
24205
  };
24262
24206
  const LegendItemPoint = ({ dataset }) => {
24263
- const { pointBackgroundColor, pointRadius, pointStyle = "" } = dataset;
24207
+ const { pointBackgroundColor, pointRadius, pointStyle } = dataset;
24264
24208
  if (!pointRadius)
24265
24209
  return null;
24266
24210
  const size = pointRadius * 2;
@@ -24347,12 +24291,12 @@ const LegendPanel = forwardRef((props, ref) => {
24347
24291
  const { data, chartArea, height = 0, width = 0 } = chart2;
24348
24292
  const { datasets } = data;
24349
24293
  const { top: top2, left: left2, bottom: bottom2, right: right2 } = chartArea;
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
+ 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)) ?? [];
24351
24295
  const style = {
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,
24296
+ left: legendPosition.includes("left") ? left2 : null,
24297
+ right: legendPosition.includes("right") ? width - right2 : null,
24298
+ top: legendPosition.includes("top") ? top2 : null,
24299
+ bottom: legendPosition.includes("bottom") ? height - bottom2 : null,
24356
24300
  maxHeight: 0.5 * (bottom2 - top2 - LEGEND_MARGIN * 2),
24357
24301
  maxWidth: 0.5 * (right2 - left2 - LEGEND_MARGIN * 2),
24358
24302
  margin: LEGEND_MARGIN
@@ -24503,7 +24447,7 @@ const Legend2 = ({
24503
24447
  LegendDropZones,
24504
24448
  {
24505
24449
  chartArea,
24506
- setLegendPosition: (position) => setLegendPosition(position),
24450
+ setLegendPosition,
24507
24451
  isDragging: isDragging2,
24508
24452
  placeholderSize: panelSize
24509
24453
  }
@@ -24521,122 +24465,116 @@ const TextLabelPosition = {
24521
24465
  BOTTOM_CENTER: "bottom-center",
24522
24466
  BOTTOM_RIGHT: "bottom-right"
24523
24467
  };
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) => {
24564
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
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
24468
  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,
24469
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
24470
+ props.chart.options = props.chart.options || {};
24471
+ props.chart.options.axes = props.chart.options.axes || {};
24472
+ props.chart.options.additionalAxesOptions = props.chart.options.additionalAxesOptions || {};
24473
+ props.chart.options.chartStyling = props.chart.options.chartStyling || {};
24474
+ props.chart.options.tooltip = props.chart.options.tooltip || {};
24475
+ props.chart.options.graph = props.chart.options.graph || {};
24476
+ props.chart.options.annotations = props.chart.options.annotations || {};
24477
+ props.chart.options.legend = props.chart.options.legend || {};
24478
+ props.chart.options.legend.customLegend = props.chart.options.legend.customLegend || { customLegendPlugin: null, customLegendContainerID: "" };
24479
+ props.chart.options.chartOptions = props.chart.options.chartOptions || {};
24480
+ props.chart.options.interactions = props.chart.options.interactions || {};
24481
+ props.chart.options.dragData = props.chart.options.dragData || {};
24482
+ const chart2 = {
24483
+ persistenceId: props.chart.persistenceId ?? "",
24484
+ controlsPortalId: props.chart.controlsPortalId ?? null,
24485
+ testId: props.chart.testId ?? null,
24486
+ data: props.chart.data,
24622
24487
  options: {
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) ?? {}
24488
+ title: props.chart.options.title || "",
24489
+ scales: props.chart.options.scales || {},
24490
+ axes: {
24491
+ x: props.chart.options.axes.x || [{}],
24492
+ y: props.chart.options.axes.y || [{}]
24493
+ },
24494
+ additionalAxesOptions: {
24495
+ chartScaleType: props.chart.options.additionalAxesOptions.chartScaleType || "linear",
24496
+ reverse: props.chart.options.additionalAxesOptions.reverse || false,
24497
+ beginAtZero: props.chart.options.additionalAxesOptions.beginAtZero || false,
24498
+ stepSize: props.chart.options.additionalAxesOptions.stepSize,
24499
+ suggestedMin: props.chart.options.additionalAxesOptions.suggestedMin,
24500
+ suggestedMax: props.chart.options.additionalAxesOptions.suggestedMax,
24501
+ range: props.chart.options.additionalAxesOptions.range,
24502
+ autoAxisPadding: props.chart.options.additionalAxesOptions.autoAxisPadding ?? false
24503
+ },
24504
+ chartStyling: {
24505
+ width: props.chart.options.chartStyling.width,
24506
+ height: props.chart.options.chartStyling.height,
24507
+ maintainAspectRatio: props.chart.options.chartStyling.maintainAspectRatio || false,
24508
+ staticChartHeight: props.chart.options.chartStyling.staticChartHeight || false,
24509
+ performanceMode: props.chart.options.chartStyling.performanceMode ?? true,
24510
+ squareAspectRatio: props.chart.options.chartStyling.squareAspectRatio || false,
24511
+ layoutPadding: props.chart.options.chartStyling.layoutPadding || {
24512
+ top: 0,
24513
+ bottom: 20,
24514
+ left: 0,
24515
+ right: 0
24516
+ }
24517
+ },
24518
+ tooltip: {
24519
+ tooltips: props.chart.options.tooltip.tooltips ?? true,
24520
+ showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false,
24521
+ hideSimulationName: props.chart.options.tooltip.hideSimulationName || false
24522
+ },
24523
+ graph: {
24524
+ lineTension: props.chart.options.graph.lineTension || 0.01,
24525
+ spanGaps: props.chart.options.graph.spanGaps || false,
24526
+ showDataLabels: props.chart.options.graph.showDataLabels || false,
24527
+ showMinorGridlines: props.chart.options.graph.showMinorGridlines || false
24528
+ },
24529
+ annotations: {
24530
+ labelAnnotation: {
24531
+ showLabel: ((_a2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _a2.showLabel) ?? false,
24532
+ text: ((_b2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _b2.text) ?? "",
24533
+ position: ((_c2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _c2.position) ?? TextLabelPosition.BOTTOM_RIGHT,
24534
+ fontSize: ((_d2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _d2.fontSize) ?? 12,
24535
+ xOffset: ((_e2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _e2.xOffset) ?? 5,
24536
+ yOffset: ((_f2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _f2.yOffset) ?? 5,
24537
+ maxWidth: ((_g2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _g2.maxWidth) ?? 300,
24538
+ lineHeight: ((_h2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _h2.lineHeight) ?? 12
24539
+ },
24540
+ showAnnotations: props.chart.options.annotations.showAnnotations ?? false,
24541
+ controlAnnotation: props.chart.options.annotations.controlAnnotation || false,
24542
+ annotationsData: props.chart.options.annotations.annotationsData || []
24543
+ },
24544
+ legend: {
24545
+ display: props.chart.options.legend.display ?? true,
24546
+ position: props.chart.options.legend.position || "bottom-left",
24547
+ align: props.chart.options.legend.align || "center",
24548
+ customLegend: props.chart.options.legend.customLegend,
24549
+ usePointStyle: props.chart.options.legend.usePointStyle ?? true
24550
+ },
24551
+ chartOptions: {
24552
+ showPoints: props.chart.options.chartOptions.showPoints ?? true,
24553
+ enableZoom: props.chart.options.chartOptions.enableZoom || true,
24554
+ enablePan: props.chart.options.chartOptions.enablePan || false,
24555
+ showLine: props.chart.options.chartOptions.showLine ?? true,
24556
+ closeOnOutsideClick: props.chart.options.chartOptions.closeOnOutsideClick || false
24557
+ },
24558
+ interactions: {
24559
+ onLegendClick: props.chart.options.interactions.onLegendClick,
24560
+ onPointHover: props.chart.options.interactions.onPointHover,
24561
+ onPointUnhover: props.chart.options.interactions.onPointUnhover,
24562
+ onAnimationComplete: props.chart.options.interactions.onAnimationComplete
24563
+ },
24564
+ depthType: props.chart.options.depthType,
24565
+ dragData: {
24566
+ enableDragData: props.chart.options.dragData.enableDragData ?? false,
24567
+ showTooltip: props.chart.options.dragData.showTooltip ?? true,
24568
+ roundPoints: props.chart.options.dragData.roundPoints ?? true,
24569
+ dragX: props.chart.options.dragData.dragX ?? true,
24570
+ dragY: props.chart.options.dragData.dragY ?? true,
24571
+ onDragStart: props.chart.options.dragData.onDragStart,
24572
+ onDrag: props.chart.options.dragData.onDrag,
24573
+ onDragEnd: props.chart.options.dragData.onDragEnd
24574
+ }
24638
24575
  }
24639
24576
  };
24577
+ return chart2;
24640
24578
  };
24641
24579
  const DEFAULT_POINT_RADIUS = 2;
24642
24580
  const DEFAULT_HOVER_RADIUS = 5;
@@ -24698,7 +24636,7 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
24698
24636
  if (formation) {
24699
24637
  const axesMin = (_a2 = axes[0]) == null ? void 0 : _a2.min;
24700
24638
  const axesMax = (_b2 = axes[0]) == null ? void 0 : _b2.max;
24701
- const [startPoint, endPoint] = data;
24639
+ const [startPoint, midPointWithLabel, endPoint] = data;
24702
24640
  if (axesMin && (startPoint == null ? void 0 : startPoint.x)) {
24703
24641
  data[0].x = Math.max(axesMin, startPoint.x);
24704
24642
  }
@@ -24720,9 +24658,9 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
24720
24658
  borderWidth: parseFloat(borderWidth) || DEFAULT_BORDER_WIDTH,
24721
24659
  borderDash: borderDash || [],
24722
24660
  borderJoinStyle: BORDER_JOIN_STYLE,
24723
- borderColor: borderColor ?? indexedColor ?? generateRandomColor(COLORS),
24661
+ borderColor: borderColor ?? indexedColor ?? generateRandomColor$1(COLORS),
24724
24662
  backgroundColor: backgroundColor ?? DEFAULT_BACKGROUND_COLOR,
24725
- pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor(COLORS),
24663
+ pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor$1(COLORS),
24726
24664
  pointRadius: pointsEnabled ? linePointRadius : DEFAULT_LINE_POINT_RADIUS,
24727
24665
  pointHoverRadius: hoverRadius,
24728
24666
  pointHitRadius: line.pointHitRadius ?? hoverRadius
@@ -24762,8 +24700,8 @@ const formatAxisLabelNumbers = (tickValue, ticks, locale = "en-gb") => {
24762
24700
  };
24763
24701
  const getLineChartAxis = (options, axisType, state, currentScales, i2 = 0) => {
24764
24702
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
24765
- const axisData = currentScales || options.axes[axisType][0] || {};
24766
- const stateAxis = state == null ? void 0 : state.axes.filter(
24703
+ const axisData = currentScales || options.axes[axisType][0];
24704
+ const stateAxis = state.axes.filter(
24767
24705
  (axis) => axis.id.startsWith(axisType)
24768
24706
  )[i2];
24769
24707
  const ticksConfigFromProps = (_b2 = (_a2 = options == null ? void 0 : options.scales) == null ? void 0 : _a2[`${i2 === 0 ? axisType : axisType + i2}`]) == null ? void 0 : _b2.ticks;
@@ -24810,17 +24748,14 @@ const getLineChartAxis = (options, axisType, state, currentScales, i2 = 0) => {
24810
24748
  };
24811
24749
  const getLineChartAxes = (options, axisType, state) => {
24812
24750
  const axesData = options.axes[axisType];
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
- );
24751
+ const axes = axesData.reduce((acc, curr, i2) => {
24752
+ const axisData = curr;
24753
+ axisData.color = curr.color || COLORS[i2] || generateRandomColor$1(COLORS);
24754
+ axisData.position = curr.position || getAxisPosition(axisType, i2);
24755
+ const axis = getLineChartAxis(options, axisType, state, axisData, i2);
24756
+ const axisId = generateAxisId(axisType, i2, true);
24757
+ return { ...acc, [axisId]: axis };
24758
+ }, {});
24824
24759
  return axes;
24825
24760
  };
24826
24761
  const getLineChartScales = (options, state) => {
@@ -24869,9 +24804,11 @@ const estimateDataSeriesHaveCloseValues = (generatedDatasets) => {
24869
24804
  }
24870
24805
  return acc;
24871
24806
  }, {});
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
- });
24807
+ return Object.values(axesFirstLast).some(
24808
+ ({ xFirst, xLast, yFirst, yLast }) => {
24809
+ return isCloseTo(xFirst, xLast, { absoluteDiff: MAX_DECIMAL_DIFF }) || isCloseTo(yFirst, yLast, { absoluteDiff: MAX_DECIMAL_DIFF });
24810
+ }
24811
+ );
24875
24812
  };
24876
24813
  const whiteSpacePercentage = 0.05;
24877
24814
  const defaultRange = { min: -1, max: 1 };
@@ -24943,20 +24880,13 @@ const getAxesDataFromMetasets = (chartRef, scalesKeys, annotationsData) => {
24943
24880
  }, {}));
24944
24881
  };
24945
24882
  const autoScale = (options, state, generatedDatasets, chartRef) => {
24946
- const {
24947
- additionalAxesOptions = {},
24948
- annotations: { annotationsData = [] } = {}
24949
- } = options || {};
24883
+ const { additionalAxesOptions = {}, annotations: { annotationsData } = {} } = options || {};
24950
24884
  const scales = getLineChartScales(options, state) || {};
24951
24885
  if (!(additionalAxesOptions == null ? void 0 : additionalAxesOptions.autoAxisPadding) && !estimateDataSeriesHaveCloseValues(generatedDatasets)) {
24952
24886
  return scales;
24953
24887
  }
24954
24888
  const scalesKeys = Object.keys(scales) ?? [];
24955
- const data = getAxesDataFromMetasets(
24956
- chartRef,
24957
- scalesKeys,
24958
- annotationsData
24959
- );
24889
+ const data = getAxesDataFromMetasets(chartRef, scalesKeys, annotationsData);
24960
24890
  const adjustedScales = data && (scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
24961
24891
  const { min: propMin = void 0, max: propMax = void 0 } = scales[key];
24962
24892
  const { min, max } = getSuggestedAxisRange({
@@ -25034,7 +24964,7 @@ const annotationLeave = ({ element }, { chart: chart2 }) => {
25034
24964
  chart2.canvas.style.cursor = CursorStyle.Initial;
25035
24965
  };
25036
24966
  const generateAnnotations = (options, state) => {
25037
- const { annotationsData } = (options == null ? void 0 : options.annotations) || {};
24967
+ const { annotationsData } = options.annotations;
25038
24968
  const annotations = annotationsData == null ? void 0 : annotationsData.reduce((acc, curr, i2) => {
25039
24969
  var _a2;
25040
24970
  if (!((_a2 = state == null ? void 0 : state.showAnnotationLineIndex) == null ? void 0 : _a2.includes(i2))) {
@@ -25086,9 +25016,9 @@ const generateAnnotations = (options, state) => {
25086
25016
  return annotations;
25087
25017
  };
25088
25018
  const getAnnotation = (options, state) => {
25089
- const { showAnnotations, annotationsData } = (options == null ? void 0 : options.annotations) || {};
25019
+ const { showAnnotations, annotationsData } = options.annotations || {};
25090
25020
  const shouldGenerateAnnotations = showAnnotations && (annotationsData == null ? void 0 : annotationsData.length);
25091
- const annotations = shouldGenerateAnnotations ? generateAnnotations(options, state) : {};
25021
+ const annotations = shouldGenerateAnnotations ? generateAnnotations(options, state) : null;
25092
25022
  return { annotations };
25093
25023
  };
25094
25024
  const getUnitsFromLabel = (label) => {
@@ -25098,12 +25028,12 @@ const getUnitsFromLabel = (label) => {
25098
25028
  };
25099
25029
  const getLineChartToolTips = (options) => {
25100
25030
  const getTooltipLabels = (dataset) => {
25101
- var _a2, _b2, _c2, _d2, _e2;
25031
+ var _a2, _b2;
25102
25032
  const xIndex = ((_a2 = dataset.xAxisID) == null ? void 0 : _a2.length) > 1 ? dataset.xAxisID[1] - 1 : 0;
25103
25033
  const yIndex = ((_b2 = dataset.yAxisID) == null ? void 0 : _b2.length) > 1 ? dataset.yAxisID[1] - 1 : 0;
25104
25034
  const xAxis = options.axes.x[xIndex];
25105
25035
  const yAxis = options.axes.y[yIndex];
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) {
25036
+ if (options.axes.x[0].position === Position.Top) {
25107
25037
  return {
25108
25038
  titleAxisLabel: (yAxis == null ? void 0 : yAxis.label) || "",
25109
25039
  valueAxisLabel: (xAxis == null ? void 0 : xAxis.label) || "",
@@ -25196,7 +25126,6 @@ const useChartOptions = ({
25196
25126
  dispatch,
25197
25127
  generatedDatasets
25198
25128
  }) => {
25199
- var _a2, _b2;
25200
25129
  const {
25201
25130
  interactions: { onAnimationComplete },
25202
25131
  annotations: {
@@ -25209,7 +25138,7 @@ const useChartOptions = ({
25209
25138
  yOffset,
25210
25139
  maxWidth,
25211
25140
  lineHeight
25212
- } = {}
25141
+ }
25213
25142
  },
25214
25143
  chartStyling: { layoutPadding }
25215
25144
  } = options;
@@ -25238,7 +25167,7 @@ const useChartOptions = ({
25238
25167
  [showAnnotationLineIndex, legendClick]
25239
25168
  );
25240
25169
  const legend2 = useMemo(
25241
- () => getLegend(options, legendClick),
25170
+ () => getLegend(options, legendClick, state),
25242
25171
  [legendEnabled]
25243
25172
  );
25244
25173
  const scales = useMemo(
@@ -25253,8 +25182,8 @@ const useChartOptions = ({
25253
25182
  () => ({
25254
25183
  enabled: panEnabled,
25255
25184
  mode: PanZoomMode.XY,
25256
- onPanComplete() {
25257
- updateAxesRangesFromChart();
25185
+ onPanComplete({ chart: chart2 }) {
25186
+ updateAxesRangesFromChart(chart2);
25258
25187
  }
25259
25188
  }),
25260
25189
  [panEnabled]
@@ -25269,8 +25198,8 @@ const useChartOptions = ({
25269
25198
  borderColor: BORDER_COLOR,
25270
25199
  borderWidth: 1
25271
25200
  },
25272
- onZoomComplete() {
25273
- updateAxesRangesFromChart();
25201
+ onZoomComplete({ chart: chart2 }) {
25202
+ updateAxesRangesFromChart(chart2);
25274
25203
  }
25275
25204
  }),
25276
25205
  [zoomEnabled]
@@ -25282,8 +25211,8 @@ const useChartOptions = ({
25282
25211
  tooltip,
25283
25212
  legend: { ...legend2, display: false },
25284
25213
  // hide default legend for line chart only
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
25214
+ [CUSTOM_LEGEND_PLUGIN_NAME]: options.legend.customLegend.customLegendPlugin && {
25215
+ containerID: options.legend.customLegend.customLegendContainerID
25287
25216
  },
25288
25217
  chartAreaBorder: {
25289
25218
  borderColor: BORDER_COLOR
@@ -25307,7 +25236,7 @@ const useChartOptions = ({
25307
25236
  },
25308
25237
  onHover: onHover(hoveredPoint, setHoveredPoint),
25309
25238
  maintainAspectRatio: options.chartStyling.maintainAspectRatio,
25310
- aspectRatio: options.chartStyling.squareAspectRatio ? 1 : 0,
25239
+ aspectRatio: options.chartStyling.squareAspectRatio ? 1 : null,
25311
25240
  animation: options.chartStyling.performanceMode ? false : {
25312
25241
  duration: ANIMATION_DURATION.FAST,
25313
25242
  onComplete: onAnimationComplete
@@ -25329,7 +25258,10 @@ const useChartOptions = ({
25329
25258
  [state, options]
25330
25259
  );
25331
25260
  };
25332
- const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
25261
+ const useChartPlugins = ({
25262
+ options,
25263
+ resetZoom: resetZoom2
25264
+ }) => {
25333
25265
  const { graph, legend: legend2 } = options;
25334
25266
  const debouncedResetZoom = useCallback(
25335
25267
  debounce$3(() => {
@@ -25339,7 +25271,7 @@ const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
25339
25271
  [resetZoom2]
25340
25272
  );
25341
25273
  const handleDoubleClick = useCallback(
25342
- (_chart, args) => {
25274
+ (chart2, args) => {
25343
25275
  const { event } = args;
25344
25276
  if (event.type === DOUBLE_CLICK) {
25345
25277
  debouncedResetZoom();
@@ -25372,19 +25304,15 @@ const getAxesRangesFromChart = (chartRef, axes) => {
25372
25304
  });
25373
25305
  };
25374
25306
  const useToggleCustomLegendVisibility = (memoState, memoOptions) => {
25375
- var _a2, _b2;
25376
25307
  useEffect(() => {
25377
- var _a3, _b3;
25378
- if ((_b3 = (_a3 = memoOptions == null ? void 0 : memoOptions.legend) == null ? void 0 : _a3.customLegend) == null ? void 0 : _b3.customLegendPlugin) {
25308
+ if (memoOptions.legend.customLegend.customLegendPlugin) {
25379
25309
  const parent = document.getElementById(
25380
25310
  memoOptions.legend.customLegend.customLegendContainerID
25381
25311
  );
25382
- if (parent !== null) {
25383
- parent.style.visibility = memoState.legendEnabled ? "visible" : "hidden";
25384
- }
25312
+ parent.style.visibility = memoState.legendEnabled ? "visible" : "hidden";
25385
25313
  }
25386
25314
  }, [
25387
- (_b2 = (_a2 = memoOptions == null ? void 0 : memoOptions.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendPlugin,
25315
+ memoOptions.legend.customLegend.customLegendPlugin,
25388
25316
  memoState.legendEnabled
25389
25317
  ]);
25390
25318
  };
@@ -25401,7 +25329,7 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
25401
25329
  ]);
25402
25330
  };
25403
25331
  const useUpdateAxesRanges = (range, dispatch) => {
25404
- const prevRange = useRef(null);
25332
+ const prevRange = useRef();
25405
25333
  const updateAxesRanges = useCallback(() => {
25406
25334
  if (range && range.x && range.y && !isEqual(range, prevRange.current)) {
25407
25335
  const axes = Object.entries(range).map(([key, { min, max }]) => ({
@@ -25585,9 +25513,9 @@ const chartAreaTextPlugin = {
25585
25513
  maxWidth: initialMaxWidth,
25586
25514
  position
25587
25515
  } = options;
25516
+ const { ctx, chartArea } = chart2;
25588
25517
  if (!showLabel || !text)
25589
25518
  return;
25590
- const { ctx, chartArea } = chart2;
25591
25519
  const maxWidth = calculateMaxWidth(initialMaxWidth, chartArea.width);
25592
25520
  const [x2, y2] = getPositionCoordinates(position, chart2, xOffset, yOffset);
25593
25521
  renderWrappedText(ctx, {
@@ -25665,7 +25593,7 @@ const LineChart = (props) => {
25665
25593
  const { translations, languageKey } = getConfig();
25666
25594
  const chart2 = getDefaultProps$2(props);
25667
25595
  const {
25668
- data: { datasets } = { datasets: [] },
25596
+ data: { datasets },
25669
25597
  options,
25670
25598
  testId,
25671
25599
  persistenceId,
@@ -25723,7 +25651,7 @@ const LineChart = (props) => {
25723
25651
  /* @__PURE__ */ jsx(
25724
25652
  Controls,
25725
25653
  {
25726
- ...props,
25654
+ props,
25727
25655
  chartRef,
25728
25656
  state,
25729
25657
  options,
@@ -25733,7 +25661,7 @@ const LineChart = (props) => {
25733
25661
  controlsPortalId
25734
25662
  }
25735
25663
  ),
25736
- table2 && state.showTable ? /* @__PURE__ */ jsx("div", { className: styles$4.table, children: table2 }) : /* @__PURE__ */ jsx(DndProvider, { backend: HTML5Backend, children: /* @__PURE__ */ jsxs("div", { className: styles$4.canvas, id: "canvas", children: [
25664
+ table2 && state.showTable ? /* @__PURE__ */ jsx("div", { className: styles$4.table, children: table2 }) : /* @__PURE__ */ jsx(DndProvider, { backend: HTML5Backend, context: window, children: /* @__PURE__ */ jsxs("div", { className: styles$4.canvas, id: "canvas", children: [
25737
25665
  /* @__PURE__ */ jsx(
25738
25666
  Line,
25739
25667
  {
@@ -25748,6 +25676,7 @@ const LineChart = (props) => {
25748
25676
  showCustomLegend && /* @__PURE__ */ jsx(
25749
25677
  Legend2,
25750
25678
  {
25679
+ props,
25751
25680
  chartRef,
25752
25681
  state,
25753
25682
  options,
@@ -25794,59 +25723,84 @@ const styles$1 = {
25794
25723
  help: help$1,
25795
25724
  autoWeight: autoWeight$1
25796
25725
  };
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
- };
25726
+ const colors$1 = [
25727
+ "#3366cc",
25728
+ "#dc3912",
25729
+ "#ff9900",
25730
+ "#109618",
25731
+ "#990099",
25732
+ "#0099c6",
25733
+ "#dd4477",
25734
+ "#66aa00",
25735
+ "#b82e2e",
25736
+ "#316395",
25737
+ "#994499",
25738
+ "#22aa99",
25739
+ "#aaaa11",
25740
+ "#6633cc",
25741
+ "#e67300",
25742
+ "#8b0707",
25743
+ "#651067",
25744
+ "#329262",
25745
+ "#5574a6",
25746
+ "#3b3eac"
25747
+ ];
25748
+ const generateRandomColor = () => {
25749
+ const color2 = `#${Math.floor(Math.random() * 16777215).toString(16)}`;
25750
+ if (colors$1.includes(color2)) {
25751
+ return generateRandomColor();
25752
+ } else {
25753
+ colors$1.push(color2);
25754
+ return color2;
25755
+ }
25833
25756
  };
25834
25757
  const getDefaultProps$1 = (props) => {
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),
25758
+ props.chart.options = props.chart.options || {};
25759
+ props.chart.options.chartStyling = props.chart.options.chartStyling || {};
25760
+ props.chart.options.tooltip = props.chart.options.tooltip || {};
25761
+ props.chart.options.graph = props.chart.options.graph || {};
25762
+ props.chart.options.legend = props.chart.options.legend || {};
25763
+ props.chart.options.chartOptions = props.chart.options.chartOptions || {};
25764
+ props.chart.options.interactions = props.chart.options.interactions || {};
25765
+ const chart2 = {
25766
+ testId: props.chart.testId ?? null,
25767
+ data: props.chart.data,
25840
25768
  options: {
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)
25769
+ title: props.chart.options.title || "",
25770
+ chartStyling: {
25771
+ width: props.chart.options.chartStyling.width,
25772
+ height: props.chart.options.chartStyling.height,
25773
+ maintainAspectRatio: props.chart.options.chartStyling.maintainAspectRatio || false,
25774
+ staticChartHeight: props.chart.options.chartStyling.staticChartHeight || false,
25775
+ performanceMode: props.chart.options.chartStyling.performanceMode != null ? props.chart.options.chartStyling.performanceMode : true
25776
+ },
25777
+ tooltip: {
25778
+ tooltips: props.chart.options.tooltip.tooltips != null ? props.chart.options.tooltip.tooltips : true,
25779
+ showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false
25780
+ },
25781
+ graph: {
25782
+ showDataLabels: props.chart.options.graph.showDataLabels || false,
25783
+ stacked: props.chart.options.graph.stacked || false,
25784
+ cutout: props.chart.options.graph.cutout || 0
25785
+ },
25786
+ legend: {
25787
+ display: props.chart.options.legend.display != null ? props.chart.options.legend.display : true,
25788
+ useDataset: props.chart.options.legend.useDataset || false,
25789
+ position: props.chart.options.legend.position || "bottom",
25790
+ align: props.chart.options.legend.align || "center"
25791
+ },
25792
+ chartOptions: {
25793
+ enableZoom: props.chart.options.chartOptions.enableZoom || false,
25794
+ enablePan: props.chart.options.chartOptions.enablePan || false
25795
+ },
25796
+ interactions: {
25797
+ onLegendClick: props.chart.options.interactions.onLegendClick,
25798
+ onPieHover: props.chart.options.interactions.onPieHover,
25799
+ onPieUnhover: props.chart.options.interactions.onPieUnhover
25800
+ }
25848
25801
  }
25849
25802
  };
25803
+ return chart2;
25850
25804
  };
25851
25805
  Chart$2.register(
25852
25806
  LinearScale$1,
@@ -25867,25 +25821,25 @@ const PieChart = (props) => {
25867
25821
  const [pointHover, setPointHover] = useState(false);
25868
25822
  const { data, options, testId } = chart2;
25869
25823
  const generateDatasets = (datasets) => {
25870
- const copyDataset = [...datasets];
25824
+ const copyDataset = JSON.parse(JSON.stringify(datasets));
25871
25825
  if (options.graph.stacked) {
25872
25826
  const generatedDataset = {
25873
25827
  label: copyDataset[0].label,
25874
25828
  backgroundColor: [],
25875
25829
  borderColor: [],
25876
- borderWidth: Number(copyDataset[0].borderWidth) || 1,
25830
+ borderWidth: parseFloat(copyDataset[0].borderWidth) || "1",
25877
25831
  data: []
25878
25832
  };
25879
- data.labels.map((_label, labelIndex) => {
25833
+ data.labels.map((label, labelIndex) => {
25880
25834
  copyDataset.map((arc, arcIndex) => {
25881
25835
  generatedDataset.data.push(arc.data[labelIndex]);
25882
25836
  const { backgroundColor } = arc;
25883
25837
  const { borderColor } = arc;
25884
25838
  generatedDataset.backgroundColor.push(
25885
- (Array.isArray(backgroundColor) ? backgroundColor[labelIndex % ((borderColor == null ? void 0 : borderColor.length) || 1)] : backgroundColor) || COLORS[labelIndex] + `${99 - 10 * arcIndex}`
25839
+ (Array.isArray(backgroundColor) ? backgroundColor[labelIndex % borderColor.length] : backgroundColor) || colors$1[labelIndex] + `${99 - 10 * arcIndex}`
25886
25840
  );
25887
25841
  generatedDataset.borderColor.push(
25888
- (Array.isArray(borderColor) ? borderColor[labelIndex % borderColor.length] : borderColor) || COLORS[labelIndex]
25842
+ (Array.isArray(borderColor) ? borderColor[labelIndex % borderColor.length] : borderColor) || colors$1[labelIndex]
25889
25843
  );
25890
25844
  });
25891
25845
  });
@@ -25894,7 +25848,9 @@ const PieChart = (props) => {
25894
25848
  const generatedDatasets2 = copyDataset.map(
25895
25849
  (pieDataset, index2) => {
25896
25850
  const borderWidth = parseFloat(pieDataset.borderWidth) || "1";
25897
- const color2 = pieDataset.data.map((_pie, i2) => COLORS[i2]) || generateRandomColor(COLORS);
25851
+ const color2 = pieDataset.data.map(
25852
+ (_pie, i2) => colors$1[i2] || generateRandomColor()
25853
+ );
25898
25854
  const borderColor = pieDataset.borderColor || color2;
25899
25855
  const backgroundColor = pieDataset.backgroundColor || color2.map((col) => col + `${99 - 11 * index2}`);
25900
25856
  return {
@@ -25914,10 +25870,10 @@ const PieChart = (props) => {
25914
25870
  text: chart2.options.title
25915
25871
  } : {};
25916
25872
  };
25917
- const legendClick = (_e2, legendItem2, legend2) => {
25873
+ const legendClick = (e2, legendItem2, legend2) => {
25918
25874
  const chartInstance = legend2.chart;
25919
25875
  const { datasets } = chartInstance.data;
25920
- const { index: index2 = 0, text = "", hidden = false } = legendItem2 || {};
25876
+ const { index: index2 } = legendItem2;
25921
25877
  if (options.graph.stacked) {
25922
25878
  if (options.legend.useDataset) {
25923
25879
  for (let i2 = 0; i2 < chartInstance.config._config.data.datasets[0].data.length; i2++) {
@@ -25929,7 +25885,7 @@ const PieChart = (props) => {
25929
25885
  }
25930
25886
  } else {
25931
25887
  for (let i2 = 0; i2 < chartInstance.config._config.data.datasets[0].data.length; i2++) {
25932
- if (parseInt(String(i2 / data.datasets.length)) === index2) {
25888
+ if (parseInt(i2 / data.datasets.length) === index2) {
25933
25889
  const meta = chartInstance.getDatasetMeta(0);
25934
25890
  const arc = meta.data[i2];
25935
25891
  arc.hidden = !arc.hidden;
@@ -25955,25 +25911,25 @@ const PieChart = (props) => {
25955
25911
  }
25956
25912
  }
25957
25913
  if (options.interactions.onLegendClick)
25958
- options.interactions.onLegendClick(text, hidden);
25914
+ options.interactions.onLegendClick(legendItem2 == null ? void 0 : legendItem2.text, legendItem2.hidden);
25959
25915
  chartInstance.update();
25960
25916
  };
25961
- const onClick = (_evt, _elements, chartInstance) => {
25917
+ const onClick = (evt, elements, chartInstance) => {
25962
25918
  chartInstance.resetZoom();
25963
25919
  };
25964
25920
  const onHover = (evt, hoveredItems) => {
25965
25921
  if (pointHover && !(hoveredItems == null ? void 0 : hoveredItems.length)) {
25966
25922
  setPointHover(false);
25967
- if (options.interactions.onUnhover) {
25968
- options.interactions.onUnhover(evt);
25923
+ if (options.interactions.onPieUnhover) {
25924
+ options.interactions.onPieUnhover(evt);
25969
25925
  }
25970
25926
  }
25971
25927
  if (!pointHover && (hoveredItems == null ? void 0 : hoveredItems.length)) {
25972
25928
  setPointHover(true);
25973
- if (options.interactions.onHover) {
25929
+ if (options.interactions.onPieHover) {
25974
25930
  const { index: index2, datasetIndex } = hoveredItems[0];
25975
25931
  const generatedDataset = generatedDatasets;
25976
- options.interactions.onHover(
25932
+ options.interactions.onPieHover(
25977
25933
  evt,
25978
25934
  datasetIndex,
25979
25935
  index2,
@@ -25987,7 +25943,7 @@ const PieChart = (props) => {
25987
25943
  display: "auto",
25988
25944
  align: "center",
25989
25945
  anchor: "center",
25990
- formatter: (_value, context) => {
25946
+ formatter: (value, context) => {
25991
25947
  if (context.chart.getDatasetMeta(
25992
25948
  options.graph.stacked ? 0 : context.datasetIndex
25993
25949
  ).data[context.dataIndex].hidden)
@@ -26006,74 +25962,85 @@ const PieChart = (props) => {
26006
25962
  };
26007
25963
  };
26008
25964
  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
- };
26063
25965
  return {
26064
25966
  position: options.legend.position,
26065
25967
  display: options.legend.display,
26066
25968
  align: options.legend.align,
26067
25969
  labels: {
26068
- generateLabels,
25970
+ generateLabels(chartInstance) {
25971
+ if (options.graph.stacked) {
25972
+ const meta = chartInstance.getDatasetMeta(0);
25973
+ if (options.legend.useDataset) {
25974
+ return data.datasets.map((data2, i2) => {
25975
+ var _a2, _b2;
25976
+ const { label } = data2.datasets[i2 % data2.datasets.length];
25977
+ const arc = meta.data[i2];
25978
+ const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
25979
+ const backgroundColor = (_a2 = data2.datasets[i2]) == null ? void 0 : _a2.backgroundColor;
25980
+ const borderColor = (_b2 = data2.datasets[i2]) == null ? void 0 : _b2.borderColor;
25981
+ return {
25982
+ text,
25983
+ fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[0] : backgroundColor) || colors$1[0] + `${99 - 20 * i2}`,
25984
+ strokeStyle: (Array.isArray(borderColor) ? borderColor[0] : borderColor) || colors$1[0],
25985
+ index: i2
25986
+ };
25987
+ });
25988
+ } else {
25989
+ return data.labels.map((data2, i2) => {
25990
+ var _a2, _b2;
25991
+ const label = data2.labels[i2];
25992
+ const arc = meta.data[parseInt(i2 * data2.datasets.length)];
25993
+ const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
25994
+ const backgroundColor = (_a2 = data2.datasets[0]) == null ? void 0 : _a2.backgroundColor;
25995
+ const borderColor = (_b2 = data2.datasets[0]) == null ? void 0 : _b2.borderColor;
25996
+ return {
25997
+ text,
25998
+ fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || colors$1[i2] + "99",
25999
+ strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % backgroundColor.length] : borderColor) || colors$1[i2],
26000
+ index: i2
26001
+ };
26002
+ });
26003
+ }
26004
+ }
26005
+ if (options.legend.useDataset) {
26006
+ return data.datasets.map((dataset, i2) => {
26007
+ var _a2, _b2;
26008
+ const meta = chartInstance.getDatasetMeta(i2);
26009
+ const text = meta.hidden ? dataset.label.split("").reduce((acc, curr) => acc + "-", "") : dataset.label;
26010
+ const backgroundColor = (_a2 = data.datasets[i2]) == null ? void 0 : _a2.backgroundColor;
26011
+ const borderColor = (_b2 = data.datasets[i2]) == null ? void 0 : _b2.borderColor;
26012
+ return {
26013
+ text,
26014
+ fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[0] : backgroundColor) || colors$1[0] + `${99 - 20 * i2}`,
26015
+ strokeStyle: (Array.isArray(borderColor) ? borderColor[0] : borderColor) || colors$1[0],
26016
+ index: i2
26017
+ };
26018
+ });
26019
+ } else {
26020
+ return data.labels.map((label, i2) => {
26021
+ var _a2, _b2;
26022
+ const meta = chartInstance.getDatasetMeta(0);
26023
+ const arc = meta.data[i2];
26024
+ const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
26025
+ const backgroundColor = (_a2 = data.datasets[0]) == null ? void 0 : _a2.backgroundColor;
26026
+ const borderColor = (_b2 = data.datasets[0]) == null ? void 0 : _b2.borderColor;
26027
+ return {
26028
+ text,
26029
+ fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || colors$1[i2] + "99",
26030
+ strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % backgroundColor.length] : borderColor) || colors$1[i2],
26031
+ index: i2
26032
+ };
26033
+ });
26034
+ }
26035
+ },
26069
26036
  boxHeight: 6,
26070
26037
  boxWidth: 6,
26071
26038
  usePointStyle: true,
26072
- filter: (item) => {
26039
+ filter: (item, data2) => {
26073
26040
  var _a2;
26074
26041
  if (!options.legend.useDataset)
26075
26042
  return true;
26076
- return !((_a2 = data.datasets[item.index]) == null ? void 0 : _a2.hideLegend);
26043
+ return !((_a2 = data2.datasets[item.index]) == null ? void 0 : _a2.hideLegend);
26077
26044
  }
26078
26045
  },
26079
26046
  onClick: legendClick
@@ -26084,7 +26051,7 @@ const PieChart = (props) => {
26084
26051
  callbacks: {
26085
26052
  title: (tooltipItem) => {
26086
26053
  const { dataIndex } = tooltipItem[0];
26087
- const index2 = options.graph.stacked ? parseInt(String(dataIndex / data.labels.length)) : dataIndex;
26054
+ const index2 = options.graph.stacked ? parseInt(dataIndex / data.labels.length) : dataIndex;
26088
26055
  const label = data.labels[index2];
26089
26056
  return `${label}`;
26090
26057
  },
@@ -26096,7 +26063,7 @@ const PieChart = (props) => {
26096
26063
  const value = tooltipItem.dataset.data[dataIndex];
26097
26064
  const labelValue = typeof value === "object" ? `${value.value || ""} ${options.tooltip.showLabelsInTooltips && value.label ? "(" + value.label + ")" : ""}` : value;
26098
26065
  const unit = (data == null ? void 0 : data.yUnit) ? `[${data == null ? void 0 : data.yUnit}]` : "";
26099
- const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, 3) : round$2(labelValue, 3);
26066
+ const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, { n: 3 }) : round$2(labelValue, 3);
26100
26067
  return `${dataLabel} ${formattedValue} ${unit}`;
26101
26068
  }
26102
26069
  },
@@ -26138,14 +26105,32 @@ const PieChart = (props) => {
26138
26105
  },
26139
26106
  hover: {
26140
26107
  mode: "nearest",
26141
- intersect: true
26108
+ intersect: "true"
26142
26109
  },
26143
26110
  onHover,
26111
+ elements: {
26112
+ pie: {
26113
+ pointStyle: "circle"
26114
+ }
26115
+ },
26144
26116
  plugins: {
26145
26117
  annotation: false,
26146
26118
  // Disable globally-registered annotation plugin
26147
26119
  title: getTitle2(),
26148
26120
  datalabels: getDatalabels(),
26121
+ // zoom: {
26122
+ // pan: {
26123
+ // enabled: ,
26124
+ // mode: ,
26125
+ // },
26126
+ // zoom: {
26127
+ // drag: {
26128
+ // enabled:,
26129
+ // },
26130
+ // mode: ,
26131
+ // speed: ,
26132
+ // },
26133
+ // },
26149
26134
  tooltip: getToolTips(),
26150
26135
  legend: getLegend2()
26151
26136
  }
@@ -38531,102 +38516,93 @@ const styles = {
38531
38516
  help,
38532
38517
  autoWeight
38533
38518
  };
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
- });
38597
38519
  const getDefaultProps = (props) => {
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,
38520
+ props.chart.options = props.chart.options || {};
38521
+ props.chart.options.axes = props.chart.options.axes || {};
38522
+ props.chart.options.additionalAxesOptions = props.chart.options.additionalAxesOptions || {};
38523
+ props.chart.options.chartStyling = props.chart.options.chartStyling || {};
38524
+ props.chart.options.tooltip = props.chart.options.tooltip || {};
38525
+ props.chart.options.graph = props.chart.options.graph || {};
38526
+ props.chart.options.annotations = props.chart.options.annotations || {};
38527
+ props.chart.options.legend = props.chart.options.legend || {};
38528
+ props.chart.options.legend.customLegend = props.chart.options.legend.customLegend || { customLegendPlugin: null, customLegendContainerID: "" };
38529
+ props.chart.options.chartOptions = props.chart.options.chartOptions || {};
38530
+ props.chart.options.interactions = props.chart.options.interactions || {};
38531
+ props.chart.options.dragData = props.chart.options.dragData || {};
38532
+ const chart2 = {
38533
+ testId: props.chart.testId ?? null,
38534
+ data: props.chart.data,
38603
38535
  options: {
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;
38536
+ title: props.chart.options.title || "",
38537
+ direction: props.chart.options.direction || "vertical",
38538
+ axes: {
38539
+ x: props.chart.options.axes.x || [{}],
38540
+ y: props.chart.options.axes.y || [{}]
38541
+ },
38542
+ additionalAxesOptions: {
38543
+ chartScaleType: props.chart.options.additionalAxesOptions.chartScaleType || "linear",
38544
+ reverse: props.chart.options.additionalAxesOptions.reverse || false,
38545
+ stacked: props.chart.options.additionalAxesOptions.stacked || false,
38546
+ beginAtZero: props.chart.options.additionalAxesOptions.beginAtZero != null ? props.chart.options.additionalAxesOptions.beginAtZero : true,
38547
+ stepSize: props.chart.options.additionalAxesOptions.stepSize,
38548
+ suggestedMin: props.chart.options.additionalAxesOptions.suggestedMin,
38549
+ suggestedMax: props.chart.options.additionalAxesOptions.suggestedMax,
38550
+ min: props.chart.options.additionalAxesOptions.min,
38551
+ max: props.chart.options.additionalAxesOptions.max
38552
+ },
38553
+ chartStyling: {
38554
+ width: props.chart.options.chartStyling.width,
38555
+ height: props.chart.options.chartStyling.height,
38556
+ maintainAspectRatio: props.chart.options.chartStyling.maintainAspectRatio || false,
38557
+ staticChartHeight: props.chart.options.chartStyling.staticChartHeight || false,
38558
+ performanceMode: props.chart.options.chartStyling.performanceMode != null ? props.chart.options.chartStyling.performanceMode : true
38559
+ },
38560
+ tooltip: {
38561
+ tooltips: props.chart.options.tooltip.tooltips != null ? props.chart.options.tooltip.tooltips : true,
38562
+ showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false
38563
+ },
38564
+ graph: {
38565
+ showDataLabels: props.chart.options.graph.showDataLabels || false,
38566
+ showMinorGridlines: props.chart.options.graph.showMinorGridlines || false
38567
+ },
38568
+ annotations: {
38569
+ showAnnotations: props.chart.options.annotations.showAnnotations != null ? props.chart.options.annotations.showAnnotations : true,
38570
+ controlAnnotation: props.chart.options.annotations.controlAnnotation || false,
38571
+ annotationsData: props.chart.options.annotations.annotationsData || []
38572
+ },
38573
+ legend: {
38574
+ display: props.chart.options.legend.display != null ? props.chart.options.legend.display : true,
38575
+ position: props.chart.options.legend.position || "bottom",
38576
+ align: props.chart.options.legend.align || "center",
38577
+ customLegend: props.chart.options.legend.customLegend
38578
+ },
38579
+ chartOptions: {
38580
+ enableZoom: props.chart.options.chartOptions.enableZoom || false,
38581
+ enablePan: props.chart.options.chartOptions.enablePan || false
38582
+ },
38583
+ interactions: {
38584
+ onLegendClick: props.chart.options.interactions.onLegendClick,
38585
+ onBarHover: props.chart.options.interactions.onBarHover,
38586
+ onBarUnhover: props.chart.options.interactions.onBarUnhover
38587
+ },
38588
+ dragData: {
38589
+ enableDragData: props.chart.options.dragData.enableDragData || false,
38590
+ showTooltip: props.chart.options.dragData.showTooltip || true,
38591
+ roundPoints: props.chart.options.dragData.roundPoints || true,
38592
+ dragX: props.chart.options.dragData.dragX || true,
38593
+ dragY: props.chart.options.dragData.dragY || true,
38594
+ onDragStart: props.chart.options.dragData.onDragStart,
38595
+ onDrag: props.chart.options.dragData.onDrag,
38596
+ onDragEnd: props.chart.options.dragData.onDragEnd
38597
+ }
38598
+ }
38599
+ };
38600
+ return chart2;
38601
+ };
38602
+ const getBarChartAxis = (chart2, axisType, currentScales, i2) => {
38603
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
38628
38604
  const isDirectionVertical = isVertical(chart2.options.direction);
38629
- const axisData = currentScale || chart2.options.axes[axisType][0];
38605
+ const axisData = currentScales || chart2.options.axes[axisType][0];
38630
38606
  const isDirectionCompatibleWithAxisType = isDirectionVertical && axisType === AxisType.Y || !isDirectionVertical && axisType === AxisType.X;
38631
38607
  const grid = (axisData == null ? void 0 : axisData.gridLines) || {};
38632
38608
  const getScaleType = () => {
@@ -38647,7 +38623,7 @@ const getBarChartAxis = ({
38647
38623
  return isLogarithmic ? LOGARITHMIC_STEPS.includes(tick) ? formatAxisLabelNumbers(tick, ticks2) : "" : formatAxisLabelNumbers(tick, ticks2);
38648
38624
  };
38649
38625
  const stepSize = !isLogarithmic ? {
38650
- stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions == null ? void 0 : additionalAxesOptions.stepSize : null)
38626
+ stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions.stepSize : null)
38651
38627
  } : {};
38652
38628
  const ticks = {
38653
38629
  ...stepSize,
@@ -38663,68 +38639,56 @@ const getBarChartAxis = ({
38663
38639
  };
38664
38640
  return {
38665
38641
  type: getScaleType(),
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,
38642
+ position: axisData.position,
38643
+ beginAtZero: chart2.options.additionalAxesOptions.beginAtZero,
38668
38644
  reverse: getReverse(),
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,
38645
+ suggestedMax: (_b2 = (_a2 = chart2.options) == null ? void 0 : _a2.additionalAxesOptions) == null ? void 0 : _b2.suggestedMax,
38646
+ suggestedMin: (_d2 = (_c2 = chart2.options) == null ? void 0 : _c2.additionalAxesOptions) == null ? void 0 : _d2.suggestedMin,
38647
+ min: isDirectionCompatibleWithAxisType ? (_f2 = (_e2 = chart2.options) == null ? void 0 : _e2.additionalAxesOptions) == null ? void 0 : _f2.min : void 0,
38648
+ max: isDirectionCompatibleWithAxisType ? (_h2 = (_g2 = chart2.options) == null ? void 0 : _g2.additionalAxesOptions) == null ? void 0 : _h2.max : void 0,
38673
38649
  title: {
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),
38650
+ display: ((_i2 = axisData.label) == null ? void 0 : _i2.length) || ((_j2 = axisData.unit) == null ? void 0 : _j2.length),
38651
+ text: axisData.label || axisData.unit,
38676
38652
  padding: 0
38677
38653
  },
38678
38654
  ticks: getTicks(),
38679
38655
  grid: {
38680
38656
  ...grid
38681
38657
  },
38682
- stacked: (_n2 = (_m2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _m2.additionalAxesOptions) == null ? void 0 : _n2.stacked
38658
+ stacked: chart2.options.additionalAxesOptions.stacked
38683
38659
  };
38684
38660
  };
38685
38661
  const getBarChartAxes = (chart2, axisType) => {
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
- );
38662
+ const axesData = chart2.options.axes[axisType];
38663
+ const axes = axesData.reduce((acc, curr, i2) => {
38664
+ const axisData = curr;
38665
+ const color2 = curr.color || COLORS[i2] || generateRandomColor$1(COLORS);
38666
+ axisData.color = color2;
38667
+ axisData.position = curr.position || getAxisPosition(axisType, i2);
38668
+ const axis = getBarChartAxis(chart2, axisType, axisData);
38669
+ const axisId = i2 === 0 ? axisType : `${axisType}${i2 + 1}`;
38670
+ return { ...acc, [axisId]: axis };
38671
+ }, {});
38700
38672
  return axes;
38701
38673
  };
38702
38674
  const getBarChartScales = (chart2) => {
38703
38675
  var _a2, _b2;
38704
38676
  const hasMultipleXAxes = ((_a2 = chart2.options.axes.x) == null ? void 0 : _a2.length) > 1;
38705
38677
  const hasMultipleYAxes = ((_b2 = chart2.options.axes.y) == null ? void 0 : _b2.length) > 1;
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 }) };
38678
+ const xAxesScales = hasMultipleXAxes ? getBarChartAxes(chart2, AxisType.X) : { x: getBarChartAxis(chart2, AxisType.X) };
38679
+ const yAxesScales = hasMultipleYAxes ? getBarChartAxes(chart2, AxisType.Y) : { y: getBarChartAxis(chart2, AxisType.Y) };
38708
38680
  return {
38709
38681
  ...xAxesScales,
38710
38682
  ...yAxesScales
38711
38683
  };
38712
38684
  };
38713
38685
  const getBarChartToolTips = (options) => {
38714
- var _a2;
38715
38686
  const getTooltipLabels = (dataset) => {
38716
- var _a3, _b2;
38687
+ var _a2, _b2;
38717
38688
  const isDirectionVertical = isVertical(options.direction);
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);
38689
+ const { x: x2, y: y2 } = options.axes;
38690
+ const xIndex = ((_a2 = dataset.xAxisID) == null ? void 0 : _a2.length) > 1 ? dataset.xAxisID[1] - 1 : 0;
38691
+ const yIndex = ((_b2 = dataset.yAxisID) == null ? void 0 : _b2.length) > 1 ? dataset.yAxisID[1] - 1 : 0;
38728
38692
  const xAxis = isDirectionVertical ? x2[xIndex] : y2[yIndex];
38729
38693
  const yAxis = isDirectionVertical ? y2[yIndex] : x2[xIndex];
38730
38694
  return {
@@ -38736,18 +38700,18 @@ const getBarChartToolTips = (options) => {
38736
38700
  valueUnit: (yAxis == null ? void 0 : yAxis.unit) || ""
38737
38701
  };
38738
38702
  };
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);
38703
+ const titleCallback = (tooltipItem, data) => {
38704
+ var _a2;
38705
+ const barLabel = ((_a2 = tooltipItem[0]) == null ? void 0 : _a2.label) || "";
38706
+ const labels = getTooltipLabels(tooltipItem[0].dataset);
38743
38707
  const { titleAxisLabel, titleUnit } = labels;
38744
38708
  const axisLabel = !titleAxisLabel && !titleUnit ? "" : `${titleAxisLabel || titleUnit}: `;
38745
38709
  return axisLabel + barLabel;
38746
38710
  };
38747
38711
  const labelCallback = (tooltipItem) => {
38748
- var _a3;
38749
- const { showLabelsInTooltips = false } = (options == null ? void 0 : options.tooltip) || {};
38750
- let label = ((_a3 = tooltipItem.dataset) == null ? void 0 : _a3.label) || "";
38712
+ var _a2;
38713
+ const { showLabelsInTooltips } = options.tooltip;
38714
+ let label = ((_a2 = tooltipItem.dataset) == null ? void 0 : _a2.label) || "";
38751
38715
  const labels = getTooltipLabels(tooltipItem.dataset);
38752
38716
  const { valueUnit, valueAxisLabel } = labels;
38753
38717
  const getTooltipItemValue = () => {
@@ -38765,12 +38729,9 @@ const getBarChartToolTips = (options) => {
38765
38729
  tooltipItemValue2 = labelNumberFormatted;
38766
38730
  }
38767
38731
  if (Array.isArray(tooltipItem.raw)) {
38768
- tooltipItemValue2 = tooltipItem.raw.reduce(
38769
- (acc, curr, i2) => {
38770
- return i2 === 0 ? `${acc} ${curr}` : `${acc}, ${curr}`;
38771
- },
38772
- ""
38773
- );
38732
+ tooltipItemValue2 = tooltipItem.raw.reduce((acc, curr, i2) => {
38733
+ return i2 === 0 ? `${acc} ${curr}` : `${acc}, ${curr}`;
38734
+ }, "");
38774
38735
  }
38775
38736
  if (typeof tooltipItem.raw === "object") {
38776
38737
  tooltipItemValue2 = formattedValue;
@@ -38785,7 +38746,7 @@ const getBarChartToolTips = (options) => {
38785
38746
  return `${label}: ${tooltipItemValue} ${unit}${valAxisLabel}${tooltipLabel}`;
38786
38747
  };
38787
38748
  return {
38788
- enabled: (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.tooltips,
38749
+ enabled: options.tooltip.tooltips,
38789
38750
  mode: ChartHoverMode.Nearest,
38790
38751
  intersect: true,
38791
38752
  padding: TOOLTIP_PADDING,
@@ -38800,11 +38761,9 @@ const getBarChartToolTips = (options) => {
38800
38761
  };
38801
38762
  };
38802
38763
  const getBarChartDataLabels = (options) => {
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];
38764
+ const { beginAtZero, reverse } = options.additionalAxesOptions;
38765
+ const formatterCallback = (value, context) => {
38766
+ const { dataset, dataIndex } = context;
38808
38767
  const dataElement = dataset.data[dataIndex];
38809
38768
  let dataLabel = "";
38810
38769
  if (typeof dataElement === "number") {
@@ -38819,7 +38778,7 @@ const getBarChartDataLabels = (options) => {
38819
38778
  };
38820
38779
  const beginAtNotZeroAlign = reverse ? AlignOptions.End : AlignOptions.Start;
38821
38780
  const beginAtNotZeroAnchor = reverse ? AlignOptions.Start : AlignOptions.End;
38822
- return ((_a2 = options == null ? void 0 : options.graph) == null ? void 0 : _a2.showDataLabels) ? {
38781
+ return options.graph.showDataLabels ? {
38823
38782
  display: AUTO,
38824
38783
  align: beginAtZero ? AlignOptions.Center : beginAtNotZeroAlign,
38825
38784
  anchor: beginAtZero ? AlignOptions.Center : beginAtNotZeroAnchor,
@@ -38841,7 +38800,6 @@ Chart$2.register(
38841
38800
  Ht
38842
38801
  );
38843
38802
  const BarChart = (props) => {
38844
- var _a2, _b2, _c2;
38845
38803
  setDefaultTheme();
38846
38804
  const chartRef = useRef(null);
38847
38805
  const [pointHover, setPointHover] = useState(false);
@@ -38852,44 +38810,42 @@ const BarChart = (props) => {
38852
38810
  setAnnotations(annotations.annotationsData)
38853
38811
  );
38854
38812
  const generateBarChartDatasets = (datasets) => {
38855
- var _a3;
38813
+ var _a2;
38856
38814
  const barDatasetsCopy = [...datasets];
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
- );
38815
+ if (annotations.controlAnnotation && annotations.showAnnotations && ((_a2 = annotations.annotationsData) == null ? void 0 : _a2.length)) {
38816
+ annotations.annotationsData.forEach((annotation2, index2) => {
38817
+ barDatasetsCopy.push({
38818
+ isAnnotation: true,
38819
+ label: annotation2.label,
38820
+ annotationIndex: index2,
38821
+ backgroundColor: annotation2.color || COLORS[index2],
38822
+ borderColor: annotation2.color || COLORS[index2],
38823
+ data: [],
38824
+ type: ChartType.Bar
38825
+ });
38826
+ });
38871
38827
  }
38872
38828
  const generatedDatasets2 = barDatasetsCopy.map((barDataset, index2) => {
38873
38829
  const colorSchema = COLORS;
38874
38830
  const colors2 = barDataset.data.map((_2, i2) => {
38875
38831
  const colorSelectionIndex = datasets.length > 1 ? index2 : i2;
38876
- return colorSchema[colorSelectionIndex] || generateRandomColor(COLORS);
38832
+ return colorSchema[colorSelectionIndex] || generateRandomColor$1(COLORS);
38877
38833
  });
38878
38834
  const backgroundColors = barDataset.backgroundColor || colors2.map((color2) => color2 + ALPHA_CHANEL);
38879
38835
  return {
38880
38836
  ...barDataset,
38881
- borderWidth: parseFloat(String(barDataset.borderWidth)) ?? 1,
38882
- borderColor: barDataset.borderColor || colors2[index2],
38837
+ borderWidth: parseFloat(barDataset.borderWidth) || "1",
38838
+ borderColor: barDataset.borderColor || colors2,
38883
38839
  backgroundColor: backgroundColors
38884
38840
  };
38885
38841
  });
38886
- return generatedDatasets2 || [];
38842
+ return generatedDatasets2;
38887
38843
  };
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;
38844
+ const generatedDatasets = generateBarChartDatasets(chart2.data.datasets);
38845
+ const legendClick = (e2, legendItem2) => {
38846
+ const index2 = legendItem2.datasetIndex;
38891
38847
  const chartInstance = chartRef.current;
38892
- if (chartInstance && index2 !== null) {
38848
+ if (chartInstance) {
38893
38849
  const { datasets } = chartInstance.data;
38894
38850
  const dataset = datasets[index2];
38895
38851
  const meta = chartInstance.getDatasetMeta(index2);
@@ -38916,30 +38872,27 @@ const BarChart = (props) => {
38916
38872
  });
38917
38873
  }
38918
38874
  if (interactions.onLegendClick) {
38919
- interactions.onLegendClick(
38920
- legendItem2 == null ? void 0 : legendItem2.text,
38921
- (legendItem2 == null ? void 0 : legendItem2.hidden) ?? false
38922
- );
38875
+ interactions.onLegendClick(legendItem2 == null ? void 0 : legendItem2.text, legendItem2.hidden);
38923
38876
  }
38924
38877
  chartInstance.update();
38925
38878
  }
38926
38879
  };
38927
- const onClick = (_evt, _elements, chartInstance) => {
38880
+ const onClick = (evt, elements, chartInstance) => {
38928
38881
  chartInstance.resetZoom();
38929
38882
  };
38930
- const onHover = (evt, hoveredItems) => {
38883
+ const onHover = (evt, hoveredItems, chartInstance) => {
38931
38884
  if (pointHover && !(hoveredItems == null ? void 0 : hoveredItems.length)) {
38932
38885
  setPointHover(false);
38933
- if (interactions.onUnhover) {
38934
- interactions.onUnhover(evt);
38886
+ if (interactions.onBarUnhover) {
38887
+ interactions.onBarUnhover(evt);
38935
38888
  }
38936
38889
  }
38937
38890
  if (!pointHover && (hoveredItems == null ? void 0 : hoveredItems.length)) {
38938
38891
  setPointHover(true);
38939
- if (interactions.onHover) {
38892
+ if (interactions.onBarHover) {
38940
38893
  const { index: index2, datasetIndex } = hoveredItems[0];
38941
38894
  const generatedDataset = generatedDatasets;
38942
- interactions.onHover(evt, datasetIndex, index2, generatedDataset);
38895
+ interactions.onBarHover(evt, datasetIndex, index2, generatedDataset);
38943
38896
  }
38944
38897
  }
38945
38898
  };
@@ -38957,7 +38910,7 @@ const BarChart = (props) => {
38957
38910
  {
38958
38911
  ref: chartRef,
38959
38912
  data: {
38960
- labels: ((_c2 = (_b2 = chart2 == null ? void 0 : chart2.data) == null ? void 0 : _b2.labels) == null ? void 0 : _c2.length) ? chart2.data.labels : [""],
38913
+ labels: chart2.data.labels.length ? chart2.data.labels : [""],
38961
38914
  datasets: generatedDatasets
38962
38915
  },
38963
38916
  options: {
@@ -38972,9 +38925,9 @@ const BarChart = (props) => {
38972
38925
  mode: ChartHoverMode.Nearest,
38973
38926
  intersect: true
38974
38927
  },
38975
- // elements: {
38976
- // bar: { pointStyle: PointStyle.Circle },
38977
- // },
38928
+ elements: {
38929
+ bar: { pointStyle: PointStyle.Circle }
38930
+ },
38978
38931
  scales: getBarChartScales(chart2),
38979
38932
  plugins: {
38980
38933
  title: getTitle(options),