@oliasoft-open-source/charts-library 5.0.3-beta-2 → 5.0.4

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
@@ -26321,6 +26321,7 @@ const chartAreaTextPlugin = {
26321
26321
  } = options;
26322
26322
  if (!showLabel || !text) return;
26323
26323
  const { ctx, chartArea } = chart2;
26324
+ if (!ctx || !chartArea) return;
26324
26325
  const maxWidth = calculateMaxWidth(initialMaxWidth, chartArea.width);
26325
26326
  const [x2, y2] = getPositionCoordinates(position, chart2, xOffset, yOffset);
26326
26327
  renderWrappedText(ctx, {
@@ -26338,8 +26339,8 @@ const getMousePositionInCoordinates = (event, canvas2, scales, xScaleID, yScaleI
26338
26339
  const rect = canvas2.getBoundingClientRect();
26339
26340
  const x2 = event.clientX - rect.left;
26340
26341
  const y2 = event.clientY - rect.top;
26341
- const xScale = scales[xScaleID];
26342
- const yScale = scales[yScaleID];
26342
+ const xScale = scales == null ? void 0 : scales[xScaleID];
26343
+ const yScale = scales == null ? void 0 : scales[yScaleID];
26343
26344
  const xValue = (xScale == null ? void 0 : xScale.getValueForPixel(x2)) ?? -1;
26344
26345
  const yValue = (yScale == null ? void 0 : yScale.getValueForPixel(y2)) ?? -1;
26345
26346
  return { x: xValue, y: yValue };
@@ -26374,8 +26375,10 @@ const calculateAnnotationMetricsInValuesInPixels = (annotation2, scales, xScaleI
26374
26375
  let centerY;
26375
26376
  let width;
26376
26377
  let height;
26377
- const xScale = scales[xScaleID];
26378
- const yScale = scales[yScaleID];
26378
+ const xScale = scales == null ? void 0 : scales[xScaleID];
26379
+ const yScale = scales == null ? void 0 : scales[yScaleID];
26380
+ if (!xScale || !yScale)
26381
+ return { centerX: -1, centerY: -1, width: 0, height: 0 };
26379
26382
  if (!isNil(xMin) && !isNil(xMax) && !isNil(yMin) && !isNil(yMax) && type === AnnotationType.BOX) {
26380
26383
  const xCenterValue = (xMin + xMax) / 2;
26381
26384
  const yCenterValue = (yMin + yMax) / 2;
@@ -26420,8 +26423,9 @@ const isWithinChartArea = ({
26420
26423
  const withinRangeY = y2 !== void 0 && dragRange.y ? y2 >= dragRange.y[0] && y2 <= dragRange.y[1] : true;
26421
26424
  return withinRangeX && withinRangeY;
26422
26425
  }
26423
- const xScale = scales[xScaleID];
26424
- const yScale = scales[yScaleID];
26426
+ const xScale = scales == null ? void 0 : scales[xScaleID];
26427
+ const yScale = scales == null ? void 0 : scales[yScaleID];
26428
+ if (!(scales == null ? void 0 : scales[xScaleID]) || !(scales == null ? void 0 : scales[yScaleID])) return false;
26425
26429
  const minX = (xScale == null ? void 0 : xScale.getValueForPixel(chartArea.left)) ?? Number.NEGATIVE_INFINITY;
26426
26430
  const maxX = (xScale == null ? void 0 : xScale.getValueForPixel(chartArea.right)) ?? Number.POSITIVE_INFINITY;
26427
26431
  const minY = (yScale == null ? void 0 : yScale.getValueForPixel(chartArea.bottom)) ?? Number.NEGATIVE_INFINITY;
@@ -26443,6 +26447,7 @@ const isWithinChartArea = ({
26443
26447
  return true;
26444
26448
  };
26445
26449
  const updateAnnotationPositionWithinBounds = (axis, newPosition, activeAnnotation, chart2, scales, xScaleID, yScaleID, metrics) => {
26450
+ if (!(chart2 == null ? void 0 : chart2.chartArea)) return;
26446
26451
  const { resizable, dragRange = null } = activeAnnotation ?? {};
26447
26452
  const checkArea = isWithinChartArea({
26448
26453
  [axis]: newPosition,
@@ -40804,7 +40809,8 @@ const gradientBackgroundPlugin = {
40804
40809
  id: "gradientBackgroundPlugin",
40805
40810
  beforeDraw: (chart2) => {
40806
40811
  const { ctx, chartArea, options } = chart2;
40807
- const gradientOptions = options.gradient;
40812
+ if (!ctx || !chartArea) return;
40813
+ const gradientOptions = options == null ? void 0 : options.gradient;
40808
40814
  const {
40809
40815
  display = false,
40810
40816
  gradientColors,