@visactor/vrender-components 0.9.2-fill-stroke.10 → 0.10.0
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/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/label/base.js +14 -14
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +2 -2
- package/cjs/label/overlap/place.js +7 -7
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/overlap/scaler.d.ts +1 -1
- package/cjs/label/overlap/scaler.js +13 -2
- package/cjs/label/overlap/scaler.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/label/base.js +14 -14
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +2 -2
- package/es/label/overlap/place.js +7 -8
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/overlap/scaler.d.ts +1 -1
- package/es/label/overlap/scaler.js +12 -1
- package/es/label/overlap/scaler.js.map +1 -1
- package/package.json +10 -4
- package/dist/vrender-components.js +0 -1
- package/dist/vrender-components.min.js +0 -1
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
|
-
}), exports.version = void 0, exports.version = "0.
|
|
20
|
+
}), exports.version = void 0, exports.version = "0.10.0", __exportStar(require("./core/base"), exports),
|
|
21
21
|
__exportStar(require("./scrollbar"), exports), __exportStar(require("./tag"), exports),
|
|
22
22
|
__exportStar(require("./crosshair"), exports), __exportStar(require("./label"), exports),
|
|
23
23
|
__exportStar(require("./axis"), exports), __exportStar(require("./segment"), exports),
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.10.0\";\n\nexport * from './core/base';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\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';\n"]}
|
package/cjs/label/base.js
CHANGED
|
@@ -101,37 +101,37 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
101
101
|
const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0} = option, bmpTool = this._bmpTool || (0,
|
|
102
102
|
overlap_1.bitmapTool)(size.width, size.height), bitmap = this._bitmap || bmpTool.bitmap(), checkBounds = strategy.some((s => "bound" === s.type));
|
|
103
103
|
avoidBaseMark && (null === (_d = this._baseMarks) || void 0 === _d || _d.forEach((mark => {
|
|
104
|
-
mark.AABBBounds && bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, mark.AABBBounds));
|
|
104
|
+
mark.AABBBounds && bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, mark.AABBBounds, !0));
|
|
105
105
|
})));
|
|
106
106
|
for (let i = 0; i < labels.length; i++) {
|
|
107
107
|
if (!1 === labels[i].visible) continue;
|
|
108
108
|
const text = (0, vrender_1.createText)(labels[i]), baseMark = null === (_e = this._baseMarks) || void 0 === _e ? void 0 : _e[i];
|
|
109
109
|
if (text.update(), (0, overlap_1.canPlace)(bmpTool, bitmap, text.AABBBounds, clampForce)) {
|
|
110
110
|
if (!checkBounds) {
|
|
111
|
-
bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, text.AABBBounds)), result.push(Object.assign(Object.assign({}, text.attribute), {
|
|
112
|
-
_insideGraphic: (0, overlap_1.canPlaceInside)(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds)
|
|
113
|
-
_computedBound: text.AABBBounds
|
|
111
|
+
bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, text.AABBBounds, !0)), result.push(Object.assign(Object.assign({}, text.attribute), {
|
|
112
|
+
_insideGraphic: (0, overlap_1.canPlaceInside)(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds)
|
|
114
113
|
}));
|
|
115
114
|
continue;
|
|
116
115
|
}
|
|
117
116
|
if (checkBounds && (null == baseMark ? void 0 : baseMark.AABBBounds) && (0, overlap_1.canPlaceInside)(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds)) {
|
|
118
|
-
bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, text.AABBBounds)), result.push(Object.assign(Object.assign({}, text.attribute), {
|
|
117
|
+
bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, text.AABBBounds, !0)), result.push(Object.assign(Object.assign({}, text.attribute), {
|
|
119
118
|
_insideGraphic: !0,
|
|
120
119
|
_computedBound: text.AABBBounds
|
|
121
120
|
}));
|
|
122
121
|
continue;
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
124
|
+
let hasPlace = !1;
|
|
125
|
+
for (let j = 0; j < strategy.length; j++) if (hasPlace = (0, overlap_1.place)(bmpTool, bitmap, strategy[j], this.attribute, text, this.getGraphicBounds(baseMark, labels[i]), this.labeling),
|
|
126
|
+
!1 !== hasPlace) {
|
|
127
|
+
result.push(Object.assign(Object.assign({}, text.attribute), {
|
|
128
|
+
x: hasPlace.x,
|
|
129
|
+
y: hasPlace.y,
|
|
130
|
+
_insideGraphic: (0, overlap_1.canPlaceInside)(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds)
|
|
131
|
+
}));
|
|
132
|
+
break;
|
|
133
133
|
}
|
|
134
|
-
!hideOnHit && result.push(Object.assign(Object.assign({}, text.attribute), {
|
|
134
|
+
!hasPlace && !hideOnHit && result.push(Object.assign(Object.assign({}, text.attribute), {
|
|
135
135
|
_insideGraphic: (0, overlap_1.canPlaceInside)(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds),
|
|
136
136
|
_computedBound: text.AABBBounds
|
|
137
137
|
}));
|
package/cjs/label/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["label/base.ts"],"names":[],"mappings":";;;AAGA,+CAU2B;AAC3B,6CAAmF;AACnF,uCAAiD;AAEjD,+DAA4D;AAC5D,kCAAwC;AACxC,0CAAyC;AACzC,uCAA8F;AAE9F,+CAAkF;AAElF,MAAsB,SAAoC,SAAQ,wBAAoB;IAAtF;;QACE,SAAI,GAAG,OAAO,CAAC;QA0EP,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,MAAM,MAAM,GAAG,CAAC,CAAC,MAA6B,CAAC;YAC/C,IAAI,MAAM,KAAK,IAAI,CAAC,UAAU,IAAI,CAAC,IAAA,gBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,EAAE;gBACzD,MAAM,CAAC,QAAQ,CAAC,qBAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBAC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WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAED,eAAe;QACb,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF;AAljBD,8BAkjBC","file":"base.js","sourcesContent":["/**\n * @description Label 基类\n */\nimport {\n IGroup,\n Text,\n createText,\n IGraphic,\n IText,\n IncreaseCount,\n AttributeUpdateType,\n FederatedPointerEvent,\n IColor\n} from '@visactor/vrender';\nimport { isFunction, IBoundsLike, isValidNumber, isEmpty } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { PointLocationCfg } from '../core/type';\nimport { labelSmartInvert } from '../util/labelSmartInvert';\nimport { traverseGroup } from '../util';\nimport { StateValue } from '../constant';\nimport { Bitmap, bitmapTool, boundToRange, canPlace, canPlaceInside, place } from './overlap';\nimport { BaseLabelAttrs, OverlapAttrs, ILabelGraphicAttribute, ILabelAnimation } from './type';\nimport { DefaultLabelAnimation, getAnimationAttributes } from './animate/animate';\n\nexport abstract class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {\n name = 'label';\n\n protected _baseMarks?: IGraphic[];\n\n protected _bitmap?: Bitmap;\n\n setBitmap(bitmap: Bitmap) {\n this._bitmap = bitmap;\n }\n\n protected _bmpTool?: ReturnType<typeof bitmapTool>;\n setBitmapTool(bmpTool: ReturnType<typeof bitmapTool>) {\n this._bmpTool = bmpTool;\n }\n\n protected _relationMap: Map<number, IGraphic>;\n\n protected _prevRelationMap: Map<number, IGraphic>;\n\n protected _textMap: Map<IGraphic, IText>;\n\n onAfterLabelOverlap?: (bitmap: Bitmap) => void;\n\n private _lastHover: IGraphic;\n private _lastSelect: IGraphic;\n\n private _enableAnimation: boolean;\n\n protected abstract labeling(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position?: BaseLabelAttrs['position'],\n offset?: number\n ): Partial<ILabelGraphicAttribute> | undefined;\n\n protected render() {\n const currentBaseMarks = this._checkMarks();\n const labels = this.layout(currentBaseMarks);\n\n this._smartInvert(labels);\n\n this._renderLabels(labels);\n }\n\n private _bindEvent(target: IGraphic) {\n if (!target) {\n return;\n }\n\n const { hover, select } = this.attribute;\n\n if (hover) {\n target.addEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n target.addEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n }\n\n if (select) {\n target.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _setStates(target: IGraphic) {\n if (!target) {\n return;\n }\n const state = this.attribute.state;\n\n if (!state || isEmpty(state)) {\n return;\n }\n\n target.states = state;\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (target !== this._lastHover && !isEmpty(target.states)) {\n target.addState(StateValue.hover, true);\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (node !== target && !isEmpty(node.states)) {\n node.addState(StateValue.hoverReverse, true);\n }\n });\n this._lastHover = target;\n }\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n if (this._lastHover) {\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (!isEmpty(node.states)) {\n node.removeState(StateValue.hoverReverse);\n node.removeState(StateValue.hover);\n }\n });\n this._lastHover = null;\n }\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (this._lastSelect === target && target.hasState('selected')) {\n // 取消选中\n this._lastSelect = null;\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (!isEmpty(node.states)) {\n node.removeState(StateValue.selectedReverse);\n node.removeState(StateValue.selected);\n }\n });\n return;\n }\n\n if (!isEmpty(target.states)) {\n target.addState(StateValue.selected, true);\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (node !== target && !isEmpty(node.states)) {\n node.addState(StateValue.selectedReverse, true);\n }\n });\n this._lastSelect = target;\n }\n };\n\n private _createLabelText(attributes: ILabelGraphicAttribute) {\n const text = createText(attributes);\n this._bindEvent(text);\n this._setStates(text);\n return text;\n }\n\n private _checkMarks() {\n const baseMarks = this.getBaseMarks();\n const currentBaseMarks: IGraphic[] = [];\n baseMarks.forEach(mark => {\n if ((mark as any).releaseStatus !== 'willRelease') {\n currentBaseMarks.push(mark);\n }\n });\n this._prevRelationMap = new Map(this._relationMap);\n this._relationMap?.clear();\n return currentBaseMarks;\n }\n\n protected layout(currentMarks?: IGraphic[]): ILabelGraphicAttribute[] {\n const { textStyle, position, offset } = this.attribute as BaseLabelAttrs;\n let { data } = this.attribute as BaseLabelAttrs;\n if (isFunction(data)) {\n data = data({});\n }\n if (!data || data.length === 0) {\n return [];\n }\n\n let labels: ILabelGraphicAttribute[] = [];\n\n if (isFunction(this.attribute.sort) && currentMarks && currentMarks.length) {\n currentMarks = currentMarks.sort(this.attribute.sort);\n }\n\n if (!this._relationMap) {\n this._relationMap = new Map();\n }\n\n // 默认根据 index 顺序排序\n for (let i = 0; i < data.length; i++) {\n const textData = data[i];\n const baseMark = currentMarks?.[i] as IGraphic;\n const labelAttribute = {\n ...textStyle,\n ...textData,\n _relatedIndex: i\n };\n this._relationMap.set(i, baseMark);\n\n if (textData) {\n const text = createText(labelAttribute);\n text.update();\n const textBounds = this.getGraphicBounds(text);\n const graphicBounds = this.getGraphicBounds(baseMark, { x: textData.x as number, y: textData.y as number });\n\n const textAttributes = this.labeling(\n textBounds,\n graphicBounds,\n isFunction(position) ? position(textData) : position,\n offset\n );\n\n if (!textAttributes) {\n continue;\n }\n\n labelAttribute.x = textAttributes.x;\n labelAttribute.y = textAttributes.y;\n\n labels.push(labelAttribute);\n }\n }\n\n this._baseMarks = currentMarks as IGraphic[];\n if (this.attribute.overlap !== false) {\n labels = this.overlapping(labels, this.attribute.overlap as OverlapAttrs);\n }\n\n return labels;\n }\n\n protected overlapping(labels: ILabelGraphicAttribute[], option: OverlapAttrs = {}) {\n if (labels.length === 0) {\n return [];\n }\n const result: ILabelGraphicAttribute[] = [];\n const baseMarkGroup = this.getBaseMarkGroup();\n const size = option.size ?? {\n width: baseMarkGroup?.AABBBounds.width() ?? 0,\n height: baseMarkGroup?.AABBBounds.height() ?? 0\n };\n\n if (size.width === 0 || size.height === 0) {\n return labels;\n }\n\n const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true } = option;\n const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);\n const bitmap = this._bitmap || bmpTool.bitmap();\n const checkBounds = strategy.some(s => s.type === 'bound');\n\n if (avoidBaseMark) {\n this._baseMarks?.forEach(mark => {\n mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds));\n });\n }\n\n for (let i = 0; i < labels.length; i++) {\n if (labels[i].visible === false) {\n continue;\n }\n const text = createText(labels[i]) as Text;\n const baseMark = this._baseMarks?.[i];\n text.update();\n\n // 默认位置可以放置\n if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce)) {\n // 如果配置了限制在图形内部,需要提前判断;\n if (!checkBounds) {\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds));\n result.push({\n ...text.attribute,\n _insideGraphic: canPlaceInside(text.AABBBounds, baseMark?.AABBBounds),\n _computedBound: text.AABBBounds\n });\n continue;\n }\n\n if (checkBounds && baseMark?.AABBBounds && canPlaceInside(text.AABBBounds, baseMark?.AABBBounds)) {\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds));\n result.push({ ...text.attribute, _insideGraphic: true, _computedBound: text.AABBBounds });\n continue;\n }\n }\n\n // 发生碰撞,根据策略寻找可放置的位置\n for (let j = 0; j < strategy.length; j++) {\n const hasPlace = place(\n bmpTool,\n bitmap,\n strategy[j],\n <BaseLabelAttrs>this.attribute,\n text,\n this.getGraphicBounds(baseMark, labels[i]),\n this.labeling\n );\n if (hasPlace) {\n result.push({\n ...text.attribute,\n _insideGraphic: canPlaceInside(text.AABBBounds, baseMark?.AABBBounds),\n _computedBound: text.AABBBounds\n });\n break;\n }\n }\n\n !hideOnHit &&\n result.push({\n ...text.attribute,\n _insideGraphic: canPlaceInside(text.AABBBounds, baseMark?.AABBBounds),\n _computedBound: text.AABBBounds\n });\n }\n\n if (isFunction(this.onAfterLabelOverlap)) {\n this.onAfterLabelOverlap(bitmap);\n }\n\n return result;\n }\n\n protected getBaseMarks() {\n const baseMarkGroup = this.getBaseMarkGroup() as IGroup;\n if (!baseMarkGroup) {\n return;\n }\n return baseMarkGroup.getChildren() as IGraphic[];\n }\n\n protected getBaseMarkGroup() {\n const { baseMarkGroupName } = this.attribute as BaseLabelAttrs;\n if (!baseMarkGroupName) {\n return;\n }\n return (this.getRootNode() as IGroup).find(node => node.name === baseMarkGroupName, true) as IGroup;\n }\n\n protected getGraphicBounds(graphic?: IGraphic, point: Partial<PointLocationCfg> = {}): IBoundsLike {\n // if (graphic && !isEmpty((graphic as any).finalAttrs)) {\n // const g = graphic.clone();\n // g.onBeforeAttributeUpdate = graphic.onBeforeAttributeUpdate;\n // g.setAttributes((graphic as any).finalAttrs);\n // g.update();\n // return g.AABBBounds;\n // }\n return (\n graphic?.AABBBounds ||\n ({\n x1: point.x,\n x2: point.x,\n y1: point.y,\n y2: point.y\n } as IBoundsLike)\n );\n }\n\n protected _renderLabels(labels: ILabelGraphicAttribute[]) {\n const animationConfig = (this.attribute.animation ?? {}) as ILabelAnimation;\n const disableAnimation = this._enableAnimation === false || (animationConfig as unknown as boolean) === false;\n const mode = animationConfig.mode ?? DefaultLabelAnimation.mode;\n const duration = animationConfig.duration ?? DefaultLabelAnimation.duration;\n const easing = animationConfig.easing ?? DefaultLabelAnimation.easing;\n const delay = animationConfig.delay ?? 0;\n\n const currentTextMap = new Map();\n const prevTextMap = this._textMap || new Map();\n const texts = [] as IText[];\n\n labels.forEach((label, index) => {\n const text = this._createLabelText(label);\n const relatedGraphic = this._relationMap.get(label._relatedIndex);\n const state = prevTextMap?.get(relatedGraphic) ? 'update' : 'enter';\n\n if (state === 'enter') {\n texts.push(text);\n currentTextMap.set(relatedGraphic, text);\n if (!disableAnimation && relatedGraphic) {\n const { from, to } = getAnimationAttributes(label, 'fadeIn');\n this.add(text);\n relatedGraphic.onAnimateBind = () => {\n text.setAttributes(from);\n const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, {\n mode,\n duration,\n easing,\n to,\n delay\n });\n relatedGraphic.on('afterAttributeUpdate', listener);\n };\n } else {\n this.add(text);\n }\n }\n\n if (state === 'update') {\n const prevText = prevTextMap.get(relatedGraphic);\n prevTextMap.delete(relatedGraphic);\n currentTextMap.set(relatedGraphic, prevText);\n if (!disableAnimation) {\n prevText.animate().to(text.attribute, duration, easing);\n if (\n animationConfig.increaseEffect !== false &&\n prevText.attribute.text !== text.attribute.text &&\n isValidNumber(Number(prevText.attribute.text) * Number(text.attribute.text))\n ) {\n prevText\n .animate()\n .play(\n new IncreaseCount(\n { text: prevText.attribute.text as string },\n { text: text.attribute.text as string },\n duration,\n easing\n )\n );\n }\n } else {\n prevText.setAttributes(text.attribute);\n }\n }\n });\n prevTextMap.forEach(label => {\n if (disableAnimation) {\n this.removeChild(label);\n } else {\n label\n ?.animate()\n .to(getAnimationAttributes(label.attribute, 'fadeOut').to, duration, easing)\n .onEnd(() => {\n this.removeChild(label);\n });\n }\n });\n\n this._textMap = currentTextMap;\n }\n\n protected _afterRelatedGraphicAttributeUpdate(\n text: IText,\n texts: IText[],\n index: number,\n relatedGraphic: IGraphic,\n { mode, duration, easing, to, delay }: ILabelAnimation & { to: any }\n ) {\n const listener = (event: any) => {\n const { detail } = event;\n if (!detail) {\n return {};\n }\n\n const isValidAnimateState =\n detail &&\n detail.type === AttributeUpdateType.ANIMATE_UPDATE &&\n detail.animationState &&\n detail.animationState.step?.type !== 'wait';\n\n if (!isValidAnimateState) {\n return {};\n }\n\n if (detail.type === AttributeUpdateType.ANIMATE_END) {\n text.setAttributes(to);\n return;\n }\n\n const onEnd = () => {\n if (relatedGraphic) {\n relatedGraphic.onAnimateBind = undefined;\n relatedGraphic.removeEventListener('afterAttributeUpdate', listener);\n }\n };\n\n switch (mode) {\n case 'after':\n // 3. 当前关联图元的动画播放结束后\n if (detail.animationState.end) {\n text.animate({ onEnd }).wait(delay).to(to, duration, easing);\n }\n break;\n case 'after-all':\n // 2. 所有完成后才开始;\n if (index === texts.length - 1) {\n if (detail.animationState.end) {\n texts.forEach(t => {\n t.animate({ onEnd }).wait(delay).to(to, duration, easing);\n });\n }\n }\n break;\n case 'same-time':\n default:\n // 1. 与当前关联图元的动画播放同时进行\n if (detail.animationState.isFirstFrameOfStep) {\n text.animate({ onEnd }).wait(delay).to(to, duration, easing);\n }\n break;\n }\n };\n return listener;\n }\n\n protected _smartInvert(labels: ILabelGraphicAttribute[]) {\n if (this.attribute.smartInvert === false) {\n return;\n }\n for (let i = 0; i < labels.length; i++) {\n const label = labels?.[i] as ILabelGraphicAttribute;\n if (!label) {\n continue;\n }\n let isInside = label._insideGraphic;\n if (isInside === undefined) {\n const text = createText(label);\n text.update();\n isInside = canPlaceInside(text.AABBBounds, this._relationMap.get(label._relatedIndex)?.AABBBounds);\n }\n /**\n * stroke 的处理逻辑\n * 1. 当文本在图元内部时,有两种情况:\n * - a. 未设置stroke:labelFill为前景色,baseMark填充色为背景色\n * - b. 设置了stroke:labelFill为前景色,labelStroke填充色为背景色\n * 2. 当文本在图元外部时,有两种情况:\n * - a. 未设置stroke:此时设置strokeColor为backgroundColor。labelFill为前景色,labelStroke填充色为背景色。避免文字一半在图元内部,一半在图元外部时,在图元外部文字不可见。\n * - b. 设置了stroke:保持strokeColor。labelFill为前景色,labelStroke填充色为背景色。\n */\n if (label.stroke && label.lineWidth > 0) {\n /**\n * 1-b, 2-b\n * 若label存在stroke,label填充色为前景色,label描边色为背景色\n * WCAG 2 字母周围的文本发光/光晕可用作背景颜色\n */\n label.fill = labelSmartInvert(\n label.fill as IColor,\n label.stroke as IColor,\n this.attribute.smartInvert?.textType,\n this.attribute.smartInvert?.contrastRatiosThreshold,\n this.attribute.smartInvert?.alternativeColors\n );\n } else if (isInside) {\n /**\n * 1-a\n * label在图元内部时,label填充色为前景色,baseMark填充色为背景色\n */\n const baseMark = this._relationMap.get(label._relatedIndex);\n const backgroundColor = baseMark.attribute.fill as IColor;\n const foregroundColor = label.fill as IColor;\n label.fill = labelSmartInvert(\n foregroundColor,\n backgroundColor,\n this.attribute.smartInvert?.textType,\n this.attribute.smartInvert?.contrastRatiosThreshold,\n this.attribute.smartInvert?.alternativeColors\n );\n } else if (label.lineWidth > 0) {\n /**\n * 2-a\n * 当文本在图元外部时,设置strokeColor为backgroundColor。labelFill为前景色,labelStroke填充色为背景色。\n */\n const baseMark = this._relationMap.get(label._relatedIndex);\n label.stroke = baseMark.attribute.fill;\n const backgroundColor = label.stroke as IColor;\n const foregroundColor = label.fill as IColor;\n label.fill = labelSmartInvert(\n foregroundColor,\n backgroundColor,\n this.attribute.smartInvert?.textType,\n this.attribute.smartInvert?.contrastRatiosThreshold,\n this.attribute.smartInvert?.alternativeColors\n );\n }\n }\n }\n\n setLocation(point: PointLocationCfg) {\n this.translateTo(point.x, point.y);\n }\n\n disableAnimation() {\n this._enableAnimation = false;\n }\n\n enableAnimation() {\n this._enableAnimation = true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["label/base.ts"],"names":[],"mappings":";;;AAGA,+CAU2B;AAC3B,6CAAmF;AACnF,uCAAiD;AAEjD,+DAA4D;AAC5D,kCAAwC;AACxC,0CAAyC;AACzC,uCAA8F;AAE9F,+CAAkF;AAElF,MAAsB,SAAoC,SAAQ,wBAAoB;IAAtF;;QACE,SAAI,GAAG,OAAO,CAAC;QA0EP,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,MAAM,MAAM,GAAG,CAAC,CAAC,MAA6B,CAAC;YAC/C,IAAI,MAAM,KAAK,IAAI,CAAC,UAAU,IAAI,CAAC,IAAA,gBAAO,EAAC,MAAM,CAAC,MAAM,CA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,MAAA,IAAI,CAAC,SAAS,CAAC,WAAW,0CAAE,uBAAuB,EACnD,MAAA,IAAI,CAAC,SAAS,CAAC,WAAW,0CAAE,iBAAiB,CAC9C,CAAC;aACH;SACF;IACH,CAAC;IAED,WAAW,CAAC,KAAuB;QACjC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAED,eAAe;QACb,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF;AApjBD,8BAojBC","file":"base.js","sourcesContent":["/**\n * @description Label 基类\n */\nimport {\n IGroup,\n Text,\n createText,\n IGraphic,\n IText,\n IncreaseCount,\n AttributeUpdateType,\n FederatedPointerEvent,\n IColor\n} from '@visactor/vrender';\nimport { isFunction, IBoundsLike, isValidNumber, isEmpty } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { PointLocationCfg } from '../core/type';\nimport { labelSmartInvert } from '../util/labelSmartInvert';\nimport { traverseGroup } from '../util';\nimport { StateValue } from '../constant';\nimport { Bitmap, bitmapTool, boundToRange, canPlace, canPlaceInside, place } from './overlap';\nimport { BaseLabelAttrs, OverlapAttrs, ILabelGraphicAttribute, ILabelAnimation } from './type';\nimport { DefaultLabelAnimation, getAnimationAttributes } from './animate/animate';\n\nexport abstract class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {\n name = 'label';\n\n protected _baseMarks?: IGraphic[];\n\n protected _bitmap?: Bitmap;\n\n setBitmap(bitmap: Bitmap) {\n this._bitmap = bitmap;\n }\n\n protected _bmpTool?: ReturnType<typeof bitmapTool>;\n setBitmapTool(bmpTool: ReturnType<typeof bitmapTool>) {\n this._bmpTool = bmpTool;\n }\n\n protected _relationMap: Map<number, IGraphic>;\n\n protected _prevRelationMap: Map<number, IGraphic>;\n\n protected _textMap: Map<IGraphic, IText>;\n\n onAfterLabelOverlap?: (bitmap: Bitmap) => void;\n\n private _lastHover: IGraphic;\n private _lastSelect: IGraphic;\n\n private _enableAnimation: boolean;\n\n protected abstract labeling(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position?: BaseLabelAttrs['position'],\n offset?: number\n ): Partial<ILabelGraphicAttribute> | undefined;\n\n protected render() {\n const currentBaseMarks = this._checkMarks();\n const labels = this.layout(currentBaseMarks);\n\n this._smartInvert(labels);\n\n this._renderLabels(labels);\n }\n\n private _bindEvent(target: IGraphic) {\n if (!target) {\n return;\n }\n\n const { hover, select } = this.attribute;\n\n if (hover) {\n target.addEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n target.addEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n }\n\n if (select) {\n target.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _setStates(target: IGraphic) {\n if (!target) {\n return;\n }\n const state = this.attribute.state;\n\n if (!state || isEmpty(state)) {\n return;\n }\n\n target.states = state;\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (target !== this._lastHover && !isEmpty(target.states)) {\n target.addState(StateValue.hover, true);\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (node !== target && !isEmpty(node.states)) {\n node.addState(StateValue.hoverReverse, true);\n }\n });\n this._lastHover = target;\n }\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n if (this._lastHover) {\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (!isEmpty(node.states)) {\n node.removeState(StateValue.hoverReverse);\n node.removeState(StateValue.hover);\n }\n });\n this._lastHover = null;\n }\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (this._lastSelect === target && target.hasState('selected')) {\n // 取消选中\n this._lastSelect = null;\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (!isEmpty(node.states)) {\n node.removeState(StateValue.selectedReverse);\n node.removeState(StateValue.selected);\n }\n });\n return;\n }\n\n if (!isEmpty(target.states)) {\n target.addState(StateValue.selected, true);\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (node !== target && !isEmpty(node.states)) {\n node.addState(StateValue.selectedReverse, true);\n }\n });\n this._lastSelect = target;\n }\n };\n\n private _createLabelText(attributes: ILabelGraphicAttribute) {\n const text = createText(attributes);\n this._bindEvent(text);\n this._setStates(text);\n return text;\n }\n\n private _checkMarks() {\n const baseMarks = this.getBaseMarks();\n const currentBaseMarks: IGraphic[] = [];\n baseMarks.forEach(mark => {\n if ((mark as any).releaseStatus !== 'willRelease') {\n currentBaseMarks.push(mark);\n }\n });\n this._prevRelationMap = new Map(this._relationMap);\n this._relationMap?.clear();\n return currentBaseMarks;\n }\n\n protected layout(currentMarks?: IGraphic[]): ILabelGraphicAttribute[] {\n const { textStyle, position, offset } = this.attribute as BaseLabelAttrs;\n let { data } = this.attribute as BaseLabelAttrs;\n if (isFunction(data)) {\n data = data({});\n }\n if (!data || data.length === 0) {\n return [];\n }\n\n let labels: ILabelGraphicAttribute[] = [];\n\n if (isFunction(this.attribute.sort) && currentMarks && currentMarks.length) {\n currentMarks = currentMarks.sort(this.attribute.sort);\n }\n\n if (!this._relationMap) {\n this._relationMap = new Map();\n }\n\n // 默认根据 index 顺序排序\n for (let i = 0; i < data.length; i++) {\n const textData = data[i];\n const baseMark = currentMarks?.[i] as IGraphic;\n const labelAttribute = {\n ...textStyle,\n ...textData,\n _relatedIndex: i\n };\n this._relationMap.set(i, baseMark);\n\n if (textData) {\n const text = createText(labelAttribute);\n text.update();\n const textBounds = this.getGraphicBounds(text);\n const graphicBounds = this.getGraphicBounds(baseMark, { x: textData.x as number, y: textData.y as number });\n\n const textAttributes = this.labeling(\n textBounds,\n graphicBounds,\n isFunction(position) ? position(textData) : position,\n offset\n );\n\n if (!textAttributes) {\n continue;\n }\n\n labelAttribute.x = textAttributes.x;\n labelAttribute.y = textAttributes.y;\n\n labels.push(labelAttribute);\n }\n }\n\n this._baseMarks = currentMarks as IGraphic[];\n if (this.attribute.overlap !== false) {\n labels = this.overlapping(labels, this.attribute.overlap as OverlapAttrs);\n }\n\n return labels;\n }\n\n protected overlapping(labels: ILabelGraphicAttribute[], option: OverlapAttrs = {}) {\n if (labels.length === 0) {\n return [];\n }\n const result: ILabelGraphicAttribute[] = [];\n const baseMarkGroup = this.getBaseMarkGroup();\n const size = option.size ?? {\n width: baseMarkGroup?.AABBBounds.width() ?? 0,\n height: baseMarkGroup?.AABBBounds.height() ?? 0\n };\n\n if (size.width === 0 || size.height === 0) {\n return labels;\n }\n\n const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true } = option;\n const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);\n const bitmap = this._bitmap || bmpTool.bitmap();\n const checkBounds = strategy.some(s => s.type === 'bound');\n\n if (avoidBaseMark) {\n this._baseMarks?.forEach(mark => {\n mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, true));\n });\n }\n\n for (let i = 0; i < labels.length; i++) {\n if (labels[i].visible === false) {\n continue;\n }\n const text = createText(labels[i]) as Text;\n const baseMark = this._baseMarks?.[i];\n text.update();\n\n // 默认位置可以放置\n if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce)) {\n // 如果配置了限制在图形内部,需要提前判断;\n if (!checkBounds) {\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push({\n ...text.attribute,\n _insideGraphic: canPlaceInside(text.AABBBounds, baseMark?.AABBBounds)\n });\n continue;\n }\n\n if (checkBounds && baseMark?.AABBBounds && canPlaceInside(text.AABBBounds, baseMark?.AABBBounds)) {\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push({ ...text.attribute, _insideGraphic: true, _computedBound: text.AABBBounds });\n continue;\n }\n }\n\n let hasPlace: ReturnType<typeof place> = false;\n // 发生碰撞,根据策略寻找可放置的位置\n for (let j = 0; j < strategy.length; j++) {\n hasPlace = place(\n bmpTool,\n bitmap,\n strategy[j],\n <BaseLabelAttrs>this.attribute,\n text,\n this.getGraphicBounds(baseMark, labels[i]),\n this.labeling\n );\n if (hasPlace !== false) {\n result.push({\n ...text.attribute,\n x: hasPlace.x,\n y: hasPlace.y,\n _insideGraphic: canPlaceInside(text.AABBBounds, baseMark?.AABBBounds)\n });\n break;\n }\n }\n\n !hasPlace &&\n !hideOnHit &&\n result.push({\n ...text.attribute,\n _insideGraphic: canPlaceInside(text.AABBBounds, baseMark?.AABBBounds),\n _computedBound: text.AABBBounds\n });\n }\n\n if (isFunction(this.onAfterLabelOverlap)) {\n this.onAfterLabelOverlap(bitmap);\n }\n\n return result;\n }\n\n protected getBaseMarks() {\n const baseMarkGroup = this.getBaseMarkGroup() as IGroup;\n if (!baseMarkGroup) {\n return;\n }\n return baseMarkGroup.getChildren() as IGraphic[];\n }\n\n protected getBaseMarkGroup() {\n const { baseMarkGroupName } = this.attribute as BaseLabelAttrs;\n if (!baseMarkGroupName) {\n return;\n }\n return (this.getRootNode() as IGroup).find(node => node.name === baseMarkGroupName, true) as IGroup;\n }\n\n protected getGraphicBounds(graphic?: IGraphic, point: Partial<PointLocationCfg> = {}): IBoundsLike {\n // if (graphic && !isEmpty((graphic as any).finalAttrs)) {\n // const g = graphic.clone();\n // g.onBeforeAttributeUpdate = graphic.onBeforeAttributeUpdate;\n // g.setAttributes((graphic as any).finalAttrs);\n // g.update();\n // return g.AABBBounds;\n // }\n return (\n graphic?.AABBBounds ||\n ({\n x1: point.x,\n x2: point.x,\n y1: point.y,\n y2: point.y\n } as IBoundsLike)\n );\n }\n\n protected _renderLabels(labels: ILabelGraphicAttribute[]) {\n const animationConfig = (this.attribute.animation ?? {}) as ILabelAnimation;\n const disableAnimation = this._enableAnimation === false || (animationConfig as unknown as boolean) === false;\n const mode = animationConfig.mode ?? DefaultLabelAnimation.mode;\n const duration = animationConfig.duration ?? DefaultLabelAnimation.duration;\n const easing = animationConfig.easing ?? DefaultLabelAnimation.easing;\n const delay = animationConfig.delay ?? 0;\n\n const currentTextMap = new Map();\n const prevTextMap = this._textMap || new Map();\n const texts = [] as IText[];\n\n labels.forEach((label, index) => {\n const text = this._createLabelText(label);\n const relatedGraphic = this._relationMap.get(label._relatedIndex);\n const state = prevTextMap?.get(relatedGraphic) ? 'update' : 'enter';\n\n if (state === 'enter') {\n texts.push(text);\n currentTextMap.set(relatedGraphic, text);\n if (!disableAnimation && relatedGraphic) {\n const { from, to } = getAnimationAttributes(label, 'fadeIn');\n this.add(text);\n relatedGraphic.onAnimateBind = () => {\n text.setAttributes(from);\n const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, {\n mode,\n duration,\n easing,\n to,\n delay\n });\n relatedGraphic.on('afterAttributeUpdate', listener);\n };\n } else {\n this.add(text);\n }\n }\n\n if (state === 'update') {\n const prevText = prevTextMap.get(relatedGraphic);\n prevTextMap.delete(relatedGraphic);\n currentTextMap.set(relatedGraphic, prevText);\n if (!disableAnimation) {\n prevText.animate().to(text.attribute, duration, easing);\n if (\n animationConfig.increaseEffect !== false &&\n prevText.attribute.text !== text.attribute.text &&\n isValidNumber(Number(prevText.attribute.text) * Number(text.attribute.text))\n ) {\n prevText\n .animate()\n .play(\n new IncreaseCount(\n { text: prevText.attribute.text as string },\n { text: text.attribute.text as string },\n duration,\n easing\n )\n );\n }\n } else {\n prevText.setAttributes(text.attribute);\n }\n }\n });\n prevTextMap.forEach(label => {\n if (disableAnimation) {\n this.removeChild(label);\n } else {\n label\n ?.animate()\n .to(getAnimationAttributes(label.attribute, 'fadeOut').to, duration, easing)\n .onEnd(() => {\n this.removeChild(label);\n });\n }\n });\n\n this._textMap = currentTextMap;\n }\n\n protected _afterRelatedGraphicAttributeUpdate(\n text: IText,\n texts: IText[],\n index: number,\n relatedGraphic: IGraphic,\n { mode, duration, easing, to, delay }: ILabelAnimation & { to: any }\n ) {\n const listener = (event: any) => {\n const { detail } = event;\n if (!detail) {\n return {};\n }\n\n const isValidAnimateState =\n detail &&\n detail.type === AttributeUpdateType.ANIMATE_UPDATE &&\n detail.animationState &&\n detail.animationState.step?.type !== 'wait';\n\n if (!isValidAnimateState) {\n return {};\n }\n\n if (detail.type === AttributeUpdateType.ANIMATE_END) {\n text.setAttributes(to);\n return;\n }\n\n const onEnd = () => {\n if (relatedGraphic) {\n relatedGraphic.onAnimateBind = undefined;\n relatedGraphic.removeEventListener('afterAttributeUpdate', listener);\n }\n };\n\n switch (mode) {\n case 'after':\n // 3. 当前关联图元的动画播放结束后\n if (detail.animationState.end) {\n text.animate({ onEnd }).wait(delay).to(to, duration, easing);\n }\n break;\n case 'after-all':\n // 2. 所有完成后才开始;\n if (index === texts.length - 1) {\n if (detail.animationState.end) {\n texts.forEach(t => {\n t.animate({ onEnd }).wait(delay).to(to, duration, easing);\n });\n }\n }\n break;\n case 'same-time':\n default:\n // 1. 与当前关联图元的动画播放同时进行\n if (detail.animationState.isFirstFrameOfStep) {\n text.animate({ onEnd }).wait(delay).to(to, duration, easing);\n }\n break;\n }\n };\n return listener;\n }\n\n protected _smartInvert(labels: ILabelGraphicAttribute[]) {\n if (this.attribute.smartInvert === false) {\n return;\n }\n for (let i = 0; i < labels.length; i++) {\n const label = labels?.[i] as ILabelGraphicAttribute;\n if (!label) {\n continue;\n }\n let isInside = label._insideGraphic;\n if (isInside === undefined) {\n const text = createText(label);\n text.update();\n isInside = canPlaceInside(text.AABBBounds, this._relationMap.get(label._relatedIndex)?.AABBBounds);\n }\n /**\n * stroke 的处理逻辑\n * 1. 当文本在图元内部时,有两种情况:\n * - a. 未设置stroke:labelFill为前景色,baseMark填充色为背景色\n * - b. 设置了stroke:labelFill为前景色,labelStroke填充色为背景色\n * 2. 当文本在图元外部时,有两种情况:\n * - a. 未设置stroke:此时设置strokeColor为backgroundColor。labelFill为前景色,labelStroke填充色为背景色。避免文字一半在图元内部,一半在图元外部时,在图元外部文字不可见。\n * - b. 设置了stroke:保持strokeColor。labelFill为前景色,labelStroke填充色为背景色。\n */\n if (label.stroke && label.lineWidth > 0) {\n /**\n * 1-b, 2-b\n * 若label存在stroke,label填充色为前景色,label描边色为背景色\n * WCAG 2 字母周围的文本发光/光晕可用作背景颜色\n */\n label.fill = labelSmartInvert(\n label.fill as IColor,\n label.stroke as IColor,\n this.attribute.smartInvert?.textType,\n this.attribute.smartInvert?.contrastRatiosThreshold,\n this.attribute.smartInvert?.alternativeColors\n );\n } else if (isInside) {\n /**\n * 1-a\n * label在图元内部时,label填充色为前景色,baseMark填充色为背景色\n */\n const baseMark = this._relationMap.get(label._relatedIndex);\n const backgroundColor = baseMark.attribute.fill as IColor;\n const foregroundColor = label.fill as IColor;\n label.fill = labelSmartInvert(\n foregroundColor,\n backgroundColor,\n this.attribute.smartInvert?.textType,\n this.attribute.smartInvert?.contrastRatiosThreshold,\n this.attribute.smartInvert?.alternativeColors\n );\n } else if (label.lineWidth > 0) {\n /**\n * 2-a\n * 当文本在图元外部时,设置strokeColor为backgroundColor。labelFill为前景色,labelStroke填充色为背景色。\n */\n const baseMark = this._relationMap.get(label._relatedIndex);\n label.stroke = baseMark.attribute.fill;\n const backgroundColor = label.stroke as IColor;\n const foregroundColor = label.fill as IColor;\n label.fill = labelSmartInvert(\n foregroundColor,\n backgroundColor,\n this.attribute.smartInvert?.textType,\n this.attribute.smartInvert?.contrastRatiosThreshold,\n this.attribute.smartInvert?.alternativeColors\n );\n }\n }\n }\n\n setLocation(point: PointLocationCfg) {\n this.translateTo(point.x, point.y);\n }\n\n disableAnimation() {\n this._enableAnimation = false;\n }\n\n enableAnimation() {\n this._enableAnimation = true;\n }\n}\n"]}
|
|
@@ -7,8 +7,8 @@ import type { Bitmap } from './bitmap';
|
|
|
7
7
|
import { BitmapTool } from './scaler';
|
|
8
8
|
export declare function canPlace($: BitmapTool, bitmap: Bitmap, bound: IBoundsLike, checkBound?: boolean): boolean;
|
|
9
9
|
export declare function canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds): boolean;
|
|
10
|
-
export declare function placeToCandidates($: BitmapTool, bitmap: Bitmap, text: Text, candidates?: PointLocationCfg[], clampForce?: boolean):
|
|
11
|
-
export declare function place<T extends BaseLabelAttrs>($: BitmapTool, bitmap: Bitmap, s: Strategy, attrs: T, text: Text, bounds: IBoundsLike, labeling?: LabelBase<T>['labeling']):
|
|
10
|
+
export declare function placeToCandidates($: BitmapTool, bitmap: Bitmap, text: Text, candidates?: PointLocationCfg[], clampForce?: boolean): PointLocationCfg | false;
|
|
11
|
+
export declare function place<T extends BaseLabelAttrs>($: BitmapTool, bitmap: Bitmap, s: Strategy, attrs: T, text: Text, bounds: IBoundsLike, labeling?: LabelBase<T>['labeling']): PointLocationCfg | false;
|
|
12
12
|
export declare const DefaultPositions: string[];
|
|
13
13
|
export declare const DefaultRectPositions: string[];
|
|
14
14
|
export declare function defaultLabelPosition(type?: string): string[];
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.defaultLabelPosition = exports.DefaultRectPositions = exports.DefaultPositions = exports.place = exports.placeToCandidates = exports.canPlaceInside = exports.canPlace = void 0;
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), scaler_1 = require("./scaler");
|
|
8
8
|
|
|
9
9
|
function canPlace($, bitmap, bound, checkBound = !0) {
|
|
10
10
|
const range = (0, scaler_1.boundToRange)($, bound);
|
|
@@ -17,12 +17,12 @@ function canPlaceInside(textBound, shapeBound) {
|
|
|
17
17
|
|
|
18
18
|
function placeToCandidates($, bitmap, text, candidates = [], clampForce = !0) {
|
|
19
19
|
for (let i = 0; i < candidates.length; i++) {
|
|
20
|
-
const tempText =
|
|
20
|
+
const tempText = text.clone();
|
|
21
21
|
if (tempText.setAttributes(candidates[i]), tempText.update(), canPlace($, bitmap, (0,
|
|
22
22
|
scaler_1.boundToRange)($, tempText.AABBBounds), clampForce)) return bitmap.setRange((0,
|
|
23
|
-
scaler_1.boundToRange)($, tempText.AABBBounds)),
|
|
24
|
-
!0;
|
|
23
|
+
scaler_1.boundToRange)($, tempText.AABBBounds, !0)), candidates[i];
|
|
25
24
|
}
|
|
25
|
+
return !1;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function place($, bitmap, s, attrs, text, bounds, labeling) {
|
|
@@ -30,7 +30,7 @@ function place($, bitmap, s, attrs, text, bounds, labeling) {
|
|
|
30
30
|
if ("bound" === s.type || "position" === s.type) {
|
|
31
31
|
if ((0, vutils_1.isFunction)(labeling)) {
|
|
32
32
|
const candidates = (((0, vutils_1.isFunction)(s.position) ? s.position(text.attribute) : s.position) || defaultLabelPosition(attrs.type)).map((p => labeling(text.AABBBounds, bounds, p, attrs.offset)));
|
|
33
|
-
return
|
|
33
|
+
return placeToCandidates($, bitmap, text, candidates, null === (_a = attrs.overlap) || void 0 === _a ? void 0 : _a.clampForce);
|
|
34
34
|
}
|
|
35
35
|
return !1;
|
|
36
36
|
}
|
|
@@ -39,14 +39,14 @@ function place($, bitmap, s, attrs, text, bounds, labeling) {
|
|
|
39
39
|
x: text.attribute.x,
|
|
40
40
|
y: text.attribute.y + dy
|
|
41
41
|
})));
|
|
42
|
-
return
|
|
42
|
+
return placeToCandidates($, bitmap, text, candidates, null === (_b = attrs.overlap) || void 0 === _b ? void 0 : _b.clampForce);
|
|
43
43
|
}
|
|
44
44
|
if ("moveX" === s.type) {
|
|
45
45
|
const candidates = (s.offset ? (0, vutils_1.isFunction)(s.offset) ? s.offset(text.attribute) : s.offset : []).map((dx => ({
|
|
46
46
|
x: text.attribute.x + dx,
|
|
47
47
|
y: text.attribute.y
|
|
48
48
|
})));
|
|
49
|
-
return
|
|
49
|
+
return placeToCandidates($, bitmap, text, candidates, null === (_c = attrs.overlap) || void 0 === _c ? void 0 : _c.clampForce);
|
|
50
50
|
}
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources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Aa;CACd,CAAC;AACW,QAAA,oBAAoB,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AAEpE,SAAgB,oBAAoB,CAAC,IAAa;IAChD,QAAQ,IAAI,EAAE;QACZ,KAAK,MAAM;YACT,OAAO,4BAAoB,CAAC;QAC9B;YACE,OAAO,wBAAgB,CAAC;KAC3B;AACH,CAAC;AAPD,oDAOC","file":"place.js","sourcesContent":["import { Text } from '@visactor/vrender';\nimport { IAABBBounds, IBoundsLike, isFunction } from '@visactor/vutils';\nimport { PointLocationCfg } from '../../core/type';\nimport type { LabelBase } from '../base';\nimport type { BaseLabelAttrs, OverlapAttrs, Strategy } from '../type';\nimport type { Bitmap } from './bitmap';\nimport { BitmapTool, boundToRange } from './scaler';\n\n/**\n * 防重叠逻辑参考 https://github.com/vega/vega/\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nexport function canPlace($: BitmapTool, bitmap: Bitmap, bound: IBoundsLike, checkBound = true) {\n const range = boundToRange($, bound);\n const outOfBounds = checkBound && bitmap.outOfBounds(range);\n\n if (outOfBounds) {\n return false;\n }\n\n return !bitmap.getRange(range);\n}\n\n/**\n * 是否在图形内部\n * @param textBound\n * @param shapeBound\n * @returns\n */\nexport function canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds) {\n if (!textBound || !shapeBound) {\n return false;\n }\n return shapeBound.encloses(textBound);\n}\n\nexport function placeToCandidates(\n $: BitmapTool,\n bitmap: Bitmap,\n text: Text,\n candidates: PointLocationCfg[] = [],\n clampForce = true\n): PointLocationCfg | false {\n for (let i = 0; i < candidates.length; i++) {\n const tempText = text.clone();\n tempText.setAttributes(candidates[i]);\n tempText.update();\n\n if (canPlace($, bitmap, boundToRange($, tempText.AABBBounds), clampForce)) {\n bitmap.setRange(boundToRange($, tempText.AABBBounds, true));\n return candidates[i];\n }\n }\n return false;\n}\n\nexport function place<T extends BaseLabelAttrs>(\n $: BitmapTool,\n bitmap: Bitmap,\n s: Strategy,\n attrs: T,\n text: Text,\n bounds: IBoundsLike,\n labeling?: LabelBase<T>['labeling']\n): PointLocationCfg | false {\n if (s.type === 'bound' || s.type === 'position') {\n if (isFunction(labeling)) {\n // TODO:这里可以 filter 掉初始位置,提升一部分性能\n const userPosition = isFunction(s.position) ? s.position(text.attribute) : s.position;\n const positions = (userPosition || defaultLabelPosition(attrs.type)) as string[];\n const candidates = positions.map(p => labeling(text.AABBBounds, bounds, p, attrs.offset) as PointLocationCfg);\n return placeToCandidates($, bitmap, text, candidates, (attrs.overlap as OverlapAttrs)?.clampForce);\n }\n return false;\n }\n\n if (s.type === 'moveY') {\n const offset = s.offset ? (isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];\n const candidates = offset.map(dy => {\n return { x: text.attribute.x as number, y: (text.attribute.y as number) + dy };\n });\n return placeToCandidates($, bitmap, text, candidates, (attrs.overlap as OverlapAttrs)?.clampForce);\n }\n\n if (s.type === 'moveX') {\n const offset = s.offset ? (isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];\n const candidates = offset.map(dx => {\n return { x: (text.attribute.x as number) + dx, y: text.attribute.y as number };\n });\n return placeToCandidates($, bitmap, text, candidates, (attrs.overlap as OverlapAttrs)?.clampForce);\n }\n return false;\n}\n\nexport const DefaultPositions = [\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-right',\n 'bottom-right',\n 'top-left',\n 'bottom-left'\n];\nexport const DefaultRectPositions = ['top', 'inside-top', 'inside'];\n\nexport function defaultLabelPosition(type?: string) {\n switch (type) {\n case 'rect':\n return DefaultRectPositions;\n default:\n return DefaultPositions;\n }\n}\n"]}
|
|
@@ -18,7 +18,7 @@ export declare function bitmapTool(width: number, height: number, padding?: numb
|
|
|
18
18
|
width: number;
|
|
19
19
|
height: number;
|
|
20
20
|
};
|
|
21
|
-
export declare function boundToRange($: BitmapTool, bound: IBoundsLike): {
|
|
21
|
+
export declare function boundToRange($: BitmapTool, bound: IBoundsLike, clamp?: boolean): {
|
|
22
22
|
x1: number;
|
|
23
23
|
x2: number;
|
|
24
24
|
y1: number;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.boundToRange = exports.bitmapTool = void 0;
|
|
6
6
|
|
|
7
|
-
const bitmap_1 = require("./bitmap");
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), bitmap_1 = require("./bitmap");
|
|
8
8
|
|
|
9
9
|
function bitmapTool(width, height, padding = 0) {
|
|
10
10
|
const ratio = Math.max(1, Math.sqrt(width * height / 1e6)), w = ~~((width + 2 * padding + ratio) / ratio), h = ~~((height + 2 * padding + ratio) / ratio), scale = _ => ~~((_ + padding) / ratio);
|
|
@@ -13,7 +13,18 @@ function bitmapTool(width, height, padding = 0) {
|
|
|
13
13
|
scale;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function boundToRange($, bound) {
|
|
16
|
+
function boundToRange($, bound, clamp = !1) {
|
|
17
|
+
if (clamp) {
|
|
18
|
+
const {x1: x1, x2: x2, y1: y1, y2: y2} = bound, _x1 = (0, vutils_1.clamp)(x1, 0, $.width), _x2 = (0,
|
|
19
|
+
vutils_1.clamp)(x2, 0, $.width), _y1 = (0, vutils_1.clamp)(y1, 0, $.height), _y2 = (0,
|
|
20
|
+
vutils_1.clamp)(y2, 0, $.height);
|
|
21
|
+
return {
|
|
22
|
+
x1: $(_x1),
|
|
23
|
+
x2: $(_x2),
|
|
24
|
+
y1: $(_y1),
|
|
25
|
+
y2: $(_y2)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
17
28
|
return {
|
|
18
29
|
x1: $(bound.x1),
|
|
19
30
|
x2: $(bound.x2),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["label/overlap/scaler.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["label/overlap/scaler.ts"],"names":[],"mappings":";;;AAAA,6CAAoE;AACpE,qCAAkC;AAiClC,SAAgB,UAAU,CAAC,KAAa,EAAE,MAAc,EAAE,OAAO,GAAG,CAAC;IACnE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,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AAO;YACL,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;YACV,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;YACV,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;YACV,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;SACX,CAAC;KACH;IAED,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACf,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACf,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACf,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;KAChB,CAAC;AACJ,CAAC;AArBD,oCAqBC","file":"scaler.js","sourcesContent":["import { IBoundsLike, clamp as clampRange } from '@visactor/vutils';\nimport { bitmap } from './bitmap';\n\n/**\n * 防重叠逻辑参考 https://github.com/vega/vega/\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nexport function bitmapTool(width: number, height: number, padding = 0) {\n const ratio = Math.max(1, Math.sqrt((width * height) / 1e6));\n const w = ~~((width + 2 * padding + ratio) / ratio);\n const h = ~~((height + 2 * padding + ratio) / ratio);\n const scale = (_: number) => ~~((_ + padding) / ratio);\n\n scale.invert = (_: number) => _ * ratio - padding;\n scale.bitmap = () => bitmap(w, h);\n scale.ratio = ratio;\n scale.padding = padding;\n scale.width = width;\n scale.height = height;\n\n return scale;\n}\n\nexport function boundToRange($: BitmapTool, bound: IBoundsLike, clamp: boolean = false) {\n if (clamp) {\n const { x1, x2, y1, y2 } = bound;\n const _x1 = clampRange(x1, 0, $.width);\n const _x2 = clampRange(x2, 0, $.width);\n const _y1 = clampRange(y1, 0, $.height);\n const _y2 = clampRange(y2, 0, $.height);\n return {\n x1: $(_x1),\n x2: $(_x2),\n y1: $(_y1),\n y2: $(_y2)\n };\n }\n\n return {\n x1: $(bound.x1),\n x2: $(bound.x2),\n y1: $(bound.y1),\n y2: $(bound.y2)\n };\n}\n\nexport type BitmapTool = ReturnType<typeof bitmapTool>;\n"]}
|