@visactor/vrender-components 1.0.18 → 1.0.19

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.
Files changed (60) hide show
  1. package/cjs/axis/line.js +2 -1
  2. package/cjs/axis/line.js.map +1 -1
  3. package/cjs/axis/tick-data/continuous.js.map +1 -1
  4. package/cjs/axis/tick-data/util.js.map +1 -1
  5. package/cjs/brush/brush.js.map +1 -1
  6. package/cjs/brush/config.js +1 -2
  7. package/cjs/data-zoom/data-zoom.d.ts +12 -83
  8. package/cjs/data-zoom/data-zoom.js +104 -542
  9. package/cjs/data-zoom/data-zoom.js.map +1 -1
  10. package/cjs/data-zoom/interaction.d.ts +65 -0
  11. package/cjs/data-zoom/interaction.js +179 -0
  12. package/cjs/data-zoom/interaction.js.map +1 -0
  13. package/cjs/data-zoom/renderer.d.ts +91 -0
  14. package/cjs/data-zoom/renderer.js +461 -0
  15. package/cjs/data-zoom/renderer.js.map +1 -0
  16. package/cjs/data-zoom/type.d.ts +8 -0
  17. package/cjs/data-zoom/type.js +11 -3
  18. package/cjs/data-zoom/type.js.map +1 -1
  19. package/cjs/data-zoom/utils.d.ts +2 -0
  20. package/cjs/data-zoom/utils.js +20 -0
  21. package/cjs/data-zoom/utils.js.map +1 -0
  22. package/cjs/index.d.ts +1 -1
  23. package/cjs/index.js +1 -1
  24. package/cjs/index.js.map +1 -1
  25. package/cjs/indicator/config.js +1 -2
  26. package/cjs/indicator/register.js +2 -1
  27. package/cjs/label/base.js +1 -1
  28. package/cjs/label/data-label-register.js +1 -1
  29. package/cjs/label/dataLabel.js +1 -1
  30. package/dist/index.es.js +1087 -742
  31. package/es/axis/line.js +2 -1
  32. package/es/axis/line.js.map +1 -1
  33. package/es/axis/tick-data/continuous.js.map +1 -1
  34. package/es/axis/tick-data/util.js.map +1 -1
  35. package/es/brush/brush.js.map +1 -1
  36. package/es/brush/config.js +1 -2
  37. package/es/data-zoom/data-zoom.d.ts +12 -83
  38. package/es/data-zoom/data-zoom.js +108 -545
  39. package/es/data-zoom/data-zoom.js.map +1 -1
  40. package/es/data-zoom/interaction.d.ts +65 -0
  41. package/es/data-zoom/interaction.js +177 -0
  42. package/es/data-zoom/interaction.js.map +1 -0
  43. package/es/data-zoom/renderer.d.ts +91 -0
  44. package/es/data-zoom/renderer.js +458 -0
  45. package/es/data-zoom/renderer.js.map +1 -0
  46. package/es/data-zoom/type.d.ts +8 -0
  47. package/es/data-zoom/type.js +13 -0
  48. package/es/data-zoom/type.js.map +1 -1
  49. package/es/data-zoom/utils.d.ts +2 -0
  50. package/es/data-zoom/utils.js +12 -0
  51. package/es/data-zoom/utils.js.map +1 -0
  52. package/es/index.d.ts +1 -1
  53. package/es/index.js +1 -1
  54. package/es/index.js.map +1 -1
  55. package/es/indicator/config.js +1 -2
  56. package/es/indicator/register.js +2 -1
  57. package/es/label/base.js +1 -1
  58. package/es/label/data-label-register.js +1 -1
  59. package/es/label/dataLabel.js +1 -1
  60. package/package.json +4 -4
@@ -0,0 +1,91 @@
1
+ import type { DataZoomAttributes } from './type';
2
+ import type { IGroup, IRect, ISymbol } from '@visactor/vrender-core';
3
+ import { Tag } from '../tag';
4
+ export interface DataZoomRendererAttrs {
5
+ attribute: Partial<Required<DataZoomAttributes>>;
6
+ getLayoutAttrFromConfig: any;
7
+ getState: () => {
8
+ start: number;
9
+ end: number;
10
+ };
11
+ setState: (state: {
12
+ start: number;
13
+ end: number;
14
+ }) => void;
15
+ getContainer: () => IGroup;
16
+ }
17
+ export declare class DataZoomRenderer {
18
+ attribute: Partial<Required<DataZoomAttributes>>;
19
+ private _getLayoutAttrFromConfig;
20
+ private _getState;
21
+ private _getContainer;
22
+ private _isHorizontal;
23
+ private _startHandlerMask;
24
+ get startHandlerMask(): IRect;
25
+ private _startHandler;
26
+ private _middleHandlerSymbol;
27
+ get middleHandlerSymbol(): ISymbol;
28
+ private _middleHandlerRect;
29
+ get middleHandlerRect(): IRect;
30
+ private _endHandlerMask;
31
+ get endHandlerMask(): IRect;
32
+ private _endHandler;
33
+ private _selectedBackground;
34
+ get selectedBackground(): IRect;
35
+ private _dragMask;
36
+ get dragMask(): IRect;
37
+ private _startText;
38
+ get startText(): Tag;
39
+ private _endText;
40
+ get endText(): Tag;
41
+ private _startValue;
42
+ get startValue(): string | number;
43
+ private _endValue;
44
+ get endValue(): string | number;
45
+ private _showText;
46
+ set showText(showText: boolean);
47
+ private _background;
48
+ get background(): IRect;
49
+ private _previewData;
50
+ set previewData(previewData: any[]);
51
+ private _previewGroup;
52
+ get previewGroup(): IGroup;
53
+ private _previewLine;
54
+ private _previewArea;
55
+ private _selectedPreviewGroupClip;
56
+ private _selectedPreviewGroup;
57
+ get selectedPreviewGroup(): IGroup;
58
+ private _selectedPreviewLine;
59
+ private _selectedPreviewArea;
60
+ private _previewPointsX;
61
+ set previewPointsX(previewPointsX: (datum: any) => number);
62
+ private _previewPointsY;
63
+ set previewPointsY(previewPointsY: (datum: any) => number);
64
+ private _previewPointsX1;
65
+ set previewPointsX1(previewPointsX1: (datum: any) => number);
66
+ private _previewPointsY1;
67
+ set previewPointsY1(previewPointsY1: (datum: any) => number);
68
+ private _statePointToData;
69
+ set statePointToData(statePointToData: (state: number) => any);
70
+ private _initAttrs;
71
+ constructor(props: DataZoomRendererAttrs);
72
+ setAttributes(props: DataZoomRendererAttrs): void;
73
+ renderDataZoom(onlyStateChange?: boolean): void;
74
+ renderDragMask(): {
75
+ start: number;
76
+ end: number;
77
+ };
78
+ private _renderBackground;
79
+ private _renderHandler;
80
+ private _renderSelectedBackground;
81
+ private _setPreviewAttributes;
82
+ private _setSelectedPreviewClipAttributes;
83
+ private _setSelectedPreviewAttributes;
84
+ private _computeBasePoints;
85
+ private _simplifyPoints;
86
+ private _getPreviewLinePoints;
87
+ private _getPreviewAreaPoints;
88
+ renderText(): void;
89
+ private _setTextAttr;
90
+ private _maybeAddLabel;
91
+ }
@@ -0,0 +1,461 @@
1
+ "use strict";
2
+
3
+ var __rest = this && this.__rest || function(s, e) {
4
+ var t = {};
5
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
6
+ if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
7
+ var i = 0;
8
+ for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
9
+ }
10
+ return t;
11
+ };
12
+
13
+ Object.defineProperty(exports, "__esModule", {
14
+ value: !0
15
+ }), exports.DataZoomRenderer = void 0;
16
+
17
+ const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), tag_1 = require("../tag"), config_1 = require("./config"), utils_1 = require("./utils");
18
+
19
+ class DataZoomRenderer {
20
+ get startHandlerMask() {
21
+ return this._startHandlerMask;
22
+ }
23
+ get middleHandlerSymbol() {
24
+ return this._middleHandlerSymbol;
25
+ }
26
+ get middleHandlerRect() {
27
+ return this._middleHandlerRect;
28
+ }
29
+ get endHandlerMask() {
30
+ return this._endHandlerMask;
31
+ }
32
+ get selectedBackground() {
33
+ return this._selectedBackground;
34
+ }
35
+ get dragMask() {
36
+ return this._dragMask;
37
+ }
38
+ get startText() {
39
+ return this._startText;
40
+ }
41
+ get endText() {
42
+ return this._endText;
43
+ }
44
+ get startValue() {
45
+ return this._startValue;
46
+ }
47
+ get endValue() {
48
+ return this._endValue;
49
+ }
50
+ set showText(showText) {
51
+ this._showText = showText;
52
+ }
53
+ get background() {
54
+ return this._background;
55
+ }
56
+ set previewData(previewData) {
57
+ this._previewData = previewData;
58
+ }
59
+ get previewGroup() {
60
+ return this._previewGroup;
61
+ }
62
+ get selectedPreviewGroup() {
63
+ return this._selectedPreviewGroup;
64
+ }
65
+ set previewPointsX(previewPointsX) {
66
+ this._previewPointsX = previewPointsX;
67
+ }
68
+ set previewPointsY(previewPointsY) {
69
+ this._previewPointsY = previewPointsY;
70
+ }
71
+ set previewPointsX1(previewPointsX1) {
72
+ this._previewPointsX1 = previewPointsX1;
73
+ }
74
+ set previewPointsY1(previewPointsY1) {
75
+ this._previewPointsY1 = previewPointsY1;
76
+ }
77
+ set statePointToData(statePointToData) {
78
+ this._statePointToData = statePointToData;
79
+ }
80
+ _initAttrs(props) {
81
+ this.attribute = props.attribute, this._isHorizontal = "top" === this.attribute.orient || "bottom" === this.attribute.orient;
82
+ const {previewData: previewData, previewPointsX: previewPointsX, previewPointsY: previewPointsY, previewPointsX1: previewPointsX1, previewPointsY1: previewPointsY1} = this.attribute;
83
+ previewData && (this._previewData = previewData), (0, vutils_1.isFunction)(previewPointsX) && (this._previewPointsX = previewPointsX),
84
+ (0, vutils_1.isFunction)(previewPointsY) && (this._previewPointsY = previewPointsY),
85
+ (0, vutils_1.isFunction)(previewPointsX1) && (this._previewPointsX1 = previewPointsX1),
86
+ (0, vutils_1.isFunction)(previewPointsY1) && (this._previewPointsY1 = previewPointsY1),
87
+ this._getState = props.getState, this._getLayoutAttrFromConfig = props.getLayoutAttrFromConfig,
88
+ this._getContainer = props.getContainer;
89
+ }
90
+ constructor(props) {
91
+ this._previewData = [], this._statePointToData = state => state;
92
+ const {showDetail: showDetail} = props.attribute;
93
+ this._showText = "auto" !== showDetail && showDetail, this._initAttrs(props);
94
+ }
95
+ setAttributes(props) {
96
+ this._initAttrs(props);
97
+ }
98
+ renderDataZoom(onlyStateChange = !1) {
99
+ var _a, _b, _c, _d, _e, _f;
100
+ const {backgroundChartStyle: backgroundChartStyle = {}, selectedBackgroundChartStyle: selectedBackgroundChartStyle = {}, brushSelect: brushSelect} = this.attribute;
101
+ this._renderBackground(), (null === (_a = backgroundChartStyle.line) || void 0 === _a ? void 0 : _a.visible) && !onlyStateChange && this._setPreviewAttributes("line", this._getContainer()),
102
+ (null === (_b = backgroundChartStyle.area) || void 0 === _b ? void 0 : _b.visible) && !onlyStateChange && this._setPreviewAttributes("area", this._getContainer()),
103
+ brushSelect && this.renderDragMask(), this._renderSelectedBackground(), (null === (_c = selectedBackgroundChartStyle.line) || void 0 === _c ? void 0 : _c.visible) && this._setSelectedPreviewClipAttributes("line", this._getContainer()),
104
+ (null === (_d = selectedBackgroundChartStyle.line) || void 0 === _d ? void 0 : _d.visible) && !onlyStateChange && this._setSelectedPreviewAttributes("line"),
105
+ (null === (_e = selectedBackgroundChartStyle.line) || void 0 === _e ? void 0 : _e.visible) && this._setSelectedPreviewClipAttributes("area", this._getContainer()),
106
+ (null === (_f = selectedBackgroundChartStyle.area) || void 0 === _f ? void 0 : _f.visible) && !onlyStateChange && this._setSelectedPreviewAttributes("area"),
107
+ this._renderHandler(), this._showText && this.renderText();
108
+ }
109
+ renderDragMask() {
110
+ const {dragMaskStyle: dragMaskStyle} = this.attribute, {position: position, width: width, height: height} = this._getLayoutAttrFromConfig(), {start: start, end: end} = this._getState();
111
+ return this._isHorizontal ? this._dragMask = this._getContainer().createOrUpdateChild("dragMask", Object.assign({
112
+ x: position.x + start * width,
113
+ y: position.y,
114
+ width: (end - start) * width,
115
+ height: height
116
+ }, dragMaskStyle), "rect") : this._dragMask = this._getContainer().createOrUpdateChild("dragMask", Object.assign({
117
+ x: position.x,
118
+ y: position.y + start * height,
119
+ width: width,
120
+ height: (end - start) * height
121
+ }, dragMaskStyle), "rect"), {
122
+ start: start,
123
+ end: end
124
+ };
125
+ }
126
+ _renderBackground() {
127
+ var _a;
128
+ const {backgroundStyle: backgroundStyle, brushSelect: brushSelect, zoomLock: zoomLock} = this.attribute, {position: position, width: width, height: height} = this._getLayoutAttrFromConfig(), group = this._getContainer();
129
+ this._background = group.createOrUpdateChild("background", Object.assign(Object.assign({
130
+ x: position.x,
131
+ y: position.y,
132
+ width: width,
133
+ height: height,
134
+ cursor: brushSelect ? "crosshair" : "auto"
135
+ }, backgroundStyle), {
136
+ pickable: !zoomLock && (null === (_a = backgroundStyle.pickable) || void 0 === _a || _a)
137
+ }), "rect");
138
+ }
139
+ _renderHandler() {
140
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
141
+ const {orient: orient, middleHandlerStyle: middleHandlerStyle = {}, startHandlerStyle: startHandlerStyle = {}, endHandlerStyle: endHandlerStyle = {}, zoomLock: zoomLock} = this.attribute, {start: start, end: end} = this._getState(), {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._getContainer();
142
+ if (this._isHorizontal) {
143
+ if (middleHandlerStyle.visible) {
144
+ const middleHandlerBackgroundSize = (null === (_c = middleHandlerStyle.background) || void 0 === _c ? void 0 : _c.size) || 10;
145
+ this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign(Object.assign({
146
+ x: position.x + start * width,
147
+ y: position.y - middleHandlerBackgroundSize,
148
+ width: (end - start) * width,
149
+ height: middleHandlerBackgroundSize
150
+ }, null === (_d = middleHandlerStyle.background) || void 0 === _d ? void 0 : _d.style), {
151
+ pickable: !zoomLock && (null === (_g = null === (_f = null === (_e = middleHandlerStyle.background) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.pickable) || void 0 === _g || _g)
152
+ }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
153
+ x: position.x + (start + end) / 2 * width,
154
+ y: position.y - middleHandlerBackgroundSize / 2,
155
+ strokeBoundsBuffer: 0,
156
+ angle: 0,
157
+ symbolType: null !== (_j = null === (_h = middleHandlerStyle.icon) || void 0 === _h ? void 0 : _h.symbolType) && void 0 !== _j ? _j : "square"
158
+ }, middleHandlerStyle.icon), {
159
+ pickable: !zoomLock && (null === (_k = middleHandlerStyle.icon.pickable) || void 0 === _k || _k)
160
+ }), "symbol");
161
+ }
162
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
163
+ x: position.x + start * width,
164
+ y: position.y + height / 2,
165
+ size: height,
166
+ symbolType: null !== (_l = startHandlerStyle.symbolType) && void 0 !== _l ? _l : "square"
167
+ }, config_1.DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle), {
168
+ pickable: !zoomLock && (null === (_m = startHandlerStyle.pickable) || void 0 === _m || _m)
169
+ }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
170
+ x: position.x + end * width,
171
+ y: position.y + height / 2,
172
+ size: height,
173
+ symbolType: null !== (_o = endHandlerStyle.symbolType) && void 0 !== _o ? _o : "square"
174
+ }, config_1.DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle), {
175
+ pickable: !zoomLock && (null === (_p = endHandlerStyle.pickable) || void 0 === _p || _p)
176
+ }), "symbol");
177
+ 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);
178
+ this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign(Object.assign({
179
+ x: position.x + start * width - startHandlerWidth / 2,
180
+ y: position.y + height / 2 - startHandlerHeight / 2,
181
+ width: startHandlerWidth,
182
+ height: startHandlerHeight,
183
+ fill: "white",
184
+ fillOpacity: 0,
185
+ zIndex: 999
186
+ }, config_1.DEFAULT_HANDLER_ATTR_MAP.horizontal), {
187
+ pickable: !zoomLock
188
+ }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
189
+ x: position.x + end * width - endHandlerWidth / 2,
190
+ y: position.y + height / 2 - endHandlerHeight / 2,
191
+ width: endHandlerWidth,
192
+ height: endHandlerHeight,
193
+ fill: "white",
194
+ fillOpacity: 0,
195
+ zIndex: 999
196
+ }, config_1.DEFAULT_HANDLER_ATTR_MAP.horizontal), {
197
+ pickable: !zoomLock
198
+ }), "rect");
199
+ } else {
200
+ if (middleHandlerStyle.visible) {
201
+ const middleHandlerBackgroundSize = (null === (_q = middleHandlerStyle.background) || void 0 === _q ? void 0 : _q.size) || 10;
202
+ this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign(Object.assign({
203
+ x: "left" === orient ? position.x - middleHandlerBackgroundSize : position.x + width,
204
+ y: position.y + start * height,
205
+ width: middleHandlerBackgroundSize,
206
+ height: (end - start) * height
207
+ }, null === (_r = middleHandlerStyle.background) || void 0 === _r ? void 0 : _r.style), {
208
+ pickable: !zoomLock && (null === (_u = null === (_t = null === (_s = middleHandlerStyle.background) || void 0 === _s ? void 0 : _s.style) || void 0 === _t ? void 0 : _t.pickable) || void 0 === _u || _u)
209
+ }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
210
+ x: "left" === orient ? position.x - middleHandlerBackgroundSize / 2 : position.x + width + middleHandlerBackgroundSize / 2,
211
+ y: position.y + (start + end) / 2 * height,
212
+ angle: Math.PI / 180 * 90,
213
+ symbolType: null !== (_w = null === (_v = middleHandlerStyle.icon) || void 0 === _v ? void 0 : _v.symbolType) && void 0 !== _w ? _w : "square",
214
+ strokeBoundsBuffer: 0
215
+ }, middleHandlerStyle.icon), {
216
+ pickable: !zoomLock && (null === (_y = null === (_x = middleHandlerStyle.icon) || void 0 === _x ? void 0 : _x.pickable) || void 0 === _y || _y)
217
+ }), "symbol");
218
+ }
219
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
220
+ x: position.x + width / 2,
221
+ y: position.y + start * height,
222
+ size: width,
223
+ symbolType: null !== (_z = startHandlerStyle.symbolType) && void 0 !== _z ? _z : "square"
224
+ }, config_1.DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle), {
225
+ pickable: !zoomLock && (null === (_0 = startHandlerStyle.pickable) || void 0 === _0 || _0)
226
+ }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
227
+ x: position.x + width / 2,
228
+ y: position.y + end * height,
229
+ size: width,
230
+ symbolType: null !== (_1 = endHandlerStyle.symbolType) && void 0 !== _1 ? _1 : "square"
231
+ }, config_1.DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle), {
232
+ pickable: !zoomLock && (null === (_2 = endHandlerStyle.pickable) || void 0 === _2 || _2)
233
+ }), "symbol");
234
+ 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);
235
+ this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign(Object.assign({
236
+ x: position.x + width / 2 + startHandlerWidth / 2,
237
+ y: position.y + start * height - startHandlerHeight / 2,
238
+ width: endHandlerHeight,
239
+ height: endHandlerWidth,
240
+ fill: "white",
241
+ fillOpacity: 0,
242
+ zIndex: 999
243
+ }, config_1.DEFAULT_HANDLER_ATTR_MAP.vertical), {
244
+ pickable: !zoomLock
245
+ }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
246
+ x: position.x + width / 2 + endHandlerWidth / 2,
247
+ y: position.y + end * height - endHandlerHeight / 2,
248
+ width: endHandlerHeight,
249
+ height: endHandlerWidth,
250
+ fill: "white",
251
+ fillOpacity: 0,
252
+ zIndex: 999
253
+ }, config_1.DEFAULT_HANDLER_ATTR_MAP.vertical), {
254
+ pickable: !zoomLock
255
+ }), "rect");
256
+ }
257
+ }
258
+ _renderSelectedBackground() {
259
+ var _a, _b;
260
+ const {selectedBackgroundStyle: selectedBackgroundStyle = {}, selectedBackgroundChartStyle: selectedBackgroundChartStyle = {}, brushSelect: brushSelect, zoomLock: zoomLock} = this.attribute, {start: start, end: end} = this._getState(), {position: position, width: width, height: height} = this._getLayoutAttrFromConfig(), group = this._getContainer();
261
+ this._isHorizontal ? this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
262
+ x: position.x + start * width,
263
+ y: position.y,
264
+ width: (end - start) * width,
265
+ height: height,
266
+ cursor: brushSelect ? "crosshair" : "move"
267
+ }, selectedBackgroundStyle), {
268
+ pickable: !zoomLock && (null === (_a = selectedBackgroundChartStyle.pickable) || void 0 === _a || _a)
269
+ }), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
270
+ x: position.x,
271
+ y: position.y + start * height,
272
+ width: width,
273
+ height: (end - start) * height,
274
+ cursor: brushSelect ? "crosshair" : "move"
275
+ }, selectedBackgroundStyle), {
276
+ pickable: !zoomLock && (null === (_b = selectedBackgroundStyle.pickable) || void 0 === _b || _b)
277
+ }), "rect");
278
+ }
279
+ _setPreviewAttributes(type, group) {
280
+ this._previewGroup || (this._previewGroup = group.createOrUpdateChild("previewGroup", {
281
+ pickable: !1
282
+ }, "group")), "line" === type ? this._previewLine = this._previewGroup.createOrUpdateChild("previewLine", {}, "line") : this._previewArea = this._previewGroup.createOrUpdateChild("previewArea", {
283
+ curveType: "basis"
284
+ }, "area");
285
+ const {backgroundChartStyle: backgroundChartStyle = {}} = this.attribute;
286
+ "line" === type && this._previewLine.setAttributes(Object.assign({
287
+ points: this._getPreviewLinePoints(),
288
+ curveType: "basis",
289
+ pickable: !1
290
+ }, backgroundChartStyle.line)), "area" === type && this._previewArea.setAttributes(Object.assign({
291
+ points: this._getPreviewAreaPoints(),
292
+ curveType: "basis",
293
+ pickable: !1
294
+ }, backgroundChartStyle.area));
295
+ }
296
+ _setSelectedPreviewClipAttributes(type, group) {
297
+ this._selectedPreviewGroupClip || (this._selectedPreviewGroupClip = group.createOrUpdateChild("selectedPreviewGroupClip", {
298
+ pickable: !1
299
+ }, "group"), this._selectedPreviewGroup = this._selectedPreviewGroupClip.createOrUpdateChild("selectedPreviewGroup", {}, "group"));
300
+ const {start: start, end: end} = this._getState(), {position: position, width: width, height: height} = this._getLayoutAttrFromConfig();
301
+ this._selectedPreviewGroupClip.setAttributes({
302
+ x: this._isHorizontal ? position.x + start * width : position.x,
303
+ y: this._isHorizontal ? position.y : position.y + start * height,
304
+ width: this._isHorizontal ? (end - start) * width : width,
305
+ height: this._isHorizontal ? height : (end - start) * height,
306
+ clip: !0,
307
+ pickable: !1
308
+ }), this._selectedPreviewGroup.setAttributes({
309
+ x: -(this._isHorizontal ? position.x + start * width : position.x),
310
+ y: -(this._isHorizontal ? position.y : position.y + start * height),
311
+ width: this._isHorizontal ? (end - start) * width : width,
312
+ height: this._isHorizontal ? height : (end - start) * height,
313
+ pickable: !1
314
+ });
315
+ }
316
+ _setSelectedPreviewAttributes(type) {
317
+ const {selectedBackgroundChartStyle: selectedBackgroundChartStyle = {}} = this.attribute;
318
+ "line" === type ? this._selectedPreviewLine = this._selectedPreviewGroup.createOrUpdateChild("selectedPreviewLine", {}, "line") : this._selectedPreviewArea = this._selectedPreviewGroup.createOrUpdateChild("selectedPreviewArea", {
319
+ curveType: "basis"
320
+ }, "area"), "line" === type && this._selectedPreviewLine.setAttributes(Object.assign({
321
+ points: this._getPreviewLinePoints(),
322
+ curveType: "basis",
323
+ pickable: !1
324
+ }, selectedBackgroundChartStyle.line)), "area" === type && this._selectedPreviewArea.setAttributes(Object.assign({
325
+ points: this._getPreviewAreaPoints(),
326
+ curveType: "basis",
327
+ pickable: !1
328
+ }, selectedBackgroundChartStyle.area));
329
+ }
330
+ _computeBasePoints() {
331
+ const {orient: orient} = this.attribute, {position: position, width: width, height: height} = this._getLayoutAttrFromConfig();
332
+ let basePointStart, basePointEnd;
333
+ return this._isHorizontal ? (basePointStart = [ {
334
+ x: position.x,
335
+ y: position.y + height
336
+ } ], basePointEnd = [ {
337
+ x: position.x + width,
338
+ y: position.y + height
339
+ } ]) : "left" === orient ? (basePointStart = [ {
340
+ x: position.x + width,
341
+ y: position.y
342
+ } ], basePointEnd = [ {
343
+ x: position.x + width,
344
+ y: position.y + height
345
+ } ]) : (basePointStart = [ {
346
+ x: position.x,
347
+ y: position.y + height
348
+ } ], basePointEnd = [ {
349
+ x: position.x,
350
+ y: position.y
351
+ } ]), {
352
+ basePointStart: basePointStart,
353
+ basePointEnd: basePointEnd
354
+ };
355
+ }
356
+ _simplifyPoints(points) {
357
+ var _a;
358
+ if (points.length > 1e4) {
359
+ const tolerance = null !== (_a = this.attribute.tolerance) && void 0 !== _a ? _a : this._previewData.length / 1e4;
360
+ return (0, vrender_core_1.flatten_simplify)(points, tolerance, !1);
361
+ }
362
+ return points;
363
+ }
364
+ _getPreviewLinePoints() {
365
+ let previewPoints = this._previewData.map((d => ({
366
+ x: this._previewPointsX && this._previewPointsX(d),
367
+ y: this._previewPointsY && this._previewPointsY(d)
368
+ })));
369
+ if (0 === previewPoints.length) return previewPoints;
370
+ previewPoints = this._simplifyPoints(previewPoints);
371
+ const {basePointStart: basePointStart, basePointEnd: basePointEnd} = this._computeBasePoints();
372
+ return basePointStart.concat(previewPoints).concat(basePointEnd);
373
+ }
374
+ _getPreviewAreaPoints() {
375
+ let previewPoints = this._previewData.map((d => ({
376
+ x: this._previewPointsX && this._previewPointsX(d),
377
+ y: this._previewPointsY && this._previewPointsY(d),
378
+ x1: this._previewPointsX1 && this._previewPointsX1(d),
379
+ y1: this._previewPointsY1 && this._previewPointsY1(d)
380
+ })));
381
+ if (0 === previewPoints.length) return previewPoints;
382
+ previewPoints = this._simplifyPoints(previewPoints);
383
+ const {basePointStart: basePointStart, basePointEnd: basePointEnd} = this._computeBasePoints();
384
+ return basePointStart.concat(previewPoints).concat(basePointEnd);
385
+ }
386
+ renderText() {
387
+ let startTextBounds = null, endTextBounds = null;
388
+ if (this._setTextAttr(startTextBounds, endTextBounds), this._showText) {
389
+ startTextBounds = this._startText.AABBBounds, endTextBounds = this._endText.AABBBounds,
390
+ this._setTextAttr(startTextBounds, endTextBounds), startTextBounds = this._startText.AABBBounds,
391
+ endTextBounds = this._endText.AABBBounds;
392
+ const {x1: x1, x2: x2, y1: y1, y2: y2} = startTextBounds, {dx: startTextDx = 0, dy: startTextDy = 0} = this.attribute.startTextStyle;
393
+ if ((new vutils_1.Bounds).set(x1, y1, x2, y2).intersects(endTextBounds)) {
394
+ const direction = "bottom" === this.attribute.orient || "right" === this.attribute.orient ? -1 : 1;
395
+ 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));
396
+ } else this._isHorizontal ? this._startText.setAttribute("dy", startTextDy) : this._startText.setAttribute("dx", startTextDx);
397
+ }
398
+ }
399
+ _setTextAttr(startTextBounds, endTextBounds) {
400
+ var _a, _b, _c, _d, _e, _f, _g, _h;
401
+ 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._getState();
402
+ this._startValue = this._statePointToData(start), this._endValue = this._statePointToData(end);
403
+ const {position: position, width: width, height: height} = this._getLayoutAttrFromConfig(), startTextValue = startTextFormat ? startTextFormat(this._startValue) : this._startValue, endTextValue = endTextFormat ? endTextFormat(this._endValue) : this._endValue, componentBoundsLike = {
404
+ x1: position.x,
405
+ y1: position.y,
406
+ x2: position.x + width,
407
+ y2: position.y + height
408
+ };
409
+ let startTextPosition, endTextPosition, startTextAlignStyle, endTextAlignStyle;
410
+ this._isHorizontal ? (startTextPosition = {
411
+ x: position.x + start * width,
412
+ y: position.y + height / 2
413
+ }, endTextPosition = {
414
+ x: position.x + end * width,
415
+ y: position.y + height / 2
416
+ }, startTextAlignStyle = {
417
+ textAlign: (0, utils_1.isTextOverflow)(componentBoundsLike, startTextBounds, "start", this._isHorizontal) ? "left" : "right",
418
+ textBaseline: null !== (_b = null === (_a = null == restStartTextStyle ? void 0 : restStartTextStyle.textStyle) || void 0 === _a ? void 0 : _a.textBaseline) && void 0 !== _b ? _b : "middle"
419
+ }, endTextAlignStyle = {
420
+ textAlign: (0, utils_1.isTextOverflow)(componentBoundsLike, endTextBounds, "end", this._isHorizontal) ? "right" : "left",
421
+ textBaseline: null !== (_d = null === (_c = null == restEndTextStyle ? void 0 : restEndTextStyle.textStyle) || void 0 === _c ? void 0 : _c.textBaseline) && void 0 !== _d ? _d : "middle"
422
+ }) : (startTextPosition = {
423
+ x: position.x + width / 2,
424
+ y: position.y + start * height
425
+ }, endTextPosition = {
426
+ x: position.x + width / 2,
427
+ y: position.y + end * height
428
+ }, startTextAlignStyle = {
429
+ textAlign: null !== (_f = null === (_e = null == restStartTextStyle ? void 0 : restStartTextStyle.textStyle) || void 0 === _e ? void 0 : _e.textAlign) && void 0 !== _f ? _f : "center",
430
+ textBaseline: (0, utils_1.isTextOverflow)(componentBoundsLike, startTextBounds, "start", this._isHorizontal) ? "top" : "bottom"
431
+ }, endTextAlignStyle = {
432
+ textAlign: null !== (_h = null === (_g = null == restEndTextStyle ? void 0 : restEndTextStyle.textStyle) || void 0 === _g ? void 0 : _g.textAlign) && void 0 !== _h ? _h : "center",
433
+ textBaseline: (0, utils_1.isTextOverflow)(componentBoundsLike, endTextBounds, "end", this._isHorizontal) ? "bottom" : "top"
434
+ }), this._startText = this._maybeAddLabel(this._getContainer(), (0, vutils_1.merge)({}, restStartTextStyle, {
435
+ text: startTextValue,
436
+ x: startTextPosition.x,
437
+ y: startTextPosition.y,
438
+ visible: this._showText,
439
+ pickable: !1,
440
+ childrenPickable: !1,
441
+ textStyle: startTextAlignStyle
442
+ }), "data-zoom-start-text"), this._endText = this._maybeAddLabel(this._getContainer(), (0,
443
+ vutils_1.merge)({}, restEndTextStyle, {
444
+ text: endTextValue,
445
+ x: endTextPosition.x,
446
+ y: endTextPosition.y,
447
+ visible: this._showText,
448
+ pickable: !1,
449
+ childrenPickable: !1,
450
+ textStyle: endTextAlignStyle
451
+ }), "data-zoom-end-text");
452
+ }
453
+ _maybeAddLabel(container, attributes, name) {
454
+ let labelShape = container.find((node => node.name === name), !0);
455
+ return labelShape ? labelShape.setAttributes(attributes) : (labelShape = new tag_1.Tag(attributes),
456
+ labelShape.name = name, container.add(labelShape)), labelShape;
457
+ }
458
+ }
459
+
460
+ exports.DataZoomRenderer = DataZoomRenderer;
461
+ //# sourceMappingURL=renderer.js.map