@oliasoft-open-source/charts-library 5.0.8-beta-1 → 5.1.0-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.js CHANGED
@@ -572,7 +572,7 @@ let Color$1 = class Color {
572
572
  }
573
573
  };
574
574
  /*!
575
- * Chart.js v4.4.9
575
+ * Chart.js v4.4.8
576
576
  * https://www.chartjs.org
577
577
  * (c) 2025 Chart.js Contributors
578
578
  * Released under the MIT License
@@ -2899,36 +2899,8 @@ function styleChanged$1(style, prevStyle) {
2899
2899
  };
2900
2900
  return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
2901
2901
  }
2902
- function getSizeForArea(scale, chartArea, field) {
2903
- return scale.options.clip ? scale[field] : chartArea[field];
2904
- }
2905
- function getDatasetArea(meta, chartArea) {
2906
- const { xScale, yScale } = meta;
2907
- if (xScale && yScale) {
2908
- return {
2909
- left: getSizeForArea(xScale, chartArea, "left"),
2910
- right: getSizeForArea(xScale, chartArea, "right"),
2911
- top: getSizeForArea(yScale, chartArea, "top"),
2912
- bottom: getSizeForArea(yScale, chartArea, "bottom")
2913
- };
2914
- }
2915
- return chartArea;
2916
- }
2917
- function getDatasetClipArea(chart2, meta) {
2918
- const clip = meta._clip;
2919
- if (clip.disabled) {
2920
- return false;
2921
- }
2922
- const area = getDatasetArea(meta, chart2.chartArea);
2923
- return {
2924
- left: clip.left === false ? 0 : area.left - (clip.left === true ? 0 : clip.left),
2925
- right: clip.right === false ? chart2.width : area.right + (clip.right === true ? 0 : clip.right),
2926
- top: clip.top === false ? 0 : area.top - (clip.top === true ? 0 : clip.top),
2927
- bottom: clip.bottom === false ? chart2.height : area.bottom + (clip.bottom === true ? 0 : clip.bottom)
2928
- };
2929
- }
2930
2902
  /*!
2931
- * Chart.js v4.4.9
2903
+ * Chart.js v4.4.8
2932
2904
  * https://www.chartjs.org
2933
2905
  * (c) 2025 Chart.js Contributors
2934
2906
  * Released under the MIT License
@@ -8030,7 +8002,7 @@ function needContext$1(proxy, names2) {
8030
8002
  }
8031
8003
  return false;
8032
8004
  }
8033
- var version$3 = "4.4.9";
8005
+ var version$3 = "4.4.8";
8034
8006
  const KNOWN_POSITIONS$1 = [
8035
8007
  "top",
8036
8008
  "bottom",
@@ -8099,6 +8071,21 @@ function determineLastEvent$1(e2, lastEvent, inChartArea, isClick) {
8099
8071
  }
8100
8072
  return e2;
8101
8073
  }
8074
+ function getSizeForArea(scale, chartArea, field) {
8075
+ return scale.options.clip ? scale[field] : chartArea[field];
8076
+ }
8077
+ function getDatasetArea(meta, chartArea) {
8078
+ const { xScale, yScale } = meta;
8079
+ if (xScale && yScale) {
8080
+ return {
8081
+ left: getSizeForArea(xScale, chartArea, "left"),
8082
+ right: getSizeForArea(xScale, chartArea, "right"),
8083
+ top: getSizeForArea(yScale, chartArea, "top"),
8084
+ bottom: getSizeForArea(yScale, chartArea, "bottom")
8085
+ };
8086
+ }
8087
+ return chartArea;
8088
+ }
8102
8089
  let Chart$2 = (_h = class {
8103
8090
  static register(...items) {
8104
8091
  registry$1.add(...items);
@@ -8591,20 +8578,27 @@ let Chart$2 = (_h = class {
8591
8578
  }
8592
8579
  _drawDataset(meta) {
8593
8580
  const ctx = this.ctx;
8581
+ const clip = meta._clip;
8582
+ const useClip = !clip.disabled;
8583
+ const area = getDatasetArea(meta, this.chartArea);
8594
8584
  const args = {
8595
8585
  meta,
8596
8586
  index: meta.index,
8597
8587
  cancelable: true
8598
8588
  };
8599
- const clip = getDatasetClipArea(this, meta);
8600
8589
  if (this.notifyPlugins("beforeDatasetDraw", args) === false) {
8601
8590
  return;
8602
8591
  }
8603
- if (clip) {
8604
- clipArea$1(ctx, clip);
8592
+ if (useClip) {
8593
+ clipArea$1(ctx, {
8594
+ left: clip.left === false ? 0 : area.left - clip.left,
8595
+ right: clip.right === false ? this.width : area.right + clip.right,
8596
+ top: clip.top === false ? 0 : area.top - clip.top,
8597
+ bottom: clip.bottom === false ? this.height : area.bottom + clip.bottom
8598
+ });
8605
8599
  }
8606
8600
  meta.controller.draw();
8607
- if (clip) {
8601
+ if (useClip) {
8608
8602
  unclipArea$1(ctx);
8609
8603
  }
8610
8604
  args.cancelable = false;
@@ -10103,13 +10097,11 @@ function computeCircularBoundary(source) {
10103
10097
  }
10104
10098
  function _drawfill(ctx, source, area) {
10105
10099
  const target = _getTarget(source);
10106
- const { chart: chart2, index: index2, line, scale, axis } = source;
10100
+ const { line, scale, axis } = source;
10107
10101
  const lineOpts = line.options;
10108
10102
  const fillOption = lineOpts.fill;
10109
10103
  const color2 = lineOpts.backgroundColor;
10110
10104
  const { above = color2, below = color2 } = fillOption || {};
10111
- const meta = chart2.getDatasetMeta(index2);
10112
- const clip = getDatasetClipArea(chart2, meta);
10113
10105
  if (target && line.points.length) {
10114
10106
  clipArea$1(ctx, area);
10115
10107
  doFill(ctx, {
@@ -10119,14 +10111,13 @@ function _drawfill(ctx, source, area) {
10119
10111
  below,
10120
10112
  area,
10121
10113
  scale,
10122
- axis,
10123
- clip
10114
+ axis
10124
10115
  });
10125
10116
  unclipArea$1(ctx);
10126
10117
  }
10127
10118
  }
10128
10119
  function doFill(ctx, cfg) {
10129
- const { line, target, above, below, area, scale, clip } = cfg;
10120
+ const { line, target, above, below, area, scale } = cfg;
10130
10121
  const property = line._loop ? "angle" : cfg.axis;
10131
10122
  ctx.save();
10132
10123
  if (property === "x" && below !== above) {
@@ -10136,8 +10127,7 @@ function doFill(ctx, cfg) {
10136
10127
  target,
10137
10128
  color: above,
10138
10129
  scale,
10139
- property,
10140
- clip
10130
+ property
10141
10131
  });
10142
10132
  ctx.restore();
10143
10133
  ctx.save();
@@ -10148,8 +10138,7 @@ function doFill(ctx, cfg) {
10148
10138
  target,
10149
10139
  color: below,
10150
10140
  scale,
10151
- property,
10152
- clip
10141
+ property
10153
10142
  });
10154
10143
  ctx.restore();
10155
10144
  }
@@ -10183,14 +10172,14 @@ function clipVertical(ctx, target, clipY) {
10183
10172
  ctx.clip();
10184
10173
  }
10185
10174
  function fill(ctx, cfg) {
10186
- const { line, target, property, color: color2, scale, clip } = cfg;
10175
+ const { line, target, property, color: color2, scale } = cfg;
10187
10176
  const segments = _segments(line, target, property);
10188
10177
  for (const { source: src, target: tgt, start, end } of segments) {
10189
10178
  const { style: { backgroundColor = color2 } = {} } = src;
10190
10179
  const notShape = target !== true;
10191
10180
  ctx.save();
10192
10181
  ctx.fillStyle = backgroundColor;
10193
- clipBounds(ctx, scale, clip, notShape && _getBounds(property, start, end));
10182
+ clipBounds(ctx, scale, notShape && _getBounds(property, start, end));
10194
10183
  ctx.beginPath();
10195
10184
  const lineLoop = !!line.pathSegment(ctx, src);
10196
10185
  let loop;
@@ -10214,30 +10203,12 @@ function fill(ctx, cfg) {
10214
10203
  ctx.restore();
10215
10204
  }
10216
10205
  }
10217
- function clipBounds(ctx, scale, clip, bounds) {
10218
- const chartArea = scale.chart.chartArea;
10206
+ function clipBounds(ctx, scale, bounds) {
10207
+ const { top: top2, bottom: bottom2 } = scale.chart.chartArea;
10219
10208
  const { property, start, end } = bounds || {};
10220
- if (property === "x" || property === "y") {
10221
- let left2, top2, right2, bottom2;
10222
- if (property === "x") {
10223
- left2 = start;
10224
- top2 = chartArea.top;
10225
- right2 = end;
10226
- bottom2 = chartArea.bottom;
10227
- } else {
10228
- left2 = chartArea.left;
10229
- top2 = start;
10230
- right2 = chartArea.right;
10231
- bottom2 = end;
10232
- }
10209
+ if (property === "x") {
10233
10210
  ctx.beginPath();
10234
- if (clip) {
10235
- left2 = Math.max(left2, clip.left);
10236
- right2 = Math.min(right2, clip.right);
10237
- top2 = Math.max(top2, clip.top);
10238
- bottom2 = Math.min(bottom2, clip.bottom);
10239
- }
10240
- ctx.rect(left2, top2, right2 - left2, bottom2 - top2);
10211
+ ctx.rect(start, top2, end - start, bottom2 - top2);
10241
10212
  ctx.clip();
10242
10213
  }
10243
10214
  }
@@ -22803,6 +22774,48 @@ const isNilOrEmpty = (value) => {
22803
22774
  return false;
22804
22775
  };
22805
22776
  const isEmptyString = (value) => value === "";
22777
+ const ellipsisAnnotationPlugin = {
22778
+ id: "ellipsisAnnotationPlugin",
22779
+ afterDatasetsDraw(chart2) {
22780
+ const ctx = chart2.ctx;
22781
+ const xScale = chart2.scales.x;
22782
+ const yScale = chart2.scales.y;
22783
+ chart2.data.datasets.forEach((dataset) => {
22784
+ const customDataset = dataset;
22785
+ customDataset.data.forEach((item) => {
22786
+ const { ellipsePoints } = item;
22787
+ if (!ellipsePoints) return;
22788
+ const [p1, p2] = ellipsePoints.major;
22789
+ const [p3, p4] = ellipsePoints.minor;
22790
+ const centerX = (p1.x + p2.x + p3.x + p4.x) / 4;
22791
+ const centerY = (p1.y + p2.y + p3.y + p4.y) / 4;
22792
+ const dx = p2.x - p1.x;
22793
+ const dy = p2.y - p1.y;
22794
+ const angle = Math.atan2(
22795
+ yScale.getPixelForValue(centerY + dy / 2) - yScale.getPixelForValue(centerY - dy / 2),
22796
+ xScale.getPixelForValue(centerX + dx / 2) - xScale.getPixelForValue(centerX - dx / 2)
22797
+ );
22798
+ const radiusX = Math.hypot(
22799
+ xScale.getPixelForValue(p1.x) - xScale.getPixelForValue(p2.x),
22800
+ yScale.getPixelForValue(p1.y) - yScale.getPixelForValue(p2.y)
22801
+ ) / 2;
22802
+ const radiusY = Math.hypot(
22803
+ xScale.getPixelForValue(p3.x) - xScale.getPixelForValue(p4.x),
22804
+ yScale.getPixelForValue(p3.y) - yScale.getPixelForValue(p4.y)
22805
+ ) / 2;
22806
+ const cx2 = xScale.getPixelForValue(centerX);
22807
+ const cy = yScale.getPixelForValue(centerY);
22808
+ ctx.save();
22809
+ ctx.beginPath();
22810
+ ctx.ellipse(cx2, cy, radiusX, radiusY, angle, 0, 2 * Math.PI);
22811
+ ctx.strokeStyle = customDataset.borderColor || DEFAULT_COLOR;
22812
+ ctx.lineWidth = customDataset.borderWidth || 1;
22813
+ ctx.stroke();
22814
+ ctx.restore();
22815
+ });
22816
+ });
22817
+ }
22818
+ };
22806
22819
  const chart$3 = "_chart_e3qdd_1";
22807
22820
  const canvas$2 = "_canvas_e3qdd_11";
22808
22821
  const fixedHeight$3 = "_fixedHeight_e3qdd_20";
@@ -24387,9 +24400,11 @@ const useChartFunctions = ({
24387
24400
  const onHover = useCallback(
24388
24401
  (hoveredPoint, setHoveredPoint, datasets) => {
24389
24402
  return (evt, hoveredItems) => {
24403
+ var _a2, _b2;
24390
24404
  if (!(hoveredItems == null ? void 0 : hoveredItems.length) && onPointUnhover && hoveredPoint) {
24391
24405
  setHoveredPoint(null);
24392
24406
  onPointUnhover(evt);
24407
+ (_a2 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _a2.update();
24393
24408
  }
24394
24409
  if ((hoveredItems == null ? void 0 : hoveredItems.length) && onPointHover) {
24395
24410
  const { index: index2, datasetIndex } = hoveredItems[0];
@@ -24398,6 +24413,7 @@ const useChartFunctions = ({
24398
24413
  if (point && !isEqual(hoveredPoint, point)) {
24399
24414
  setHoveredPoint(point);
24400
24415
  onPointHover(evt, datasetIndex, index2, datasets);
24416
+ (_b2 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _b2.update();
24401
24417
  }
24402
24418
  }
24403
24419
  };
@@ -25339,8 +25355,8 @@ const estimateDataSeriesHaveCloseValues = (generatedDatasets) => {
25339
25355
  }
25340
25356
  const axesFirstLast = generatedDatasets == null ? void 0 : generatedDatasets.reduce((acc, dataset) => {
25341
25357
  var _a3, _b2, _c2, _d2;
25342
- const xAxisId = (dataset == null ? void 0 : dataset.xAxisID) ?? "x";
25343
- const yAxisId = (dataset == null ? void 0 : dataset.yAxisID) ?? "y";
25358
+ const xAxisId = (dataset == null ? void 0 : dataset.xAxisID) ?? "defaultX";
25359
+ const yAxisId = (dataset == null ? void 0 : dataset.yAxisID) ?? "defaultY";
25344
25360
  const data = (dataset == null ? void 0 : dataset.data) ?? [];
25345
25361
  if (data && (data == null ? void 0 : data.length)) {
25346
25362
  const { x: xFirstCurrent, y: yFirstCurrent } = (data == null ? void 0 : data[0]) ?? {};
@@ -25419,24 +25435,18 @@ const getSuggestedAxisRange = ({
25419
25435
  max: round$2(maxAxisValue, DECIMAL_POINT_TOLERANCE)
25420
25436
  };
25421
25437
  };
25422
- const getAxesDataFromMetasets = (generatedDatasets, scalesKeys, annotationsData) => {
25423
- if (!Array.isArray(generatedDatasets) || !Array.isArray(scalesKeys)) {
25424
- return {};
25425
- }
25426
- const annotations = getAnnotationsData(annotationsData);
25427
- return scalesKeys.reduce((acc, axisKey) => {
25428
- const axisType = getAxisTypeFromKey(axisKey);
25429
- const datasetValues = generatedDatasets.filter((dataset) => {
25430
- const axisId = dataset[`${axisType}AxisID`] ?? axisType;
25431
- return axisId === axisKey;
25432
- }).flatMap((dataset) => {
25433
- const data = (dataset == null ? void 0 : dataset.data) ?? [];
25434
- return data.map((point) => point[axisType]);
25435
- });
25436
- const annotationValues = (annotations == null ? void 0 : annotations[axisKey]) ?? [];
25437
- acc[axisKey] = [.../* @__PURE__ */ new Set([...datasetValues, ...annotationValues])];
25438
- return acc;
25439
- }, {});
25438
+ const getAxesDataFromMetasets = (chartRef, scalesKeys, annotationsData) => {
25439
+ var _a2;
25440
+ if (!chartRef || !scalesKeys) return {};
25441
+ const metasets = ((_a2 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _a2.getSortedVisibleDatasetMetas()) ?? [];
25442
+ const annotData = getAnnotationsData(annotationsData);
25443
+ return metasets && (scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
25444
+ const data = metasets.filter((dataset) => Object.values(dataset).includes(key)).flatMap((dataset) => dataset._parsed).map((parsedData) => parsedData[getAxisTypeFromKey(key)]).concat((annotData == null ? void 0 : annotData[key]) ?? []);
25445
+ return {
25446
+ ...acc,
25447
+ [key]: [...new Set(data)]
25448
+ };
25449
+ }, {}));
25440
25450
  };
25441
25451
  const shouldCalculate = (min, max) => !isNil(min) || !isNil(max);
25442
25452
  const autoScale = (options, state, generatedDatasets, chartRef) => {
@@ -25451,7 +25461,7 @@ const autoScale = (options, state, generatedDatasets, chartRef) => {
25451
25461
  }
25452
25462
  const scalesKeys = Object.keys(scales) ?? [];
25453
25463
  const data = getAxesDataFromMetasets(
25454
- generatedDatasets,
25464
+ chartRef,
25455
25465
  scalesKeys,
25456
25466
  annotationsData
25457
25467
  );
@@ -25780,7 +25790,12 @@ const generateAnnotations = (annotationsData) => {
25780
25790
  [AnnotationType.BOX]: color2,
25781
25791
  [AnnotationType.ELLIPSE]: TRANSPARENT
25782
25792
  }[type] || TRANSPARENT;
25783
- const borderWidth = type === AnnotationType.LINE ? BORDER_WIDTH.INITIAL : 0;
25793
+ const borderWidth = {
25794
+ [AnnotationType.LINE]: BORDER_WIDTH.INITIAL,
25795
+ [AnnotationType.BOX]: BORDER_WIDTH.ZERO,
25796
+ [AnnotationType.POINT]: BORDER_WIDTH.ZERO,
25797
+ [AnnotationType.ELLIPSE]: (ann == null ? void 0 : ann.borderWidth) ?? 0
25798
+ }[type] ?? 0;
25784
25799
  const borderDash = type === AnnotationType.LINE ? ANNOTATION_DASH : void 0;
25785
25800
  const defLabel = {
25786
25801
  content: ann == null ? void 0 : ann.label,
@@ -26807,19 +26822,6 @@ const annotationDraggerPlugin = {
26807
26822
  }
26808
26823
  }
26809
26824
  };
26810
- const tooltipNullGuard = {
26811
- id: "tooltipNullGuard",
26812
- beforeUpdate(chart2) {
26813
- var _a2;
26814
- const tt2 = chart2 == null ? void 0 : chart2.tooltip;
26815
- if (tt2 && ((_a2 = tt2 == null ? void 0 : tt2.getActiveElements()) == null ? void 0 : _a2.some(({ datasetIndex }) => {
26816
- const meta = chart2 == null ? void 0 : chart2.getDatasetMeta(datasetIndex);
26817
- return !meta || !(meta == null ? void 0 : meta.controller);
26818
- }))) {
26819
- tt2 == null ? void 0 : tt2.setActiveElements([], { x: 0, y: 0 });
26820
- }
26821
- }
26822
- };
26823
26825
  var defaultTranslations = /* @__PURE__ */ ((defaultTranslations2) => {
26824
26826
  defaultTranslations2["label"] = "Label";
26825
26827
  defaultTranslations2["pointsLines"] = "Points & lines";
@@ -27304,7 +27306,7 @@ Chart$2.register(
27304
27306
  annotation,
27305
27307
  chartAreaTextPlugin,
27306
27308
  annotationDraggerPlugin,
27307
- tooltipNullGuard
27309
+ ellipsisAnnotationPlugin
27308
27310
  );
27309
27311
  const LineChart = (props) => {
27310
27312
  var _a2, _b2;