@oliasoft-open-source/charts-library 4.8.0-beta-8 → 4.8.1-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 (30) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +314 -176
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/bar-chart/bar-chart.stories.d.ts +2 -2
  5. package/dist/src/components/bar-chart/utils/use-bar-chart-options.d.ts +6 -6
  6. package/dist/src/components/common/common.interface.d.ts +2 -2
  7. package/dist/src/components/common/helpers/chart-consts.d.ts +1 -1
  8. package/dist/src/components/common/helpers/chart-utils.d.ts +2 -2
  9. package/dist/src/components/common/helpers/get-chart-annotation.d.ts +13 -13
  10. package/dist/src/components/common/hooks/use-legend-state.d.ts +3 -3
  11. package/dist/src/components/common/hooks/use-legend.d.ts +2 -3
  12. package/dist/src/components/common/legend-component/legend-panel.d.ts +1 -2
  13. package/dist/src/components/common/legend-component/state/legend-context.d.ts +1 -1
  14. package/dist/src/components/common/plugins/annotation-dragger-plugin/event-helpers.d.ts +2 -2
  15. package/dist/src/components/common/plugins/annotation-dragger-plugin/helpers.d.ts +2 -2
  16. package/dist/src/components/common/plugins/annotation-dragger-plugin/point-annotation-label.d.ts +1 -1
  17. package/dist/src/components/line-chart/line-chart.stories.d.ts +2 -2
  18. package/dist/src/components/line-chart/line-chart.test-case.stories.d.ts +1 -1
  19. package/dist/src/components/line-chart/utils/get-axes-ranges-from-chart.d.ts +1 -1
  20. package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +1 -1
  21. package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +1 -1
  22. package/dist/src/components/pie-chart/pie-chart.stories.d.ts +1 -1
  23. package/dist/src/components/pie-chart/use-pie-chart-config.d.ts +2 -2
  24. package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +8 -8
  25. package/dist/src/components/scatter-chart/scatter-chart-get-default-props.d.ts +1 -1
  26. package/dist/src/components/scatter-chart/scatter-chart.d.ts +1 -1
  27. package/dist/src/components/scatter-chart/scatter-chart.stories.d.ts +1 -1
  28. package/dist/src/components/scatter-chart/utils/get-scales-config.d.ts +1 -1
  29. package/dist/src/components/scatter-chart/utils/get-tooltip-config.d.ts +2 -2
  30. package/package.json +10 -9
package/dist/index.js CHANGED
@@ -11,9 +11,9 @@ import cx from "classnames";
11
11
  import { Portal, Icon, Menu, Tooltip as Tooltip$2, Button, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer, Flex, Text } from "@oliasoft-open-source/react-ui-library";
12
12
  import { isEmpty, isArray as isArray$2, some, has, isNil, cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, map as map$3, find, get as get$1, noop as noop$2 } from "lodash";
13
13
  /*!
14
- * @kurkle/color v0.3.2
14
+ * @kurkle/color v0.3.4
15
15
  * https://github.com/kurkle/color#readme
16
- * (c) 2023 Jukka Kurkela
16
+ * (c) 2024 Jukka Kurkela
17
17
  * Released under the MIT License
18
18
  */
19
19
  function round$1(v2) {
@@ -2341,9 +2341,9 @@ function parseMaxStyle$1(styleValue, node, parentProperty) {
2341
2341
  }
2342
2342
  return valueInPixels;
2343
2343
  }
2344
- const getComputedStyle$1 = (element) => element.ownerDocument.defaultView.getComputedStyle(element, null);
2344
+ const getComputedStyle$2 = (element) => element.ownerDocument.defaultView.getComputedStyle(element, null);
2345
2345
  function getStyle$1(el, property) {
2346
- return getComputedStyle$1(el).getPropertyValue(property);
2346
+ return getComputedStyle$2(el).getPropertyValue(property);
2347
2347
  }
2348
2348
  const positions$2 = [
2349
2349
  "top",
@@ -2389,7 +2389,7 @@ function getRelativePosition$2(event, chart2) {
2389
2389
  return event;
2390
2390
  }
2391
2391
  const { canvas: canvas2, currentDevicePixelRatio } = chart2;
2392
- const style = getComputedStyle$1(canvas2);
2392
+ const style = getComputedStyle$2(canvas2);
2393
2393
  const borderBox = style.boxSizing === "border-box";
2394
2394
  const paddings = getPositionedStyle$1(style, "padding");
2395
2395
  const borders = getPositionedStyle$1(style, "border", "width");
@@ -2415,7 +2415,7 @@ function getContainerSize$1(canvas2, width, height) {
2415
2415
  height = canvas2.clientHeight;
2416
2416
  } else {
2417
2417
  const rect = container.getBoundingClientRect();
2418
- const containerStyle = getComputedStyle$1(container);
2418
+ const containerStyle = getComputedStyle$2(container);
2419
2419
  const containerBorder = getPositionedStyle$1(containerStyle, "border", "width");
2420
2420
  const containerPadding = getPositionedStyle$1(containerStyle, "padding");
2421
2421
  width = rect.width - containerPadding.width - containerBorder.width;
@@ -2433,7 +2433,7 @@ function getContainerSize$1(canvas2, width, height) {
2433
2433
  }
2434
2434
  const round1$1 = (v2) => Math.round(v2 * 10) / 10;
2435
2435
  function getMaximumSize$1(canvas2, bbWidth, bbHeight, aspectRatio) {
2436
- const style = getComputedStyle$1(canvas2);
2436
+ const style = getComputedStyle$2(canvas2);
2437
2437
  const margins = getPositionedStyle$1(style, "margin");
2438
2438
  const maxWidth = parseMaxStyle$1(style.maxWidth, canvas2, "clientWidth") || INFINITY$1;
2439
2439
  const maxHeight = parseMaxStyle$1(style.maxHeight, canvas2, "clientHeight") || INFINITY$1;
@@ -5242,7 +5242,6 @@ function getAxisItems$1(chart2, position, axis, intersect, useFinalPosition) {
5242
5242
  return items;
5243
5243
  }
5244
5244
  var Interaction$1 = {
5245
- evaluateInteractionItems: evaluateInteractionItems$1,
5246
5245
  modes: {
5247
5246
  index(chart2, e2, options, useFinalPosition) {
5248
5247
  const position = getRelativePosition$2(e2, chart2);
@@ -5504,7 +5503,6 @@ function placeBoxes$1(boxes, chartArea, params, stacks) {
5504
5503
  for (const layout2 of boxes) {
5505
5504
  const box = layout2.box;
5506
5505
  const stack = stacks[layout2.stack] || {
5507
- count: 1,
5508
5506
  placed: 0,
5509
5507
  weight: 1
5510
5508
  };
@@ -14923,9 +14921,9 @@ var hammer = { exports: {} };
14923
14921
  var hammerExports = hammer.exports;
14924
14922
  const Hammer = /* @__PURE__ */ getDefaultExportFromCjs(hammerExports);
14925
14923
  /*!
14926
- * chartjs-plugin-zoom v2.0.1
14927
- * undefined
14928
- * (c) 2016-2023 chartjs-plugin-zoom Contributors
14924
+ * chartjs-plugin-zoom v2.2.0
14925
+ * https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
14926
+ * (c) 2016-2024 chartjs-plugin-zoom Contributors
14929
14927
  * Released under the MIT License
14930
14928
  */
14931
14929
  const getModifierKey = (opts) => opts && opts.enabled && opts.modifierKey;
@@ -15002,7 +15000,9 @@ function getState(chart2) {
15002
15000
  originalScaleLimits: {},
15003
15001
  updatedScaleLimits: {},
15004
15002
  handlers: {},
15005
- panDelta: {}
15003
+ panDelta: {},
15004
+ dragging: false,
15005
+ panning: false
15006
15006
  };
15007
15007
  chartStates$1.set(chart2, state);
15008
15008
  }
@@ -15011,20 +15011,43 @@ function getState(chart2) {
15011
15011
  function removeState(chart2) {
15012
15012
  chartStates$1.delete(chart2);
15013
15013
  }
15014
- function zoomDelta(scale, zoom2, center) {
15015
- const range = scale.max - scale.min;
15016
- const newRange = range * (zoom2 - 1);
15017
- const centerPoint = scale.isHorizontal() ? center.x : center.y;
15018
- const minPercent = Math.max(0, Math.min(
15019
- 1,
15020
- (scale.getValueForPixel(centerPoint) - scale.min) / range || 0
15021
- ));
15014
+ function zoomDelta(val, min, range, newRange) {
15015
+ const minPercent = Math.max(0, Math.min(1, (val - min) / range || 0));
15022
15016
  const maxPercent = 1 - minPercent;
15023
15017
  return {
15024
15018
  min: newRange * minPercent,
15025
15019
  max: newRange * maxPercent
15026
15020
  };
15027
15021
  }
15022
+ function getValueAtPoint(scale, point) {
15023
+ const pixel = scale.isHorizontal() ? point.x : point.y;
15024
+ return scale.getValueForPixel(pixel);
15025
+ }
15026
+ function linearZoomDelta(scale, zoom2, center) {
15027
+ const range = scale.max - scale.min;
15028
+ const newRange = range * (zoom2 - 1);
15029
+ const centerValue = getValueAtPoint(scale, center);
15030
+ return zoomDelta(centerValue, scale.min, range, newRange);
15031
+ }
15032
+ function logarithmicZoomRange(scale, zoom2, center) {
15033
+ const centerValue = getValueAtPoint(scale, center);
15034
+ if (centerValue === void 0) {
15035
+ return { min: scale.min, max: scale.max };
15036
+ }
15037
+ const logMin = Math.log10(scale.min);
15038
+ const logMax = Math.log10(scale.max);
15039
+ const logCenter = Math.log10(centerValue);
15040
+ const logRange = logMax - logMin;
15041
+ const newLogRange = logRange * (zoom2 - 1);
15042
+ const delta = zoomDelta(logCenter, logMin, logRange, newLogRange);
15043
+ return {
15044
+ min: Math.pow(10, logMin + delta.min),
15045
+ max: Math.pow(10, logMax - delta.max)
15046
+ };
15047
+ }
15048
+ function getScaleLimits$1(scale, limits) {
15049
+ return limits && (limits[scale.id] || limits[scale.axis]) || {};
15050
+ }
15028
15051
  function getLimit(state, scale, scaleLimits, prop, fallback) {
15029
15052
  let limit = scaleLimits[prop];
15030
15053
  if (limit === "original") {
@@ -15033,7 +15056,7 @@ function getLimit(state, scale, scaleLimits, prop, fallback) {
15033
15056
  }
15034
15057
  return valueOrDefault$1(limit, fallback);
15035
15058
  }
15036
- function getRange(scale, pixel0, pixel1) {
15059
+ function linearRange(scale, pixel0, pixel1) {
15037
15060
  const v0 = scale.getValueForPixel(pixel0);
15038
15061
  const v1 = scale.getValueForPixel(pixel1);
15039
15062
  return {
@@ -15041,17 +15064,19 @@ function getRange(scale, pixel0, pixel1) {
15041
15064
  max: Math.max(v0, v1)
15042
15065
  };
15043
15066
  }
15044
- function updateRange(scale, { min, max }, limits, zoom2 = false) {
15045
- const state = getState(scale.chart);
15046
- const { id, axis, options: scaleOpts } = scale;
15047
- const scaleLimits = limits && (limits[id] || limits[axis]) || {};
15048
- const { minRange = 0 } = scaleLimits;
15049
- const minLimit = getLimit(state, scale, scaleLimits, "min", -Infinity);
15050
- const maxLimit = getLimit(state, scale, scaleLimits, "max", Infinity);
15051
- const range = zoom2 ? Math.max(max - min, minRange) : scale.max - scale.min;
15067
+ function fixRange(range, { min, max, minLimit, maxLimit }, originalLimits) {
15052
15068
  const offset = (range - max + min) / 2;
15053
15069
  min -= offset;
15054
15070
  max += offset;
15071
+ const origMin = originalLimits.min.options ?? originalLimits.min.scale;
15072
+ const origMax = originalLimits.max.options ?? originalLimits.max.scale;
15073
+ const epsilon = range / 1e6;
15074
+ if (almostEquals$1(min, origMin, epsilon)) {
15075
+ min = origMin;
15076
+ }
15077
+ if (almostEquals$1(max, origMax, epsilon)) {
15078
+ max = origMax;
15079
+ }
15055
15080
  if (min < minLimit) {
15056
15081
  min = minLimit;
15057
15082
  max = Math.min(minLimit + range, maxLimit);
@@ -15059,18 +15084,40 @@ function updateRange(scale, { min, max }, limits, zoom2 = false) {
15059
15084
  max = maxLimit;
15060
15085
  min = Math.max(maxLimit - range, minLimit);
15061
15086
  }
15062
- scaleOpts.min = min;
15063
- scaleOpts.max = max;
15064
- state.updatedScaleLimits[scale.id] = { min, max };
15065
- return scale.parse(min) !== scale.min || scale.parse(max) !== scale.max;
15087
+ return { min, max };
15088
+ }
15089
+ function updateRange(scale, { min, max }, limits, zoom2 = false) {
15090
+ const state = getState(scale.chart);
15091
+ const { options: scaleOpts } = scale;
15092
+ const scaleLimits = getScaleLimits$1(scale, limits);
15093
+ const { minRange = 0 } = scaleLimits;
15094
+ const minLimit = getLimit(state, scale, scaleLimits, "min", -Infinity);
15095
+ const maxLimit = getLimit(state, scale, scaleLimits, "max", Infinity);
15096
+ if (zoom2 === "pan" && (min < minLimit || max > maxLimit)) {
15097
+ return true;
15098
+ }
15099
+ const scaleRange = scale.max - scale.min;
15100
+ const range = zoom2 ? Math.max(max - min, minRange) : scaleRange;
15101
+ if (zoom2 && range === minRange && scaleRange <= minRange) {
15102
+ return true;
15103
+ }
15104
+ const newRange = fixRange(range, { min, max, minLimit, maxLimit }, state.originalScaleLimits[scale.id]);
15105
+ scaleOpts.min = newRange.min;
15106
+ scaleOpts.max = newRange.max;
15107
+ state.updatedScaleLimits[scale.id] = newRange;
15108
+ return scale.parse(newRange.min) !== scale.min || scale.parse(newRange.max) !== scale.max;
15066
15109
  }
15067
15110
  function zoomNumericalScale(scale, zoom2, center, limits) {
15068
- const delta = zoomDelta(scale, zoom2, center);
15111
+ const delta = linearZoomDelta(scale, zoom2, center);
15069
15112
  const newRange = { min: scale.min + delta.min, max: scale.max - delta.max };
15070
15113
  return updateRange(scale, newRange, limits, true);
15071
15114
  }
15115
+ function zoomLogarithmicScale(scale, zoom2, center, limits) {
15116
+ const newRange = logarithmicZoomRange(scale, zoom2, center);
15117
+ return updateRange(scale, newRange, limits, true);
15118
+ }
15072
15119
  function zoomRectNumericalScale(scale, from2, to2, limits) {
15073
- updateRange(scale, getRange(scale, from2, to2), limits, true);
15120
+ updateRange(scale, linearRange(scale, from2, to2), limits, true);
15074
15121
  }
15075
15122
  const integerChange = (v2) => v2 === 0 || isNaN(v2) ? 0 : v2 < 0 ? Math.min(Math.round(v2), -1) : Math.max(Math.round(v2), 1);
15076
15123
  function existCategoryFromMaxZoom(scale) {
@@ -15084,7 +15131,7 @@ function existCategoryFromMaxZoom(scale) {
15084
15131
  }
15085
15132
  }
15086
15133
  function zoomCategoryScale(scale, zoom2, center, limits) {
15087
- const delta = zoomDelta(scale, zoom2, center);
15134
+ const delta = linearZoomDelta(scale, zoom2, center);
15088
15135
  if (scale.min === scale.max && zoom2 < 1) {
15089
15136
  existCategoryFromMaxZoom(scale);
15090
15137
  }
@@ -15115,40 +15162,32 @@ function panCategoryScale(scale, delta, limits) {
15115
15162
  }
15116
15163
  const OFFSETS = {
15117
15164
  second: 500,
15118
- // 500 ms
15119
15165
  minute: 30 * 1e3,
15120
- // 30 s
15121
15166
  hour: 30 * 60 * 1e3,
15122
- // 30 m
15123
15167
  day: 12 * 60 * 60 * 1e3,
15124
- // 12 h
15125
15168
  week: 3.5 * 24 * 60 * 60 * 1e3,
15126
- // 3.5 d
15127
15169
  month: 15 * 24 * 60 * 60 * 1e3,
15128
- // 15 d
15129
15170
  quarter: 60 * 24 * 60 * 60 * 1e3,
15130
- // 60 d
15131
15171
  year: 182 * 24 * 60 * 60 * 1e3
15132
- // 182 d
15133
15172
  };
15134
- function panNumericalScale(scale, delta, limits, canZoom = false) {
15173
+ function panNumericalScale(scale, delta, limits, pan2 = false) {
15135
15174
  const { min: prevStart, max: prevEnd, options } = scale;
15136
15175
  const round2 = options.time && options.time.round;
15137
15176
  const offset = OFFSETS[round2] || 0;
15138
15177
  const newMin = scale.getValueForPixel(scale.getPixelForValue(prevStart + offset) - delta);
15139
15178
  const newMax = scale.getValueForPixel(scale.getPixelForValue(prevEnd + offset) - delta);
15140
- const { min: minLimit = -Infinity, max: maxLimit = Infinity } = canZoom && limits && limits[scale.axis] || {};
15141
- if (isNaN(newMin) || isNaN(newMax) || newMin < minLimit || newMax > maxLimit) {
15179
+ if (isNaN(newMin) || isNaN(newMax)) {
15142
15180
  return true;
15143
15181
  }
15144
- return updateRange(scale, { min: newMin, max: newMax }, limits, canZoom);
15182
+ return updateRange(scale, { min: newMin, max: newMax }, limits, pan2 ? "pan" : false);
15145
15183
  }
15146
15184
  function panNonLinearScale(scale, delta, limits) {
15147
15185
  return panNumericalScale(scale, delta, limits, true);
15148
15186
  }
15149
15187
  const zoomFunctions = {
15150
15188
  category: zoomCategoryScale,
15151
- default: zoomNumericalScale
15189
+ default: zoomNumericalScale,
15190
+ logarithmic: zoomLogarithmicScale
15152
15191
  };
15153
15192
  const zoomRectFunctions = {
15154
15193
  default: zoomRectNumericalScale
@@ -15193,9 +15232,9 @@ function doZoom(scale, amount, center, limits) {
15193
15232
  const fn = zoomFunctions[scale.type] || zoomFunctions.default;
15194
15233
  callback$1(fn, [scale, amount, center, limits]);
15195
15234
  }
15196
- function doZoomRect(scale, amount, from2, to2, limits) {
15235
+ function doZoomRect(scale, from2, to2, limits) {
15197
15236
  const fn = zoomRectFunctions[scale.type] || zoomRectFunctions.default;
15198
- callback$1(fn, [scale, amount, from2, to2, limits]);
15237
+ callback$1(fn, [scale, from2, to2, limits]);
15199
15238
  }
15200
15239
  function getCenter(chart2) {
15201
15240
  const ca = chart2.chartArea;
@@ -15204,7 +15243,7 @@ function getCenter(chart2) {
15204
15243
  y: (ca.top + ca.bottom) / 2
15205
15244
  };
15206
15245
  }
15207
- function zoom(chart2, amount, transition = "none") {
15246
+ function zoom(chart2, amount, transition = "none", trigger = "api") {
15208
15247
  const { x: x2 = 1, y: y2 = 1, focalPoint = getCenter(chart2) } = typeof amount === "number" ? { x: amount, y: amount } : amount;
15209
15248
  const state = getState(chart2);
15210
15249
  const { options: { limits, zoom: zoomOptions } } = state;
@@ -15220,9 +15259,9 @@ function zoom(chart2, amount, transition = "none") {
15220
15259
  }
15221
15260
  });
15222
15261
  chart2.update(transition);
15223
- callback$1(zoomOptions.onZoom, [{ chart: chart2 }]);
15262
+ callback$1(zoomOptions.onZoom, [{ chart: chart2, trigger }]);
15224
15263
  }
15225
- function zoomRect(chart2, p0, p1, transition = "none") {
15264
+ function zoomRect(chart2, p0, p1, transition = "none", trigger = "api") {
15226
15265
  const state = getState(chart2);
15227
15266
  const { options: { limits, zoom: zoomOptions } } = state;
15228
15267
  const { mode = "xy" } = zoomOptions;
@@ -15237,13 +15276,16 @@ function zoomRect(chart2, p0, p1, transition = "none") {
15237
15276
  }
15238
15277
  });
15239
15278
  chart2.update(transition);
15240
- callback$1(zoomOptions.onZoom, [{ chart: chart2 }]);
15279
+ callback$1(zoomOptions.onZoom, [{ chart: chart2, trigger }]);
15241
15280
  }
15242
- function zoomScale(chart2, scaleId, range, transition = "none") {
15243
- storeOriginalScaleLimits(chart2, getState(chart2));
15281
+ function zoomScale(chart2, scaleId, range, transition = "none", trigger = "api") {
15282
+ var _a2;
15283
+ const state = getState(chart2);
15284
+ storeOriginalScaleLimits(chart2, state);
15244
15285
  const scale = chart2.scales[scaleId];
15245
15286
  updateRange(scale, range, void 0, true);
15246
15287
  chart2.update(transition);
15288
+ callback$1((_a2 = state.options.zoom) == null ? void 0 : _a2.onZoom, [{ chart: chart2, trigger }]);
15247
15289
  }
15248
15290
  function resetZoom(chart2, transition = "default") {
15249
15291
  const state = getState(chart2);
@@ -15257,6 +15299,7 @@ function resetZoom(chart2, transition = "default") {
15257
15299
  delete scaleOptions.min;
15258
15300
  delete scaleOptions.max;
15259
15301
  }
15302
+ delete state.updatedScaleLimits[scale.id];
15260
15303
  });
15261
15304
  chart2.update(transition);
15262
15305
  callback$1(state.options.zoom.onZoomComplete, [{ chart: chart2 }]);
@@ -15324,6 +15367,14 @@ function getInitialScaleBounds(chart2) {
15324
15367
  }
15325
15368
  return scaleBounds;
15326
15369
  }
15370
+ function getZoomedScaleBounds(chart2) {
15371
+ const state = getState(chart2);
15372
+ const scaleBounds = {};
15373
+ for (const scaleId of Object.keys(chart2.scales)) {
15374
+ scaleBounds[scaleId] = state.updatedScaleLimits[scaleId];
15375
+ }
15376
+ return scaleBounds;
15377
+ }
15327
15378
  function isZoomedOrPanned(chart2) {
15328
15379
  const scaleBounds = getInitialScaleBounds(chart2);
15329
15380
  for (const scaleId of Object.keys(chart2.scales)) {
@@ -15337,6 +15388,11 @@ function isZoomedOrPanned(chart2) {
15337
15388
  }
15338
15389
  return false;
15339
15390
  }
15391
+ function isZoomingOrPanning(chart2) {
15392
+ const state = getState(chart2);
15393
+ return state.panning || state.dragging;
15394
+ }
15395
+ const clamp$1 = (x2, from2, to2) => Math.min(to2, Math.max(from2, x2));
15340
15396
  function removeHandler(chart2, type) {
15341
15397
  const { handlers } = getState(chart2);
15342
15398
  const handler = handlers[type];
@@ -15354,7 +15410,8 @@ function addHandler(chart2, target, type, handler) {
15354
15410
  removeHandler(chart2, type);
15355
15411
  handlers[type] = (event) => handler(chart2, event, options);
15356
15412
  handlers[type].target = target;
15357
- target.addEventListener(type, handlers[type]);
15413
+ const passive = type === "wheel" ? false : void 0;
15414
+ target.addEventListener(type, handlers[type], { passive });
15358
15415
  }
15359
15416
  function mouseMove(chart2, event) {
15360
15417
  const state = getState(chart2);
@@ -15374,10 +15431,20 @@ function keyDown(chart2, event) {
15374
15431
  state.dragStart = state.dragEnd = null;
15375
15432
  chart2.update("none");
15376
15433
  }
15434
+ function getPointPosition(event, chart2) {
15435
+ if (event.target !== chart2.canvas) {
15436
+ const canvasArea = chart2.canvas.getBoundingClientRect();
15437
+ return {
15438
+ x: event.clientX - canvasArea.left,
15439
+ y: event.clientY - canvasArea.top
15440
+ };
15441
+ }
15442
+ return getRelativePosition$2(event, chart2);
15443
+ }
15377
15444
  function zoomStart(chart2, event, zoomOptions) {
15378
15445
  const { onZoomStart, onZoomRejected } = zoomOptions;
15379
15446
  if (onZoomStart) {
15380
- const point = getRelativePosition$2(event, chart2);
15447
+ const point = getPointPosition(event, chart2);
15381
15448
  if (callback$1(onZoomStart, [{ chart: chart2, event, point }]) === false) {
15382
15449
  callback$1(onZoomRejected, [{ chart: chart2, event }]);
15383
15450
  return false;
@@ -15385,6 +15452,12 @@ function zoomStart(chart2, event, zoomOptions) {
15385
15452
  }
15386
15453
  }
15387
15454
  function mouseDown(chart2, event) {
15455
+ if (chart2.legend) {
15456
+ const point = getRelativePosition$2(event, chart2);
15457
+ if (_isPointInArea$1(point, chart2.legend)) {
15458
+ return;
15459
+ }
15460
+ }
15388
15461
  const state = getState(chart2);
15389
15462
  const { pan: panOptions, zoom: zoomOptions = {} } = state.options;
15390
15463
  if (event.button !== 0 || keyPressed(getModifierKey(panOptions), event) || keyNotPressed(getModifierKey(zoomOptions.drag), event)) {
@@ -15394,30 +15467,52 @@ function mouseDown(chart2, event) {
15394
15467
  return;
15395
15468
  }
15396
15469
  state.dragStart = event;
15397
- addHandler(chart2, chart2.canvas, "mousemove", mouseMove);
15470
+ addHandler(chart2, chart2.canvas.ownerDocument, "mousemove", mouseMove);
15398
15471
  addHandler(chart2, window.document, "keydown", keyDown);
15399
15472
  }
15400
- function computeDragRect(chart2, mode, beginPointEvent, endPointEvent) {
15473
+ function applyAspectRatio({ begin, end }, aspectRatio) {
15474
+ let width = end.x - begin.x;
15475
+ let height = end.y - begin.y;
15476
+ const ratio = Math.abs(width / height);
15477
+ if (ratio > aspectRatio) {
15478
+ width = Math.sign(width) * Math.abs(height * aspectRatio);
15479
+ } else if (ratio < aspectRatio) {
15480
+ height = Math.sign(height) * Math.abs(width / aspectRatio);
15481
+ }
15482
+ end.x = begin.x + width;
15483
+ end.y = begin.y + height;
15484
+ }
15485
+ function applyMinMaxProps(rect, chartArea, points, { min, max, prop }) {
15486
+ rect[min] = clamp$1(Math.min(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
15487
+ rect[max] = clamp$1(Math.max(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
15488
+ }
15489
+ function getRelativePoints(chart2, pointEvents, maintainAspectRatio) {
15490
+ const points = {
15491
+ begin: getPointPosition(pointEvents.dragStart, chart2),
15492
+ end: getPointPosition(pointEvents.dragEnd, chart2)
15493
+ };
15494
+ if (maintainAspectRatio) {
15495
+ const aspectRatio = chart2.chartArea.width / chart2.chartArea.height;
15496
+ applyAspectRatio(points, aspectRatio);
15497
+ }
15498
+ return points;
15499
+ }
15500
+ function computeDragRect(chart2, mode, pointEvents, maintainAspectRatio) {
15401
15501
  const xEnabled = directionEnabled(mode, "x", chart2);
15402
15502
  const yEnabled = directionEnabled(mode, "y", chart2);
15403
- let { top: top2, left: left2, right: right2, bottom: bottom2, width: chartWidth, height: chartHeight } = chart2.chartArea;
15404
- const beginPoint = getRelativePosition$2(beginPointEvent, chart2);
15405
- const endPoint = getRelativePosition$2(endPointEvent, chart2);
15503
+ const { top: top2, left: left2, right: right2, bottom: bottom2, width: chartWidth, height: chartHeight } = chart2.chartArea;
15504
+ const rect = { top: top2, left: left2, right: right2, bottom: bottom2 };
15505
+ const points = getRelativePoints(chart2, pointEvents, maintainAspectRatio && xEnabled && yEnabled);
15406
15506
  if (xEnabled) {
15407
- left2 = Math.min(beginPoint.x, endPoint.x);
15408
- right2 = Math.max(beginPoint.x, endPoint.x);
15507
+ applyMinMaxProps(rect, chart2.chartArea, points, { min: "left", max: "right", prop: "x" });
15409
15508
  }
15410
15509
  if (yEnabled) {
15411
- top2 = Math.min(beginPoint.y, endPoint.y);
15412
- bottom2 = Math.max(beginPoint.y, endPoint.y);
15510
+ applyMinMaxProps(rect, chart2.chartArea, points, { min: "top", max: "bottom", prop: "y" });
15413
15511
  }
15414
- const width = right2 - left2;
15415
- const height = bottom2 - top2;
15512
+ const width = rect.right - rect.left;
15513
+ const height = rect.bottom - rect.top;
15416
15514
  return {
15417
- left: left2,
15418
- top: top2,
15419
- right: right2,
15420
- bottom: bottom2,
15515
+ ...rect,
15421
15516
  width,
15422
15517
  height,
15423
15518
  zoomX: xEnabled && width ? 1 + (chartWidth - width) / chartWidth : 1,
@@ -15430,8 +15525,8 @@ function mouseUp(chart2, event) {
15430
15525
  return;
15431
15526
  }
15432
15527
  removeHandler(chart2, "mousemove");
15433
- const { mode, onZoomComplete, drag: { threshold = 0 } } = state.options.zoom;
15434
- const rect = computeDragRect(chart2, mode, state.dragStart, event);
15528
+ const { mode, onZoomComplete, drag: { threshold = 0, maintainAspectRatio } } = state.options.zoom;
15529
+ const rect = computeDragRect(chart2, mode, { dragStart: state.dragStart, dragEnd: event }, maintainAspectRatio);
15435
15530
  const distanceX = directionEnabled(mode, "x", chart2) ? rect.width : 0;
15436
15531
  const distanceY = directionEnabled(mode, "y", chart2) ? rect.height : 0;
15437
15532
  const distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
@@ -15441,8 +15536,9 @@ function mouseUp(chart2, event) {
15441
15536
  chart2.update("none");
15442
15537
  return;
15443
15538
  }
15444
- zoomRect(chart2, { x: rect.left, y: rect.top }, { x: rect.right, y: rect.bottom }, "zoom");
15445
- setTimeout(() => state.dragging = false, 500);
15539
+ zoomRect(chart2, { x: rect.left, y: rect.top }, { x: rect.right, y: rect.bottom }, "zoom", "drag");
15540
+ state.dragging = false;
15541
+ state.filterNextClick = true;
15446
15542
  callback$1(onZoomComplete, [{ chart: chart2 }]);
15447
15543
  }
15448
15544
  function wheelPreconditions(chart2, event, zoomOptions) {
@@ -15467,19 +15563,18 @@ function wheel(chart2, event) {
15467
15563
  return;
15468
15564
  }
15469
15565
  const rect = event.target.getBoundingClientRect();
15470
- const speed = 1 + (event.deltaY >= 0 ? -zoomOptions.wheel.speed : zoomOptions.wheel.speed);
15566
+ const speed = zoomOptions.wheel.speed;
15567
+ const percentage = event.deltaY >= 0 ? 2 - 1 / (1 - speed) : 1 + speed;
15471
15568
  const amount = {
15472
- x: speed,
15473
- y: speed,
15569
+ x: percentage,
15570
+ y: percentage,
15474
15571
  focalPoint: {
15475
15572
  x: event.clientX - rect.left,
15476
15573
  y: event.clientY - rect.top
15477
15574
  }
15478
15575
  };
15479
- zoom(chart2, amount);
15480
- if (onZoomComplete) {
15481
- onZoomComplete();
15482
- }
15576
+ zoom(chart2, amount, "zoom", "wheel");
15577
+ callback$1(onZoomComplete, [{ chart: chart2 }]);
15483
15578
  }
15484
15579
  function addDebouncedHandler(chart2, name, handler, delay) {
15485
15580
  if (handler) {
@@ -15559,13 +15654,19 @@ function handlePinch(chart2, state, e2) {
15559
15654
  y: center.y - rect.top
15560
15655
  }
15561
15656
  };
15562
- zoom(chart2, amount);
15657
+ zoom(chart2, amount, "zoom", "pinch");
15563
15658
  state.scale = e2.scale;
15564
15659
  }
15565
15660
  }
15566
- function startPinch(chart2, state) {
15661
+ function startPinch(chart2, state, event) {
15567
15662
  if (state.options.zoom.pinch.enabled) {
15568
- state.scale = 1;
15663
+ const point = getRelativePosition$2(event, chart2);
15664
+ if (callback$1(state.options.zoom.onZoomStart, [{ chart: chart2, event, point }]) === false) {
15665
+ state.scale = null;
15666
+ callback$1(state.options.zoom.onZoomRejected, [{ chart: chart2, event }]);
15667
+ } else {
15668
+ state.scale = 1;
15669
+ }
15569
15670
  }
15570
15671
  }
15571
15672
  function endPinch(chart2, state, e2) {
@@ -15598,13 +15699,13 @@ function startPan(chart2, state, event) {
15598
15699
  }
15599
15700
  state.panScales = getEnabledScalesByPoint(state.options.pan, point, chart2);
15600
15701
  state.delta = { x: 0, y: 0 };
15601
- clearTimeout(state.panEndTimeout);
15602
15702
  handlePan(chart2, state, event);
15603
15703
  }
15604
15704
  function endPan(chart2, state) {
15605
15705
  state.delta = null;
15606
15706
  if (state.panning) {
15607
- state.panEndTimeout = setTimeout(() => state.panning = false, 500);
15707
+ state.panning = false;
15708
+ state.filterNextClick = true;
15608
15709
  callback$1(state.options.pan.onPanComplete, [{ chart: chart2 }]);
15609
15710
  }
15610
15711
  }
@@ -15616,7 +15717,7 @@ function startHammer(chart2, options) {
15616
15717
  const mc = new Hammer.Manager(canvas2);
15617
15718
  if (zoomOptions && zoomOptions.pinch.enabled) {
15618
15719
  mc.add(new Hammer.Pinch());
15619
- mc.on("pinchstart", () => startPinch(chart2, state));
15720
+ mc.on("pinchstart", (e2) => startPinch(chart2, state, e2));
15620
15721
  mc.on("pinch", (e2) => handlePinch(chart2, state, e2));
15621
15722
  mc.on("pinchend", (e2) => endPinch(chart2, state, e2));
15622
15723
  }
@@ -15644,14 +15745,29 @@ function stopHammer(chart2) {
15644
15745
  hammers.delete(chart2);
15645
15746
  }
15646
15747
  }
15647
- var version$2 = "2.0.1";
15748
+ function hammerOptionsChanged(oldOptions, newOptions) {
15749
+ var _a2, _b2, _c2, _d2;
15750
+ const { pan: oldPan, zoom: oldZoom } = oldOptions;
15751
+ const { pan: newPan, zoom: newZoom } = newOptions;
15752
+ if (((_b2 = (_a2 = oldZoom == null ? void 0 : oldZoom.zoom) == null ? void 0 : _a2.pinch) == null ? void 0 : _b2.enabled) !== ((_d2 = (_c2 = newZoom == null ? void 0 : newZoom.zoom) == null ? void 0 : _c2.pinch) == null ? void 0 : _d2.enabled)) {
15753
+ return true;
15754
+ }
15755
+ if ((oldPan == null ? void 0 : oldPan.enabled) !== (newPan == null ? void 0 : newPan.enabled)) {
15756
+ return true;
15757
+ }
15758
+ if ((oldPan == null ? void 0 : oldPan.threshold) !== (newPan == null ? void 0 : newPan.threshold)) {
15759
+ return true;
15760
+ }
15761
+ return false;
15762
+ }
15763
+ var version$2 = "2.2.0";
15648
15764
  function draw$2(chart2, caller, options) {
15649
15765
  const dragOptions = options.zoom.drag;
15650
15766
  const { dragStart, dragEnd } = getState(chart2);
15651
15767
  if (dragOptions.drawTime !== caller || !dragEnd) {
15652
15768
  return;
15653
15769
  }
15654
- const { left: left2, top: top2, width, height } = computeDragRect(chart2, options.zoom.mode, dragStart, dragEnd);
15770
+ const { left: left2, top: top2, width, height } = computeDragRect(chart2, options.zoom.mode, { dragStart, dragEnd }, dragOptions.maintainAspectRatio);
15655
15771
  const ctx = chart2.ctx;
15656
15772
  ctx.save();
15657
15773
  ctx.beginPath();
@@ -15710,17 +15826,30 @@ var plugin$1 = {
15710
15826
  chart2.resetZoom = (transition) => resetZoom(chart2, transition);
15711
15827
  chart2.getZoomLevel = () => getZoomLevel(chart2);
15712
15828
  chart2.getInitialScaleBounds = () => getInitialScaleBounds(chart2);
15829
+ chart2.getZoomedScaleBounds = () => getZoomedScaleBounds(chart2);
15713
15830
  chart2.isZoomedOrPanned = () => isZoomedOrPanned(chart2);
15831
+ chart2.isZoomingOrPanning = () => isZoomingOrPanning(chart2);
15714
15832
  },
15715
- beforeEvent(chart2) {
15716
- const state = getState(chart2);
15717
- if (state.panning || state.dragging) {
15833
+ beforeEvent(chart2, { event }) {
15834
+ if (isZoomingOrPanning(chart2)) {
15718
15835
  return false;
15719
15836
  }
15837
+ if (event.type === "click" || event.type === "mouseup") {
15838
+ const state = getState(chart2);
15839
+ if (state.filterNextClick) {
15840
+ state.filterNextClick = false;
15841
+ return false;
15842
+ }
15843
+ }
15720
15844
  },
15721
15845
  beforeUpdate: function(chart2, args, options) {
15722
15846
  const state = getState(chart2);
15847
+ const previousOptions = state.options;
15723
15848
  state.options = options;
15849
+ if (hammerOptionsChanged(previousOptions, options)) {
15850
+ stopHammer(chart2);
15851
+ startHammer(chart2, options);
15852
+ }
15724
15853
  addListeners(chart2, options);
15725
15854
  },
15726
15855
  beforeDatasetsDraw(chart2, _args, options) {
@@ -17632,7 +17761,7 @@ function resolveLimitedLineProperties(scales, area, options) {
17632
17761
  }
17633
17762
  function calculateX({ properties, options }, labelSize, position, padding) {
17634
17763
  const { x: start, x2: end, width: size } = properties;
17635
- return calculatePosition({ start, end, size, borderWidth: options.borderWidth }, {
17764
+ return calculatePosition({ start, end, borderWidth: options.borderWidth }, {
17636
17765
  position: position.x,
17637
17766
  padding: { start: padding.left, end: padding.right },
17638
17767
  adjust: options.label.xAdjust,
@@ -17641,7 +17770,7 @@ function calculateX({ properties, options }, labelSize, position, padding) {
17641
17770
  }
17642
17771
  function calculateY({ properties, options }, labelSize, position, padding) {
17643
17772
  const { y: start, y2: end, height: size } = properties;
17644
- return calculatePosition({ start, end, size, borderWidth: options.borderWidth }, {
17773
+ return calculatePosition({ start, end, borderWidth: options.borderWidth }, {
17645
17774
  position: position.y,
17646
17775
  padding: { start: padding.top, end: padding.bottom },
17647
17776
  adjust: options.label.yAdjust,
@@ -19237,10 +19366,7 @@ var randomString = function randomString2() {
19237
19366
  };
19238
19367
  var ActionTypes = {
19239
19368
  INIT: "@@redux/INIT" + randomString(),
19240
- REPLACE: "@@redux/REPLACE" + randomString(),
19241
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
19242
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
19243
- }
19369
+ REPLACE: "@@redux/REPLACE" + randomString()
19244
19370
  };
19245
19371
  function isPlainObject(obj) {
19246
19372
  if (typeof obj !== "object" || obj === null) return false;
@@ -22390,10 +22516,6 @@ const canvas$2 = "_canvas_e3qdd_11";
22390
22516
  const fixedHeight$3 = "_fixedHeight_e3qdd_20";
22391
22517
  const stretchHeight$3 = "_stretchHeight_e3qdd_26";
22392
22518
  const squareAspectRatio$1 = "_squareAspectRatio_e3qdd_32";
22393
- const zoomForm$3 = "_zoomForm_e3qdd_43";
22394
- const zoomReset$3 = "_zoomReset_e3qdd_51";
22395
- const help$3 = "_help_e3qdd_54";
22396
- const autoWeight$3 = "_autoWeight_e3qdd_58";
22397
22519
  const table = "_table_e3qdd_62";
22398
22520
  const styles$5 = {
22399
22521
  chart: chart$3,
@@ -22401,10 +22523,6 @@ const styles$5 = {
22401
22523
  fixedHeight: fixedHeight$3,
22402
22524
  stretchHeight: stretchHeight$3,
22403
22525
  squareAspectRatio: squareAspectRatio$1,
22404
- zoomForm: zoomForm$3,
22405
- zoomReset: zoomReset$3,
22406
- help: help$3,
22407
- autoWeight: autoWeight$3,
22408
22526
  table
22409
22527
  };
22410
22528
  const TOGGLE_ZOOM = "TOGGLE_ZOOM";
@@ -22718,7 +22836,6 @@ const WHITE_COLOR_AS_DECIMAL = 16777215;
22718
22836
  const AUTO = "auto";
22719
22837
  const ANIMATION_DURATION = {
22720
22838
  NO: 0,
22721
- SLOW: 400,
22722
22839
  FAST: 1e3
22723
22840
  };
22724
22841
  const DEFAULT_CHART_NAME = "new_chart";
@@ -23197,31 +23314,31 @@ function IconBase(props) {
23197
23314
  }) : elem(DefaultContext);
23198
23315
  }
23199
23316
  function TbArrowsMove(props) {
23200
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M18 9l3 3l-3 3" } }, { "tag": "path", "attr": { "d": "M15 12h6" } }, { "tag": "path", "attr": { "d": "M6 9l-3 3l3 3" } }, { "tag": "path", "attr": { "d": "M3 12h6" } }, { "tag": "path", "attr": { "d": "M9 18l3 3l3 -3" } }, { "tag": "path", "attr": { "d": "M12 15v6" } }, { "tag": "path", "attr": { "d": "M15 6l-3 -3l-3 3" } }, { "tag": "path", "attr": { "d": "M12 3v6" } }] })(props);
23317
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M18 9l3 3l-3 3" } }, { "tag": "path", "attr": { "d": "M15 12h6" } }, { "tag": "path", "attr": { "d": "M6 9l-3 3l3 3" } }, { "tag": "path", "attr": { "d": "M3 12h6" } }, { "tag": "path", "attr": { "d": "M9 18l3 3l3 -3" } }, { "tag": "path", "attr": { "d": "M12 15v6" } }, { "tag": "path", "attr": { "d": "M15 6l-3 -3l-3 3" } }, { "tag": "path", "attr": { "d": "M12 3v6" } }] })(props);
23201
23318
  }
23202
23319
  function TbBan(props) {
23203
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" } }, { "tag": "path", "attr": { "d": "M5.7 5.7l12.6 12.6" } }] })(props);
23320
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" } }, { "tag": "path", "attr": { "d": "M5.7 5.7l12.6 12.6" } }] })(props);
23204
23321
  }
23205
23322
  function TbCircleFilled(props) {
23206
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M7 3.34a10 10 0 1 1 -4.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 4.995 -8.336z", "strokeWidth": "0", "fill": "currentColor" } }] })(props);
23323
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M7 3.34a10 10 0 1 1 -4.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 4.995 -8.336z", "strokeWidth": "0", "fill": "currentColor" } }] })(props);
23207
23324
  }
23208
23325
  function TbHandStop(props) {
23209
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5" } }, { "tag": "path", "attr": { "d": "M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5" } }, { "tag": "path", "attr": { "d": "M14 5.5a1.5 1.5 0 0 1 3 0v6.5" } }, { "tag": "path", "attr": { "d": "M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47" } }] })(props);
23326
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5" } }, { "tag": "path", "attr": { "d": "M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5" } }, { "tag": "path", "attr": { "d": "M14 5.5a1.5 1.5 0 0 1 3 0v6.5" } }, { "tag": "path", "attr": { "d": "M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47" } }] })(props);
23210
23327
  }
23211
23328
  function TbList(props) {
23212
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M9 6l11 0" } }, { "tag": "path", "attr": { "d": "M9 12l11 0" } }, { "tag": "path", "attr": { "d": "M9 18l11 0" } }, { "tag": "path", "attr": { "d": "M5 6l0 .01" } }, { "tag": "path", "attr": { "d": "M5 12l0 .01" } }, { "tag": "path", "attr": { "d": "M5 18l0 .01" } }] })(props);
23329
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M9 6l11 0" } }, { "tag": "path", "attr": { "d": "M9 12l11 0" } }, { "tag": "path", "attr": { "d": "M9 18l11 0" } }, { "tag": "path", "attr": { "d": "M5 6l0 .01" } }, { "tag": "path", "attr": { "d": "M5 12l0 .01" } }, { "tag": "path", "attr": { "d": "M5 18l0 .01" } }] })(props);
23213
23330
  }
23214
23331
  function TbRuler(props) {
23215
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M5 4h14a1 1 0 0 1 1 1v5a1 1 0 0 1 -1 1h-7a1 1 0 0 0 -1 1v7a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1" } }, { "tag": "path", "attr": { "d": "M4 8l2 0" } }, { "tag": "path", "attr": { "d": "M4 12l3 0" } }, { "tag": "path", "attr": { "d": "M4 16l2 0" } }, { "tag": "path", "attr": { "d": "M8 4l0 2" } }, { "tag": "path", "attr": { "d": "M12 4l0 3" } }, { "tag": "path", "attr": { "d": "M16 4l0 2" } }] })(props);
23332
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M5 4h14a1 1 0 0 1 1 1v5a1 1 0 0 1 -1 1h-7a1 1 0 0 0 -1 1v7a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1" } }, { "tag": "path", "attr": { "d": "M4 8l2 0" } }, { "tag": "path", "attr": { "d": "M4 12l3 0" } }, { "tag": "path", "attr": { "d": "M4 16l2 0" } }, { "tag": "path", "attr": { "d": "M8 4l0 2" } }, { "tag": "path", "attr": { "d": "M12 4l0 3" } }, { "tag": "path", "attr": { "d": "M16 4l0 2" } }] })(props);
23216
23333
  }
23217
23334
  function TbSquareFilled(props) {
23218
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M19 2h-14a3 3 0 0 0 -3 3v14a3 3 0 0 0 3 3h14a3 3 0 0 0 3 -3v-14a3 3 0 0 0 -3 -3z", "strokeWidth": "0", "fill": "currentColor" } }] })(props);
23335
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M19 2h-14a3 3 0 0 0 -3 3v14a3 3 0 0 0 3 3h14a3 3 0 0 0 3 -3v-14a3 3 0 0 0 -3 -3z", "strokeWidth": "0", "fill": "currentColor" } }] })(props);
23219
23336
  }
23220
23337
  function TbX(props) {
23221
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M18 6l-12 12" } }, { "tag": "path", "attr": { "d": "M6 6l12 12" } }] })(props);
23338
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M18 6l-12 12" } }, { "tag": "path", "attr": { "d": "M6 6l12 12" } }] })(props);
23222
23339
  }
23223
23340
  function TbZoomIn(props) {
23224
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0" } }, { "tag": "path", "attr": { "d": "M7 10l6 0" } }, { "tag": "path", "attr": { "d": "M10 7l0 6" } }, { "tag": "path", "attr": { "d": "M21 21l-6 -6" } }] })(props);
23341
+ return GenIcon({ "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0" } }, { "tag": "path", "attr": { "d": "M7 10l6 0" } }, { "tag": "path", "attr": { "d": "M10 7l0 6" } }, { "tag": "path", "attr": { "d": "M21 21l-6 -6" } }] })(props);
23225
23342
  }
23226
23343
  function getDragOptions({
23227
23344
  onTogglePan,
@@ -23442,8 +23559,11 @@ function checkCanvasDimensions(canvas2) {
23442
23559
  function createImage(url) {
23443
23560
  return new Promise((resolve2, reject) => {
23444
23561
  const img = new Image();
23445
- img.decode = () => resolve2(img);
23446
- img.onload = () => resolve2(img);
23562
+ img.onload = () => {
23563
+ img.decode().then(() => {
23564
+ requestAnimationFrame(() => resolve2(img));
23565
+ });
23566
+ };
23447
23567
  img.onerror = reject;
23448
23568
  img.crossOrigin = "anonymous";
23449
23569
  img.decoding = "async";
@@ -23647,11 +23767,15 @@ async function cloneSingleNode(node, options) {
23647
23767
  if (isInstanceOfElement(node, HTMLIFrameElement)) {
23648
23768
  return cloneIFrameElement(node);
23649
23769
  }
23650
- return node.cloneNode(false);
23770
+ return node.cloneNode(isSVGElement(node));
23651
23771
  }
23652
23772
  const isSlotElement = (node) => node.tagName != null && node.tagName.toUpperCase() === "SLOT";
23773
+ const isSVGElement = (node) => node.tagName != null && node.tagName.toUpperCase() === "SVG";
23653
23774
  async function cloneChildren(nativeNode, clonedNode, options) {
23654
23775
  var _a2, _b2;
23776
+ if (isSVGElement(clonedNode)) {
23777
+ return clonedNode;
23778
+ }
23655
23779
  let children = [];
23656
23780
  if (isSlotElement(nativeNode) && nativeNode.assignedNodes) {
23657
23781
  children = toArray(nativeNode.assignedNodes());
@@ -23844,7 +23968,13 @@ async function embedImageNode(clonedNode, options) {
23844
23968
  const dataURL = await resourceToDataURL(url, getMimeType(url), options);
23845
23969
  await new Promise((resolve2, reject) => {
23846
23970
  clonedNode.onload = resolve2;
23847
- clonedNode.onerror = reject;
23971
+ clonedNode.onerror = options.onImageErrorHandler ? (...attributes) => {
23972
+ try {
23973
+ resolve2(options.onImageErrorHandler(...attributes));
23974
+ } catch (error) {
23975
+ reject(error);
23976
+ }
23977
+ } : reject;
23848
23978
  const image = clonedNode;
23849
23979
  if (image.decode) {
23850
23980
  image.decode = resolve2;
@@ -24018,9 +24148,29 @@ async function parseWebFontRules(node, options) {
24018
24148
  const cssRules = await getCSSRules(styleSheets, options);
24019
24149
  return getWebFontRules(cssRules);
24020
24150
  }
24151
+ function normalizeFontFamily(font) {
24152
+ return font.trim().replace(/["']/g, "");
24153
+ }
24154
+ function getUsedFonts(node) {
24155
+ const fonts = /* @__PURE__ */ new Set();
24156
+ function traverse(node2) {
24157
+ const fontFamily = node2.style.fontFamily || getComputedStyle(node2).fontFamily;
24158
+ fontFamily.split(",").forEach((font) => {
24159
+ fonts.add(normalizeFontFamily(font));
24160
+ });
24161
+ Array.from(node2.children).forEach((child) => {
24162
+ if (child instanceof HTMLElement) {
24163
+ traverse(child);
24164
+ }
24165
+ });
24166
+ }
24167
+ traverse(node);
24168
+ return fonts;
24169
+ }
24021
24170
  async function getWebFontCSS(node, options) {
24022
24171
  const rules = await parseWebFontRules(node, options);
24023
- const cssTexts = await Promise.all(rules.map((rule) => {
24172
+ const usedFonts = getUsedFonts(node);
24173
+ const cssTexts = await Promise.all(rules.filter((rule) => usedFonts.has(normalizeFontFamily(rule.style.fontFamily))).map((rule) => {
24024
24174
  const baseUrl = rule.parentStyleSheet ? rule.parentStyleSheet.href : null;
24025
24175
  return embedResources(rule.cssText, baseUrl, options);
24026
24176
  }));
@@ -26175,22 +26325,37 @@ const useUpdateAxesRanges = ({
26175
26325
  const useSaveInitialAxesRanges = (chartRef, dispatch, generatedDatasets) => {
26176
26326
  var _a2;
26177
26327
  const prevDatasets = useRef(null);
26328
+ const getDatasetsHash = (datasets) => {
26329
+ if (!datasets.length) return "";
26330
+ const datasetHashes = datasets.map((dataset) => {
26331
+ const data = dataset.data ?? [];
26332
+ if (!data.length) return "empty";
26333
+ const firstDataPoint = data.at(0);
26334
+ const lastDataPoint = data.at(-1);
26335
+ return `${firstDataPoint}-${lastDataPoint}`;
26336
+ });
26337
+ return `${datasets.length}-${datasetHashes.join("|")}`;
26338
+ };
26178
26339
  useEffect(() => {
26179
- var _a3, _b2;
26180
- if (((_a3 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _a3.scales) && !isEqual(prevDatasets.current, generatedDatasets)) {
26181
- const scales = ((_b2 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _b2.scales) ?? {};
26182
- const initialAxesRanges = Object.entries(scales).map(
26183
- ([id, { min, max, _range: range }]) => ({
26184
- id,
26185
- min: (range == null ? void 0 : range.min) ?? min,
26186
- max: (range == null ? void 0 : range.max) ?? max
26187
- })
26188
- );
26189
- dispatch({
26190
- type: SAVE_INITIAL_AXES_RANGES,
26191
- payload: { initialAxesRanges }
26192
- });
26193
- prevDatasets.current = generatedDatasets;
26340
+ var _a3;
26341
+ if ((_a3 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _a3.scales) {
26342
+ const prevHash = prevDatasets.current ? getDatasetsHash(prevDatasets.current) : "";
26343
+ const currentHash = getDatasetsHash(generatedDatasets);
26344
+ if (prevHash !== currentHash) {
26345
+ const scales = chartRef.current.scales;
26346
+ const initialAxesRanges = Object.entries(scales).map(
26347
+ ([id, { min, max, _range: range }]) => ({
26348
+ id,
26349
+ min: (range == null ? void 0 : range.min) ?? min,
26350
+ max: (range == null ? void 0 : range.max) ?? max
26351
+ })
26352
+ );
26353
+ dispatch({
26354
+ type: SAVE_INITIAL_AXES_RANGES,
26355
+ payload: { initialAxesRanges }
26356
+ });
26357
+ prevDatasets.current = generatedDatasets;
26358
+ }
26194
26359
  }
26195
26360
  }, [(_a2 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _a2.scales, generatedDatasets]);
26196
26361
  };
@@ -26850,7 +27015,6 @@ const legendItemBox = "_legendItemBox_wpro0_90";
26850
27015
  const legendItemLine = "_legendItemLine_wpro0_95";
26851
27016
  const legendItemPoint = "_legendItemPoint_wpro0_103";
26852
27017
  const legendItemText = "_legendItemText_wpro0_110";
26853
- const scrollbars = "_scrollbars_wpro0_113";
26854
27018
  const dropzoneContainer = "_dropzoneContainer_wpro0_140";
26855
27019
  const dropzone = "_dropzone_wpro0_140";
26856
27020
  const left = "_left_wpro0_149";
@@ -26872,7 +27036,6 @@ const styles$3 = {
26872
27036
  legendItemLine,
26873
27037
  legendItemPoint,
26874
27038
  legendItemText,
26875
- scrollbars,
26876
27039
  dropzoneContainer,
26877
27040
  dropzone,
26878
27041
  left,
@@ -27412,18 +27575,10 @@ const initializeLineChart = ({ languageKey = "en", ...options }) => {
27412
27575
  const chart$2 = "_chart_1jdnu_1";
27413
27576
  const fixedHeight$2 = "_fixedHeight_1jdnu_13";
27414
27577
  const stretchHeight$2 = "_stretchHeight_1jdnu_19";
27415
- const zoomForm$2 = "_zoomForm_1jdnu_32";
27416
- const zoomReset$2 = "_zoomReset_1jdnu_40";
27417
- const help$2 = "_help_1jdnu_43";
27418
- const autoWeight$2 = "_autoWeight_1jdnu_47";
27419
27578
  const styles$2 = {
27420
27579
  chart: chart$2,
27421
27580
  fixedHeight: fixedHeight$2,
27422
- stretchHeight: stretchHeight$2,
27423
- zoomForm: zoomForm$2,
27424
- zoomReset: zoomReset$2,
27425
- help: help$2,
27426
- autoWeight: autoWeight$2
27581
+ stretchHeight: stretchHeight$2
27427
27582
  };
27428
27583
  const defaultChartStyling$2 = (styling) => ({
27429
27584
  width: styling == null ? void 0 : styling.width,
@@ -29779,9 +29934,9 @@ function parseMaxStyle(styleValue, node, parentProperty) {
29779
29934
  }
29780
29935
  return valueInPixels;
29781
29936
  }
29782
- const getComputedStyle = (element) => window.getComputedStyle(element, null);
29937
+ const getComputedStyle$1 = (element) => window.getComputedStyle(element, null);
29783
29938
  function getStyle(el, property) {
29784
- return getComputedStyle(el).getPropertyValue(property);
29939
+ return getComputedStyle$1(el).getPropertyValue(property);
29785
29940
  }
29786
29941
  const positions = ["top", "right", "bottom", "left"];
29787
29942
  function getPositionedStyle(styles2, style, suffix) {
@@ -29818,7 +29973,7 @@ function getRelativePosition(evt, chart2) {
29818
29973
  return evt;
29819
29974
  }
29820
29975
  const { canvas: canvas2, currentDevicePixelRatio } = chart2;
29821
- const style = getComputedStyle(canvas2);
29976
+ const style = getComputedStyle$1(canvas2);
29822
29977
  const borderBox = style.boxSizing === "border-box";
29823
29978
  const paddings = getPositionedStyle(style, "padding");
29824
29979
  const borders = getPositionedStyle(style, "border", "width");
@@ -29844,7 +29999,7 @@ function getContainerSize(canvas2, width, height) {
29844
29999
  height = canvas2.clientHeight;
29845
30000
  } else {
29846
30001
  const rect = container.getBoundingClientRect();
29847
- const containerStyle = getComputedStyle(container);
30002
+ const containerStyle = getComputedStyle$1(container);
29848
30003
  const containerBorder = getPositionedStyle(containerStyle, "border", "width");
29849
30004
  const containerPadding = getPositionedStyle(containerStyle, "padding");
29850
30005
  width = rect.width - containerPadding.width - containerBorder.width;
@@ -29862,7 +30017,7 @@ function getContainerSize(canvas2, width, height) {
29862
30017
  }
29863
30018
  const round1 = (v2) => Math.round(v2 * 10) / 10;
29864
30019
  function getMaximumSize(canvas2, bbWidth, bbHeight, aspectRatio) {
29865
- const style = getComputedStyle(canvas2);
30020
+ const style = getComputedStyle$1(canvas2);
29866
30021
  const margins = getPositionedStyle(style, "margin");
29867
30022
  const maxWidth = parseMaxStyle(style.maxWidth, canvas2, "clientWidth") || INFINITY;
29868
30023
  const maxHeight = parseMaxStyle(style.maxHeight, canvas2, "clientHeight") || INFINITY;
@@ -34503,7 +34658,6 @@ function getAxisItems(chart2, position, axis, intersect, useFinalPosition) {
34503
34658
  return items;
34504
34659
  }
34505
34660
  var Interaction = {
34506
- evaluateInteractionItems,
34507
34661
  modes: {
34508
34662
  index(chart2, e2, options, useFinalPosition) {
34509
34663
  const position = getRelativePosition(e2, chart2);
@@ -34730,7 +34884,7 @@ function placeBoxes(boxes, chartArea, params, stacks) {
34730
34884
  let { x: x2, y: y2 } = chartArea;
34731
34885
  for (const layout2 of boxes) {
34732
34886
  const box = layout2.box;
34733
- const stack = stacks[layout2.stack] || { count: 1, placed: 0, weight: 1 };
34887
+ const stack = stacks[layout2.stack] || { placed: 0, weight: 1 };
34734
34888
  const weight = layout2.stackWeight / stack.weight || 1;
34735
34889
  if (layout2.horizontal) {
34736
34890
  const width = chartArea.w * weight;
@@ -40357,20 +40511,12 @@ const chart$1 = "_chart_x1sru_1";
40357
40511
  const canvas$1 = "_canvas_x1sru_10";
40358
40512
  const fixedHeight$1 = "_fixedHeight_x1sru_19";
40359
40513
  const stretchHeight$1 = "_stretchHeight_x1sru_25";
40360
- const zoomForm$1 = "_zoomForm_x1sru_38";
40361
- const zoomReset$1 = "_zoomReset_x1sru_46";
40362
- const help$1 = "_help_x1sru_49";
40363
- const autoWeight$1 = "_autoWeight_x1sru_53";
40364
40514
  const actions = "_actions_x1sru_57";
40365
40515
  const styles$1 = {
40366
40516
  chart: chart$1,
40367
40517
  canvas: canvas$1,
40368
40518
  fixedHeight: fixedHeight$1,
40369
40519
  stretchHeight: stretchHeight$1,
40370
- zoomForm: zoomForm$1,
40371
- zoomReset: zoomReset$1,
40372
- help: help$1,
40373
- autoWeight: autoWeight$1,
40374
40520
  actions
40375
40521
  };
40376
40522
  const defaultAxes$1 = (axes) => ({
@@ -40887,20 +41033,12 @@ const canvas = "_canvas_1qlu1_11";
40887
41033
  const fixedHeight = "_fixedHeight_1qlu1_20";
40888
41034
  const stretchHeight = "_stretchHeight_1qlu1_26";
40889
41035
  const squareAspectRatio = "_squareAspectRatio_1qlu1_32";
40890
- const zoomForm = "_zoomForm_1qlu1_43";
40891
- const zoomReset = "_zoomReset_1qlu1_51";
40892
- const help = "_help_1qlu1_54";
40893
- const autoWeight = "_autoWeight_1qlu1_58";
40894
41036
  const styles = {
40895
41037
  chart,
40896
41038
  canvas,
40897
41039
  fixedHeight,
40898
41040
  stretchHeight,
40899
- squareAspectRatio,
40900
- zoomForm,
40901
- zoomReset,
40902
- help,
40903
- autoWeight
41041
+ squareAspectRatio
40904
41042
  };
40905
41043
  Chart$2.register(
40906
41044
  LinearScale$1,