@visactor/vtable-calendar 1.18.6-alpha.0 → 1.18.6

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.
@@ -18261,6 +18261,18 @@
18261
18261
  const changeEvent = new CustomEvent(eventName, details);
18262
18262
  changeEvent.manager = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem.manager, this.dispatchEvent(changeEvent);
18263
18263
  }
18264
+ eventPosToStagePos(e) {
18265
+ var _a, _b;
18266
+ const result = {
18267
+ x: 0,
18268
+ y: 0
18269
+ },
18270
+ stagePoints = null !== (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventPointTransform(e)) && void 0 !== _b ? _b : {
18271
+ x: 0,
18272
+ y: 0
18273
+ };
18274
+ return this.globalTransMatrix.transformPoint(stagePoints, result), result;
18275
+ }
18264
18276
  }
18265
18277
 
18266
18278
  const MathPickerContribution = Symbol.for("MathPickerContribution");
@@ -23973,7 +23985,7 @@
23973
23985
  const MIN_TICK_GAP = 12;
23974
23986
  const calculateFlushPos = (basePosition, size, rangePosition, otherEnd) => rangePosition < basePosition ? Math.max(basePosition - size / 2, rangePosition) : rangePosition > basePosition ? Math.min(basePosition - size / 2, rangePosition - size) : rangePosition < otherEnd ? rangePosition : rangePosition - size;
23975
23987
  const getCartesianLabelBounds = (scale, domain, op) => {
23976
- var _a;
23988
+ var _a, _b, _c;
23977
23989
  const {
23978
23990
  labelStyle: labelStyle,
23979
23991
  axisOrientType: axisOrientType,
@@ -23989,27 +24001,32 @@
23989
24001
  scaleY = 0;
23990
24002
  isHorizontal || (isVertical ? (scaleX = 0, scaleY = 1) : startAngle && (scaleX = Math.cos(startAngle), scaleY = -Math.sin(startAngle)));
23991
24003
  const textMeasure = initTextMeasure(labelStyle),
23992
- range = scale.range(),
23993
- labelBoundsList = domain.map((v, i) => {
23994
- var _a, _b;
23995
- const str = labelFormatter ? labelFormatter(v) : `${v}`,
23996
- {
23997
- width: width,
23998
- height: height
23999
- } = textMeasure.quickMeasure(str),
24000
- textWidth = Math.max(width, 12),
24001
- textHeight = Math.max(height, 12),
24002
- pos = scale.scale(v),
24003
- baseTextX = scaleX * pos,
24004
- baseTextY = scaleY * pos;
24005
- let align,
24006
- baseline,
24007
- textX = baseTextX,
24008
- textY = baseTextY;
24009
- labelFlush && isHorizontal && 0 === i ? textX = calculateFlushPos(baseTextX, textWidth, range[0], range[range.length - 1]) : labelFlush && isHorizontal && i === domain.length - 1 ? textX = calculateFlushPos(baseTextX, textWidth, range[range.length - 1], range[0]) : align = null !== (_a = labelStyle.textAlign) && void 0 !== _a ? _a : "center", "right" === align ? textX -= textWidth : "center" === align && (textX -= textWidth / 2), labelFlush && isVertical && 0 === i ? textY = calculateFlushPos(baseTextY, textHeight, range[0], range[range.length - 1]) : labelFlush && isVertical && i === domain.length - 1 ? textY = calculateFlushPos(baseTextY, textHeight, range[range.length - 1], range[0]) : baseline = null !== (_b = labelStyle.textBaseline) && void 0 !== _b ? _b : "middle", "bottom" === baseline ? textY -= textHeight : "middle" === baseline && (textY -= textHeight / 2);
24010
- const bounds = new AABBBounds$1().set(textX, textY, textX + textWidth, textY + textHeight);
24011
- return labelAngle && bounds.rotate(labelAngle, baseTextX, baseTextY), bounds;
24012
- });
24004
+ range = scale.range();
24005
+ let labelBoundsList = [];
24006
+ for (let i = 0; i < domain.length; i++) {
24007
+ const v = domain[i],
24008
+ str = labelFormatter ? labelFormatter(v) : `${v}`;
24009
+ if (isPlainObject$5(str)) {
24010
+ labelBoundsList = void 0;
24011
+ break;
24012
+ }
24013
+ const {
24014
+ width: width,
24015
+ height: height
24016
+ } = textMeasure.quickMeasure(str),
24017
+ textWidth = Math.max(width, 12),
24018
+ textHeight = Math.max(height, 12),
24019
+ pos = scale.scale(v),
24020
+ baseTextX = scaleX * pos,
24021
+ baseTextY = scaleY * pos;
24022
+ let align,
24023
+ baseline,
24024
+ textX = baseTextX,
24025
+ textY = baseTextY;
24026
+ labelFlush && isHorizontal && 0 === i ? textX = calculateFlushPos(baseTextX, textWidth, range[0], range[range.length - 1]) : labelFlush && isHorizontal && i === domain.length - 1 ? textX = calculateFlushPos(baseTextX, textWidth, range[range.length - 1], range[0]) : align = null !== (_b = labelStyle.textAlign) && void 0 !== _b ? _b : "center", "right" === align ? textX -= textWidth : "center" === align && (textX -= textWidth / 2), labelFlush && isVertical && 0 === i ? textY = calculateFlushPos(baseTextY, textHeight, range[0], range[range.length - 1]) : labelFlush && isVertical && i === domain.length - 1 ? textY = calculateFlushPos(baseTextY, textHeight, range[range.length - 1], range[0]) : baseline = null !== (_c = labelStyle.textBaseline) && void 0 !== _c ? _c : "middle", "bottom" === baseline ? textY -= textHeight : "middle" === baseline && (textY -= textHeight / 2);
24027
+ const bounds = new AABBBounds$1().set(textX, textY, textX + textWidth, textY + textHeight);
24028
+ labelAngle && bounds.rotate(labelAngle, baseTextX, baseTextY), labelBoundsList.push(bounds);
24029
+ }
24013
24030
  return labelBoundsList;
24014
24031
  };
24015
24032
  const isAxisHorizontal = axisOrientType => ["bottom", "top", "z"].includes(axisOrientType);
@@ -24520,7 +24537,7 @@
24520
24537
  }
24521
24538
  }
24522
24539
  const continuousTicks = (scale, op) => {
24523
- var _a, _b;
24540
+ var _a, _b, _c, _d;
24524
24541
  if (!isContinuous(scale.type)) return convertDomainToTickData(scale.domain());
24525
24542
  const range = scale.range(),
24526
24543
  rangeSize = Math.abs(range[range.length - 1] - range[0]);
@@ -24572,23 +24589,25 @@
24572
24589
  step = Math.floor(scaleTicks.length * MIN_FONT_SIZE / rangeSize);
24573
24590
  scaleTicks.forEach((tick, index) => {
24574
24591
  index % step != 0 && index !== scaleTicks.length - 1 || samplingScaleTicks.push(tick);
24575
- }), items = getCartesianLabelBounds(scale, samplingScaleTicks, op).map((bounds, i) => ({
24592
+ }), items = null === (_c = getCartesianLabelBounds(scale, samplingScaleTicks, op)) || void 0 === _c ? void 0 : _c.map((bounds, i) => ({
24576
24593
  AABBBounds: bounds,
24577
24594
  value: samplingScaleTicks[i]
24578
24595
  }));
24579
- } else items = getCartesianLabelBounds(scale, scaleTicks, op).map((bounds, i) => ({
24596
+ } else items = null === (_d = getCartesianLabelBounds(scale, scaleTicks, op)) || void 0 === _d ? void 0 : _d.map((bounds, i) => ({
24580
24597
  AABBBounds: bounds,
24581
24598
  value: scaleTicks[i]
24582
24599
  }));
24583
- const firstSourceItem = items[0],
24584
- lastSourceItem = last$1(items),
24585
- samplingMethod = breakData && breakData() ? methods.greedy : methods.parity;
24586
- for (; items.length >= 3 && hasOverlap(items, labelGap);) items = samplingMethod(items, labelGap);
24587
- const checkFirst = op.labelFirstVisible;
24588
- let checkLast = op.labelLastVisible;
24589
- textIntersect(firstSourceItem, lastSourceItem, labelGap) && items.includes(lastSourceItem) && items.length > 1 && checkFirst && checkLast && (items.splice(items.indexOf(lastSourceItem), 1), checkLast = !1), forceItemVisible(firstSourceItem, items, checkFirst, item => textIntersect(item, firstSourceItem, labelGap)), forceItemVisible(lastSourceItem, items, checkLast, item => textIntersect(item, lastSourceItem, labelGap) || !(!checkFirst || item === firstSourceItem) && textIntersect(item, firstSourceItem, labelGap), !0);
24590
- const ticks = items.map(item => item.value);
24591
- ticks.length < 3 && labelFlush && (ticks.length > 1 && ticks.pop(), last$1(ticks) !== last$1(scaleTicks) && ticks.push(last$1(scaleTicks))), scaleTicks = ticks;
24600
+ if (items) {
24601
+ const firstSourceItem = items[0],
24602
+ lastSourceItem = last$1(items),
24603
+ samplingMethod = breakData && breakData() ? methods.greedy : methods.parity;
24604
+ for (; items.length >= 3 && hasOverlap(items, labelGap);) items = samplingMethod(items, labelGap);
24605
+ const checkFirst = op.labelFirstVisible;
24606
+ let checkLast = op.labelLastVisible;
24607
+ textIntersect(firstSourceItem, lastSourceItem, labelGap) && items.includes(lastSourceItem) && items.length > 1 && checkFirst && checkLast && (items.splice(items.indexOf(lastSourceItem), 1), checkLast = !1), forceItemVisible(firstSourceItem, items, checkFirst, item => textIntersect(item, firstSourceItem, labelGap)), forceItemVisible(lastSourceItem, items, checkLast, item => textIntersect(item, lastSourceItem, labelGap) || !(!checkFirst || item === firstSourceItem) && textIntersect(item, firstSourceItem, labelGap), !0);
24608
+ const ticks = items.map(item => item.value);
24609
+ ticks.length < 3 && labelFlush && (ticks.length > 1 && ticks.pop(), last$1(ticks) !== last$1(scaleTicks) && ticks.push(last$1(scaleTicks))), scaleTicks = ticks;
24610
+ }
24592
24611
  }
24593
24612
  return convertDomainToTickData(scaleTicks);
24594
24613
  };
@@ -24602,7 +24621,10 @@
24602
24621
  }
24603
24622
  };
24604
24623
 
24605
- const getOneDimensionalLabelBounds = (scale, domain, op, isHorizontal) => getCartesianLabelBounds(scale, domain, op).map(bounds => isHorizontal ? [bounds.x1, bounds.x2, bounds.width()] : [bounds.y1, bounds.y2, bounds.height()]),
24624
+ const getOneDimensionalLabelBounds = (scale, domain, op, isHorizontal) => {
24625
+ const labelBoundsList = getCartesianLabelBounds(scale, domain, op);
24626
+ return labelBoundsList && labelBoundsList.map(bounds => isHorizontal ? [bounds.x1, bounds.x2, bounds.width()] : [bounds.y1, bounds.y2, bounds.height()]);
24627
+ },
24606
24628
  boundsOverlap = function (prevBounds, nextBounds) {
24607
24629
  let gap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
24608
24630
  return Math.max(prevBounds[0], nextBounds[0]) - gap / 2 <= Math.min(prevBounds[1], nextBounds[1]) + gap / 2;
@@ -24636,23 +24658,27 @@
24636
24658
  rangeStart = minInArray$1(range),
24637
24659
  rangeEnd = maxInArray$1(range);
24638
24660
  if (domain.length <= rangeSize / fontSize) {
24639
- const incrementUnit = (rangeEnd - rangeStart) / domain.length,
24640
- labelBoundsList = getOneDimensionalLabelBounds(scale, domain, op, isHorizontal),
24641
- minBoundsLength = Math.min(...labelBoundsList.map(bounds => bounds[2])),
24642
- stepResult = getStep$1(domain, labelBoundsList, labelGap, op.labelLastVisible, Math.floor(minBoundsLength / incrementUnit), !1);
24643
- scaleTicks = scale.stepTicks(stepResult.step), op.labelLastVisible && (stepResult.delCount && (scaleTicks = scaleTicks.slice(0, scaleTicks.length - stepResult.delCount)), scaleTicks.push(domain[domain.length - 1]));
24661
+ const labelBoundsList = getOneDimensionalLabelBounds(scale, domain, op, isHorizontal);
24662
+ if (labelBoundsList) {
24663
+ const minBoundsLength = Math.min(...labelBoundsList.map(bounds => bounds[2])),
24664
+ incrementUnit = (rangeEnd - rangeStart) / domain.length,
24665
+ stepResult = getStep$1(domain, labelBoundsList, labelGap, op.labelLastVisible, Math.floor(minBoundsLength / incrementUnit), !1);
24666
+ scaleTicks = scale.stepTicks(stepResult.step), op.labelLastVisible && (stepResult.delCount && (scaleTicks = scaleTicks.slice(0, scaleTicks.length - stepResult.delCount)), scaleTicks.push(domain[domain.length - 1]));
24667
+ }
24644
24668
  } else {
24645
24669
  const tempDomain = [domain[0], domain[Math.floor(domain.length / 2)], domain[domain.length - 1]],
24646
24670
  tempList = getOneDimensionalLabelBounds(scale, tempDomain, op, isHorizontal);
24647
- let maxBounds = null;
24648
- tempList.forEach(current => {
24649
- maxBounds ? maxBounds[2] < current[2] && (maxBounds = current) : maxBounds = current;
24650
- });
24651
- const step = rangeEnd - rangeStart - labelGap > 0 ? Math.ceil(domain.length * (labelGap + maxBounds[2]) / (rangeEnd - rangeStart - labelGap)) : domain.length - 1;
24652
- scaleTicks = scale.stepTicks(step), !op.labelLastVisible || scaleTicks.length && scaleTicks[scaleTicks.length - 1] === domain[domain.length - 1] || (scaleTicks.length && Math.abs(scale.scale(scaleTicks[scaleTicks.length - 1]) - scale.scale(domain[domain.length - 1])) < maxBounds[2] && (scaleTicks = scaleTicks.slice(0, -1)), scaleTicks.push(domain[domain.length - 1]));
24671
+ if (tempList) {
24672
+ let maxBounds = null;
24673
+ tempList.forEach(current => {
24674
+ maxBounds ? maxBounds[2] < current[2] && (maxBounds = current) : maxBounds = current;
24675
+ });
24676
+ const step = rangeEnd - rangeStart - labelGap > 0 ? Math.ceil(domain.length * (labelGap + maxBounds[2]) / (rangeEnd - rangeStart - labelGap)) : domain.length - 1;
24677
+ scaleTicks = scale.stepTicks(step), !op.labelLastVisible || scaleTicks.length && scaleTicks[scaleTicks.length - 1] === domain[domain.length - 1] || (scaleTicks.length && Math.abs(scale.scale(scaleTicks[scaleTicks.length - 1]) - scale.scale(domain[domain.length - 1])) < maxBounds[2] && (scaleTicks = scaleTicks.slice(0, -1)), scaleTicks.push(domain[domain.length - 1]));
24678
+ }
24653
24679
  }
24654
- } else scaleTicks = scale.domain();
24655
- return convertDomainToTickData(scaleTicks);
24680
+ }
24681
+ return isNil$5(scaleTicks) && (scaleTicks = scale.domain()), convertDomainToTickData(scaleTicks);
24656
24682
  };
24657
24683
  const getStep$1 = (domain, labelBoundsList, labelGap, labelLastVisible, defaultStep, areAllBoundsSame) => {
24658
24684
  let resultDelCount = 0,
@@ -49646,7 +49672,7 @@
49646
49672
  constructor(container) {
49647
49673
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
49648
49674
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
49649
- if (super(), this.showFrozenIcon = !0, this.version = "1.18.6-alpha.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
49675
+ if (super(), this.showFrozenIcon = !0, this.version = "1.18.6", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
49650
49676
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
49651
49677
  options: options,
49652
49678
  container: container