@visactor/vrender-components 0.19.9 → 0.19.10

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.es.js CHANGED
@@ -4271,6 +4271,12 @@ function colorArrayToString(color) {
4271
4271
  return Array.isArray(color) && isNumber(color[0]) ? alphaChannel ? `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])},${color[3].toFixed(2)})` : `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])})` : color;
4272
4272
  }
4273
4273
  function interpolateColor(from, to, ratio, alphaChannel, cb) {
4274
+ if (Array.isArray(from) && !isNumber(from[0]) || Array.isArray(to) && !isNumber(to[0])) {
4275
+ return new Array(4).fill(0).map((_, index) => _interpolateColor(isArray(from) ? from[index] : from, isArray(to) ? to[index] : to, ratio, alphaChannel));
4276
+ }
4277
+ return _interpolateColor(from, to, ratio, alphaChannel, cb);
4278
+ }
4279
+ function _interpolateColor(from, to, ratio, alphaChannel, cb) {
4274
4280
  if (!from || !to) return from && colorArrayToString(from) || to && colorArrayToString(to) || !1;
4275
4281
  let fromArray,
4276
4282
  toArray,
@@ -4781,7 +4787,7 @@ class Graphic extends Node {
4781
4787
  animate.stateNames = stateNames, animate.to(animateAttrs, null !== (_b = null === (_a = this.stateAnimateConfig) || void 0 === _a ? void 0 : _a.duration) && void 0 !== _b ? _b : DefaultStateAnimateConfig.duration, null !== (_d = null === (_c = this.stateAnimateConfig) || void 0 === _c ? void 0 : _c.easing) && void 0 !== _d ? _d : DefaultStateAnimateConfig.easing), noAnimateAttrs && this.setAttributes(noAnimateAttrs, !1, {
4782
4788
  type: AttributeUpdateType.STATE
4783
4789
  });
4784
- } else this.setAttributes(attrs, !1, {
4790
+ } else this.stopStateAnimates(), this.setAttributes(attrs, !1, {
4785
4791
  type: AttributeUpdateType.STATE
4786
4792
  });
4787
4793
  }
@@ -4811,7 +4817,7 @@ class Graphic extends Node {
4811
4817
  }), value;
4812
4818
  }
4813
4819
  clearStates(hasAnimation) {
4814
- this.stopStateAnimates(), this.hasState() && this.normalAttrs ? (this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
4820
+ this.hasState() && this.normalAttrs ? (this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
4815
4821
  }
4816
4822
  removeState(stateName, hasAnimation) {
4817
4823
  if ((this.currentStates ? this.currentStates.indexOf(stateName) : -1) >= 0) {
@@ -4837,7 +4843,6 @@ class Graphic extends Node {
4837
4843
  var _a;
4838
4844
  if (!states.length) return void this.clearStates(hasAnimation);
4839
4845
  if (!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) !== states.length || states.some((stateName, index) => this.currentStates[index] !== stateName))) return;
4840
- this.stopStateAnimates();
4841
4846
  const stateAttrs = {};
4842
4847
  states.forEach(stateName => {
4843
4848
  var _a;
@@ -11961,7 +11966,8 @@ var __decorate$z = undefined && undefined.__decorate || function (decorators, ta
11961
11966
  if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
11962
11967
  };
11963
11968
  const DrawItemInterceptor = Symbol.for("DrawItemInterceptor");
11964
- const tempDirtyBounds = new AABBBounds();
11969
+ const tempDirtyBounds = new AABBBounds(),
11970
+ tempBackupDirtyBounds = new AABBBounds();
11965
11971
  class ShadowRootDrawItemInterceptorContribution {
11966
11972
  constructor() {
11967
11973
  this.order = 1;
@@ -11978,11 +11984,11 @@ class ShadowRootDrawItemInterceptorContribution {
11978
11984
  context: context
11979
11985
  } = drawContext;
11980
11986
  if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
11981
- tempDirtyBounds.copy(drawContribution.dirtyBounds);
11987
+ tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
11982
11988
  const m = graphic.globalTransMatrix.getInverse();
11983
- drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);
11989
+ drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
11984
11990
  }
11985
- return drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix), context.highPerformanceRestore(), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds && drawContribution.dirtyBounds.copy(tempDirtyBounds), !0;
11991
+ return drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix), context.highPerformanceRestore(), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds && (drawContribution.dirtyBounds.copy(tempDirtyBounds), drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds)), !0;
11986
11992
  }
11987
11993
  }
11988
11994
  class DebugDrawItemInterceptorContribution {
@@ -15397,6 +15403,30 @@ function createTextGraphicByType(textAttributes, typeKey = 'type') {
15397
15403
  }
15398
15404
  return graphicCreator.text(textAttributes);
15399
15405
  }
15406
+ function alignTextInLine(layoutAlign, graphic, textAlign, pos, textWidth) {
15407
+ if (layoutAlign === 'right') {
15408
+ if (textAlign === 'center') {
15409
+ graphic.setAttribute('x', pos - textWidth / 2);
15410
+ }
15411
+ else if (textAlign === 'right' || textAlign === 'end') {
15412
+ graphic.setAttribute('x', pos);
15413
+ }
15414
+ else {
15415
+ graphic.setAttribute('x', pos - textWidth);
15416
+ }
15417
+ }
15418
+ else {
15419
+ if (textAlign === 'center') {
15420
+ graphic.setAttribute('x', pos + textWidth / 2);
15421
+ }
15422
+ else if (textAlign === 'right' || textAlign === 'end') {
15423
+ graphic.setAttribute('x', pos + textWidth);
15424
+ }
15425
+ else {
15426
+ graphic.setAttribute('x', pos);
15427
+ }
15428
+ }
15429
+ }
15400
15430
 
15401
15431
  const deltaXYToAngle = (y, x) => {
15402
15432
  const angle = Math.atan2(y, x);
@@ -28416,7 +28446,7 @@ class Tooltip extends AbstractComponent {
28416
28446
  }
28417
28447
  render() {
28418
28448
  var _a;
28419
- const { visible, content, panel, keyWidth, valueWidth, hasContentShape, autoCalculatePosition, autoMeasure } = this.attribute;
28449
+ const { visible, content, panel, keyWidth, valueWidth, hasContentShape, autoCalculatePosition, autoMeasure, align } = this.attribute;
28420
28450
  if (!visible) {
28421
28451
  this.hideAll();
28422
28452
  return;
@@ -28480,103 +28510,122 @@ class Tooltip extends AbstractComponent {
28480
28510
  this._tooltipContent.setAttribute('y', padding[0] + titleHeight);
28481
28511
  let lastYPos = 0;
28482
28512
  content.forEach((item, i) => {
28483
- var _a, _b, _c;
28484
28513
  const itemAttr = Tooltip.getContentAttr(this.attribute, i);
28485
28514
  if (!isVisible(itemAttr)) {
28486
28515
  return;
28487
28516
  }
28488
28517
  const itemGroupName = `${TOOLTIP_CONTENT_NAME}-${i}`;
28489
28518
  const itemGroup = this._tooltipContent.createOrUpdateChild(itemGroupName, { visible: true, x: 0, y: lastYPos }, 'group');
28490
- let x = 0;
28491
- if (isVisible(itemAttr.shape)) {
28492
- itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_SHAPE_NAME_SUFFIX}`, Object.assign({ visible: true, x: itemAttr.shape.size / 2, y: itemAttr.shape.size / 2 +
28493
- (((_a = calculateLineHeight(itemAttr.key.lineHeight, itemAttr.key.fontSize)) !== null && _a !== void 0 ? _a : itemAttr.key.fontSize) -
28494
- itemAttr.shape.size) /
28495
- 2 }, itemAttr.shape), 'symbol');
28496
- }
28519
+ const shapeOffsetWidth = itemAttr.shape.size + itemAttr.shape.spacing;
28520
+ let x = align === 'right'
28521
+ ? (hasContentShape ? shapeOffsetWidth : 0) +
28522
+ (isVisible(itemAttr.key) ? keyWidth + itemAttr.key.spacing : 0) +
28523
+ (isVisible(itemAttr.value) ? valueWidth : 0)
28524
+ : 0;
28525
+ const shapeGraphic = this._createShape(itemAttr, itemGroup, itemGroupName);
28497
28526
  if (hasContentShape) {
28498
- x += itemAttr.shape.size + itemAttr.shape.spacing;
28499
- }
28500
- if (isVisible(itemAttr.key)) {
28501
- let element;
28502
- if (itemAttr.key.multiLine) {
28503
- element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_KEY_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true }, getRichTextAttribute(itemAttr.key)), { textBaseline: 'top' }), 'richtext');
28527
+ if (shapeGraphic) {
28528
+ shapeGraphic.setAttribute('x', x);
28504
28529
  }
28505
- else if (typeof itemAttr.key.text === 'object' &&
28506
- itemAttr.key.text !== null &&
28507
- (itemAttr.key.text.type === 'rich' ||
28508
- itemAttr.key.text.type === 'html')) {
28509
- if (itemAttr.key.text.type === 'rich') {
28510
- element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true }, getRichTextAttribute(itemAttr.key)), { textBaseline: 'top' }), 'richtext');
28511
- }
28512
- else {
28513
- element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
28514
- html: Object.assign(Object.assign({ dom: itemAttr.key.text.text }, DEFAULT_HTML_TEXT_SPEC), itemAttr.key)
28515
- }, 'richtext');
28516
- }
28530
+ if (align === 'right') {
28531
+ x -= shapeOffsetWidth;
28517
28532
  }
28518
28533
  else {
28519
- element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_KEY_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true, text: ((_b = itemAttr.key.text) !== null && _b !== void 0 ? _b : '') }, itemAttr.key), { textBaseline: 'top' }), 'text');
28534
+ x += shapeOffsetWidth;
28520
28535
  }
28521
- const { textAlign } = itemAttr.key;
28522
- if (textAlign === 'center') {
28523
- element.setAttribute('x', x + keyWidth / 2);
28524
- }
28525
- else if (textAlign === 'right' || textAlign === 'end') {
28526
- element.setAttribute('x', x + keyWidth);
28527
- }
28528
- else {
28529
- element.setAttribute('x', x);
28530
- }
28531
- element.setAttribute('y', 0);
28532
- x += keyWidth + itemAttr.key.spacing;
28533
28536
  }
28534
- if (isVisible(itemAttr.value)) {
28535
- let element;
28536
- if (itemAttr.value.multiLine) {
28537
- element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true }, getRichTextAttribute(itemAttr.value)), { textBaseline: 'top' }), 'richtext');
28538
- }
28539
- else if (typeof itemAttr.value.text === 'object' &&
28540
- itemAttr.value.text !== null &&
28541
- (itemAttr.value.text.type === 'rich' ||
28542
- itemAttr.value.text.type === 'html')) {
28543
- if (itemAttr.value.text.type === 'rich') {
28544
- element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true }, getRichTextAttribute(itemAttr.value)), { textBaseline: 'top' }), 'richtext');
28545
- }
28546
- else {
28547
- element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
28548
- html: Object.assign({ dom: itemAttr.value.text.text, container: '', width: 30, height: 30, style: {} }, itemAttr.value)
28549
- }, 'richtext');
28550
- }
28537
+ const keyGraphic = this._createKey(itemAttr, itemGroup, itemGroupName);
28538
+ if (keyGraphic) {
28539
+ alignTextInLine(align, keyGraphic, itemAttr.key.textAlign, x, keyWidth);
28540
+ keyGraphic.setAttribute('y', 0);
28541
+ if (align === 'right') {
28542
+ x -= keyWidth + itemAttr.key.spacing;
28551
28543
  }
28552
28544
  else {
28553
- element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true, text: ((_c = itemAttr.value.text) !== null && _c !== void 0 ? _c : '') }, itemAttr.value), { textBaseline: 'top' }), 'text');
28545
+ x += keyWidth + itemAttr.key.spacing;
28554
28546
  }
28547
+ }
28548
+ const valueGraphic = this._createValue(itemAttr, itemGroup, itemGroupName);
28549
+ if (valueGraphic) {
28555
28550
  let textAlign = 'right';
28556
28551
  if (isValid(itemAttr.value.textAlign)) {
28557
28552
  textAlign = itemAttr.value.textAlign;
28558
28553
  }
28559
- else if (!isVisible(itemAttr.key)) {
28554
+ else if (!isVisible(itemAttr.key) && align !== 'right') {
28560
28555
  textAlign = 'left';
28561
28556
  }
28562
- element.setAttribute('textAlign', textAlign);
28563
- if (textAlign === 'center') {
28564
- element.setAttribute('x', x + valueWidth / 2);
28565
- }
28566
- else if (textAlign === 'right' || textAlign === 'end') {
28567
- element.setAttribute('x', x + valueWidth);
28568
- }
28569
- else {
28570
- element.setAttribute('x', x);
28571
- }
28572
- x += valueWidth;
28573
- element.setAttribute('y', 0);
28574
- itemGroup.add(element);
28557
+ valueGraphic.setAttribute('textAlign', textAlign);
28558
+ alignTextInLine(align, valueGraphic, textAlign, x, valueWidth);
28559
+ valueGraphic.setAttribute('y', 0);
28575
28560
  }
28576
28561
  lastYPos += itemAttr.height + itemAttr.spaceRow;
28577
28562
  });
28578
28563
  }
28579
28564
  }
28565
+ _createShape(itemAttr, itemGroup, itemGroupName) {
28566
+ var _a;
28567
+ if (isVisible(itemAttr.shape)) {
28568
+ return itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_SHAPE_NAME_SUFFIX}`, Object.assign({ visible: true, x: itemAttr.shape.size / 2, y: itemAttr.shape.size / 2 +
28569
+ (((_a = calculateLineHeight(itemAttr.key.lineHeight, itemAttr.key.fontSize)) !== null && _a !== void 0 ? _a : itemAttr.key.fontSize) -
28570
+ itemAttr.shape.size) /
28571
+ 2 }, itemAttr.shape), 'symbol');
28572
+ }
28573
+ return;
28574
+ }
28575
+ _createKey(itemAttr, itemGroup, itemGroupName) {
28576
+ var _a;
28577
+ if (isVisible(itemAttr.key)) {
28578
+ let element;
28579
+ if (itemAttr.key.multiLine) {
28580
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_KEY_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true }, getRichTextAttribute(itemAttr.key)), { textBaseline: 'top' }), 'richtext');
28581
+ }
28582
+ else if (typeof itemAttr.key.text === 'object' &&
28583
+ itemAttr.key.text !== null &&
28584
+ (itemAttr.key.text.type === 'rich' ||
28585
+ itemAttr.key.text.type === 'html')) {
28586
+ if (itemAttr.key.text.type === 'rich') {
28587
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true }, getRichTextAttribute(itemAttr.key)), { textBaseline: 'top' }), 'richtext');
28588
+ }
28589
+ else {
28590
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
28591
+ html: Object.assign(Object.assign({ dom: itemAttr.key.text.text }, DEFAULT_HTML_TEXT_SPEC), itemAttr.key)
28592
+ }, 'richtext');
28593
+ }
28594
+ }
28595
+ else {
28596
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_KEY_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true, text: ((_a = itemAttr.key.text) !== null && _a !== void 0 ? _a : '') }, itemAttr.key), { textBaseline: 'top' }), 'text');
28597
+ }
28598
+ return element;
28599
+ }
28600
+ return;
28601
+ }
28602
+ _createValue(itemAttr, itemGroup, itemGroupName) {
28603
+ var _a;
28604
+ if (isVisible(itemAttr.value)) {
28605
+ let element;
28606
+ if (itemAttr.value.multiLine) {
28607
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true }, getRichTextAttribute(itemAttr.value)), { textBaseline: 'top' }), 'richtext');
28608
+ }
28609
+ else if (typeof itemAttr.value.text === 'object' &&
28610
+ itemAttr.value.text !== null &&
28611
+ (itemAttr.value.text.type === 'rich' ||
28612
+ itemAttr.value.text.type === 'html')) {
28613
+ if (itemAttr.value.text.type === 'rich') {
28614
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true }, getRichTextAttribute(itemAttr.value)), { textBaseline: 'top' }), 'richtext');
28615
+ }
28616
+ else {
28617
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
28618
+ html: Object.assign({ dom: itemAttr.value.text.text, container: '', width: 30, height: 30, style: {} }, itemAttr.value)
28619
+ }, 'richtext');
28620
+ }
28621
+ }
28622
+ else {
28623
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, Object.assign(Object.assign({ visible: true, text: ((_a = itemAttr.value.text) !== null && _a !== void 0 ? _a : '') }, itemAttr.value), { textBaseline: 'top' }), 'text');
28624
+ }
28625
+ return element;
28626
+ }
28627
+ return;
28628
+ }
28580
28629
  setAttributes(params, forceUpdateTag) {
28581
28630
  const keys = Object.keys(params);
28582
28631
  if (this.attribute.autoCalculatePosition && keys.every(key => TOOLTIP_POSITION_ATTRIBUTES.includes(key))) {
@@ -29084,6 +29133,6 @@ EmptyTip.defaultAttributes = {
29084
29133
  }
29085
29134
  };
29086
29135
 
29087
- const version = "0.19.9";
29136
+ const version = "0.19.10";
29088
29137
 
29089
- export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AreaLabel, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupFadeIn, GroupFadeOut, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineDataLabel, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Title, Tooltip, VTag, angle, angleLabelOrientAttribute, angleTo, clampRadian, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, direction, fuzzyEqualNumber, getCircleLabelPosition, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, loadPoptip, measureTextSize, normalize, reactAttributeTransform, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
29138
+ export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AreaLabel, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupFadeIn, GroupFadeOut, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineDataLabel, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Title, Tooltip, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, clampRadian, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, direction, fuzzyEqualNumber, getCircleLabelPosition, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, loadPoptip, measureTextSize, normalize, reactAttributeTransform, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.19.9";
1
+ export declare const version = "0.19.10";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.19.9";
1
+ export const version = "0.19.10";
2
2
 
3
3
  export * from "./core/base";
4
4
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.19.9\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.19.10\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
@@ -1,3 +1,4 @@
1
+ import type { IGroup, IText, IRichText, ISymbol } from '@visactor/vrender-core';
1
2
  import { AbstractComponent } from '../core/base';
2
3
  import type { TooltipAttributes, TooltipRowAttrs, TooltipRowStyleAttrs } from './type';
3
4
  import type { ComponentOptions } from '../interface';
@@ -11,6 +12,9 @@ export declare class Tooltip extends AbstractComponent<Required<TooltipAttribute
11
12
  static defaultAttributes: Partial<TooltipAttributes>;
12
13
  constructor(attributes: TooltipAttributes, options?: ComponentOptions);
13
14
  protected render(): void;
15
+ protected _createShape(itemAttr: TooltipRowAttrs & TooltipRowStyleAttrs, itemGroup: IGroup, itemGroupName: string): ISymbol;
16
+ protected _createKey(itemAttr: TooltipRowAttrs & TooltipRowStyleAttrs, itemGroup: IGroup, itemGroupName: string): IRichText | IText;
17
+ protected _createValue(itemAttr: TooltipRowAttrs & TooltipRowStyleAttrs, itemGroup: IGroup, itemGroupName: string): IRichText | IText;
14
18
  setAttributes(params: Partial<Required<TooltipAttributes>>, forceUpdateTag?: boolean | undefined): void;
15
19
  static calculateTooltipPosition(attribute: Partial<TooltipAttributes>): Partial<TooltipAttributes>;
16
20
  static measureTooltip(attribute: Partial<TooltipAttributes>): Partial<TooltipAttributes>;
@@ -4,7 +4,7 @@ import { merge, isValid, normalizePadding, isNil } from "@visactor/vutils";
4
4
 
5
5
  import { AbstractComponent } from "../core/base";
6
6
 
7
- import { initTextMeasure } from "../util/text";
7
+ import { alignTextInLine, initTextMeasure } from "../util/text";
8
8
 
9
9
  import { isVisible } from "../util";
10
10
 
@@ -27,7 +27,7 @@ export class Tooltip extends AbstractComponent {
27
27
  }
28
28
  render() {
29
29
  var _a;
30
- const {visible: visible, content: content, panel: panel, keyWidth: keyWidth, valueWidth: valueWidth, hasContentShape: hasContentShape, autoCalculatePosition: autoCalculatePosition, autoMeasure: autoMeasure} = this.attribute;
30
+ const {visible: visible, content: content, panel: panel, keyWidth: keyWidth, valueWidth: valueWidth, hasContentShape: hasContentShape, autoCalculatePosition: autoCalculatePosition, autoMeasure: autoMeasure, align: align} = this.attribute;
31
31
  if (!visible) return void this.hideAll();
32
32
  autoMeasure && Tooltip.measureTooltip(this.attribute), autoCalculatePosition && Tooltip.calculateTooltipPosition(this.attribute);
33
33
  const padding = normalizePadding(this.attribute.padding);
@@ -73,77 +73,90 @@ export class Tooltip extends AbstractComponent {
73
73
  this._tooltipContent.setAttribute("x", padding[3]), this._tooltipContent.setAttribute("y", padding[0] + titleHeight);
74
74
  let lastYPos = 0;
75
75
  content.forEach(((item, i) => {
76
- var _a, _b, _c;
77
76
  const itemAttr = Tooltip.getContentAttr(this.attribute, i);
78
77
  if (!isVisible(itemAttr)) return;
79
78
  const itemGroupName = `tooltip-content-${i}`, itemGroup = this._tooltipContent.createOrUpdateChild(itemGroupName, {
80
79
  visible: !0,
81
80
  x: 0,
82
81
  y: lastYPos
83
- }, "group");
84
- let x = 0;
85
- if (isVisible(itemAttr.shape) && itemGroup.createOrUpdateChild(`${itemGroupName}-shape`, Object.assign({
86
- visible: !0,
87
- x: itemAttr.shape.size / 2,
88
- y: itemAttr.shape.size / 2 + ((null !== (_a = calculateLineHeight(itemAttr.key.lineHeight, itemAttr.key.fontSize)) && void 0 !== _a ? _a : itemAttr.key.fontSize) - itemAttr.shape.size) / 2
89
- }, itemAttr.shape), "symbol"), hasContentShape && (x += itemAttr.shape.size + itemAttr.shape.spacing),
90
- isVisible(itemAttr.key)) {
91
- let element;
92
- element = itemAttr.key.multiLine ? itemGroup.createOrUpdateChild(`${itemGroupName}-key`, Object.assign(Object.assign({
93
- visible: !0
94
- }, getRichTextAttribute(itemAttr.key)), {
95
- textBaseline: "top"
96
- }), "richtext") : "object" != typeof itemAttr.key.text || null === itemAttr.key.text || "rich" !== itemAttr.key.text.type && "html" !== itemAttr.key.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-key`, Object.assign(Object.assign({
97
- visible: !0,
98
- text: null !== (_b = itemAttr.key.text) && void 0 !== _b ? _b : ""
99
- }, itemAttr.key), {
100
- textBaseline: "top"
101
- }), "text") : "rich" === itemAttr.key.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
102
- visible: !0
103
- }, getRichTextAttribute(itemAttr.key)), {
104
- textBaseline: "top"
105
- }), "richtext") : itemGroup.createOrUpdateChild(`${itemGroupName}-value`, {
106
- html: Object.assign(Object.assign({
107
- dom: itemAttr.key.text.text
108
- }, DEFAULT_HTML_TEXT_SPEC), itemAttr.key)
109
- }, "richtext");
110
- const {textAlign: textAlign} = itemAttr.key;
111
- "center" === textAlign ? element.setAttribute("x", x + keyWidth / 2) : "right" === textAlign || "end" === textAlign ? element.setAttribute("x", x + keyWidth) : element.setAttribute("x", x),
112
- element.setAttribute("y", 0), x += keyWidth + itemAttr.key.spacing;
113
- }
114
- if (isVisible(itemAttr.value)) {
115
- let element;
116
- element = itemAttr.value.multiLine ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
117
- visible: !0
118
- }, getRichTextAttribute(itemAttr.value)), {
119
- textBaseline: "top"
120
- }), "richtext") : "object" != typeof itemAttr.value.text || null === itemAttr.value.text || "rich" !== itemAttr.value.text.type && "html" !== itemAttr.value.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
121
- visible: !0,
122
- text: null !== (_c = itemAttr.value.text) && void 0 !== _c ? _c : ""
123
- }, itemAttr.value), {
124
- textBaseline: "top"
125
- }), "text") : "rich" === itemAttr.value.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
126
- visible: !0
127
- }, getRichTextAttribute(itemAttr.value)), {
128
- textBaseline: "top"
129
- }), "richtext") : itemGroup.createOrUpdateChild(`${itemGroupName}-value`, {
130
- html: Object.assign({
131
- dom: itemAttr.value.text.text,
132
- container: "",
133
- width: 30,
134
- height: 30,
135
- style: {}
136
- }, itemAttr.value)
137
- }, "richtext");
82
+ }, "group"), shapeOffsetWidth = itemAttr.shape.size + itemAttr.shape.spacing;
83
+ let x = "right" === align ? (hasContentShape ? shapeOffsetWidth : 0) + (isVisible(itemAttr.key) ? keyWidth + itemAttr.key.spacing : 0) + (isVisible(itemAttr.value) ? valueWidth : 0) : 0;
84
+ const shapeGraphic = this._createShape(itemAttr, itemGroup, itemGroupName);
85
+ hasContentShape && (shapeGraphic && shapeGraphic.setAttribute("x", x), "right" === align ? x -= shapeOffsetWidth : x += shapeOffsetWidth);
86
+ const keyGraphic = this._createKey(itemAttr, itemGroup, itemGroupName);
87
+ keyGraphic && (alignTextInLine(align, keyGraphic, itemAttr.key.textAlign, x, keyWidth),
88
+ keyGraphic.setAttribute("y", 0), "right" === align ? x -= keyWidth + itemAttr.key.spacing : x += keyWidth + itemAttr.key.spacing);
89
+ const valueGraphic = this._createValue(itemAttr, itemGroup, itemGroupName);
90
+ if (valueGraphic) {
138
91
  let textAlign = "right";
139
- isValid(itemAttr.value.textAlign) ? textAlign = itemAttr.value.textAlign : isVisible(itemAttr.key) || (textAlign = "left"),
140
- element.setAttribute("textAlign", textAlign), "center" === textAlign ? element.setAttribute("x", x + valueWidth / 2) : "right" === textAlign || "end" === textAlign ? element.setAttribute("x", x + valueWidth) : element.setAttribute("x", x),
141
- x += valueWidth, element.setAttribute("y", 0), itemGroup.add(element);
92
+ isValid(itemAttr.value.textAlign) ? textAlign = itemAttr.value.textAlign : isVisible(itemAttr.key) || "right" === align || (textAlign = "left"),
93
+ valueGraphic.setAttribute("textAlign", textAlign), alignTextInLine(align, valueGraphic, textAlign, x, valueWidth),
94
+ valueGraphic.setAttribute("y", 0);
142
95
  }
143
96
  lastYPos += itemAttr.height + itemAttr.spaceRow;
144
97
  }));
145
98
  }
146
99
  }
100
+ _createShape(itemAttr, itemGroup, itemGroupName) {
101
+ var _a;
102
+ if (isVisible(itemAttr.shape)) return itemGroup.createOrUpdateChild(`${itemGroupName}-shape`, Object.assign({
103
+ visible: !0,
104
+ x: itemAttr.shape.size / 2,
105
+ y: itemAttr.shape.size / 2 + ((null !== (_a = calculateLineHeight(itemAttr.key.lineHeight, itemAttr.key.fontSize)) && void 0 !== _a ? _a : itemAttr.key.fontSize) - itemAttr.shape.size) / 2
106
+ }, itemAttr.shape), "symbol");
107
+ }
108
+ _createKey(itemAttr, itemGroup, itemGroupName) {
109
+ var _a;
110
+ if (isVisible(itemAttr.key)) {
111
+ let element;
112
+ return element = itemAttr.key.multiLine ? itemGroup.createOrUpdateChild(`${itemGroupName}-key`, Object.assign(Object.assign({
113
+ visible: !0
114
+ }, getRichTextAttribute(itemAttr.key)), {
115
+ textBaseline: "top"
116
+ }), "richtext") : "object" != typeof itemAttr.key.text || null === itemAttr.key.text || "rich" !== itemAttr.key.text.type && "html" !== itemAttr.key.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-key`, Object.assign(Object.assign({
117
+ visible: !0,
118
+ text: null !== (_a = itemAttr.key.text) && void 0 !== _a ? _a : ""
119
+ }, itemAttr.key), {
120
+ textBaseline: "top"
121
+ }), "text") : "rich" === itemAttr.key.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
122
+ visible: !0
123
+ }, getRichTextAttribute(itemAttr.key)), {
124
+ textBaseline: "top"
125
+ }), "richtext") : itemGroup.createOrUpdateChild(`${itemGroupName}-value`, {
126
+ html: Object.assign(Object.assign({
127
+ dom: itemAttr.key.text.text
128
+ }, DEFAULT_HTML_TEXT_SPEC), itemAttr.key)
129
+ }, "richtext"), element;
130
+ }
131
+ }
132
+ _createValue(itemAttr, itemGroup, itemGroupName) {
133
+ var _a;
134
+ if (isVisible(itemAttr.value)) {
135
+ let element;
136
+ return element = itemAttr.value.multiLine ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
137
+ visible: !0
138
+ }, getRichTextAttribute(itemAttr.value)), {
139
+ textBaseline: "top"
140
+ }), "richtext") : "object" != typeof itemAttr.value.text || null === itemAttr.value.text || "rich" !== itemAttr.value.text.type && "html" !== itemAttr.value.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
141
+ visible: !0,
142
+ text: null !== (_a = itemAttr.value.text) && void 0 !== _a ? _a : ""
143
+ }, itemAttr.value), {
144
+ textBaseline: "top"
145
+ }), "text") : "rich" === itemAttr.value.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
146
+ visible: !0
147
+ }, getRichTextAttribute(itemAttr.value)), {
148
+ textBaseline: "top"
149
+ }), "richtext") : itemGroup.createOrUpdateChild(`${itemGroupName}-value`, {
150
+ html: Object.assign({
151
+ dom: itemAttr.value.text.text,
152
+ container: "",
153
+ width: 30,
154
+ height: 30,
155
+ style: {}
156
+ }, itemAttr.value)
157
+ }, "richtext"), element;
158
+ }
159
+ }
147
160
  setAttributes(params, forceUpdateTag) {
148
161
  const keys = Object.keys(params);
149
162
  this.attribute.autoCalculatePosition && keys.every((key => TOOLTIP_POSITION_ATTRIBUTES.includes(key))) ? (this._mergeAttributes(params, keys),