@visactor/vrender-components 0.18.0-alpha.0 → 0.18.0-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/cjs/axis/base.js +24 -24
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/grid/base.js +1 -1
- package/cjs/axis/grid/base.js.map +1 -1
- package/cjs/axis/line.js +59 -52
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/overlap/auto-hide.d.ts +1 -0
- package/cjs/axis/overlap/auto-hide.js +10 -2
- package/cjs/axis/overlap/auto-hide.js.map +1 -1
- package/cjs/axis/overlap/auto-limit.d.ts +1 -0
- package/cjs/axis/overlap/auto-limit.js +5 -3
- package/cjs/axis/overlap/auto-limit.js.map +1 -1
- package/cjs/axis/type.d.ts +1 -0
- package/cjs/axis/type.js.map +1 -1
- package/cjs/brush/brush.js +4 -4
- package/cjs/brush/brush.js.map +1 -1
- package/cjs/checkbox/checkbox.js +2 -1
- package/cjs/checkbox/checkbox.js.map +1 -1
- package/cjs/core/type.d.ts +10 -8
- package/cjs/core/type.js.map +1 -1
- package/cjs/data-zoom/data-zoom.d.ts +5 -1
- package/cjs/data-zoom/data-zoom.js +136 -78
- package/cjs/data-zoom/data-zoom.js.map +1 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -2
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/indicator.d.ts +3 -1
- package/cjs/indicator/indicator.js +60 -46
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.d.ts +1 -0
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/label/arc.d.ts +2 -2
- package/cjs/label/arc.js +38 -35
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +6 -8
- package/cjs/label/base.js +92 -65
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/line.js +3 -4
- package/cjs/label/line.js.map +1 -1
- package/cjs/label/type.d.ts +15 -8
- package/cjs/label/type.js.map +1 -1
- package/cjs/label/util.d.ts +4 -0
- package/cjs/label/util.js +24 -3
- package/cjs/label/util.js.map +1 -1
- package/cjs/legend/base.js +1 -1
- package/cjs/legend/base.js.map +1 -1
- package/cjs/legend/discrete/discrete.d.ts +1 -14
- package/cjs/legend/discrete/discrete.js +39 -60
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/legend/discrete/type.d.ts +0 -1
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/legend/type.d.ts +2 -2
- package/cjs/legend/type.js.map +1 -1
- package/cjs/marker/area.js +5 -1
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +1 -0
- package/cjs/marker/base.js +6 -3
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/line.js +7 -1
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +1 -0
- package/cjs/marker/point.js +24 -11
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/type.d.ts +1 -0
- package/cjs/marker/type.js.map +1 -1
- package/cjs/pager/pager.d.ts +0 -2
- package/cjs/pager/pager.js +8 -16
- package/cjs/pager/pager.js.map +1 -1
- package/cjs/pager/type.d.ts +0 -1
- package/cjs/pager/type.js.map +1 -1
- package/cjs/scrollbar/scrollbar.js +9 -3
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/cjs/segment/segment.js +1 -1
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/slider/slider.js +1 -1
- package/cjs/slider/slider.js.map +1 -1
- package/cjs/tag/tag.js +28 -42
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/title/title.js +2 -2
- package/cjs/title/title.js.map +1 -1
- package/cjs/tooltip/tooltip.js +1 -1
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/util/limit-shape.d.ts +4 -0
- package/cjs/util/limit-shape.js +13 -4
- package/cjs/util/limit-shape.js.map +1 -1
- package/cjs/util/text.d.ts +5 -2
- package/cjs/util/text.js +19 -6
- package/cjs/util/text.js.map +1 -1
- package/es/axis/base.js +22 -26
- package/es/axis/base.js.map +1 -1
- package/es/axis/grid/base.js +1 -1
- package/es/axis/grid/base.js.map +1 -1
- package/es/axis/line.js +59 -50
- package/es/axis/line.js.map +1 -1
- package/es/axis/overlap/auto-hide.d.ts +1 -0
- package/es/axis/overlap/auto-hide.js +10 -2
- package/es/axis/overlap/auto-hide.js.map +1 -1
- package/es/axis/overlap/auto-limit.d.ts +1 -0
- package/es/axis/overlap/auto-limit.js +5 -3
- package/es/axis/overlap/auto-limit.js.map +1 -1
- package/es/axis/type.d.ts +1 -0
- package/es/axis/type.js.map +1 -1
- package/es/brush/brush.js +4 -4
- package/es/brush/brush.js.map +1 -1
- package/es/checkbox/checkbox.js +2 -1
- package/es/checkbox/checkbox.js.map +1 -1
- package/es/core/type.d.ts +10 -8
- package/es/core/type.js.map +1 -1
- package/es/data-zoom/data-zoom.d.ts +5 -1
- package/es/data-zoom/data-zoom.js +135 -74
- package/es/data-zoom/data-zoom.js.map +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/index.js.map +1 -1
- package/es/indicator/indicator.d.ts +3 -1
- package/es/indicator/indicator.js +57 -47
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.d.ts +1 -0
- package/es/indicator/type.js.map +1 -1
- package/es/label/arc.d.ts +2 -2
- package/es/label/arc.js +38 -35
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +6 -8
- package/es/label/base.js +92 -65
- package/es/label/base.js.map +1 -1
- package/es/label/line.js +3 -4
- package/es/label/line.js.map +1 -1
- package/es/label/type.d.ts +15 -8
- package/es/label/type.js.map +1 -1
- package/es/label/util.d.ts +4 -0
- package/es/label/util.js +22 -2
- package/es/label/util.js.map +1 -1
- package/es/legend/base.js +1 -1
- package/es/legend/base.js.map +1 -1
- package/es/legend/discrete/discrete.d.ts +1 -14
- package/es/legend/discrete/discrete.js +40 -58
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/legend/discrete/type.d.ts +0 -1
- package/es/legend/discrete/type.js.map +1 -1
- package/es/legend/type.d.ts +2 -2
- package/es/legend/type.js.map +1 -1
- package/es/marker/area.js +6 -2
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +1 -0
- package/es/marker/base.js +6 -3
- package/es/marker/base.js.map +1 -1
- package/es/marker/line.js +8 -2
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +1 -0
- package/es/marker/point.js +25 -11
- package/es/marker/point.js.map +1 -1
- package/es/marker/type.d.ts +1 -0
- package/es/marker/type.js.map +1 -1
- package/es/pager/pager.d.ts +0 -2
- package/es/pager/pager.js +8 -17
- package/es/pager/pager.js.map +1 -1
- package/es/pager/type.d.ts +0 -1
- package/es/pager/type.js.map +1 -1
- package/es/scrollbar/scrollbar.js +9 -3
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/es/segment/segment.js +1 -1
- package/es/segment/segment.js.map +1 -1
- package/es/slider/slider.js +1 -1
- package/es/slider/slider.js.map +1 -1
- package/es/tag/tag.js +29 -45
- package/es/tag/tag.js.map +1 -1
- package/es/title/title.js +3 -3
- package/es/title/title.js.map +1 -1
- package/es/tooltip/tooltip.js +1 -1
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/util/limit-shape.d.ts +4 -0
- package/es/util/limit-shape.js +11 -3
- package/es/util/limit-shape.js.map +1 -1
- package/es/util/text.d.ts +5 -2
- package/es/util/text.js +17 -5
- package/es/util/text.js.map +1 -1
- package/package.json +5 -5
- package/dist/index.js +0 -29932
- package/dist/index.min.js +0 -1
package/es/core/type.d.ts
CHANGED
|
@@ -28,16 +28,18 @@ export type Padding = number | number[] | {
|
|
|
28
28
|
right?: number;
|
|
29
29
|
};
|
|
30
30
|
type CommonTextContent = {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
text?: string | string[] | number | number[] | {
|
|
32
|
+
type?: 'text';
|
|
33
|
+
text: string | string[] | number | number[];
|
|
34
|
+
};
|
|
33
35
|
};
|
|
34
36
|
type RichTextContent = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
text?: {
|
|
38
|
+
type: 'rich';
|
|
39
|
+
text: IRichTextCharacter[];
|
|
40
|
+
};
|
|
37
41
|
};
|
|
38
|
-
type
|
|
39
|
-
type?: '
|
|
40
|
-
text?: string | HTMLElement;
|
|
42
|
+
export type TextContent = (CommonTextContent | RichTextContent) & {
|
|
43
|
+
type?: 'text' | 'rich';
|
|
41
44
|
};
|
|
42
|
-
export type TextContent = CommonTextContent | RichTextContent | HtmlTextContent;
|
|
43
45
|
export {};
|
package/es/core/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IRichTextCharacter } from '@visactor/vrender-core';\n\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport interface LocationCfg {\n [key: string]: any;\n}\n\nexport interface PointLocationCfg extends LocationCfg {\n /**\n * 位置 x\n * @type {number}\n */\n x: number;\n /**\n * 位置 y\n * @type {number}\n */\n y: number;\n}\n\nexport interface RegionLocationCfg extends LocationCfg {\n /**\n * 起始点\n */\n start: Point;\n /**\n * 结束点\n */\n end: Point;\n}\n\nexport type State<T> = {\n [key: string]: T;\n};\n\nexport type BaseGraphicAttributes<T> = {\n /**\n * 基础样式设置\n */\n style?: T;\n /**\n * 状态样式设置\n */\n state?: State<T>;\n};\n\nexport type Padding =\n | number\n | number[]\n | {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n };\n\ntype CommonTextContent = {\n type?: 'text';\n
|
|
1
|
+
{"version":3,"sources":["../src/core/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IRichTextCharacter } from '@visactor/vrender-core';\n\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport interface LocationCfg {\n [key: string]: any;\n}\n\nexport interface PointLocationCfg extends LocationCfg {\n /**\n * 位置 x\n * @type {number}\n */\n x: number;\n /**\n * 位置 y\n * @type {number}\n */\n y: number;\n}\n\nexport interface RegionLocationCfg extends LocationCfg {\n /**\n * 起始点\n */\n start: Point;\n /**\n * 结束点\n */\n end: Point;\n}\n\nexport type State<T> = {\n [key: string]: T;\n};\n\nexport type BaseGraphicAttributes<T> = {\n /**\n * 基础样式设置\n */\n style?: T;\n /**\n * 状态样式设置\n */\n state?: State<T>;\n};\n\nexport type Padding =\n | number\n | number[]\n | {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n };\n\ntype CommonTextContent = {\n text?:\n | string\n | string[]\n | number\n | number[]\n | {\n type?: 'text';\n text: string | string[] | number | number[];\n };\n};\n\ntype RichTextContent = {\n text?: {\n type: 'rich';\n text: IRichTextCharacter[];\n };\n};\n\nexport type TextContent = (CommonTextContent | RichTextContent) & {\n /** @deprecated */\n type?: 'text' | 'rich';\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FederatedPointerEvent, IGroup } from '@visactor/vrender-core';
|
|
2
|
-
import type { IPointLike } from '@visactor/vutils';
|
|
2
|
+
import type { IBoundsLike, IPointLike } from '@visactor/vutils';
|
|
3
3
|
import { AbstractComponent } from '../core/base';
|
|
4
4
|
import type { TagAttributes } from '../tag';
|
|
5
5
|
import { Tag } from '../tag';
|
|
@@ -154,7 +154,9 @@ export declare class DataZoom extends AbstractComponent<Required<DataZoomAttribu
|
|
|
154
154
|
private _previewPointsY1;
|
|
155
155
|
private _statePointToData;
|
|
156
156
|
private _layoutAttrFromConfig;
|
|
157
|
+
setPropsFromAttrs(): void;
|
|
157
158
|
constructor(attributes: DataZoomAttributes, options?: ComponentOptions);
|
|
159
|
+
setAttributes(params: Partial<Required<DataZoomAttributes>>, forceUpdateTag?: boolean): void;
|
|
158
160
|
protected bindEvents(): void;
|
|
159
161
|
protected dragMaskSize(): number;
|
|
160
162
|
protected setStateAttr(start: number, end: number, shouldRender: boolean): void;
|
|
@@ -170,6 +172,8 @@ export declare class DataZoom extends AbstractComponent<Required<DataZoomAttribu
|
|
|
170
172
|
protected backgroundDragZoom(startPos: IPointLike, endPos: IPointLike): void;
|
|
171
173
|
protected moveZoomWithMiddle(middle: number): void;
|
|
172
174
|
protected renderDragMask(): void;
|
|
175
|
+
protected isTextOverflow(componentBoundsLike: IBoundsLike, textBounds: IBoundsLike | null, layout: 'start' | 'end'): boolean;
|
|
176
|
+
protected setTextAttr(startTextBounds: IBoundsLike, endTextBounds: IBoundsLike): void;
|
|
173
177
|
protected renderText(): void;
|
|
174
178
|
protected getLayoutAttrFromConfig(): any;
|
|
175
179
|
protected render(): void;
|
|
@@ -10,7 +10,7 @@ var __rest = this && this.__rest || function(s, e) {
|
|
|
10
10
|
|
|
11
11
|
import { vglobal } from "@visactor/vrender-core";
|
|
12
12
|
|
|
13
|
-
import { array, clamp, debounce, isFunction, isValid, merge, throttle } from "@visactor/vutils";
|
|
13
|
+
import { Bounds, array, clamp, debounce, isFunction, isValid, merge, throttle } from "@visactor/vutils";
|
|
14
14
|
|
|
15
15
|
import { AbstractComponent } from "../core/base";
|
|
16
16
|
|
|
@@ -30,6 +30,16 @@ const delayMap = {
|
|
|
30
30
|
loadDataZoomComponent();
|
|
31
31
|
|
|
32
32
|
export class DataZoom extends AbstractComponent {
|
|
33
|
+
setPropsFromAttrs() {
|
|
34
|
+
const {start: start, end: end, orient: orient, previewData: previewData, previewPointsX: previewPointsX, previewPointsY: previewPointsY, previewPointsX1: previewPointsX1, previewPointsY1: previewPointsY1} = this.attribute;
|
|
35
|
+
start && (this.state.start = start), end && (this.state.end = end);
|
|
36
|
+
const {width: width, height: height} = this.getLayoutAttrFromConfig();
|
|
37
|
+
this._spanCache = this.state.end - this.state.start, this._isHorizontal = "top" === orient || "bottom" === orient,
|
|
38
|
+
this._layoutCache.max = this._isHorizontal ? width : height, this._layoutCache.attPos = this._isHorizontal ? "x" : "y",
|
|
39
|
+
this._layoutCache.attSize = this._isHorizontal ? "width" : "height", previewData && (this._previewData = previewData),
|
|
40
|
+
isFunction(previewPointsX) && (this._previewPointsX = previewPointsX), isFunction(previewPointsY) && (this._previewPointsY = previewPointsY),
|
|
41
|
+
isFunction(previewPointsX1) && (this._previewPointsX1 = previewPointsX1), isFunction(previewPointsY1) && (this._previewPointsY1 = previewPointsY1);
|
|
42
|
+
}
|
|
33
43
|
constructor(attributes, options) {
|
|
34
44
|
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DataZoom.defaultAttributes, attributes)),
|
|
35
45
|
this.name = "dataZoom", this._previewData = [], this._activeState = !1, this._activeCache = {
|
|
@@ -76,14 +86,12 @@ export class DataZoom extends AbstractComponent {
|
|
|
76
86
|
tag: this._activeTag
|
|
77
87
|
}));
|
|
78
88
|
}), this.attribute.delayTime);
|
|
79
|
-
const {
|
|
80
|
-
start && (this.state.start = start), end && (this.state.end = end), this._spanCache = this.state.end - this.state.start,
|
|
81
|
-
this._isHorizontal = "top" === orient || "bottom" === orient, this._layoutCache.max = this._isHorizontal ? width : height,
|
|
82
|
-
this._layoutCache.attPos = this._isHorizontal ? "x" : "y", this._layoutCache.attSize = this._isHorizontal ? "width" : "height",
|
|
89
|
+
const {position: position, showDetail: showDetail} = attributes;
|
|
83
90
|
this._activeCache.startPos = position, this._activeCache.lastPos = position, this._showText = "auto" !== showDetail && showDetail,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
this.setPropsFromAttrs();
|
|
92
|
+
}
|
|
93
|
+
setAttributes(params, forceUpdateTag) {
|
|
94
|
+
super.setAttributes(params, forceUpdateTag), this.setPropsFromAttrs();
|
|
87
95
|
}
|
|
88
96
|
bindEvents() {
|
|
89
97
|
if (this.attribute.disableTriggerEvent) return;
|
|
@@ -115,7 +123,7 @@ export class DataZoom extends AbstractComponent {
|
|
|
115
123
|
}
|
|
116
124
|
eventPosToStagePos(e) {
|
|
117
125
|
var _a, _b;
|
|
118
|
-
const {x: x, y: y} = vglobal.mapToCanvasPoint(e);
|
|
126
|
+
const {x: x, y: y} = vglobal.mapToCanvasPoint(e, this.stage.window.getContext().canvas.nativeCanvas);
|
|
119
127
|
return {
|
|
120
128
|
x: x - ((null === (_a = this.stage) || void 0 === _a ? void 0 : _a.x) || 0),
|
|
121
129
|
y: y - ((null === (_b = this.stage) || void 0 === _b ? void 0 : _b.y) || 0)
|
|
@@ -169,55 +177,79 @@ export class DataZoom extends AbstractComponent {
|
|
|
169
177
|
height: this._activeState && this._activeTag === DataZoomActiveTag.background && Math.abs(this.dragMaskSize()) || 0
|
|
170
178
|
}, dragMaskStyle), "rect");
|
|
171
179
|
}
|
|
172
|
-
|
|
173
|
-
|
|
180
|
+
isTextOverflow(componentBoundsLike, textBounds, layout) {
|
|
181
|
+
if (!textBounds) return !1;
|
|
182
|
+
if (this._isHorizontal) {
|
|
183
|
+
if ("start" === layout) {
|
|
184
|
+
if (textBounds.x1 < componentBoundsLike.x1) return !0;
|
|
185
|
+
} else if (textBounds.x2 > componentBoundsLike.x2) return !0;
|
|
186
|
+
} else if ("start" === layout) {
|
|
187
|
+
if (textBounds.y1 < componentBoundsLike.y1) return !0;
|
|
188
|
+
} else if (textBounds.y2 > componentBoundsLike.y2) return !0;
|
|
189
|
+
return !1;
|
|
190
|
+
}
|
|
191
|
+
setTextAttr(startTextBounds, endTextBounds) {
|
|
192
|
+
const {startTextStyle: startTextStyle, endTextStyle: endTextStyle} = this.attribute, {formatMethod: startTextFormat} = startTextStyle, restStartTextStyle = __rest(startTextStyle, [ "formatMethod" ]), {formatMethod: endTextFormat} = endTextStyle, restEndTextStyle = __rest(endTextStyle, [ "formatMethod" ]), {start: start, end: end} = this.state;
|
|
174
193
|
this._startValue = this._statePointToData(start), this._endValue = this._statePointToData(end);
|
|
175
|
-
const {position: position, width: width, height: height} = this.getLayoutAttrFromConfig()
|
|
176
|
-
|
|
177
|
-
|
|
194
|
+
const {position: position, width: width, height: height} = this.getLayoutAttrFromConfig(), startTextValue = startTextFormat ? startTextFormat(this._startValue) : this._startValue, endTextValue = endTextFormat ? endTextFormat(this._endValue) : this._endValue, componentBoundsLike = {
|
|
195
|
+
x1: position.x,
|
|
196
|
+
y1: position.y,
|
|
197
|
+
x2: position.x + width,
|
|
198
|
+
y2: position.y + height
|
|
199
|
+
};
|
|
200
|
+
let startTextPosition, endTextPosition, startTextAlignStyle, endTextAlignStyle;
|
|
201
|
+
this._isHorizontal ? (startTextPosition = {
|
|
178
202
|
x: position.x + start * width,
|
|
179
|
-
y: position.y + height / 2
|
|
180
|
-
|
|
181
|
-
pickable: !1,
|
|
182
|
-
childrenPickable: !1,
|
|
183
|
-
textStyle: {
|
|
184
|
-
textAlign: "right",
|
|
185
|
-
textBaseline: "middle"
|
|
186
|
-
}
|
|
187
|
-
}), `data-zoom-start-text-${position}`), this._endText = this.maybeAddLabel(this._container, merge({}, restEndTextStyle, {
|
|
188
|
-
text: endTextFormat ? endTextFormat(this._endValue) : this._endValue,
|
|
203
|
+
y: position.y + height / 2
|
|
204
|
+
}, endTextPosition = {
|
|
189
205
|
x: position.x + end * width,
|
|
190
|
-
y: position.y + height / 2
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}), `data-zoom-end-text-${position}`)) : (this._startText = this.maybeAddLabel(this._container, merge({}, restStartStyle, {
|
|
199
|
-
text: startTextFormat ? startTextFormat(this._startValue) : this._startValue,
|
|
206
|
+
y: position.y + height / 2
|
|
207
|
+
}, startTextAlignStyle = {
|
|
208
|
+
textAlign: this.isTextOverflow(componentBoundsLike, startTextBounds, "start") ? "left" : "right",
|
|
209
|
+
textBaseline: "middle"
|
|
210
|
+
}, endTextAlignStyle = {
|
|
211
|
+
textAlign: this.isTextOverflow(componentBoundsLike, endTextBounds, "end") ? "right" : "left",
|
|
212
|
+
textBaseline: "middle"
|
|
213
|
+
}) : (startTextPosition = {
|
|
200
214
|
x: position.x + width / 2,
|
|
201
|
-
y: position.y + start * height
|
|
215
|
+
y: position.y + start * height
|
|
216
|
+
}, endTextPosition = {
|
|
217
|
+
x: position.x + width / 2,
|
|
218
|
+
y: position.y + end * height
|
|
219
|
+
}, startTextAlignStyle = {
|
|
220
|
+
textAlign: "center",
|
|
221
|
+
textBaseline: this.isTextOverflow(componentBoundsLike, startTextBounds, "start") ? "top" : "bottom"
|
|
222
|
+
}, endTextAlignStyle = {
|
|
223
|
+
textAlign: "center",
|
|
224
|
+
textBaseline: this.isTextOverflow(componentBoundsLike, endTextBounds, "end") ? "bottom" : "top"
|
|
225
|
+
}), this._startText = this.maybeAddLabel(this._container, merge({}, restStartTextStyle, {
|
|
226
|
+
text: startTextValue,
|
|
227
|
+
x: startTextPosition.x,
|
|
228
|
+
y: startTextPosition.y,
|
|
202
229
|
visible: this._showText,
|
|
203
230
|
pickable: !1,
|
|
204
231
|
childrenPickable: !1,
|
|
205
|
-
textStyle:
|
|
206
|
-
textAlign: "center",
|
|
207
|
-
textBaseline: "bottom"
|
|
208
|
-
}
|
|
232
|
+
textStyle: startTextAlignStyle
|
|
209
233
|
}), `data-zoom-start-text-${position}`), this._endText = this.maybeAddLabel(this._container, merge({}, restEndTextStyle, {
|
|
210
|
-
text:
|
|
211
|
-
x:
|
|
212
|
-
y:
|
|
234
|
+
text: endTextValue,
|
|
235
|
+
x: endTextPosition.x,
|
|
236
|
+
y: endTextPosition.y,
|
|
213
237
|
visible: this._showText,
|
|
214
238
|
pickable: !1,
|
|
215
239
|
childrenPickable: !1,
|
|
216
|
-
textStyle:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
240
|
+
textStyle: endTextAlignStyle
|
|
241
|
+
}), `data-zoom-end-text-${position}`);
|
|
242
|
+
}
|
|
243
|
+
renderText() {
|
|
244
|
+
let startTextBounds = null, endTextBounds = null;
|
|
245
|
+
this.setTextAttr(startTextBounds, endTextBounds), startTextBounds = this._startText.AABBBounds,
|
|
246
|
+
endTextBounds = this._endText.AABBBounds, this.setTextAttr(startTextBounds, endTextBounds),
|
|
247
|
+
startTextBounds = this._startText.AABBBounds, endTextBounds = this._endText.AABBBounds;
|
|
248
|
+
const {x1: x1, x2: x2, y1: y1, y2: y2} = startTextBounds, {dx: startTextDx = 0, dy: startTextDy = 0} = this.attribute.startTextStyle;
|
|
249
|
+
if ((new Bounds).set(x1, y1, x2, y2).intersects(endTextBounds)) {
|
|
250
|
+
const direction = "bottom" === this.attribute.orient || "right" === this.attribute.orient ? -1 : 1;
|
|
251
|
+
this._isHorizontal ? this._startText.setAttribute("dy", startTextDy + direction * Math.abs(endTextBounds.y1 - endTextBounds.y2)) : this._startText.setAttribute("dx", startTextDx + direction * Math.abs(endTextBounds.x1 - endTextBounds.x2));
|
|
252
|
+
} else this._isHorizontal ? this._startText.setAttribute("dy", startTextDy) : this._startText.setAttribute("dx", startTextDx);
|
|
221
253
|
}
|
|
222
254
|
getLayoutAttrFromConfig() {
|
|
223
255
|
var _a, _b, _c, _d;
|
|
@@ -249,59 +281,72 @@ export class DataZoom extends AbstractComponent {
|
|
|
249
281
|
render() {
|
|
250
282
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
251
283
|
this._layoutAttrFromConfig = null;
|
|
252
|
-
const {orient: orient, backgroundStyle: backgroundStyle, backgroundChartStyle: backgroundChartStyle = {}, selectedBackgroundStyle: selectedBackgroundStyle = {}, selectedBackgroundChartStyle: selectedBackgroundChartStyle = {}, middleHandlerStyle: middleHandlerStyle = {}, startHandlerStyle: startHandlerStyle = {}, endHandlerStyle: endHandlerStyle = {}, brushSelect: brushSelect} = this.attribute, {start: start, end: end} = this.state, {position: position, width: width, height: height} = this.getLayoutAttrFromConfig(), startHandlerMinSize = null !== (_a = startHandlerStyle.triggerMinSize) && void 0 !== _a ? _a : 40, endHandlerMinSize = null !== (_b = endHandlerStyle.triggerMinSize) && void 0 !== _b ? _b : 40, group = this.createOrUpdateChild("dataZoom-container", {}, "group");
|
|
253
|
-
if (this._container = group, this._background = group.createOrUpdateChild("background", Object.assign({
|
|
284
|
+
const {orient: orient, backgroundStyle: backgroundStyle, backgroundChartStyle: backgroundChartStyle = {}, selectedBackgroundStyle: selectedBackgroundStyle = {}, selectedBackgroundChartStyle: selectedBackgroundChartStyle = {}, middleHandlerStyle: middleHandlerStyle = {}, startHandlerStyle: startHandlerStyle = {}, endHandlerStyle: endHandlerStyle = {}, brushSelect: brushSelect, zoomLock: zoomLock} = this.attribute, {start: start, end: end} = this.state, {position: position, width: width, height: height} = this.getLayoutAttrFromConfig(), startHandlerMinSize = null !== (_a = startHandlerStyle.triggerMinSize) && void 0 !== _a ? _a : 40, endHandlerMinSize = null !== (_b = endHandlerStyle.triggerMinSize) && void 0 !== _b ? _b : 40, group = this.createOrUpdateChild("dataZoom-container", {}, "group");
|
|
285
|
+
if (this._container = group, this._background = group.createOrUpdateChild("background", Object.assign(Object.assign({
|
|
254
286
|
x: position.x,
|
|
255
287
|
y: position.y,
|
|
256
288
|
width: width,
|
|
257
289
|
height: height,
|
|
258
290
|
cursor: brushSelect ? "crosshair" : "auto"
|
|
259
|
-
}, backgroundStyle),
|
|
291
|
+
}, backgroundStyle), {
|
|
292
|
+
pickable: !zoomLock
|
|
293
|
+
}), "rect"), (null === (_c = backgroundChartStyle.line) || void 0 === _c ? void 0 : _c.visible) && this.setPreviewAttributes("line", group),
|
|
260
294
|
(null === (_d = backgroundChartStyle.area) || void 0 === _d ? void 0 : _d.visible) && this.setPreviewAttributes("area", group),
|
|
261
|
-
brushSelect && this.renderDragMask(), this._isHorizontal ? this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign({
|
|
295
|
+
brushSelect && this.renderDragMask(), this._isHorizontal ? this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
|
|
262
296
|
x: position.x + start * width,
|
|
263
297
|
y: position.y,
|
|
264
298
|
width: (end - start) * width,
|
|
265
299
|
height: height,
|
|
266
300
|
cursor: brushSelect ? "crosshair" : "move"
|
|
267
|
-
}, selectedBackgroundStyle),
|
|
301
|
+
}, selectedBackgroundStyle), {
|
|
302
|
+
pickable: !zoomLock
|
|
303
|
+
}), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
|
|
268
304
|
x: position.x,
|
|
269
305
|
y: position.y + start * height,
|
|
270
306
|
width: width,
|
|
271
307
|
height: (end - start) * height,
|
|
272
308
|
cursor: brushSelect ? "crosshair" : "move"
|
|
273
|
-
}, selectedBackgroundStyle),
|
|
309
|
+
}, selectedBackgroundStyle), {
|
|
310
|
+
pickable: !zoomLock
|
|
311
|
+
}), "rect"), (null === (_e = selectedBackgroundChartStyle.line) || void 0 === _e ? void 0 : _e.visible) && this.setSelectedPreviewAttributes("line", group),
|
|
274
312
|
(null === (_f = selectedBackgroundChartStyle.area) || void 0 === _f ? void 0 : _f.visible) && this.setSelectedPreviewAttributes("area", group),
|
|
275
|
-
this.
|
|
313
|
+
this._isHorizontal) {
|
|
276
314
|
if (middleHandlerStyle.visible) {
|
|
277
315
|
const middleHandlerBackgroundSize = (null === (_g = middleHandlerStyle.background) || void 0 === _g ? void 0 : _g.size) || 10;
|
|
278
|
-
this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign({
|
|
316
|
+
this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign(Object.assign({
|
|
279
317
|
x: position.x + start * width,
|
|
280
318
|
y: position.y - middleHandlerBackgroundSize,
|
|
281
319
|
width: (end - start) * width,
|
|
282
320
|
height: middleHandlerBackgroundSize
|
|
283
|
-
}, null === (_h = middleHandlerStyle.background) || void 0 === _h ? void 0 : _h.style),
|
|
284
|
-
|
|
321
|
+
}, null === (_h = middleHandlerStyle.background) || void 0 === _h ? void 0 : _h.style), {
|
|
322
|
+
pickable: !zoomLock
|
|
323
|
+
}), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
|
|
285
324
|
x: position.x + (start + end) / 2 * width,
|
|
286
325
|
y: position.y - middleHandlerBackgroundSize / 2,
|
|
287
326
|
strokeBoundsBuffer: 0,
|
|
288
327
|
angle: 0,
|
|
289
328
|
symbolType: null !== (_k = null === (_j = middleHandlerStyle.icon) || void 0 === _j ? void 0 : _j.symbolType) && void 0 !== _k ? _k : "square"
|
|
290
|
-
}, middleHandlerStyle.icon),
|
|
329
|
+
}, middleHandlerStyle.icon), {
|
|
330
|
+
pickable: !zoomLock
|
|
331
|
+
}), "symbol");
|
|
291
332
|
}
|
|
292
|
-
this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign({
|
|
333
|
+
this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
|
|
293
334
|
x: position.x + start * width,
|
|
294
335
|
y: position.y + height / 2,
|
|
295
336
|
size: height,
|
|
296
337
|
symbolType: null !== (_l = startHandlerStyle.symbolType) && void 0 !== _l ? _l : "square"
|
|
297
|
-
}, DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle),
|
|
338
|
+
}, DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle), {
|
|
339
|
+
pickable: !zoomLock
|
|
340
|
+
}), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
|
|
298
341
|
x: position.x + end * width,
|
|
299
342
|
y: position.y + height / 2,
|
|
300
343
|
size: height,
|
|
301
344
|
symbolType: null !== (_m = endHandlerStyle.symbolType) && void 0 !== _m ? _m : "square"
|
|
302
|
-
}, DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle),
|
|
345
|
+
}, DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle), {
|
|
346
|
+
pickable: !zoomLock
|
|
347
|
+
}), "symbol");
|
|
303
348
|
const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize), startHandlerHeight = Math.max(this._startHandler.AABBBounds.height(), startHandlerMinSize), endHandlerWidth = Math.max(this._endHandler.AABBBounds.width(), endHandlerMinSize), endHandlerHeight = Math.max(this._endHandler.AABBBounds.height(), endHandlerMinSize);
|
|
304
|
-
this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign({
|
|
349
|
+
this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign(Object.assign({
|
|
305
350
|
x: position.x + start * width - startHandlerWidth / 2,
|
|
306
351
|
y: position.y + height / 2 - startHandlerHeight / 2,
|
|
307
352
|
width: startHandlerWidth,
|
|
@@ -309,7 +354,9 @@ export class DataZoom extends AbstractComponent {
|
|
|
309
354
|
fill: "white",
|
|
310
355
|
fillOpacity: 0,
|
|
311
356
|
zIndex: 999
|
|
312
|
-
}, DEFAULT_HANDLER_ATTR_MAP.horizontal),
|
|
357
|
+
}, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
|
|
358
|
+
pickable: !zoomLock
|
|
359
|
+
}), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
|
|
313
360
|
x: position.x + end * width - endHandlerWidth / 2,
|
|
314
361
|
y: position.y + height / 2 - endHandlerHeight / 2,
|
|
315
362
|
width: endHandlerWidth,
|
|
@@ -317,37 +364,46 @@ export class DataZoom extends AbstractComponent {
|
|
|
317
364
|
fill: "white",
|
|
318
365
|
fillOpacity: 0,
|
|
319
366
|
zIndex: 999
|
|
320
|
-
}, DEFAULT_HANDLER_ATTR_MAP.horizontal),
|
|
367
|
+
}, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
|
|
368
|
+
pickable: !zoomLock
|
|
369
|
+
}), "rect");
|
|
321
370
|
} else {
|
|
322
371
|
if (middleHandlerStyle.visible) {
|
|
323
372
|
const middleHandlerBackgroundSize = (null === (_o = middleHandlerStyle.background) || void 0 === _o ? void 0 : _o.size) || 10;
|
|
324
|
-
this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign({
|
|
373
|
+
this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign(Object.assign({
|
|
325
374
|
x: "left" === orient ? position.x - middleHandlerBackgroundSize : position.x + width,
|
|
326
375
|
y: position.y + start * height,
|
|
327
376
|
width: middleHandlerBackgroundSize,
|
|
328
377
|
height: (end - start) * height
|
|
329
|
-
}, null === (_p = middleHandlerStyle.background) || void 0 === _p ? void 0 : _p.style),
|
|
330
|
-
|
|
378
|
+
}, null === (_p = middleHandlerStyle.background) || void 0 === _p ? void 0 : _p.style), {
|
|
379
|
+
pickable: !zoomLock
|
|
380
|
+
}), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
|
|
331
381
|
x: "left" === orient ? position.x - middleHandlerBackgroundSize / 2 : position.x + width + middleHandlerBackgroundSize / 2,
|
|
332
382
|
y: position.y + (start + end) / 2 * height,
|
|
333
383
|
angle: Math.PI / 180 * 90,
|
|
334
384
|
symbolType: null !== (_r = null === (_q = middleHandlerStyle.icon) || void 0 === _q ? void 0 : _q.symbolType) && void 0 !== _r ? _r : "square",
|
|
335
385
|
strokeBoundsBuffer: 0
|
|
336
|
-
}, middleHandlerStyle.icon),
|
|
386
|
+
}, middleHandlerStyle.icon), {
|
|
387
|
+
pickable: !zoomLock
|
|
388
|
+
}), "symbol");
|
|
337
389
|
}
|
|
338
|
-
this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign({
|
|
390
|
+
this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
|
|
339
391
|
x: position.x + width / 2,
|
|
340
392
|
y: position.y + start * height,
|
|
341
393
|
size: width,
|
|
342
394
|
symbolType: null !== (_s = startHandlerStyle.symbolType) && void 0 !== _s ? _s : "square"
|
|
343
|
-
}, DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle),
|
|
395
|
+
}, DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle), {
|
|
396
|
+
pickable: !zoomLock
|
|
397
|
+
}), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
|
|
344
398
|
x: position.x + width / 2,
|
|
345
399
|
y: position.y + end * height,
|
|
346
400
|
size: width,
|
|
347
401
|
symbolType: null !== (_t = endHandlerStyle.symbolType) && void 0 !== _t ? _t : "square"
|
|
348
|
-
}, DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle),
|
|
402
|
+
}, DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle), {
|
|
403
|
+
pickable: !zoomLock
|
|
404
|
+
}), "symbol");
|
|
349
405
|
const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize), startHandlerHeight = Math.max(this._startHandler.AABBBounds.height(), startHandlerMinSize), endHandlerWidth = Math.max(this._endHandler.AABBBounds.width(), endHandlerMinSize), endHandlerHeight = Math.max(this._endHandler.AABBBounds.height(), endHandlerMinSize);
|
|
350
|
-
this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign({
|
|
406
|
+
this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign(Object.assign({
|
|
351
407
|
x: position.x + width / 2 + startHandlerWidth / 2,
|
|
352
408
|
y: position.y + start * height - startHandlerHeight / 2,
|
|
353
409
|
width: endHandlerHeight,
|
|
@@ -355,7 +411,9 @@ export class DataZoom extends AbstractComponent {
|
|
|
355
411
|
fill: "white",
|
|
356
412
|
fillOpacity: 0,
|
|
357
413
|
zIndex: 999
|
|
358
|
-
}, DEFAULT_HANDLER_ATTR_MAP.vertical),
|
|
414
|
+
}, DEFAULT_HANDLER_ATTR_MAP.vertical), {
|
|
415
|
+
pickable: !zoomLock
|
|
416
|
+
}), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
|
|
359
417
|
x: position.x + width / 2 + endHandlerWidth / 2,
|
|
360
418
|
y: position.y + end * height - endHandlerHeight / 2,
|
|
361
419
|
width: endHandlerHeight,
|
|
@@ -363,8 +421,11 @@ export class DataZoom extends AbstractComponent {
|
|
|
363
421
|
fill: "white",
|
|
364
422
|
fillOpacity: 0,
|
|
365
423
|
zIndex: 999
|
|
366
|
-
}, DEFAULT_HANDLER_ATTR_MAP.vertical),
|
|
424
|
+
}, DEFAULT_HANDLER_ATTR_MAP.vertical), {
|
|
425
|
+
pickable: !zoomLock
|
|
426
|
+
}), "rect");
|
|
367
427
|
}
|
|
428
|
+
this._showText && this.renderText();
|
|
368
429
|
}
|
|
369
430
|
computeBasePoints() {
|
|
370
431
|
const {orient: orient} = this.attribute, {position: position, width: width, height: height} = this.getLayoutAttrFromConfig();
|