@visactor/vrender 1.0.43-alpha.0 → 1.0.43-alpha.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
@@ -31726,6 +31726,11 @@
31726
31726
  }
31727
31727
  }
31728
31728
  class DefaultTicker extends EventEmitter {
31729
+ pushFrameTime(time) {
31730
+ this.frameTimeHistory.push(time);
31731
+ const overflow = this.frameTimeHistory.length - 600;
31732
+ overflow > 0 && this.frameTimeHistory.splice(0, overflow);
31733
+ }
31729
31734
  constructor(stage) {
31730
31735
  super(), this.timelines = [], this.frameTimeHistory = [], this.handleTick = (handler, params) => {
31731
31736
  const {
@@ -31733,10 +31738,10 @@
31733
31738
  } = null != params ? params : {};
31734
31739
  if (this.ifCanStop()) return this.stop(), !1;
31735
31740
  const currentTime = handler.getTime();
31736
- this._lastTickTime = currentTime, this.lastFrameTime < 0 && (this.lastFrameTime = currentTime - this.interval + this.timeOffset, this.frameTimeHistory.push(this.lastFrameTime));
31741
+ this._lastTickTime = currentTime, this.lastFrameTime < 0 && (this.lastFrameTime = currentTime - this.interval + this.timeOffset, this.pushFrameTime(this.lastFrameTime));
31737
31742
  const delta = currentTime - this.lastFrameTime,
31738
31743
  skip = this.checkSkip(delta);
31739
- return skip || (this._handlerTick(delta), this.lastFrameTime = currentTime, this.frameTimeHistory.push(this.lastFrameTime)), once || handler.tick(this.interval, this.handleTick), !skip;
31744
+ return skip || (this._handlerTick(delta), this.lastFrameTime = currentTime, this.pushFrameTime(this.lastFrameTime)), once || handler.tick(this.interval, this.handleTick), !skip;
31740
31745
  }, this._handlerTick = delta => {
31741
31746
  this.status === exports.STATUS.RUNNING && (this.tickCounts++, this.timelines.forEach(timeline => {
31742
31747
  timeline.tick(delta);
@@ -31828,7 +31833,7 @@
31828
31833
  }
31829
31834
  release() {
31830
31835
  var _a;
31831
- this.stop(), this.timelines = [], null === (_a = this.tickerHandler) || void 0 === _a || _a.release(), this.tickerHandler = null, this.lastFrameTime = -1, application.global.hooks.onSetEnv.unTap("graph-ticker", this._handleGraphTick);
31836
+ this.stop(), this.timelines = [], this.frameTimeHistory.length = 0, null === (_a = this.tickerHandler) || void 0 === _a || _a.release(), this.tickerHandler = null, this.lastFrameTime = -1, application.global.hooks.onSetEnv.unTap("graph-ticker", this._handleGraphTick);
31832
31837
  }
31833
31838
  checkSkip(delta) {
31834
31839
  var _a, _b, _c;
@@ -44973,16 +44978,6 @@
44973
44978
  strokeBoundsBuffer: 0
44974
44979
  }
44975
44980
  };
44976
- const LAYOUT_LEVEL = {
44977
- background: 0,
44978
- preview: 1,
44979
- dragMask: 2,
44980
- selectedBackground: 3,
44981
- selectedPreview: 4,
44982
- handler: 5,
44983
- handlerText: 5,
44984
- handlerMask: 999
44985
- };
44986
44981
 
44987
44982
  const isTextOverflow = (componentBoundsLike, textBounds, layout, isHorizontal) => {
44988
44983
  if (!textBounds) return !1;
@@ -45114,14 +45109,12 @@
45114
45109
  x: position.x + start * width,
45115
45110
  y: position.y,
45116
45111
  width: (end - start) * width,
45117
- height: height,
45118
- zIndex: LAYOUT_LEVEL.dragMask
45112
+ height: height
45119
45113
  }, dragMaskStyle), "rect") : this._dragMask = this._getContainer().createOrUpdateChild("dragMask", Object.assign({
45120
45114
  x: position.x,
45121
45115
  y: position.y + start * height,
45122
45116
  width: width,
45123
- height: (end - start) * height,
45124
- zIndex: LAYOUT_LEVEL.dragMask
45117
+ height: (end - start) * height
45125
45118
  }, dragMaskStyle), "rect"), {
45126
45119
  start: start,
45127
45120
  end: end
@@ -45145,8 +45138,7 @@
45145
45138
  y: position.y,
45146
45139
  width: width,
45147
45140
  height: height,
45148
- cursor: brushSelect ? "crosshair" : "auto",
45149
- zIndex: LAYOUT_LEVEL.background
45141
+ cursor: brushSelect ? "crosshair" : "auto"
45150
45142
  }, backgroundStyle), {
45151
45143
  pickable: !zoomLock && (null === (_a = backgroundStyle.pickable) || void 0 === _a || _a)
45152
45144
  }), "rect");
@@ -45179,8 +45171,7 @@
45179
45171
  x: position.x + start * width,
45180
45172
  y: position.y - middleHandlerBackgroundSize,
45181
45173
  width: (end - start) * width,
45182
- height: middleHandlerBackgroundSize,
45183
- zIndex: LAYOUT_LEVEL.handler
45174
+ height: middleHandlerBackgroundSize
45184
45175
  }, null === (_d = middleHandlerStyle.background) || void 0 === _d ? void 0 : _d.style), {
45185
45176
  pickable: !zoomLock && (null === (_g = null === (_f = null === (_e = middleHandlerStyle.background) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.pickable) || void 0 === _g || _g)
45186
45177
  }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
@@ -45188,29 +45179,24 @@
45188
45179
  y: position.y - middleHandlerBackgroundSize / 2,
45189
45180
  strokeBoundsBuffer: 0,
45190
45181
  angle: 0,
45191
- symbolType: null !== (_j = null === (_h = middleHandlerStyle.icon) || void 0 === _h ? void 0 : _h.symbolType) && void 0 !== _j ? _j : "square",
45192
- zIndex: LAYOUT_LEVEL.handler
45182
+ symbolType: null !== (_j = null === (_h = middleHandlerStyle.icon) || void 0 === _h ? void 0 : _h.symbolType) && void 0 !== _j ? _j : "square"
45193
45183
  }, middleHandlerStyle.icon), {
45194
45184
  pickable: !zoomLock && (null === (_k = middleHandlerStyle.icon.pickable) || void 0 === _k || _k)
45195
45185
  }), "symbol");
45196
45186
  }
45197
- this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign(Object.assign({
45187
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
45198
45188
  x: position.x + start * width,
45199
45189
  y: position.y + height / 2,
45200
45190
  size: height,
45201
45191
  symbolType: null !== (_l = startHandlerStyle.symbolType) && void 0 !== _l ? _l : "square"
45202
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
45203
- zIndex: LAYOUT_LEVEL.handler
45204
- }), startHandlerStyle), {
45192
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle), {
45205
45193
  pickable: !zoomLock && (null === (_m = startHandlerStyle.pickable) || void 0 === _m || _m)
45206
- }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign(Object.assign({
45194
+ }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
45207
45195
  x: position.x + end * width,
45208
45196
  y: position.y + height / 2,
45209
45197
  size: height,
45210
45198
  symbolType: null !== (_o = endHandlerStyle.symbolType) && void 0 !== _o ? _o : "square"
45211
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
45212
- zIndex: LAYOUT_LEVEL.handler
45213
- }), endHandlerStyle), {
45199
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle), {
45214
45200
  pickable: !zoomLock && (null === (_p = endHandlerStyle.pickable) || void 0 === _p || _p)
45215
45201
  }), "symbol");
45216
45202
  const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize),
@@ -45224,7 +45210,7 @@
45224
45210
  height: startHandlerHeight,
45225
45211
  fill: "white",
45226
45212
  fillOpacity: 0,
45227
- zIndex: LAYOUT_LEVEL.handlerMask
45213
+ zIndex: 999
45228
45214
  }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
45229
45215
  pickable: !zoomLock
45230
45216
  }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
@@ -45234,7 +45220,7 @@
45234
45220
  height: endHandlerHeight,
45235
45221
  fill: "white",
45236
45222
  fillOpacity: 0,
45237
- zIndex: LAYOUT_LEVEL.handlerMask
45223
+ zIndex: 999
45238
45224
  }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
45239
45225
  pickable: !zoomLock
45240
45226
  }), "rect");
@@ -45245,8 +45231,7 @@
45245
45231
  x: "left" === orient ? position.x - middleHandlerBackgroundSize : position.x + width,
45246
45232
  y: position.y + start * height,
45247
45233
  width: middleHandlerBackgroundSize,
45248
- height: (end - start) * height,
45249
- zIndex: LAYOUT_LEVEL.handler
45234
+ height: (end - start) * height
45250
45235
  }, null === (_r = middleHandlerStyle.background) || void 0 === _r ? void 0 : _r.style), {
45251
45236
  pickable: !zoomLock && (null === (_u = null === (_t = null === (_s = middleHandlerStyle.background) || void 0 === _s ? void 0 : _s.style) || void 0 === _t ? void 0 : _t.pickable) || void 0 === _u || _u)
45252
45237
  }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
@@ -45254,27 +45239,23 @@
45254
45239
  y: position.y + (start + end) / 2 * height,
45255
45240
  angle: Math.PI / 180 * 90,
45256
45241
  symbolType: null !== (_w = null === (_v = middleHandlerStyle.icon) || void 0 === _v ? void 0 : _v.symbolType) && void 0 !== _w ? _w : "square",
45257
- strokeBoundsBuffer: 0,
45258
- zIndex: LAYOUT_LEVEL.handler
45242
+ strokeBoundsBuffer: 0
45259
45243
  }, middleHandlerStyle.icon), {
45260
45244
  pickable: !zoomLock && (null === (_y = null === (_x = middleHandlerStyle.icon) || void 0 === _x ? void 0 : _x.pickable) || void 0 === _y || _y)
45261
45245
  }), "symbol");
45262
45246
  }
45263
- this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign(Object.assign({
45247
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
45264
45248
  x: position.x + width / 2,
45265
45249
  y: position.y + start * height,
45266
45250
  size: width,
45267
45251
  symbolType: null !== (_z = startHandlerStyle.symbolType) && void 0 !== _z ? _z : "square"
45268
- }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
45269
- zIndex: LAYOUT_LEVEL.handler
45270
- }), startHandlerStyle), {
45252
+ }, DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle), {
45271
45253
  pickable: !zoomLock && (null === (_0 = startHandlerStyle.pickable) || void 0 === _0 || _0)
45272
45254
  }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
45273
45255
  x: position.x + width / 2,
45274
45256
  y: position.y + end * height,
45275
45257
  size: width,
45276
- symbolType: null !== (_1 = endHandlerStyle.symbolType) && void 0 !== _1 ? _1 : "square",
45277
- zIndex: LAYOUT_LEVEL.handler
45258
+ symbolType: null !== (_1 = endHandlerStyle.symbolType) && void 0 !== _1 ? _1 : "square"
45278
45259
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle), {
45279
45260
  pickable: !zoomLock && (null === (_2 = endHandlerStyle.pickable) || void 0 === _2 || _2)
45280
45261
  }), "symbol");
@@ -45289,7 +45270,7 @@
45289
45270
  height: endHandlerWidth,
45290
45271
  fill: "white",
45291
45272
  fillOpacity: 0,
45292
- zIndex: LAYOUT_LEVEL.handlerMask
45273
+ zIndex: 999
45293
45274
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
45294
45275
  pickable: !zoomLock
45295
45276
  }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
@@ -45299,7 +45280,7 @@
45299
45280
  height: endHandlerWidth,
45300
45281
  fill: "white",
45301
45282
  fillOpacity: 0,
45302
- zIndex: LAYOUT_LEVEL.handlerMask
45283
+ zIndex: 999
45303
45284
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
45304
45285
  pickable: !zoomLock
45305
45286
  }), "rect");
@@ -45328,8 +45309,7 @@
45328
45309
  y: position.y,
45329
45310
  width: (end - start) * width,
45330
45311
  height: height,
45331
- cursor: brushSelect ? "crosshair" : "move",
45332
- zIndex: LAYOUT_LEVEL.selectedBackground
45312
+ cursor: brushSelect ? "crosshair" : "move"
45333
45313
  }, selectedBackgroundStyle), {
45334
45314
  pickable: !zoomLock && (null === (_a = selectedBackgroundChartStyle.pickable) || void 0 === _a || _a)
45335
45315
  }), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
@@ -45337,16 +45317,14 @@
45337
45317
  y: position.y + start * height,
45338
45318
  width: width,
45339
45319
  height: (end - start) * height,
45340
- cursor: brushSelect ? "crosshair" : "move",
45341
- zIndex: LAYOUT_LEVEL.selectedBackground
45320
+ cursor: brushSelect ? "crosshair" : "move"
45342
45321
  }, selectedBackgroundStyle), {
45343
45322
  pickable: !zoomLock && (null === (_b = selectedBackgroundStyle.pickable) || void 0 === _b || _b)
45344
45323
  }), "rect");
45345
45324
  }
45346
45325
  _setPreviewAttributes(type, group) {
45347
45326
  this._previewGroup || (this._previewGroup = group.createOrUpdateChild("previewGroup", {
45348
- pickable: !1,
45349
- zIndex: LAYOUT_LEVEL.preview
45327
+ pickable: !1
45350
45328
  }, "group")), "line" === type ? this._previewLine = this._previewGroup.createOrUpdateChild("previewLine", {}, "line") : this._previewArea = this._previewGroup.createOrUpdateChild("previewArea", {
45351
45329
  curveType: "basis"
45352
45330
  }, "area");
@@ -45365,8 +45343,7 @@
45365
45343
  }
45366
45344
  _setSelectedPreviewClipAttributes(type, group) {
45367
45345
  this._selectedPreviewGroupClip || (this._selectedPreviewGroupClip = group.createOrUpdateChild("selectedPreviewGroupClip", {
45368
- pickable: !1,
45369
- zIndex: LAYOUT_LEVEL.selectedPreview
45346
+ pickable: !1
45370
45347
  }, "group"), this._selectedPreviewGroup = this._selectedPreviewGroupClip.createOrUpdateChild("selectedPreviewGroup", {}, "group"));
45371
45348
  const {
45372
45349
  start: start,
@@ -49201,7 +49178,31 @@
49201
49178
  return graphicCreator.symbol(style);
49202
49179
  }
49203
49180
  _renderHandlerText(value, position) {
49204
- var _a, _b, _c;
49181
+ return graphicCreator.text(this._getHandlerTextAttributes(value, position));
49182
+ }
49183
+ _getHandlerPosition(isStart) {
49184
+ return this.attribute.range && isStart ? "start" : "end";
49185
+ }
49186
+ _getHandlerTextStyle(value, position) {
49187
+ const {
49188
+ align: align,
49189
+ handlerSize = 14,
49190
+ handlerText = {},
49191
+ railHeight: railHeight,
49192
+ railWidth: railWidth,
49193
+ slidable: slidable
49194
+ } = this.attribute;
49195
+ return isFunction$1(handlerText.style) ? handlerText.style(value, position, {
49196
+ layout: this.attribute.layout,
49197
+ align: align,
49198
+ railWidth: railWidth,
49199
+ railHeight: railHeight,
49200
+ handlerSize: handlerSize,
49201
+ slidable: slidable
49202
+ }) : handlerText.style;
49203
+ }
49204
+ _getHandlerTextAttributes(value, position) {
49205
+ var _a, _b;
49205
49206
  const {
49206
49207
  align: align,
49207
49208
  handlerSize = 14,
@@ -49213,13 +49214,13 @@
49213
49214
  isHorizontal = this._isHorizontal,
49214
49215
  pos = this.calculatePosByValue(value, position),
49215
49216
  textSpace = null !== (_a = handlerText.space) && void 0 !== _a ? _a : 4,
49217
+ handlerTextStyle = this._getHandlerTextStyle(value, position),
49216
49218
  textStyle = {
49217
49219
  text: handlerText.formatter ? handlerText.formatter(value) : value.toFixed(null !== (_b = handlerText.precision) && void 0 !== _b ? _b : 0),
49218
- lineHeight: null === (_c = handlerText.style) || void 0 === _c ? void 0 : _c.lineHeight,
49220
+ lineHeight: null == handlerTextStyle ? void 0 : handlerTextStyle.lineHeight,
49219
49221
  cursor: !1 === slidable ? "default" : getDefaultCursor(isHorizontal)
49220
49222
  };
49221
- isHorizontal ? "top" === align ? (textStyle.textBaseline = "bottom", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight - handlerSize) / 2 - textSpace) : (textStyle.textBaseline = "top", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight + handlerSize) / 2 + textSpace) : "left" === align ? (textStyle.textBaseline = "middle", textStyle.textAlign = "end", textStyle.x = (railWidth - handlerSize) / 2 - textSpace, textStyle.y = pos) : (textStyle.textBaseline = "middle", textStyle.textAlign = "start", textStyle.x = (railWidth + handlerSize) / 2 + textSpace, textStyle.y = pos);
49222
- return graphicCreator.text(Object.assign(Object.assign({}, textStyle), handlerText.style));
49223
+ return isHorizontal ? "top" === align ? (textStyle.textBaseline = "bottom", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight - handlerSize) / 2 - textSpace) : (textStyle.textBaseline = "top", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight + handlerSize) / 2 + textSpace) : "left" === align ? (textStyle.textBaseline = "middle", textStyle.textAlign = "end", textStyle.x = (railWidth - handlerSize) / 2 - textSpace, textStyle.y = pos) : (textStyle.textBaseline = "middle", textStyle.textAlign = "start", textStyle.x = (railWidth + handlerSize) / 2 + textSpace, textStyle.y = pos), Object.assign(Object.assign({}, textStyle), handlerTextStyle);
49223
49224
  }
49224
49225
  _renderTooltip() {
49225
49226
  var _a;
@@ -49347,31 +49348,19 @@
49347
49348
  }
49348
49349
  }
49349
49350
  _updateHandler(handler, position, value) {
49350
- var _a;
49351
49351
  const isHorizontal = this._isHorizontal;
49352
49352
  handler.setAttribute(isHorizontal ? "x" : "y", position);
49353
49353
  const updateHandlerText = handler.name === exports.SLIDER_ELEMENT_NAME.startHandler ? this._startHandlerText : this._endHandlerText;
49354
49354
  if (updateHandlerText) {
49355
- const {
49356
- handlerText = {}
49357
- } = this.attribute;
49358
- updateHandlerText.setAttributes({
49359
- text: handlerText.formatter ? handlerText.formatter(value) : value.toFixed(null !== (_a = handlerText.precision) && void 0 !== _a ? _a : 0),
49360
- [isHorizontal ? "x" : "y"]: position
49361
- });
49355
+ const handlerPosition = this._getHandlerPosition(handler.name === exports.SLIDER_ELEMENT_NAME.startHandler);
49356
+ updateHandlerText.setAttributes(this._getHandlerTextAttributes(value, handlerPosition));
49362
49357
  }
49363
49358
  handler.name === exports.SLIDER_ELEMENT_NAME.startHandler ? (this._currentValue.startValue = value, this._currentValue.startPos = position) : (this._currentValue.endValue = value, this._currentValue.endPos = position);
49364
49359
  }
49365
49360
  _updateHandlerText(handlerText, position, value) {
49366
- var _a;
49367
49361
  const isHorizontal = this._isHorizontal,
49368
- {
49369
- handlerText: handlerTextAttr = {}
49370
- } = this.attribute;
49371
- handlerText.setAttributes({
49372
- [isHorizontal ? "x" : "y"]: position,
49373
- text: handlerTextAttr.formatter ? handlerTextAttr.formatter(value) : value.toFixed(null !== (_a = handlerTextAttr.precision) && void 0 !== _a ? _a : 0)
49374
- });
49362
+ handlerPosition = this._getHandlerPosition(handlerText.name === exports.SLIDER_ELEMENT_NAME.startHandlerText);
49363
+ handlerText.setAttributes(this._getHandlerTextAttributes(value, handlerPosition));
49375
49364
  const updateHandler = handlerText.name === exports.SLIDER_ELEMENT_NAME.startHandlerText ? this._startHandler : this._endHandler;
49376
49365
  updateHandler && updateHandler.setAttributes({
49377
49366
  [isHorizontal ? "x" : "y"]: position
@@ -53147,7 +53136,7 @@
53147
53136
  select: !0
53148
53137
  };
53149
53138
 
53150
- const version = "1.0.43-alpha.0";
53139
+ const version = "1.0.43-alpha.1";
53151
53140
  preLoadAllModule();
53152
53141
  if (isBrowserEnv()) {
53153
53142
  loadBrowserEnv(container);