@visactor/vrender-components 0.19.7-alpha.1 → 0.19.7

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.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.19.7-alpha.1", __exportStar(require("./core/base"), exports),
20
+ }), exports.version = void 0, exports.version = "0.19.7", __exportStar(require("./core/base"), exports),
21
21
  __exportStar(require("./core/type"), exports), __exportStar(require("./scrollbar"), exports),
22
22
  __exportStar(require("./tag"), exports), __exportStar(require("./poptip"), exports),
23
23
  __exportStar(require("./crosshair"), exports), __exportStar(require("./label"), exports),
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,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;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.19.7-alpha.1\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,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;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.19.7\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
@@ -16,6 +16,7 @@ export declare class ColorContinuousLegend extends LegendBase<ColorLegendAttribu
16
16
  };
17
17
  handlerSize: number;
18
18
  handlerStyle: {
19
+ fill: any;
19
20
  lineWidth: number;
20
21
  stroke: string;
21
22
  outerBorder: {
@@ -92,8 +92,15 @@ class ColorContinuousLegend extends base_1.LegendBase {
92
92
  res;
93
93
  }
94
94
  _updateColor() {
95
- const {layout: layout = "horizontal", colors: colors, railWidth: railWidth, railHeight: railHeight} = this.attribute, {startHandler: startHandler, endHandler: endHandler, track: track} = this._slider, {startValue: startValue, endValue: endValue, startPos: startPos, endPos: endPos} = this._slider.currentValue, startHandlerColor = this._colorScale.scale(startValue), endHandlerColor = this._colorScale.scale(endValue);
96
- null == startHandler || startHandler.setAttribute("fill", startHandlerColor), null == endHandler || endHandler.setAttribute("fill", endHandlerColor);
95
+ const {layout: layout = "horizontal", colors: colors, railWidth: railWidth, railHeight: railHeight} = this.attribute, {startHandler: startHandler, endHandler: endHandler, track: track} = this._slider, {startValue: startValue, endValue: endValue, startPos: startPos, endPos: endPos} = this._slider.currentValue;
96
+ if (startHandler && !startHandler.attribute.fill) {
97
+ const startHandlerColor = this._colorScale.scale(startValue);
98
+ startHandler.setAttribute("fill", startHandlerColor);
99
+ }
100
+ if (endHandler && !endHandler.attribute.fill) {
101
+ const endHandlerColor = this._colorScale.scale(endValue);
102
+ endHandler.setAttribute("fill", endHandlerColor);
103
+ }
97
104
  const railLen = "horizontal" === layout ? railWidth : railHeight;
98
105
  if (Math.abs(startPos - endPos) !== railLen && colors && colors.length > 1) {
99
106
  const stops = this._color.stops, start = Math.min(startPos, endPos), end = Math.max(startPos, endPos), startRatio = start / railLen, endRatio = end / railLen, range = endRatio - startRatio, betweenStops = stops.filter((stop => stop.offset > startRatio && stop.offset < endRatio)), minValue = Math.min(startValue, endValue), maxValue = Math.max(startValue, endValue), startColor = this._colorScale.scale(minValue), endColor = this._colorScale.scale(maxValue), newStops = [ {
@@ -128,6 +135,7 @@ exports.ColorContinuousLegend = ColorContinuousLegend, ColorContinuousLegend.def
128
135
  },
129
136
  handlerSize: 10,
130
137
  handlerStyle: {
138
+ fill: null,
131
139
  lineWidth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,CAAC;YACZ,MAAM,EAAE,MAAM;SACf;KACF;CACF,CAAC","file":"color.js","sourcesContent":["/**\n * @description 连续颜色图例\n * TODO:\n * showHandlers 测试\n */\nimport { merge, isEmpty, get, isNil } from '@visactor/vutils';\nimport type { FederatedPointerEvent, FederatedEvent, IColor, ILinearGradient, INode } from '@visactor/vrender-core';\nimport type { ILinearScale } from '@visactor/vscale';\nimport { LinearScale } from '@visactor/vscale';\nimport { LegendBase } from '../base';\nimport { Slider } from '../../slider';\nimport { DEFAULT_TITLE_SPACE } from '../constant';\nimport type { ColorLegendAttributes } from './type';\nimport type { ComponentOptions } from '../../interface';\nimport { loadColorContinuousLegendComponent } from '../register';\n\nloadColorContinuousLegendComponent();\nexport class ColorContinuousLegend extends LegendBase<ColorLegendAttributes> {\n name = 'colorLegend';\n\n static defaultAttributes = {\n layout: 'horizontal',\n title: {\n // orient: 'top',\n align: 'start',\n space: DEFAULT_TITLE_SPACE,\n textStyle: {\n fontSize: 12,\n fontWeight: 'bold',\n fill: 'rgba(46, 47, 50, 1)'\n }\n },\n handlerSize: 10,\n handlerStyle: {\n lineWidth: 4,\n stroke: '#fff',\n outerBorder: {\n distance: 2,\n lineWidth: 1,\n stroke: '#ccc'\n }\n },\n tooltip: {\n shapeStyle: {\n lineWidth: 4,\n stroke: '#fff'\n }\n }\n };\n\n private _slider!: Slider;\n private _colorScale!: ILinearScale;\n private _color: IColor | undefined;\n\n constructor(attributes: ColorLegendAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, ColorContinuousLegend.defaultAttributes, attributes));\n }\n\n /**\n * 更新数据选中范围\n * @param value 选中数据范围\n * @returns\n */\n setSelected(value: number[]) {\n if (!this._slider) {\n return;\n }\n this._slider.setValue(value);\n this._updateColor();\n }\n\n protected _renderContent(): void {\n const {\n colors,\n slidable,\n layout,\n align,\n min,\n max,\n value,\n railWidth,\n railHeight,\n showHandler = true,\n handlerSize,\n handlerStyle,\n railStyle,\n trackStyle,\n startText,\n endText,\n handlerText,\n showTooltip,\n tooltip,\n inverse,\n disableTriggerEvent\n } = this.attribute as ColorLegendAttributes;\n\n // 创建 colorScale\n const domain = [];\n const step = (max - min) / (colors.length - 1);\n for (let i = 0; i < colors.length; i++) {\n domain.push(min + step * i);\n }\n\n this._colorScale = new LinearScale().domain(domain, true).range(colors);\n this._color = this._getTrackColor();\n\n const slider = new Slider({\n x: 0,\n y: 0,\n range: {\n draggableTrack: true\n },\n slidable,\n layout,\n align,\n min,\n max,\n value,\n railWidth,\n railHeight,\n showHandler,\n handlerSize,\n handlerStyle,\n railStyle,\n trackStyle: {\n fill: this._color,\n ...trackStyle\n },\n startText,\n endText,\n handlerText,\n showTooltip,\n tooltip,\n disableTriggerEvent,\n inverse\n });\n this._innerView.add(slider as unknown as INode);\n this._slider = slider;\n // 做下位置调整,对齐\n slider.translateTo(\n 0 - slider.AABBBounds.x1,\n (this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', DEFAULT_TITLE_SPACE) : 0) -\n slider.AABBBounds.y1\n );\n this._updateColor();\n }\n\n protected _bindEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n if (this._slider) {\n this._slider.addEventListener('change', this._onSliderChange as EventListenerOrEventListenerObject);\n this._slider.addEventListener('sliderTooltip', this._onSliderToolipChange as EventListenerOrEventListenerObject);\n }\n }\n\n private _getTrackColor(): IColor | undefined {\n const { colors, layout, inverse } = this.attribute as ColorLegendAttributes;\n\n if (isEmpty(colors)) {\n return undefined;\n }\n const count = colors.length;\n if (count === 1) {\n return colors[0];\n }\n const stops = [];\n\n for (let i = 0; i < count; i++) {\n const percent = i / (count - 1);\n stops.push({\n offset: percent,\n color: colors[i]\n });\n }\n const isHorizontal = layout === 'horizontal';\n\n const res: IColor = {\n gradient: 'linear',\n stops,\n x0: 0,\n y0: 0,\n x1: isHorizontal ? 1 : 0,\n y1: isHorizontal ? 0 : 1\n };\n\n if (inverse) {\n if (isHorizontal) {\n res.x0 = 1;\n res.x1 = 0;\n } else {\n res.y0 = 1;\n res.y1 = 0;\n }\n }\n\n return res;\n }\n\n private _onSliderToolipChange = (e: FederatedEvent) => {\n const tooltipShape = this._slider.tooltipShape;\n\n if (tooltipShape && e.detail && !isNil(e.detail.value)) {\n const color = this._colorScale.scale(e.detail.value);\n\n tooltipShape.setAttribute('fill', color);\n }\n\n this.dispatchEvent(e);\n };\n\n private _onSliderChange = (e: FederatedEvent) => {\n // 更新 handler 以及 track 的渐变色\n this._updateColor();\n this.dispatchEvent(e);\n };\n\n private _updateColor() {\n const { layout = 'horizontal', colors, railWidth, railHeight } = this.attribute as ColorLegendAttributes;\n const { startHandler, endHandler, track } = this._slider;\n const { startValue, endValue, startPos, endPos } = this._slider.currentValue;\n\n // 计算颜色\n const startHandlerColor = this._colorScale.scale(startValue);\n const endHandlerColor = this._colorScale.scale(endValue);\n startHandler?.setAttribute('fill', startHandlerColor);\n endHandler?.setAttribute('fill', endHandlerColor);\n\n const isHorizontal = layout === 'horizontal';\n const railLen = isHorizontal ? railWidth : railHeight;\n const trackLength = Math.abs((startPos as number) - (endPos as number));\n\n // 计算渐变色\n if (trackLength !== railLen && colors && colors.length > 1) {\n const stops = (this._color as ILinearGradient).stops;\n const start = Math.min(startPos as number, endPos as number);\n const end = Math.max(startPos as number, endPos as number);\n const startRatio = start / railLen;\n const endRatio = end / railLen;\n const range = endRatio - startRatio;\n const betweenStops = stops.filter(stop => stop.offset > startRatio && stop.offset < endRatio);\n\n const minValue = Math.min(startValue, endValue);\n const maxValue = Math.max(startValue, endValue);\n const startColor = this._colorScale.scale(minValue);\n const endColor = this._colorScale.scale(maxValue);\n const newStops = [{ offset: 0, color: startColor }];\n betweenStops.forEach(stop => {\n newStops.push({\n offset: (stop.offset - startRatio) / range,\n color: stop.color\n });\n });\n newStops.push({\n offset: 1,\n color: endColor\n });\n track.setAttribute('fill', {\n ...(this._color as ILinearGradient),\n stops: newStops\n });\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/legend/color/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M,EAAE,MAAM;SACf;KACF;IACD,OAAO,EAAE;QACP,UAAU,EAAE;YACV,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;SACf;KACF;CACF,CAAC","file":"color.js","sourcesContent":["/**\n * @description 连续颜色图例\n * TODO:\n * showHandlers 测试\n */\nimport { merge, isEmpty, get, isNil } from '@visactor/vutils';\nimport type { FederatedPointerEvent, FederatedEvent, IColor, ILinearGradient, INode } from '@visactor/vrender-core';\nimport type { ILinearScale } from '@visactor/vscale';\nimport { LinearScale } from '@visactor/vscale';\nimport { LegendBase } from '../base';\nimport { Slider } from '../../slider';\nimport { DEFAULT_TITLE_SPACE } from '../constant';\nimport type { ColorLegendAttributes } from './type';\nimport type { ComponentOptions } from '../../interface';\nimport { loadColorContinuousLegendComponent } from '../register';\n\nloadColorContinuousLegendComponent();\nexport class ColorContinuousLegend extends LegendBase<ColorLegendAttributes> {\n name = 'colorLegend';\n\n static defaultAttributes = {\n layout: 'horizontal',\n title: {\n // orient: 'top',\n align: 'start',\n space: DEFAULT_TITLE_SPACE,\n textStyle: {\n fontSize: 12,\n fontWeight: 'bold',\n fill: 'rgba(46, 47, 50, 1)'\n }\n },\n handlerSize: 10,\n handlerStyle: {\n fill: null as any,\n lineWidth: 4,\n stroke: '#fff',\n outerBorder: {\n distance: 2,\n lineWidth: 1,\n stroke: '#ccc'\n }\n },\n tooltip: {\n shapeStyle: {\n lineWidth: 4,\n stroke: '#fff'\n }\n }\n };\n\n private _slider!: Slider;\n private _colorScale!: ILinearScale;\n private _color: IColor | undefined;\n\n constructor(attributes: ColorLegendAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, ColorContinuousLegend.defaultAttributes, attributes));\n }\n\n /**\n * 更新数据选中范围\n * @param value 选中数据范围\n * @returns\n */\n setSelected(value: number[]) {\n if (!this._slider) {\n return;\n }\n this._slider.setValue(value);\n this._updateColor();\n }\n\n protected _renderContent(): void {\n const {\n colors,\n slidable,\n layout,\n align,\n min,\n max,\n value,\n railWidth,\n railHeight,\n showHandler = true,\n handlerSize,\n handlerStyle,\n railStyle,\n trackStyle,\n startText,\n endText,\n handlerText,\n showTooltip,\n tooltip,\n inverse,\n disableTriggerEvent\n } = this.attribute as ColorLegendAttributes;\n\n // 创建 colorScale\n const domain = [];\n const step = (max - min) / (colors.length - 1);\n for (let i = 0; i < colors.length; i++) {\n domain.push(min + step * i);\n }\n\n this._colorScale = new LinearScale().domain(domain, true).range(colors);\n this._color = this._getTrackColor();\n\n const slider = new Slider({\n x: 0,\n y: 0,\n range: {\n draggableTrack: true\n },\n slidable,\n layout,\n align,\n min,\n max,\n value,\n railWidth,\n railHeight,\n showHandler,\n handlerSize,\n handlerStyle,\n railStyle,\n trackStyle: {\n fill: this._color,\n ...trackStyle\n },\n startText,\n endText,\n handlerText,\n showTooltip,\n tooltip,\n disableTriggerEvent,\n inverse\n });\n this._innerView.add(slider as unknown as INode);\n this._slider = slider;\n // 做下位置调整,对齐\n slider.translateTo(\n 0 - slider.AABBBounds.x1,\n (this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', DEFAULT_TITLE_SPACE) : 0) -\n slider.AABBBounds.y1\n );\n this._updateColor();\n }\n\n protected _bindEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n if (this._slider) {\n this._slider.addEventListener('change', this._onSliderChange as EventListenerOrEventListenerObject);\n this._slider.addEventListener('sliderTooltip', this._onSliderToolipChange as EventListenerOrEventListenerObject);\n }\n }\n\n private _getTrackColor(): IColor | undefined {\n const { colors, layout, inverse } = this.attribute as ColorLegendAttributes;\n\n if (isEmpty(colors)) {\n return undefined;\n }\n const count = colors.length;\n if (count === 1) {\n return colors[0];\n }\n const stops = [];\n\n for (let i = 0; i < count; i++) {\n const percent = i / (count - 1);\n stops.push({\n offset: percent,\n color: colors[i]\n });\n }\n const isHorizontal = layout === 'horizontal';\n\n const res: IColor = {\n gradient: 'linear',\n stops,\n x0: 0,\n y0: 0,\n x1: isHorizontal ? 1 : 0,\n y1: isHorizontal ? 0 : 1\n };\n\n if (inverse) {\n if (isHorizontal) {\n res.x0 = 1;\n res.x1 = 0;\n } else {\n res.y0 = 1;\n res.y1 = 0;\n }\n }\n\n return res;\n }\n\n private _onSliderToolipChange = (e: FederatedEvent) => {\n const tooltipShape = this._slider.tooltipShape;\n\n if (tooltipShape && e.detail && !isNil(e.detail.value)) {\n const color = this._colorScale.scale(e.detail.value);\n\n tooltipShape.setAttribute('fill', color);\n }\n\n this.dispatchEvent(e);\n };\n\n private _onSliderChange = (e: FederatedEvent) => {\n // 更新 handler 以及 track 的渐变色\n this._updateColor();\n this.dispatchEvent(e);\n };\n\n private _updateColor() {\n const { layout = 'horizontal', colors, railWidth, railHeight } = this.attribute as ColorLegendAttributes;\n const { startHandler, endHandler, track } = this._slider;\n const { startValue, endValue, startPos, endPos } = this._slider.currentValue;\n // 计算颜色\n if (startHandler) {\n if (!startHandler.attribute.fill) {\n const startHandlerColor = this._colorScale.scale(startValue);\n startHandler.setAttribute('fill', startHandlerColor);\n }\n }\n\n if (endHandler) {\n if (!endHandler.attribute.fill) {\n const endHandlerColor = this._colorScale.scale(endValue);\n endHandler.setAttribute('fill', endHandlerColor);\n }\n }\n\n const isHorizontal = layout === 'horizontal';\n const railLen = isHorizontal ? railWidth : railHeight;\n const trackLength = Math.abs((startPos as number) - (endPos as number));\n\n // 计算渐变色\n if (trackLength !== railLen && colors && colors.length > 1) {\n const stops = (this._color as ILinearGradient).stops;\n const start = Math.min(startPos as number, endPos as number);\n const end = Math.max(startPos as number, endPos as number);\n const startRatio = start / railLen;\n const endRatio = end / railLen;\n const range = endRatio - startRatio;\n const betweenStops = stops.filter(stop => stop.offset > startRatio && stop.offset < endRatio);\n\n const minValue = Math.min(startValue, endValue);\n const maxValue = Math.max(startValue, endValue);\n const startColor = this._colorScale.scale(minValue);\n const endColor = this._colorScale.scale(maxValue);\n const newStops = [{ offset: 0, color: startColor }];\n betweenStops.forEach(stop => {\n newStops.push({\n offset: (stop.offset - startRatio) / range,\n color: stop.color\n });\n });\n newStops.push({\n offset: 1,\n color: endColor\n });\n track.setAttribute('fill', {\n ...(this._color as ILinearGradient),\n stops: newStops\n });\n }\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -8800,7 +8800,7 @@ let DefaultGraphicService = class {
8800
8800
  onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
8801
8801
  beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
8802
8802
  afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
8803
- }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds(), this._rectBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._symbolBoundsContribitions = [new DefaultSymbolOuterBorderBoundsContribution()], this._circleBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._arcBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._pathBoundsContribitions = [new DefaultOuterBorderBoundsContribution()];
8803
+ }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds(), this._rectBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._symbolBoundsContribitions = [new DefaultSymbolOuterBorderBoundsContribution()], this._imageBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._circleBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._arcBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._pathBoundsContribitions = [new DefaultOuterBorderBoundsContribution()];
8804
8804
  }
8805
8805
  onAttributeUpdate(graphic) {
8806
8806
  this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
@@ -9201,7 +9201,9 @@ let DefaultGraphicService = class {
9201
9201
  }
9202
9202
  const tb1 = this.tempAABBBounds1,
9203
9203
  tb2 = this.tempAABBBounds2;
9204
- return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), this.transformAABBBounds(attribute, aabbBounds, imageTheme, !1, graphic), aabbBounds;
9204
+ return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), this._imageBoundsContribitions.length && this._imageBoundsContribitions.forEach(c => {
9205
+ c.updateBounds(attribute, imageTheme, tb1, graphic), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
9206
+ }), this.transformAABBBounds(attribute, aabbBounds, imageTheme, !1, graphic), aabbBounds;
9205
9207
  }
9206
9208
  combindShadowAABBBounds(bounds, graphic) {
9207
9209
  if (graphic && graphic.shadowRoot) {
@@ -10129,70 +10131,6 @@ function createRectPath(path, x, y, width, height, rectCornerRadius) {
10129
10131
  return path.closePath(), path;
10130
10132
  }
10131
10133
 
10132
- class DefaultImageBackgroundRenderContribution extends DefaultBaseBackgroundRenderContribution {
10133
- constructor() {
10134
- super(...arguments), this.time = BaseRenderContributionTime.beforeFillStroke;
10135
- }
10136
- drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
10137
- const {
10138
- background: background,
10139
- backgroundMode = graphicAttribute.backgroundMode,
10140
- backgroundFit = graphicAttribute.backgroundFit
10141
- } = graphic.attribute;
10142
- if (background) if (graphic.backgroundImg) {
10143
- const res = graphic.resources.get(background);
10144
- if ("success" !== res.state || !res.data) return;
10145
- if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
10146
- const groupAttribute = getTheme(graphic.parent).group,
10147
- {
10148
- scrollX = groupAttribute.scrollX,
10149
- scrollY = groupAttribute.scrollY
10150
- } = graphic.parent.attribute;
10151
- context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.translate(scrollX, scrollY);
10152
- }
10153
- const b = graphic.AABBBounds;
10154
- this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
10155
- } else if (isObject(background)) {
10156
- const {
10157
- stroke: stroke,
10158
- fill: fill,
10159
- lineWidth = 1,
10160
- cornerRadius = 0,
10161
- expandX = 0,
10162
- expandY = 0
10163
- } = background;
10164
- if (!stroke && !fill) return;
10165
- context.beginPath();
10166
- const {
10167
- x: x,
10168
- y: y,
10169
- width: width,
10170
- height: height
10171
- } = getActualPosition(graphic);
10172
- cornerRadius ? createRectPath(context, x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY, cornerRadius) : context.rect(x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY), context.globalAlpha = 1, fill && (context.fillStyle = fill, context.fill()), stroke && lineWidth > 0 && (context.lineWidth = lineWidth, context.strokeStyle = stroke, context.stroke());
10173
- } else {
10174
- context.beginPath();
10175
- const b = graphic.AABBBounds;
10176
- context.rect(x, y, b.width(), b.height()), context.fillStyle = background, context.globalAlpha = 1, context.fill();
10177
- }
10178
- }
10179
- }
10180
- function getActualPosition(graphic) {
10181
- const boundsPadding = parsePadding(graphic.attribute.boundsPadding),
10182
- bounds = graphic.AABBBounds;
10183
- let x = bounds.x1,
10184
- y = bounds.y1,
10185
- width = bounds.width(),
10186
- height = bounds.height();
10187
- return isNumber(boundsPadding) ? (x += boundsPadding, y += boundsPadding, width -= 2 * boundsPadding, height -= 2 * boundsPadding) : (x += boundsPadding[3], y += boundsPadding[0], width -= boundsPadding[1] + boundsPadding[3], height -= boundsPadding[0] + boundsPadding[2]), {
10188
- x: x,
10189
- y: y,
10190
- width: width,
10191
- height: height
10192
- };
10193
- }
10194
- const defaultImageBackgroundRenderContribution = new DefaultImageBackgroundRenderContribution();
10195
-
10196
10134
  var __decorate$K = undefined && undefined.__decorate || function (decorators, target, key, desc) {
10197
10135
  var d,
10198
10136
  c = arguments.length,
@@ -10299,6 +10237,79 @@ const defaultRectRenderContribution = new DefaultRectRenderContribution();
10299
10237
  const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;
10300
10238
  const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
10301
10239
 
10240
+ class DefaultImageBackgroundRenderContribution extends DefaultBaseBackgroundRenderContribution {
10241
+ constructor() {
10242
+ super(...arguments), this.time = BaseRenderContributionTime.beforeFillStroke;
10243
+ }
10244
+ drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
10245
+ const {
10246
+ background: background,
10247
+ backgroundMode = graphicAttribute.backgroundMode,
10248
+ backgroundFit = graphicAttribute.backgroundFit
10249
+ } = graphic.attribute;
10250
+ if (background) if (graphic.backgroundImg) {
10251
+ const res = graphic.resources.get(background);
10252
+ if ("success" !== res.state || !res.data) return;
10253
+ if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
10254
+ const groupAttribute = getTheme(graphic.parent).group,
10255
+ {
10256
+ scrollX = groupAttribute.scrollX,
10257
+ scrollY = groupAttribute.scrollY
10258
+ } = graphic.parent.attribute;
10259
+ context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.translate(scrollX, scrollY);
10260
+ }
10261
+ const b = graphic.AABBBounds;
10262
+ this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
10263
+ } else if (isObject(background)) {
10264
+ const {
10265
+ stroke: stroke,
10266
+ fill: fill,
10267
+ lineWidth = 1,
10268
+ cornerRadius = 0,
10269
+ expandX = 0,
10270
+ expandY = 0
10271
+ } = background;
10272
+ if (!stroke && !fill) return;
10273
+ context.beginPath();
10274
+ const {
10275
+ x: x,
10276
+ y: y,
10277
+ width: width,
10278
+ height: height
10279
+ } = getActualPosition(graphic);
10280
+ cornerRadius ? createRectPath(context, x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY, cornerRadius) : context.rect(x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY), context.globalAlpha = 1, fill && (context.fillStyle = fill, context.fill()), stroke && lineWidth > 0 && (context.lineWidth = lineWidth, context.strokeStyle = stroke, context.stroke());
10281
+ } else {
10282
+ context.beginPath();
10283
+ const b = graphic.AABBBounds;
10284
+ context.rect(x, y, b.width(), b.height()), context.fillStyle = background, context.globalAlpha = 1, context.fill();
10285
+ }
10286
+ }
10287
+ }
10288
+ function getActualPosition(graphic) {
10289
+ const boundsPadding = parsePadding(graphic.attribute.boundsPadding),
10290
+ bounds = graphic.AABBBounds;
10291
+ let x = bounds.x1,
10292
+ y = bounds.y1,
10293
+ width = bounds.width(),
10294
+ height = bounds.height();
10295
+ return isNumber(boundsPadding) ? (x += boundsPadding, y += boundsPadding, width -= 2 * boundsPadding, height -= 2 * boundsPadding) : (x += boundsPadding[3], y += boundsPadding[0], width -= boundsPadding[1] + boundsPadding[3], height -= boundsPadding[0] + boundsPadding[2]), {
10296
+ x: x,
10297
+ y: y,
10298
+ width: width,
10299
+ height: height
10300
+ };
10301
+ }
10302
+ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
10303
+ constructor() {
10304
+ super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
10305
+ }
10306
+ drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
10307
+ return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
10308
+ }
10309
+ }
10310
+ const defaultImageRenderContribution = new DefaultImageRenderContribution();
10311
+ const defaultImageBackgroundRenderContribution = new DefaultImageBackgroundRenderContribution();
10312
+
10302
10313
  class DefaultSymbolRenderContribution {
10303
10314
  constructor() {
10304
10315
  this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
@@ -11868,15 +11879,17 @@ var __decorate$A = undefined && undefined.__decorate || function (decorators, ta
11868
11879
  const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
11869
11880
  let DefaultCanvasImageRender = class extends BaseRender {
11870
11881
  constructor(imageRenderContribitions) {
11871
- super(), this.imageRenderContribitions = imageRenderContribitions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageBackgroundRenderContribution], this.init(imageRenderContribitions);
11882
+ super(), this.imageRenderContribitions = imageRenderContribitions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(imageRenderContribitions);
11872
11883
  }
11873
- drawShape(image, context, x, y, drawContext, params, fillCb) {
11884
+ drawShape(image, context, x, y, drawContext, params, fillCb, strokeCb) {
11874
11885
  const imageAttribute = getTheme(image).image,
11875
11886
  {
11876
11887
  width = imageAttribute.width,
11877
11888
  height = imageAttribute.height,
11878
11889
  repeatX = imageAttribute.repeatX,
11879
11890
  repeatY = imageAttribute.repeatY,
11891
+ x: originX = imageAttribute.x,
11892
+ y: originY = imageAttribute.y,
11880
11893
  cornerRadius = imageAttribute.cornerRadius,
11881
11894
  image: url
11882
11895
  } = image.attribute,
@@ -11901,7 +11914,7 @@ let DefaultCanvasImageRender = class extends BaseRender {
11901
11914
  } else context.drawImage(res.data, x, y, width, height);
11902
11915
  needRestore && context.restore();
11903
11916
  }
11904
- this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
11917
+ doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke())), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
11905
11918
  }
11906
11919
  draw(image, renderService, drawContext) {
11907
11920
  const {
@@ -13249,7 +13262,9 @@ application.layerService = layerService;
13249
13262
  let _isBrowserEnv;
13250
13263
  function initIsBrowserEnv() {
13251
13264
  if (null == _isBrowserEnv) try {
13252
- _isBrowserEnv = globalThis === window, _isBrowserEnv && (_isBrowserEnv = !!document.createElement);
13265
+ const canvas = document.createElement("canvas"),
13266
+ ctx = canvas.getContext("2d");
13267
+ _isBrowserEnv = !!(window && canvas.getBoundingClientRect && requestAnimationFrame && window.devicePixelRatio && ctx && ctx.isPointInPath && ctx.isPointInStroke), _isBrowserEnv && (_isBrowserEnv = !!document.createElement);
13253
13268
  } catch (err) {
13254
13269
  _isBrowserEnv = !1;
13255
13270
  }
@@ -21632,13 +21647,13 @@ class DataZoom extends AbstractComponent {
21632
21647
  end = Math.min(Math.max(end, 0), 1);
21633
21648
  if (startAttr !== start || endAttr !== end) {
21634
21649
  this.setStateAttr(start, end, true);
21635
- }
21636
- if (realTime) {
21637
- this._dispatchEvent('change', {
21638
- start,
21639
- end,
21640
- tag: this._activeTag
21641
- });
21650
+ if (realTime) {
21651
+ this._dispatchEvent('change', {
21652
+ start,
21653
+ end,
21654
+ tag: this._activeTag
21655
+ });
21656
+ }
21642
21657
  }
21643
21658
  };
21644
21659
  this._onHandlerPointerMove = this.attribute.delayTime === 0
@@ -21657,12 +21672,12 @@ class DataZoom extends AbstractComponent {
21657
21672
  brushSelect && this.renderDragMask();
21658
21673
  if (start !== this.state.start || end !== this.state.end) {
21659
21674
  this.setStateAttr(this.state.start, this.state.end, true);
21675
+ this._dispatchEvent('change', {
21676
+ start: this.state.start,
21677
+ end: this.state.end,
21678
+ tag: this._activeTag
21679
+ });
21660
21680
  }
21661
- this._dispatchEvent('change', {
21662
- start: this.state.start,
21663
- end: this.state.end,
21664
- tag: this._activeTag
21665
- });
21666
21681
  if (vglobal.env === 'browser') {
21667
21682
  vglobal.removeEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
21668
21683
  vglobal.removeEventListener('pointerup', this._onHandlerPointerUp);
@@ -26414,10 +26429,18 @@ class ColorContinuousLegend extends LegendBase {
26414
26429
  const { layout = 'horizontal', colors, railWidth, railHeight } = this.attribute;
26415
26430
  const { startHandler, endHandler, track } = this._slider;
26416
26431
  const { startValue, endValue, startPos, endPos } = this._slider.currentValue;
26417
- const startHandlerColor = this._colorScale.scale(startValue);
26418
- const endHandlerColor = this._colorScale.scale(endValue);
26419
- startHandler === null || startHandler === void 0 ? void 0 : startHandler.setAttribute('fill', startHandlerColor);
26420
- endHandler === null || endHandler === void 0 ? void 0 : endHandler.setAttribute('fill', endHandlerColor);
26432
+ if (startHandler) {
26433
+ if (!startHandler.attribute.fill) {
26434
+ const startHandlerColor = this._colorScale.scale(startValue);
26435
+ startHandler.setAttribute('fill', startHandlerColor);
26436
+ }
26437
+ }
26438
+ if (endHandler) {
26439
+ if (!endHandler.attribute.fill) {
26440
+ const endHandlerColor = this._colorScale.scale(endValue);
26441
+ endHandler.setAttribute('fill', endHandlerColor);
26442
+ }
26443
+ }
26421
26444
  const isHorizontal = layout === 'horizontal';
26422
26445
  const railLen = isHorizontal ? railWidth : railHeight;
26423
26446
  const trackLength = Math.abs(startPos - endPos);
@@ -26461,6 +26484,7 @@ ColorContinuousLegend.defaultAttributes = {
26461
26484
  },
26462
26485
  handlerSize: 10,
26463
26486
  handlerStyle: {
26487
+ fill: null,
26464
26488
  lineWidth: 4,
26465
26489
  stroke: '#fff',
26466
26490
  outerBorder: {
@@ -28005,6 +28029,9 @@ class Brush extends AbstractComponent {
28005
28029
  : delayMap[this.attribute.delayType](this._onBrushing, this.attribute.delayTime);
28006
28030
  this._onBrushEnd = (e) => {
28007
28031
  var _a;
28032
+ if (!this._activeDrawState && !this._activeMoveState) {
28033
+ return;
28034
+ }
28008
28035
  e.preventDefault();
28009
28036
  const { removeOnClick = true } = this.attribute;
28010
28037
  if (this._activeDrawState && !this._isDrawedBeforeEnd && removeOnClick) {
@@ -29059,6 +29086,6 @@ EmptyTip.defaultAttributes = {
29059
29086
  }
29060
29087
  };
29061
29088
 
29062
- const version = "0.19.7-alpha.1";
29089
+ const version = "0.19.7";
29063
29090
 
29064
29091
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AreaLabel, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupFadeIn, GroupFadeOut, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineDataLabel, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Title, Tooltip, VTag, angle, angleLabelOrientAttribute, angleTo, clampRadian, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, direction, fuzzyEqualNumber, getCircleLabelPosition, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, loadPoptip, measureTextSize, normalize, reactAttributeTransform, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
package/es/brush/brush.js CHANGED
@@ -36,6 +36,7 @@ export class Brush extends AbstractComponent {
36
36
  }, this._onBrushingWithDelay = 0 === this.attribute.delayTime ? this._onBrushing : delayMap[this.attribute.delayType](this._onBrushing, this.attribute.delayTime),
37
37
  this._onBrushEnd = e => {
38
38
  var _a;
39
+ if (!this._activeDrawState && !this._activeMoveState) return;
39
40
  e.preventDefault();
40
41
  const {removeOnClick: removeOnClick = !0} = this.attribute;
41
42
  this._activeDrawState && !this._isDrawedBeforeEnd && removeOnClick ? ((null === (_a = this._operatingMask) || void 0 === _a ? void 0 : _a._AABBBounds.empty()) && this._dispatchEvent(IOperateType.brushClear, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/brush/brush.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAW,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,kBAAkB,EAAE,CAAC;AACrB,MAAM,OAAO,KAAM,SAAQ,iBAA4C;IAuBrE,YAAY,UAA2B,EAAE,OAA0B;QACjE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,iBAAiB,EAAE,UAAU,C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AAsB,CAAC;QAC5F,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,kBAAkB;QAChB,MAAM,EACJ,SAAS,GAAG,UAAU,EACtB,SAAS,GAAG,CAAC,EACb,OAAO,GAAG,wBAAwB,CAAC,OAAO,EAC1C,aAAa,GAAG,wBAAwB,CAAC,aAAa,EACtD,UAAU,GAAG,wBAAwB,CAAC,UAAU,EAChD,YAAY,GAAG,wBAAwB,CAAC,YAAY,EACrD,GAAG,IAAI,CAAC,SAA4B,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,aAA8B,CAAC,CAAC;QAC7E,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAqC,CAAC,CAAC;QAC1F,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,WAA4B,CAAC,CAAC;QAC9E,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,WAA4B,CAAC,CAAC;IAClF,CAAC;;AAvZM,uBAAiB,GAAG,wBAAwB,CAAC","file":"brush.js","sourcesContent":["/**\n * @description 框选组件\n */\nimport type { FederatedPointerEvent, IGroup, IPolygon } from '@visactor/vrender-core';\nimport { graphicCreator, vglobal } from '@visactor/vrender-core';\nimport type { IBounds, IPointLike } from '@visactor/vutils';\nimport { cloneDeep, debounce, merge, polygonContainPoint, throttle } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { BrushAttributes } from './type';\nimport { IOperateType } from './type';\nimport { DEFAULT_BRUSH_ATTRIBUTES, DEFAULT_SIZE_THRESHOLD } from './config';\nimport type { ComponentOptions } from '../interface';\nimport { loadBrushComponent } from './register';\n\nconst delayMap = {\n debounce: debounce,\n throttle: throttle\n};\n\nloadBrushComponent();\nexport class Brush extends AbstractComponent<Required<BrushAttributes>> {\n name = 'brush';\n static defaultAttributes = DEFAULT_BRUSH_ATTRIBUTES;\n\n private _container!: IGroup;\n\n // 绘制mask时的相关属性\n private _activeDrawState = false; // 用于标记绘制状态\n private _cacheDrawPoints: IPointLike[] = []; // 用于维护鼠标走过的路径,主要用于绘制mask的点\n private _isDrawedBeforeEnd = false;\n // 移动mask时的相关属性\n private _activeMoveState = false; // 用于标记移动状态\n private _operatingMaskMoveDx = 0; // 用于标记移动的位移量\n private _operatingMaskMoveDy = 0;\n private _operatingMaskMoveRangeX: [number, number] = [-Infinity, Infinity];\n private _operatingMaskMoveRangeY: [number, number] = [-Infinity, Infinity];\n private _cacheMovePoint!: IPointLike; // 用于维护鼠标所在位置,主要用于计算位移量\n\n private _operatingMask!: IPolygon; // 用于标记正在绘制的mask 或 正在移动的mask\n\n // 透出给上层的属性(主要是所有mask的AABBBounds,这里用的是dict存储方便添加和修改)\n private _brushMaskAABBBoundsDict: { [name: string]: IBounds } = {};\n\n constructor(attributes: BrushAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Brush.defaultAttributes, attributes));\n }\n\n private _bindBrushEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n const {\n trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger,\n updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,\n endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger,\n resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger\n } = this.attribute as BrushAttributes;\n // 拖拽绘制开始\n this.stage.addEventListener(trigger, this._onBrushStart as EventListener);\n // 拖拽绘制时\n this.stage.addEventListener(updateTrigger, this._onBrushingWithDelay as EventListener);\n // 拖拽绘制结束\n this.stage.addEventListener(endTrigger, this._onBrushEnd as EventListener);\n this.stage.addEventListener(resetTrigger, this._onBrushEnd as EventListener);\n }\n\n private _isPosInBrushMask(e: FederatedPointerEvent) {\n const pos = this.eventPosToStagePos(e);\n const brushMasks = this._container.getChildren();\n for (let i = 0; i < brushMasks.length; i++) {\n const { points = [], dx = 0, dy = 0 } = (brushMasks[i] as IPolygon).attribute;\n const pointsConsiderOffset: IPointLike[] = points.map((point: IPointLike) => {\n return {\n x: point.x + dx,\n y: point.y + dy\n };\n });\n if (polygonContainPoint(pointsConsiderOffset, pos.x, pos.y)) {\n this._operatingMask = brushMasks[i] as IPolygon;\n return true;\n }\n }\n return false;\n }\n\n /**\n * 开始绘制 或 移动\n * @description\n * 1. 判断状态: 如果在brushMask中,则属于移动状态; 否则属于绘制状态\n *(移动状态和绘制状态互斥, 且移动状态考虑brushMoved配置, 如果在brush点内但brushMoved为false, 则走绘制状态, 而非两个状态都不响应, 此效果与echarts保持一致)\n * 2. 判断坐标是否在有效交互范围内\n * 2. 如果是移动状态: 标记移动状态 & 标记正在移动的mask & 初始化mask的dx和dy\n * 3. 如果是绘制状态: 标记绘制状态 & 标记正在绘制的mask & 清除之前的mask & 添加新的mask\n */\n private _onBrushStart = (e: FederatedPointerEvent) => {\n if (this._outOfInteractiveRange(e)) {\n return;\n }\n e.stopPropagation();\n\n const brushMoved = this.attribute.brushMoved ?? true;\n this._activeMoveState = brushMoved && this._isPosInBrushMask(e); // 如果是移动状态,在这里会标记operatingMask为正在移动的mask\n this._activeDrawState = !this._activeMoveState;\n\n this._activeDrawState && this._initDraw(e); // 如果是绘制状态,在这里会标记operatingMask为正在绘制的mask\n this._activeMoveState && this._initMove(e);\n };\n\n /**\n * 绘制 或 移动 中\n * @description\n * 1. 如果是绘制状态: 更新_cacheDrawPoints 和 mask的points属性\n * 2. 如果是移动状态: 标记移动状态 & 计算位移量 & 给被移动的mask偏移属性\n */\n private _onBrushing = (e: FederatedPointerEvent) => {\n if (this._outOfInteractiveRange(e)) {\n return;\n }\n\n if (this._activeDrawState || this._activeMoveState) {\n e.stopPropagation();\n }\n\n this._activeDrawState && this._drawing(e); // 如果是绘制状态,在这里会标记operatingMask为正在绘制的mask\n this._activeMoveState && this._moving(e);\n };\n\n private _onBrushingWithDelay =\n this.attribute.delayTime === 0\n ? this._onBrushing\n : delayMap[this.attribute.delayType](this._onBrushing, this.attribute.delayTime);\n\n /**\n * 结束绘制 和 移动\n * @description 取消绘制 和 移动 状态\n */\n private _onBrushEnd = (e: FederatedPointerEvent) => {\n e.preventDefault();\n const { removeOnClick = true } = this.attribute as BrushAttributes;\n if (this._activeDrawState && !this._isDrawedBeforeEnd && removeOnClick) {\n // _isDrawedBeforeEnd有两种情况:\n // 1. 没有绘制mask\n // 2. 绘制了mask但没有超过阈值\n // 只有第2种情况才会触发clear, 可以理解为双击才触发clear\n if (this._operatingMask?._AABBBounds.empty()) {\n this._dispatchEvent(IOperateType.brushClear, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n this._container.incrementalClearChild();\n this._brushMaskAABBBoundsDict = {};\n } else {\n if (this._activeDrawState) {\n this._dispatchEvent(IOperateType.drawEnd, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n\n if (this._activeMoveState) {\n this._dispatchEvent(IOperateType.moveEnd, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n }\n\n this._activeDrawState = false;\n this._activeMoveState = false;\n this._isDrawedBeforeEnd = false;\n if (this._operatingMask) {\n this._operatingMask.setAttribute('pickable', false);\n }\n };\n\n /**\n * 初始化绘制状态\n * @description 清除之前的mask & 添加新的mask\n */\n private _initDraw(e: FederatedPointerEvent) {\n const { brushMode } = this.attribute as BrushAttributes;\n const pos = this.eventPosToStagePos(e);\n this._cacheDrawPoints = [pos];\n this._isDrawedBeforeEnd = false;\n if (brushMode === 'single') {\n this._brushMaskAABBBoundsDict = {};\n this._container.incrementalClearChild();\n }\n this._addBrushMask();\n this._dispatchEvent(IOperateType.drawStart, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n\n /**\n * 初始化移动状态\n * @description 初始化mask的dx和dy\n */\n private _initMove(e: FederatedPointerEvent) {\n this._cacheMovePoint = this.eventPosToStagePos(e);\n\n this._operatingMaskMoveDx = this._operatingMask.attribute.dx ?? 0;\n this._operatingMaskMoveDy = this._operatingMask.attribute.dy ?? 0;\n\n // 计算最大移动范围, 为了将brushMask限制在交互范围内\n const { interactiveRange } = this.attribute as BrushAttributes;\n const { minY = -Infinity, maxY = Infinity, minX = -Infinity, maxX = Infinity } = interactiveRange;\n\n const { x1, x2, y1, y2 } = this._operatingMask.globalAABBBounds;\n const minMoveStepX = minX - x1;\n const maxMoveStepX = maxX - x2;\n const minMoveStepY = minY - y1;\n const maxMoveStepY = maxY - y2;\n\n this._operatingMaskMoveRangeX = [minMoveStepX, maxMoveStepX];\n this._operatingMaskMoveRangeY = [minMoveStepY, maxMoveStepY];\n\n this._operatingMask.setAttribute('pickable', true);\n this._dispatchEvent(IOperateType.moveStart, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n\n /**\n * 绘制中\n * @description 更新_cacheDrawPoints 和 mask的points属性\n */\n private _drawing(e: FederatedPointerEvent) {\n const pos = this.eventPosToStagePos(e);\n const { sizeThreshold = DEFAULT_SIZE_THRESHOLD, brushType } = this.attribute as BrushAttributes;\n\n const cacheLength = this._cacheDrawPoints.length;\n\n // 如果当前点的位置和上一次点的位置一致,则无需更新\n if (cacheLength > 0) {\n const lastPos = this._cacheDrawPoints[this._cacheDrawPoints.length - 1] ?? ({} as IPointLike);\n if (pos.x === lastPos.x && pos.y === lastPos.y) {\n return;\n }\n }\n // 更新交互位置\n if (brushType === 'polygon' || cacheLength <= 1) {\n this._cacheDrawPoints.push(pos);\n } else {\n this._cacheDrawPoints[cacheLength - 1] = pos;\n }\n // 更新mask形状\n const maskPoints = this._computeMaskPoints();\n this._operatingMask.setAttribute('points', maskPoints);\n\n // 更新形状之后再判断是否需要正在绘制\n // if not, 则_isDrawedBeforeEnd false\n // then: 1. 不暴露drawing状态 2. 在brushEnd时该形状会被清空\n const { x1 = 0, x2 = 0, y1 = 0, y2 = 0 } = this._operatingMask?._AABBBounds;\n this._isDrawedBeforeEnd =\n !this._operatingMask._AABBBounds.empty() &&\n !!(Math.abs(x2 - x1) > sizeThreshold || Math.abs(y1 - y2) > sizeThreshold);\n if (this._isDrawedBeforeEnd) {\n this._brushMaskAABBBoundsDict[this._operatingMask.name] = this._operatingMask.AABBBounds;\n this._dispatchEvent(IOperateType.drawing, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n }\n\n /**\n * 移动中\n * @description 标记移动状态 & 计算位移量 & 给被移动的mask偏移属性\n */\n private _moving(e: FederatedPointerEvent) {\n const startPos = this._cacheMovePoint;\n const pos = this.eventPosToStagePos(e);\n // 如果当前点的位置和上一次点的位置一致,则无需更新\n if (pos.x === startPos?.x && pos.y === startPos?.y) {\n return;\n }\n\n const moveStepX = pos.x - startPos.x;\n const moveStepY = pos.y - startPos.y;\n const moveX =\n Math.min(this._operatingMaskMoveRangeX[1], Math.max(this._operatingMaskMoveRangeX[0], moveStepX)) +\n this._operatingMaskMoveDx;\n const moveY =\n Math.min(this._operatingMaskMoveRangeY[1], Math.max(this._operatingMaskMoveRangeY[0], moveStepY)) +\n this._operatingMaskMoveDy;\n\n this._operatingMask.setAttributes({\n dx: moveX,\n dy: moveY\n });\n this._brushMaskAABBBoundsDict[this._operatingMask.name] = this._operatingMask.AABBBounds;\n this._dispatchEvent(IOperateType.moving, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n\n /**\n * 构造brushMask的points属性\n * @description 根据不同的brushType从_cacheDrawPoints中取points\n * 1. 'rect': 只取鼠标轨迹_cacheDrawPoints的第一个点和最后一个点\n * 2. 'x': 只取鼠标轨迹_cacheDrawPoints的第一个点和最后一个点的x坐标\n * 3. 'y': 只取鼠标轨迹_cacheDrawPoints的第一个点和最后一个点的y坐标\n * 4. 'polygon': 取鼠标轨迹_cacheDrawPoints的所有点\n */\n private _computeMaskPoints() {\n const { brushType, xRange = [0, 0], yRange = [0, 0] } = this.attribute as BrushAttributes;\n let maskPoints: IPointLike[] = [];\n const startPoint = this._cacheDrawPoints[0];\n const endPoint = this._cacheDrawPoints[this._cacheDrawPoints.length - 1];\n\n if (brushType === 'rect') {\n maskPoints = [\n startPoint,\n {\n x: endPoint.x,\n y: startPoint.y\n },\n endPoint,\n {\n x: startPoint.x,\n y: endPoint.y\n }\n ];\n } else if (brushType === 'x') {\n maskPoints = [\n {\n x: startPoint.x,\n y: yRange[0]\n },\n {\n x: endPoint.x,\n y: yRange[0]\n },\n {\n x: endPoint.x,\n y: yRange[1]\n },\n {\n x: startPoint.x,\n y: yRange[1]\n }\n ];\n } else if (brushType === 'y') {\n maskPoints = [\n {\n x: xRange[0],\n y: startPoint.y\n },\n {\n x: xRange[0],\n y: endPoint.y\n },\n {\n x: xRange[1],\n y: endPoint.y\n },\n {\n x: xRange[1],\n y: startPoint.y\n }\n ];\n } else {\n maskPoints = cloneDeep(this._cacheDrawPoints); // _cacheDrawPoints在不断更新,所以这里需要cloneDeep\n }\n return maskPoints;\n }\n\n private _addBrushMask() {\n const { brushStyle, hasMask } = this.attribute as BrushAttributes;\n const brushMask = graphicCreator.polygon({\n points: cloneDeep(this._cacheDrawPoints), // _cacheDrawPoints在不断更新,所以这里需要cloneDeep\n cursor: 'move',\n pickable: false,\n ...brushStyle,\n opacity: hasMask ? brushStyle.opacity ?? 1 : 0\n });\n brushMask.name = `brush-${Date.now()}`; // 用Date给mask唯一标记\n this._operatingMask = brushMask;\n this._container.add(brushMask);\n this._brushMaskAABBBoundsDict[brushMask.name] = brushMask.AABBBounds;\n }\n\n private _outOfInteractiveRange(e: FederatedPointerEvent) {\n // 在返回坐标时,将其限制在交互范围内\n const { interactiveRange } = this.attribute as BrushAttributes;\n const { minY = -Infinity, maxY = Infinity, minX = -Infinity, maxX = Infinity } = interactiveRange;\n const pos = this.eventPosToStagePos(e);\n if (pos.x > maxX || pos.x < minX || pos.y > maxY || pos.y < minY) {\n return true;\n }\n return false;\n }\n\n /** 事件系统坐标转换为stage坐标 */\n protected eventPosToStagePos(e: FederatedPointerEvent) {\n return this.stage.eventPointTransform(e);\n }\n\n protected render() {\n this._bindBrushEvents();\n const group = this.createOrUpdateChild('brush-container', {}, 'group') as unknown as IGroup;\n this._container = group;\n }\n\n releaseBrushEvents(): void {\n const {\n delayType = 'throttle',\n delayTime = 0,\n trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger,\n updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,\n endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger,\n resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger\n } = this.attribute as BrushAttributes;\n this.stage.removeEventListener(trigger, this._onBrushStart as EventListener);\n this.stage.removeEventListener(updateTrigger, this._onBrushingWithDelay as EventListener);\n this.stage.removeEventListener(endTrigger, this._onBrushEnd as EventListener);\n this.stage.removeEventListener(resetTrigger, this._onBrushEnd as EventListener);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/brush/brush.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAW,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,QAAQ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C,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE;YAChE,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAGS,kBAAkB,CAAC,CAAwB;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAES,MAAM;QACd,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,EAAE,EAAE,OAAO,CAAsB,CAAC;QAC5F,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,kBAAkB;QAChB,MAAM,EACJ,SAAS,GAAG,UAAU,EACtB,SAAS,GAAG,CAAC,EACb,OAAO,GAAG,wBAAwB,CAAC,OAAO,EAC1C,aAAa,GAAG,wBAAwB,CAAC,aAAa,EACtD,UAAU,GAAG,wBAAwB,CAAC,UAAU,EAChD,YAAY,GAAG,wBAAwB,CAAC,YAAY,EACrD,GAAG,IAAI,CAAC,SAA4B,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,aAA8B,CAAC,CAAC;QAC7E,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAqC,CAAC,CAAC;QAC1F,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,WAA4B,CAAC,CAAC;QAC9E,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,WAA4B,CAAC,CAAC;IAClF,CAAC;;AA3ZM,uBAAiB,GAAG,wBAAwB,CAAC","file":"brush.js","sourcesContent":["/**\n * @description 框选组件\n */\nimport type { FederatedPointerEvent, IGroup, IPolygon } from '@visactor/vrender-core';\nimport { graphicCreator, vglobal } from '@visactor/vrender-core';\nimport type { IBounds, IPointLike } from '@visactor/vutils';\nimport { cloneDeep, debounce, merge, polygonContainPoint, throttle } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { BrushAttributes } from './type';\nimport { IOperateType } from './type';\nimport { DEFAULT_BRUSH_ATTRIBUTES, DEFAULT_SIZE_THRESHOLD } from './config';\nimport type { ComponentOptions } from '../interface';\nimport { loadBrushComponent } from './register';\n\nconst delayMap = {\n debounce: debounce,\n throttle: throttle\n};\n\nloadBrushComponent();\nexport class Brush extends AbstractComponent<Required<BrushAttributes>> {\n name = 'brush';\n static defaultAttributes = DEFAULT_BRUSH_ATTRIBUTES;\n\n private _container!: IGroup;\n\n // 绘制mask时的相关属性\n private _activeDrawState = false; // 用于标记绘制状态\n private _cacheDrawPoints: IPointLike[] = []; // 用于维护鼠标走过的路径,主要用于绘制mask的点\n private _isDrawedBeforeEnd = false;\n // 移动mask时的相关属性\n private _activeMoveState = false; // 用于标记移动状态\n private _operatingMaskMoveDx = 0; // 用于标记移动的位移量\n private _operatingMaskMoveDy = 0;\n private _operatingMaskMoveRangeX: [number, number] = [-Infinity, Infinity];\n private _operatingMaskMoveRangeY: [number, number] = [-Infinity, Infinity];\n private _cacheMovePoint!: IPointLike; // 用于维护鼠标所在位置,主要用于计算位移量\n\n private _operatingMask!: IPolygon; // 用于标记正在绘制的mask 或 正在移动的mask\n\n // 透出给上层的属性(主要是所有mask的AABBBounds,这里用的是dict存储方便添加和修改)\n private _brushMaskAABBBoundsDict: { [name: string]: IBounds } = {};\n\n constructor(attributes: BrushAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Brush.defaultAttributes, attributes));\n }\n\n private _bindBrushEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n const {\n trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger,\n updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,\n endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger,\n resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger\n } = this.attribute as BrushAttributes;\n // 拖拽绘制开始\n this.stage.addEventListener(trigger, this._onBrushStart as EventListener);\n // 拖拽绘制时\n this.stage.addEventListener(updateTrigger, this._onBrushingWithDelay as EventListener);\n // 拖拽绘制结束\n this.stage.addEventListener(endTrigger, this._onBrushEnd as EventListener);\n this.stage.addEventListener(resetTrigger, this._onBrushEnd as EventListener);\n }\n\n private _isPosInBrushMask(e: FederatedPointerEvent) {\n const pos = this.eventPosToStagePos(e);\n const brushMasks = this._container.getChildren();\n for (let i = 0; i < brushMasks.length; i++) {\n const { points = [], dx = 0, dy = 0 } = (brushMasks[i] as IPolygon).attribute;\n const pointsConsiderOffset: IPointLike[] = points.map((point: IPointLike) => {\n return {\n x: point.x + dx,\n y: point.y + dy\n };\n });\n if (polygonContainPoint(pointsConsiderOffset, pos.x, pos.y)) {\n this._operatingMask = brushMasks[i] as IPolygon;\n return true;\n }\n }\n return false;\n }\n\n /**\n * 开始绘制 或 移动\n * @description\n * 1. 判断状态: 如果在brushMask中,则属于移动状态; 否则属于绘制状态\n *(移动状态和绘制状态互斥, 且移动状态考虑brushMoved配置, 如果在brush点内但brushMoved为false, 则走绘制状态, 而非两个状态都不响应, 此效果与echarts保持一致)\n * 2. 判断坐标是否在有效交互范围内\n * 2. 如果是移动状态: 标记移动状态 & 标记正在移动的mask & 初始化mask的dx和dy\n * 3. 如果是绘制状态: 标记绘制状态 & 标记正在绘制的mask & 清除之前的mask & 添加新的mask\n */\n private _onBrushStart = (e: FederatedPointerEvent) => {\n if (this._outOfInteractiveRange(e)) {\n return;\n }\n e.stopPropagation();\n\n const brushMoved = this.attribute.brushMoved ?? true;\n this._activeMoveState = brushMoved && this._isPosInBrushMask(e); // 如果是移动状态,在这里会标记operatingMask为正在移动的mask\n this._activeDrawState = !this._activeMoveState;\n\n this._activeDrawState && this._initDraw(e); // 如果是绘制状态,在这里会标记operatingMask为正在绘制的mask\n this._activeMoveState && this._initMove(e);\n };\n\n /**\n * 绘制 或 移动 中\n * @description\n * 1. 如果是绘制状态: 更新_cacheDrawPoints 和 mask的points属性\n * 2. 如果是移动状态: 标记移动状态 & 计算位移量 & 给被移动的mask偏移属性\n */\n private _onBrushing = (e: FederatedPointerEvent) => {\n if (this._outOfInteractiveRange(e)) {\n return;\n }\n\n if (this._activeDrawState || this._activeMoveState) {\n e.stopPropagation();\n }\n\n this._activeDrawState && this._drawing(e); // 如果是绘制状态,在这里会标记operatingMask为正在绘制的mask\n this._activeMoveState && this._moving(e);\n };\n\n private _onBrushingWithDelay =\n this.attribute.delayTime === 0\n ? this._onBrushing\n : delayMap[this.attribute.delayType](this._onBrushing, this.attribute.delayTime);\n\n /**\n * 结束绘制 和 移动\n * @description 取消绘制 和 移动 状态\n */\n private _onBrushEnd = (e: FederatedPointerEvent) => {\n if (!this._activeDrawState && !this._activeMoveState) {\n return;\n }\n\n e.preventDefault();\n const { removeOnClick = true } = this.attribute as BrushAttributes;\n if (this._activeDrawState && !this._isDrawedBeforeEnd && removeOnClick) {\n // _isDrawedBeforeEnd有两种情况:\n // 1. 没有绘制mask\n // 2. 绘制了mask但没有超过阈值\n // 只有第2种情况才会触发clear, 可以理解为双击才触发clear\n if (this._operatingMask?._AABBBounds.empty()) {\n this._dispatchEvent(IOperateType.brushClear, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n this._container.incrementalClearChild();\n this._brushMaskAABBBoundsDict = {};\n } else {\n if (this._activeDrawState) {\n this._dispatchEvent(IOperateType.drawEnd, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n\n if (this._activeMoveState) {\n this._dispatchEvent(IOperateType.moveEnd, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n }\n\n this._activeDrawState = false;\n this._activeMoveState = false;\n this._isDrawedBeforeEnd = false;\n if (this._operatingMask) {\n this._operatingMask.setAttribute('pickable', false);\n }\n };\n\n /**\n * 初始化绘制状态\n * @description 清除之前的mask & 添加新的mask\n */\n private _initDraw(e: FederatedPointerEvent) {\n const { brushMode } = this.attribute as BrushAttributes;\n const pos = this.eventPosToStagePos(e);\n this._cacheDrawPoints = [pos];\n this._isDrawedBeforeEnd = false;\n if (brushMode === 'single') {\n this._brushMaskAABBBoundsDict = {};\n this._container.incrementalClearChild();\n }\n this._addBrushMask();\n this._dispatchEvent(IOperateType.drawStart, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n\n /**\n * 初始化移动状态\n * @description 初始化mask的dx和dy\n */\n private _initMove(e: FederatedPointerEvent) {\n this._cacheMovePoint = this.eventPosToStagePos(e);\n\n this._operatingMaskMoveDx = this._operatingMask.attribute.dx ?? 0;\n this._operatingMaskMoveDy = this._operatingMask.attribute.dy ?? 0;\n\n // 计算最大移动范围, 为了将brushMask限制在交互范围内\n const { interactiveRange } = this.attribute as BrushAttributes;\n const { minY = -Infinity, maxY = Infinity, minX = -Infinity, maxX = Infinity } = interactiveRange;\n\n const { x1, x2, y1, y2 } = this._operatingMask.globalAABBBounds;\n const minMoveStepX = minX - x1;\n const maxMoveStepX = maxX - x2;\n const minMoveStepY = minY - y1;\n const maxMoveStepY = maxY - y2;\n\n this._operatingMaskMoveRangeX = [minMoveStepX, maxMoveStepX];\n this._operatingMaskMoveRangeY = [minMoveStepY, maxMoveStepY];\n\n this._operatingMask.setAttribute('pickable', true);\n this._dispatchEvent(IOperateType.moveStart, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n\n /**\n * 绘制中\n * @description 更新_cacheDrawPoints 和 mask的points属性\n */\n private _drawing(e: FederatedPointerEvent) {\n const pos = this.eventPosToStagePos(e);\n const { sizeThreshold = DEFAULT_SIZE_THRESHOLD, brushType } = this.attribute as BrushAttributes;\n\n const cacheLength = this._cacheDrawPoints.length;\n\n // 如果当前点的位置和上一次点的位置一致,则无需更新\n if (cacheLength > 0) {\n const lastPos = this._cacheDrawPoints[this._cacheDrawPoints.length - 1] ?? ({} as IPointLike);\n if (pos.x === lastPos.x && pos.y === lastPos.y) {\n return;\n }\n }\n // 更新交互位置\n if (brushType === 'polygon' || cacheLength <= 1) {\n this._cacheDrawPoints.push(pos);\n } else {\n this._cacheDrawPoints[cacheLength - 1] = pos;\n }\n // 更新mask形状\n const maskPoints = this._computeMaskPoints();\n this._operatingMask.setAttribute('points', maskPoints);\n\n // 更新形状之后再判断是否需要正在绘制\n // if not, 则_isDrawedBeforeEnd false\n // then: 1. 不暴露drawing状态 2. 在brushEnd时该形状会被清空\n const { x1 = 0, x2 = 0, y1 = 0, y2 = 0 } = this._operatingMask?._AABBBounds;\n this._isDrawedBeforeEnd =\n !this._operatingMask._AABBBounds.empty() &&\n !!(Math.abs(x2 - x1) > sizeThreshold || Math.abs(y1 - y2) > sizeThreshold);\n if (this._isDrawedBeforeEnd) {\n this._brushMaskAABBBoundsDict[this._operatingMask.name] = this._operatingMask.AABBBounds;\n this._dispatchEvent(IOperateType.drawing, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n }\n\n /**\n * 移动中\n * @description 标记移动状态 & 计算位移量 & 给被移动的mask偏移属性\n */\n private _moving(e: FederatedPointerEvent) {\n const startPos = this._cacheMovePoint;\n const pos = this.eventPosToStagePos(e);\n // 如果当前点的位置和上一次点的位置一致,则无需更新\n if (pos.x === startPos?.x && pos.y === startPos?.y) {\n return;\n }\n\n const moveStepX = pos.x - startPos.x;\n const moveStepY = pos.y - startPos.y;\n const moveX =\n Math.min(this._operatingMaskMoveRangeX[1], Math.max(this._operatingMaskMoveRangeX[0], moveStepX)) +\n this._operatingMaskMoveDx;\n const moveY =\n Math.min(this._operatingMaskMoveRangeY[1], Math.max(this._operatingMaskMoveRangeY[0], moveStepY)) +\n this._operatingMaskMoveDy;\n\n this._operatingMask.setAttributes({\n dx: moveX,\n dy: moveY\n });\n this._brushMaskAABBBoundsDict[this._operatingMask.name] = this._operatingMask.AABBBounds;\n this._dispatchEvent(IOperateType.moving, {\n operateMask: this._operatingMask as any,\n operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,\n event: e\n });\n }\n\n /**\n * 构造brushMask的points属性\n * @description 根据不同的brushType从_cacheDrawPoints中取points\n * 1. 'rect': 只取鼠标轨迹_cacheDrawPoints的第一个点和最后一个点\n * 2. 'x': 只取鼠标轨迹_cacheDrawPoints的第一个点和最后一个点的x坐标\n * 3. 'y': 只取鼠标轨迹_cacheDrawPoints的第一个点和最后一个点的y坐标\n * 4. 'polygon': 取鼠标轨迹_cacheDrawPoints的所有点\n */\n private _computeMaskPoints() {\n const { brushType, xRange = [0, 0], yRange = [0, 0] } = this.attribute as BrushAttributes;\n let maskPoints: IPointLike[] = [];\n const startPoint = this._cacheDrawPoints[0];\n const endPoint = this._cacheDrawPoints[this._cacheDrawPoints.length - 1];\n\n if (brushType === 'rect') {\n maskPoints = [\n startPoint,\n {\n x: endPoint.x,\n y: startPoint.y\n },\n endPoint,\n {\n x: startPoint.x,\n y: endPoint.y\n }\n ];\n } else if (brushType === 'x') {\n maskPoints = [\n {\n x: startPoint.x,\n y: yRange[0]\n },\n {\n x: endPoint.x,\n y: yRange[0]\n },\n {\n x: endPoint.x,\n y: yRange[1]\n },\n {\n x: startPoint.x,\n y: yRange[1]\n }\n ];\n } else if (brushType === 'y') {\n maskPoints = [\n {\n x: xRange[0],\n y: startPoint.y\n },\n {\n x: xRange[0],\n y: endPoint.y\n },\n {\n x: xRange[1],\n y: endPoint.y\n },\n {\n x: xRange[1],\n y: startPoint.y\n }\n ];\n } else {\n maskPoints = cloneDeep(this._cacheDrawPoints); // _cacheDrawPoints在不断更新,所以这里需要cloneDeep\n }\n return maskPoints;\n }\n\n private _addBrushMask() {\n const { brushStyle, hasMask } = this.attribute as BrushAttributes;\n const brushMask = graphicCreator.polygon({\n points: cloneDeep(this._cacheDrawPoints), // _cacheDrawPoints在不断更新,所以这里需要cloneDeep\n cursor: 'move',\n pickable: false,\n ...brushStyle,\n opacity: hasMask ? brushStyle.opacity ?? 1 : 0\n });\n brushMask.name = `brush-${Date.now()}`; // 用Date给mask唯一标记\n this._operatingMask = brushMask;\n this._container.add(brushMask);\n this._brushMaskAABBBoundsDict[brushMask.name] = brushMask.AABBBounds;\n }\n\n private _outOfInteractiveRange(e: FederatedPointerEvent) {\n // 在返回坐标时,将其限制在交互范围内\n const { interactiveRange } = this.attribute as BrushAttributes;\n const { minY = -Infinity, maxY = Infinity, minX = -Infinity, maxX = Infinity } = interactiveRange;\n const pos = this.eventPosToStagePos(e);\n if (pos.x > maxX || pos.x < minX || pos.y > maxY || pos.y < minY) {\n return true;\n }\n return false;\n }\n\n /** 事件系统坐标转换为stage坐标 */\n protected eventPosToStagePos(e: FederatedPointerEvent) {\n return this.stage.eventPointTransform(e);\n }\n\n protected render() {\n this._bindBrushEvents();\n const group = this.createOrUpdateChild('brush-container', {}, 'group') as unknown as IGroup;\n this._container = group;\n }\n\n releaseBrushEvents(): void {\n const {\n delayType = 'throttle',\n delayTime = 0,\n trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger,\n updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,\n endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger,\n resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger\n } = this.attribute as BrushAttributes;\n this.stage.removeEventListener(trigger, this._onBrushStart as EventListener);\n this.stage.removeEventListener(updateTrigger, this._onBrushingWithDelay as EventListener);\n this.stage.removeEventListener(endTrigger, this._onBrushEnd as EventListener);\n this.stage.removeEventListener(resetTrigger, this._onBrushEnd as EventListener);\n }\n}\n"]}
@@ -115,4 +115,5 @@ export const DEFAULT_HANDLER_ATTR_MAP = {
115
115
  pickMode: "imprecise",
116
116
  strokeBoundsBuffer: 0
117
117
  }
118
- };
118
+ };
119
+ //# sourceMappingURL=config.js.map
@@ -78,12 +78,12 @@ export class DataZoom extends AbstractComponent {
78
78
  end = start + dis, this._activeTag = DataZoomActiveTag.endHandler) : start += dis : this._activeTag === DataZoomActiveTag.endHandler && (end + dis < start ? (end = start,
79
79
  start = end + dis, this._activeTag = DataZoomActiveTag.startHandler) : end += dis),
80
80
  this._activeCache.lastPos = pos, brushSelect && this.renderDragMask()), start = Math.min(Math.max(start, 0), 1),
81
- end = Math.min(Math.max(end, 0), 1), startAttr === start && endAttr === end || this.setStateAttr(start, end, !0),
81
+ end = Math.min(Math.max(end, 0), 1), startAttr === start && endAttr === end || (this.setStateAttr(start, end, !0),
82
82
  realTime && this._dispatchEvent("change", {
83
83
  start: start,
84
84
  end: end,
85
85
  tag: this._activeTag
86
- });
86
+ }));
87
87
  }, this._onHandlerPointerMove = 0 === this.attribute.delayTime ? this._pointerMove : delayMap[this.attribute.delayType](this._pointerMove, this.attribute.delayTime),
88
88
  this._onHandlerPointerUp = e => {
89
89
  e.preventDefault();
@@ -92,12 +92,12 @@ export class DataZoom extends AbstractComponent {
92
92
  const pos = this.eventPosToStagePos(e);
93
93
  this.backgroundDragZoom(this._activeCache.startPos, pos);
94
94
  }
95
- this._activeState = !1, brushSelect && this.renderDragMask(), start === this.state.start && end === this.state.end || this.setStateAttr(this.state.start, this.state.end, !0),
95
+ this._activeState = !1, brushSelect && this.renderDragMask(), start === this.state.start && end === this.state.end || (this.setStateAttr(this.state.start, this.state.end, !0),
96
96
  this._dispatchEvent("change", {
97
97
  start: this.state.start,
98
98
  end: this.state.end,
99
99
  tag: this._activeTag
100
- }), "browser" === vglobal.env && (vglobal.removeEventListener("pointermove", this._onHandlerPointerMove, {
100
+ })), "browser" === vglobal.env && (vglobal.removeEventListener("pointermove", this._onHandlerPointerMove, {
101
101
  capture: !0
102
102
  }), vglobal.removeEventListener("pointerup", this._onHandlerPointerUp)), this.removeEventListener("pointermove", this._onHandlerPointerMove, {
103
103
  capture: !0