@oliasoft-open-source/charts-library 4.7.5 → 4.7.7-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -572,7 +572,7 @@ let Color$1 = class Color {
572
572
  }
573
573
  };
574
574
  /*!
575
- * Chart.js v4.4.6
575
+ * Chart.js v4.4.7
576
576
  * https://www.chartjs.org
577
577
  * (c) 2024 Chart.js Contributors
578
578
  * Released under the MIT License
@@ -584,7 +584,7 @@ const uid$1 = /* @__PURE__ */ (() => {
584
584
  return () => id++;
585
585
  })();
586
586
  function isNullOrUndef$1(value) {
587
- return value === null || typeof value === "undefined";
587
+ return value === null || value === void 0;
588
588
  }
589
589
  function isArray$1(value) {
590
590
  if (Array.isArray && Array.isArray(value)) {
@@ -2883,7 +2883,7 @@ function styleChanged$1(style, prevStyle) {
2883
2883
  return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
2884
2884
  }
2885
2885
  /*!
2886
- * Chart.js v4.4.6
2886
+ * Chart.js v4.4.7
2887
2887
  * https://www.chartjs.org
2888
2888
  * (c) 2024 Chart.js Contributors
2889
2889
  * Released under the MIT License
@@ -7977,7 +7977,7 @@ function needContext$1(proxy, names2) {
7977
7977
  }
7978
7978
  return false;
7979
7979
  }
7980
- var version$3 = "4.4.6";
7980
+ var version$3 = "4.4.7";
7981
7981
  const KNOWN_POSITIONS$1 = [
7982
7982
  "top",
7983
7983
  "bottom",
@@ -13035,7 +13035,7 @@ function cloneData(data) {
13035
13035
  function ChartComponent(props, ref) {
13036
13036
  const { height = 150, width = 300, redraw = false, datasetIdKey, type, data, options, plugins = [], fallbackContent, updateMode, ...canvasProps } = props;
13037
13037
  const canvasRef = useRef(null);
13038
- const chartRef = useRef();
13038
+ const chartRef = useRef(null);
13039
13039
  const renderChart = () => {
13040
13040
  if (!canvasRef.current) return;
13041
13041
  chartRef.current = new Chart$2(canvasRef.current, {
@@ -13105,20 +13105,22 @@ function ChartComponent(props, ref) {
13105
13105
  renderChart();
13106
13106
  return () => destroyChart();
13107
13107
  }, []);
13108
- return /* @__PURE__ */ React__default.createElement("canvas", Object.assign({
13108
+ return /* @__PURE__ */ React__default.createElement("canvas", {
13109
13109
  ref: canvasRef,
13110
13110
  role: "img",
13111
13111
  height,
13112
- width
13113
- }, canvasProps), fallbackContent);
13112
+ width,
13113
+ ...canvasProps
13114
+ }, fallbackContent);
13114
13115
  }
13115
13116
  const Chart$1 = /* @__PURE__ */ forwardRef(ChartComponent);
13116
13117
  function createTypedChart(type, registerables) {
13117
13118
  Chart$2.register(registerables);
13118
- return /* @__PURE__ */ forwardRef((props, ref) => /* @__PURE__ */ React__default.createElement(Chart$1, Object.assign({}, props, {
13119
+ return /* @__PURE__ */ forwardRef((props, ref) => /* @__PURE__ */ React__default.createElement(Chart$1, {
13120
+ ...props,
13119
13121
  ref,
13120
13122
  type
13121
- })));
13123
+ }));
13122
13124
  }
13123
13125
  const Line = /* @__PURE__ */ createTypedChart("line", LineController$1);
13124
13126
  const Bar = /* @__PURE__ */ createTypedChart("bar", BarController$1);
@@ -26011,7 +26013,7 @@ const useChartOptions = ({
26011
26013
  annotation: toAnnotationObject(annotation2),
26012
26014
  zoom: { pan: panOptions, zoom: zoomOptions },
26013
26015
  tooltip,
26014
- legend: { ...legend2, display: false },
26016
+ legend: { ...legend2, display: false, events: [] },
26015
26017
  // hide default legend for line chart only
26016
26018
  customLegendPlugin,
26017
26019
  chartAreaBorder: {
@@ -26524,7 +26526,9 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
26524
26526
  );
26525
26527
  const metrics = calculateAnnotationMetricsInValues(annotation2);
26526
26528
  if (annotation2 && annotation2.enableDrag && !isNil(metrics.centerY) && !isNil(metrics.centerX)) {
26527
- canvas2.style.cursor = CursorStyle.Move;
26529
+ if (!isNil(canvas2) && !isNil(canvas2.style)) {
26530
+ canvas2.style.cursor = CursorStyle.Move;
26531
+ }
26528
26532
  const dragStartX = x2 - metrics.centerX;
26529
26533
  const dragStartY = y2 - metrics.centerY;
26530
26534
  setDraggingState(true, annotation2, dragStartX, dragStartY);
@@ -26535,7 +26539,9 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
26535
26539
  };
26536
26540
  const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAnnotation, dragStartX, dragStartY, chart2) => {
26537
26541
  if (isDragging2 && activeAnnotation) {
26538
- canvas2.style.cursor = CursorStyle.Move;
26542
+ if (!isNil(canvas2) && !isNil(canvas2.style)) {
26543
+ canvas2.style.cursor = CursorStyle.Move;
26544
+ }
26539
26545
  const annotationId = activeAnnotation == null ? void 0 : activeAnnotation.id;
26540
26546
  setAnnotationBorderWidth(chart2, annotationId, BORDER_WIDTH.HOVERED);
26541
26547
  const dragAxis = (activeAnnotation == null ? void 0 : activeAnnotation.dragAxis) ?? DragAxis.Both;
@@ -26621,7 +26627,9 @@ const handleAnnotationMouseUp = (isDragging2, activeAnnotation, chart2, setDragg
26621
26627
  activeAnnotation
26622
26628
  );
26623
26629
  }
26624
- chart2.canvas.style.cursor = CursorStyle.Pointer;
26630
+ if (!isNil(chart2) && !isNil(chart2 == null ? void 0 : chart2.canvas) && !isNil(chart2 == null ? void 0 : chart2.canvas.style)) {
26631
+ chart2.canvas.style.cursor = CursorStyle.Pointer;
26632
+ }
26625
26633
  setDraggingState(false, null);
26626
26634
  }
26627
26635
  chart2.update();
@@ -26632,10 +26640,16 @@ const annotationLabel = (ctx, annotations, scales) => {
26632
26640
  var _a2;
26633
26641
  if (annotation2.type === AnnotationType.POINT && !isNil(annotation2 == null ? void 0 : annotation2.label) && ((_a2 = annotation2 == null ? void 0 : annotation2.label) == null ? void 0 : _a2.display)) {
26634
26642
  const { content, font, color: color2, position, padding } = (annotation2 == null ? void 0 : annotation2.label) ?? {};
26643
+ const { xScaleID = "x", yScaleID = "y" } = annotation2;
26635
26644
  ctx.save();
26636
26645
  ctx.font = font;
26637
26646
  ctx.fillStyle = color2;
26638
- const { centerX = -1, centerY = -1 } = calculateAnnotationMetricsInValuesInPixels(annotation2, scales);
26647
+ const { centerX = -1, centerY = -1 } = calculateAnnotationMetricsInValuesInPixels(
26648
+ annotation2,
26649
+ scales,
26650
+ xScaleID,
26651
+ yScaleID
26652
+ );
26639
26653
  const textWidth = ctx.measureText(content).width;
26640
26654
  let textX = centerX - textWidth / 2;
26641
26655
  let textY = centerY + 20;
@@ -40322,7 +40336,7 @@ const useBarChartOptions = ({
40322
40336
  datalabels: getBarChartDataLabels(options),
40323
40337
  annotation: toAnnotationObject(annotation2),
40324
40338
  tooltip: getBarChartToolTips(options),
40325
- legend: { ...legend2, display: false },
40339
+ legend: { ...legend2, display: false, events: [] },
40326
40340
  // hide default legend
40327
40341
  customLegendPlugin,
40328
40342
  chartAreaBorder: {
@@ -40689,7 +40703,7 @@ const useScatterChartConfig = (chart2, chartRef) => {
40689
40703
  onComplete: interactions == null ? void 0 : interactions.onAnimationComplete
40690
40704
  },
40691
40705
  plugins: {
40692
- legend: { ...legend2, display: false },
40706
+ legend: { ...legend2, display: false, events: [] },
40693
40707
  // hide default legend
40694
40708
  customLegendPlugin,
40695
40709
  title: getTitle(defaultOptions),