@visactor/react-vchart 2.0.23-alpha.0 → 2.0.23-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/build/index.js CHANGED
@@ -14571,7 +14571,6 @@
14571
14571
  const tempConstantXYKey = ["x", "y"],
14572
14572
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
14573
14573
  tempConstantAngleKey = ["angle"],
14574
- builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
14575
14574
  point = new Point();
14576
14575
  const NOWORK_ANIMATE_ATTR = {
14577
14576
  strokeSeg: 1,
@@ -14628,7 +14627,7 @@
14628
14627
  }
14629
14628
  constructor(params = {}) {
14630
14629
  var _a;
14631
- super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
14630
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
14632
14631
  }
14633
14632
  getGraphicService() {
14634
14633
  var _a, _b;
@@ -14817,7 +14816,7 @@
14817
14816
  });
14818
14817
  }
14819
14818
  setAttributes(params, forceUpdateTag = !1, context) {
14820
- params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
14819
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
14821
14820
  }
14822
14821
  _setAttributes(params, forceUpdateTag = !1, context) {
14823
14822
  const keys = Object.keys(params);
@@ -14832,7 +14831,7 @@
14832
14831
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
14833
14832
  [key]: value
14834
14833
  }, this.attribute, key, context);
14835
- params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
14834
+ params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "shadowGraphic" === key && this.setShadowGraphic(value);
14836
14835
  }
14837
14836
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
14838
14837
  for (let i = 0; i < k.length; i++) {
@@ -14851,7 +14850,7 @@
14851
14850
  const context = {
14852
14851
  type: AttributeUpdateType.INIT
14853
14852
  };
14854
- params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background && this.loadImage(params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
14853
+ params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
14855
14854
  }
14856
14855
  translate(x, y) {
14857
14856
  var _a, _b;
@@ -15242,9 +15241,6 @@
15242
15241
  function backgroundNotImage(image) {
15243
15242
  return "string" == typeof image ? !(image.startsWith("<svg") || isValidUrl$1(image) || image.includes("/") || isBase64$1(image)) : !(!image.fill && !image.stroke) || !("string" != typeof image.gradient || !Array.isArray(image.stops));
15244
15243
  }
15245
- function isExternalTexture(texture) {
15246
- return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$2(texture));
15247
- }
15248
15244
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
15249
15245
 
15250
15246
  var GroupUpdateAABBBoundsMode;
@@ -18896,7 +18892,6 @@
18896
18892
  }
18897
18893
  const defaultBaseClipRenderAfterContribution = new DefaultBaseClipRenderAfterContribution();
18898
18894
 
18899
- const builtinProceduralTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid"]);
18900
18895
  function formatRatio(ratio) {
18901
18896
  return ratio <= .5 ? 4 * ratio - 1 : -4 * ratio + 3;
18902
18897
  }
@@ -19010,43 +19005,38 @@
19010
19005
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
19011
19006
  }
19012
19007
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
19013
- var _a, _b, _c, _d, _e, _f;
19008
+ var _a;
19014
19009
  const {
19015
19010
  textureRatio = graphicAttribute.textureRatio,
19016
19011
  textureOptions = null
19017
19012
  } = graphic.attribute;
19018
- let pattern = null;
19019
- const textureRadius = null !== (_a = null == textureOptions ? void 0 : textureOptions.radius) && void 0 !== _a ? _a : 0,
19020
- patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr, textureRadius);
19021
- if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
19022
- if ("string" == typeof texture) switch (texture) {
19023
- case "circle":
19024
- pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
19025
- break;
19026
- case "diamond":
19027
- pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
19028
- break;
19029
- case "rect":
19030
- pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
19031
- break;
19032
- case "vertical-line":
19033
- pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
19034
- break;
19035
- case "horizontal-line":
19036
- pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
19037
- break;
19038
- case "bias-lr":
19039
- pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
19040
- break;
19041
- case "bias-rl":
19042
- pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
19043
- break;
19044
- case "grid":
19045
- pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
19046
- }
19047
- pattern || (pattern = this.createResourcePattern(texture, graphic, context, texturePadding, textureRadius)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
19013
+ let pattern = this.textureMap.get(texture);
19014
+ if (!pattern) switch (texture) {
19015
+ case "circle":
19016
+ pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
19017
+ break;
19018
+ case "diamond":
19019
+ pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
19020
+ break;
19021
+ case "rect":
19022
+ pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
19023
+ break;
19024
+ case "vertical-line":
19025
+ pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
19026
+ break;
19027
+ case "horizontal-line":
19028
+ pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
19029
+ break;
19030
+ case "bias-lr":
19031
+ pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
19032
+ break;
19033
+ case "bias-rl":
19034
+ pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
19035
+ break;
19036
+ case "grid":
19037
+ pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
19048
19038
  }
19049
- if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
19039
+ if (textureOptions && textureOptions.dynamicTexture) {
19050
19040
  const {
19051
19041
  gridConfig = {},
19052
19042
  useNewCanvas: useNewCanvas
@@ -19091,24 +19081,10 @@
19091
19081
  for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
19092
19082
  const _x = x + cellSize / 2 + j * cellSize,
19093
19083
  _y = y + cellSize / 2 + i * cellSize;
19094
- null === (_b = textureOptions.beforeDynamicTexture) || void 0 === _b || _b.call(textureOptions, context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height()), context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height());
19084
+ null === (_a = textureOptions.beforeDynamicTexture) || void 0 === _a || _a.call(textureOptions, context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height()), context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height());
19095
19085
  }
19096
19086
  useNewCanvas && (originalContext.globalAlpha = 1, originalContext.drawImage(newCanvas.nativeCanvas, 0, 0, newCanvas.nativeCanvas.width, newCanvas.nativeCanvas.height, b.x1, b.y1, b.width() * originalContext.dpr, b.height() * originalContext.dpr)), originalContext.restore();
19097
- } else if (pattern) {
19098
- if (pattern.setTransform) {
19099
- const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
19100
- alignOffsetX = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _c ? _c : 0,
19101
- alignOffsetY = null !== (_d = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _d ? _d : 0;
19102
- let translateX = 0,
19103
- translateY = 0;
19104
- if (alignToGraphic) {
19105
- const m = context.currentMatrix;
19106
- translateX = (null !== (_e = null == m ? void 0 : m.e) && void 0 !== _e ? _e : 0) + x + alignOffsetX, translateY = (null !== (_f = null == m ? void 0 : m.f) && void 0 !== _f ? _f : 0) + y + alignOffsetY;
19107
- } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
19108
- pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
19109
- }
19110
- context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
19111
- } else if ("wave" === texture) {
19087
+ } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
19112
19088
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
19113
19089
  const b = graphic.AABBBounds;
19114
19090
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -19116,45 +19092,6 @@
19116
19092
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
19117
19093
  }
19118
19094
  }
19119
- getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr, textureRadius) {
19120
- return "string" != typeof texture ? texturePadding > 0 || textureRadius > 0 ? null : texture : "wave" === texture ? null : builtinProceduralTextureTypes.has(texture) ? `builtin:${texture}|size:${textureSize}|padding:${texturePadding}|color:${textureColor}|dpr:${dpr}` : `resource:${texture}|padding:${texturePadding}|radius:${textureRadius}|dpr:${dpr}`;
19121
- }
19122
- createResourcePattern(texture, graphic, context, texturePadding, textureRadius) {
19123
- var _a;
19124
- const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
19125
- data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
19126
- if (!data) return null;
19127
- if (texturePadding > 0 || textureRadius > 0) {
19128
- const w = data.naturalWidth || data.width,
19129
- h = data.naturalHeight || data.height;
19130
- if (w > 0 && h > 0) {
19131
- const tileW = w + 2 * texturePadding,
19132
- tileH = h + 2 * texturePadding,
19133
- canvas = canvasAllocate.allocate({
19134
- width: tileW,
19135
- height: tileH,
19136
- dpr: context.dpr
19137
- }),
19138
- ctx = canvas.getContext("2d");
19139
- if (ctx) {
19140
- if (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, tileW, tileH), textureRadius > 0) {
19141
- const r = Math.max(0, Math.min(textureRadius, Math.min(w, h) / 2)),
19142
- x0 = texturePadding,
19143
- y0 = texturePadding,
19144
- x1 = x0 + w,
19145
- y1 = y0 + h;
19146
- ctx.beginPath(), ctx.moveTo(x0 + r, y0), ctx.lineTo(x1 - r, y0), ctx.quadraticCurveTo(x1, y0, x1, y0 + r), ctx.lineTo(x1, y1 - r), ctx.quadraticCurveTo(x1, y1, x1 - r, y1), ctx.lineTo(x0 + r, y1), ctx.quadraticCurveTo(x0, y1, x0, y1 - r), ctx.lineTo(x0, y0 + r), ctx.quadraticCurveTo(x0, y0, x0 + r, y0), ctx.closePath(), ctx.clip();
19147
- }
19148
- ctx.drawImage(data, texturePadding, texturePadding, w, h);
19149
- const pattern = context.createPattern(canvas.nativeCanvas, "repeat");
19150
- return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), canvasAllocate.free(canvas), pattern;
19151
- }
19152
- canvasAllocate.free(canvas);
19153
- }
19154
- }
19155
- const pattern = context.createPattern(data, "repeat");
19156
- return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
19157
- }
19158
19095
  }
19159
19096
  const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();
19160
19097
 
@@ -54990,8 +54927,10 @@
54990
54927
  const record = data[i];
54991
54928
  if (record) {
54992
54929
  const startValue = record[startField],
54993
- endValue = record[endField || startField];
54994
- if (startValue <= value && endValue >= value) return record;
54930
+ endValue = record[endField || startField],
54931
+ min = Math.min(startValue, endValue),
54932
+ max = Math.max(startValue, endValue);
54933
+ if (min <= value && max >= value) return record;
54995
54934
  }
54996
54935
  }
54997
54936
  return null;
@@ -59063,8 +59002,11 @@
59063
59002
  field2 = "xField" === field ? series.fieldX2 : series.fieldY2,
59064
59003
  datum = getDatumByValue(series.getViewData().latestData, +value, field1, field2);
59065
59004
  if (datum) {
59066
- const startX = "xField" === field ? series.dataToPositionX(datum) : series.dataToPositionY(datum);
59067
- field2 ? (bandSize = Math.abs(startX - ("xField" === field ? series.dataToPositionX1(datum) : series.dataToPositionY1(datum))), value = `${datum[field1]} ~ ${datum[field2]}`) : bandSize = 1, coord = startX;
59005
+ const posStart = "xField" === field ? series.dataToPositionX(datum) : series.dataToPositionY(datum);
59006
+ if (field2) {
59007
+ const posEnd = "xField" === field ? series.dataToPositionX1(datum) : series.dataToPositionY1(datum);
59008
+ bandSize = Math.abs(posStart - posEnd), coord = Math.min(posStart, posEnd), value = `${datum[field1]} ~ ${datum[field2]}`;
59009
+ } else bandSize = 1, coord = posStart;
59068
59010
  }
59069
59011
  niceLabelFormatter = axis.niceLabelFormatter;
59070
59012
  }
@@ -89318,7 +89260,7 @@
89318
89260
 
89319
89261
  const VChartSimple = createChart('VChartSimple');
89320
89262
 
89321
- const version = "2.0.21";
89263
+ const version = "2.0.22";
89322
89264
 
89323
89265
  exports.Area = Area;
89324
89266
  exports.AreaChart = AreaChart;