@visactor/vrender-components 0.19.9-beta.1 → 0.19.10-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/axis/util.js CHANGED
@@ -70,4 +70,5 @@ function getPolarAngleLabelPosition(angle, center, radius, labelOffset, inside,
70
70
 
71
71
  exports.clampRadian = clampRadian, exports.isInRange = isInRange, exports.getCircleLabelPosition = getCircleLabelPosition,
72
72
  exports.getElMap = getElMap, exports.getVerticalCoord = getVerticalCoord, exports.getCircleVerticalVector = getCircleVerticalVector,
73
- exports.angleLabelOrientAttribute = angleLabelOrientAttribute, exports.getPolarAngleLabelPosition = getPolarAngleLabelPosition;
73
+ exports.angleLabelOrientAttribute = angleLabelOrientAttribute, exports.getPolarAngleLabelPosition = getPolarAngleLabelPosition;
74
+ //# sourceMappingURL=util.js.map
package/cjs/brush/type.js CHANGED
@@ -8,5 +8,4 @@ Object.defineProperty(exports, "__esModule", {
8
8
  IOperateType.drawStart = "drawStart", IOperateType.drawEnd = "drawEnd", IOperateType.drawing = "drawing",
9
9
  IOperateType.moving = "moving", IOperateType.moveStart = "moveStart", IOperateType.moveEnd = "moveEnd",
10
10
  IOperateType.brushClear = "brushClear";
11
- }(IOperateType = exports.IOperateType || (exports.IOperateType = {}));
12
- //# sourceMappingURL=type.js.map
11
+ }(IOperateType = exports.IOperateType || (exports.IOperateType = {}));
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.19.9-beta.1";
1
+ export declare const version = "0.19.10-beta.1";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
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.9-beta.1", __exportStar(require("./core/base"), exports),
20
+ }), exports.version = void 0, exports.version = "0.19.10-beta.1", __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,eAAe,CAAC;AAEvC,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.9-beta.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,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.10-beta.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"]}
@@ -92,12 +92,13 @@ 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;
96
- if (startHandler && !startHandler.attribute.fill) {
95
+ var _a;
96
+ const {layout: layout = "horizontal", colors: colors, railWidth: railWidth, railHeight: railHeight} = this.attribute, {startHandler: startHandler, endHandler: endHandler, track: track, attribute: attribute} = this._slider, {startValue: startValue, endValue: endValue, startPos: startPos, endPos: endPos} = this._slider.currentValue, handlerColor = null === (_a = attribute.handlerStyle) || void 0 === _a ? void 0 : _a.fill;
97
+ if (startHandler && !handlerColor) {
97
98
  const startHandlerColor = this._colorScale.scale(startValue);
98
99
  startHandler.setAttribute("fill", startHandlerColor);
99
100
  }
100
- if (endHandler && !endHandler.attribute.fill) {
101
+ if (endHandler && !handlerColor) {
101
102
  const endHandlerColor = this._colorScale.scale(endValue);
102
103
  endHandler.setAttribute("fill", endHandlerColor);
103
104
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/legend/color/color.ts"],"names":[],"mappings":";;;AAKA,6CAA8D;AAG9D,6CAA+C;AAC/C,kCAAqC;AACrC,yCAAsC;AACtC,0CAAkD;AAGlD,0CAAiE;AAEjE,IAAA,6CAAkC,GAAE,CAAC;AACrC,MAAa,qBAAsB,SAAQ,iBAAiC;IAsC1E,YAAY,UAAiC,EAAE,OAA0B;QACvE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,qBAAqB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAtC5G,SAAI,GAAG,aAAa,CAAC;QAuLb,0BAAqB,GAAG,CAAC,CAAiB,EAAE,EAAE;YACpD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;YAE/C,IAAI,YAAY,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,IAAA,cAAK,EAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBACtD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAErD,YAAY,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;aAC1C;YAED,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC,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,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,8BAAmB;QAC1B,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,qBAAqB;SAC5B;KACF;IACD,WAAW,EAAE,EAAE;IACf,YAAY,EAAE;QACZ,IAAI,EAAE,IAAW;QACjB,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;QACd,WAAW,EAAE;YACX,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC;YACZ,MAAM,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"]}
1
+ {"version":3,"sources":["../src/legend/color/color.ts"],"names":[],"mappings":";;;AAKA,6CAA8D;AAG9D,6CAA+C;AAC/C,kCAAqC;AACrC,yCAAsC;AACtC,0CAAkD;AAGlD,0CAAiE;AAEjE,IAAA,6CAAkC,GAAE,CAAC;AACrC,MAAa,qBAAsB,SAAQ,iBAAiC;IAsC1E,YAAY,UAAiC,EAAE,OAA0B;QACvE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,qBAAqB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAtC5G,SAAI,GAAG,aAAa,CAAC;QAuLb,0BAAqB,GAAG,CAAC,CAAiB,EAAE,EAAE;YACpD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;YAE/C,IAAI,YAAY,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,IAAA,cAAK,EAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBACtD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,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IAAI,CAAC,MAA0B,KACnC,KAAK,EAAE,QAAQ,IACf,CAAC;SACJ;IACH,CAAC;;AA5PH,sDA6PC;AA1PQ,uCAAiB,GAAG;IACzB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE;QAEL,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,8BAAmB;QAC1B,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,qBAAqB;SAC5B;KACF;IACD,WAAW,EAAE,EAAE;IACf,YAAY,EAAE;QACZ,IAAI,EAAE,IAAW;QACjB,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;QACd,WAAW,EAAE;YACX,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC;YACZ,MAAM,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, attribute } = this._slider;\n const { startValue, endValue, startPos, endPos } = this._slider.currentValue;\n const handlerColor = attribute.handlerStyle?.fill;\n // 计算颜色\n if (startHandler && !handlerColor) {\n const startHandlerColor = this._colorScale.scale(startValue);\n startHandler.setAttribute('fill', startHandlerColor);\n }\n\n if (endHandler && !handlerColor) {\n const endHandlerColor = this._colorScale.scale(endValue);\n endHandler.setAttribute('fill', endHandlerColor);\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
@@ -26426,20 +26426,18 @@ class ColorContinuousLegend extends LegendBase {
26426
26426
  return res;
26427
26427
  }
26428
26428
  _updateColor() {
26429
+ var _a;
26429
26430
  const { layout = 'horizontal', colors, railWidth, railHeight } = this.attribute;
26430
- const { startHandler, endHandler, track } = this._slider;
26431
+ const { startHandler, endHandler, track, attribute } = this._slider;
26431
26432
  const { startValue, endValue, startPos, endPos } = this._slider.currentValue;
26432
- if (startHandler) {
26433
- if (!startHandler.attribute.fill) {
26434
- const startHandlerColor = this._colorScale.scale(startValue);
26435
- startHandler.setAttribute('fill', startHandlerColor);
26436
- }
26433
+ const handlerColor = (_a = attribute.handlerStyle) === null || _a === void 0 ? void 0 : _a.fill;
26434
+ if (startHandler && !handlerColor) {
26435
+ const startHandlerColor = this._colorScale.scale(startValue);
26436
+ startHandler.setAttribute('fill', startHandlerColor);
26437
26437
  }
26438
- if (endHandler) {
26439
- if (!endHandler.attribute.fill) {
26440
- const endHandlerColor = this._colorScale.scale(endValue);
26441
- endHandler.setAttribute('fill', endHandlerColor);
26442
- }
26438
+ if (endHandler && !handlerColor) {
26439
+ const endHandlerColor = this._colorScale.scale(endValue);
26440
+ endHandler.setAttribute('fill', endHandlerColor);
26443
26441
  }
26444
26442
  const isHorizontal = layout === 'horizontal';
26445
26443
  const railLen = isHorizontal ? railWidth : railHeight;
@@ -29086,6 +29084,6 @@ EmptyTip.defaultAttributes = {
29086
29084
  }
29087
29085
  };
29088
29086
 
29089
- const version = "0.19.9-beta.1";
29087
+ const version = "0.19.10-beta.1";
29090
29088
 
29091
29089
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AreaLabel, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupFadeIn, GroupFadeOut, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineDataLabel, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Title, Tooltip, VTag, angle, angleLabelOrientAttribute, angleTo, clampRadian, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, direction, fuzzyEqualNumber, getCircleLabelPosition, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, loadPoptip, measureTextSize, normalize, reactAttributeTransform, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
package/es/axis/util.js CHANGED
@@ -65,4 +65,5 @@ export function getPolarAngleLabelPosition(angle, center, radius, labelOffset, i
65
65
  y: 0
66
66
  }, radius, angle), labelPoint = getVerticalCoord(point, getCircleVerticalVector(labelOffset, point, center, inside));
67
67
  return getCircleLabelPosition(labelPoint, getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside), text, style);
68
- }
68
+ }
69
+ //# sourceMappingURL=util.js.map
package/es/brush/type.js CHANGED
@@ -4,5 +4,4 @@ export var IOperateType;
4
4
  IOperateType.drawStart = "drawStart", IOperateType.drawEnd = "drawEnd", IOperateType.drawing = "drawing",
5
5
  IOperateType.moving = "moving", IOperateType.moveStart = "moveStart", IOperateType.moveEnd = "moveEnd",
6
6
  IOperateType.brushClear = "brushClear";
7
- }(IOperateType || (IOperateType = {}));
8
- //# sourceMappingURL=type.js.map
7
+ }(IOperateType || (IOperateType = {}));
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.19.9-beta.1";
1
+ export declare const version = "0.19.10-beta.1";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.19.9-beta.1";
1
+ export const version = "0.19.10-beta.1";
2
2
 
3
3
  export * from "./core/base";
4
4
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;AAEvC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.19.9-beta.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,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.19.10-beta.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"]}
@@ -94,12 +94,13 @@ export class ColorContinuousLegend extends LegendBase {
94
94
  res;
95
95
  }
96
96
  _updateColor() {
97
- 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;
98
- if (startHandler && !startHandler.attribute.fill) {
97
+ var _a;
98
+ const {layout: layout = "horizontal", colors: colors, railWidth: railWidth, railHeight: railHeight} = this.attribute, {startHandler: startHandler, endHandler: endHandler, track: track, attribute: attribute} = this._slider, {startValue: startValue, endValue: endValue, startPos: startPos, endPos: endPos} = this._slider.currentValue, handlerColor = null === (_a = attribute.handlerStyle) || void 0 === _a ? void 0 : _a.fill;
99
+ if (startHandler && !handlerColor) {
99
100
  const startHandlerColor = this._colorScale.scale(startValue);
100
101
  startHandler.setAttribute("fill", startHandlerColor);
101
102
  }
102
- if (endHandler && !endHandler.attribute.fill) {
103
+ if (endHandler && !handlerColor) {
103
104
  const endHandlerColor = this._colorScale.scale(endValue);
104
105
  endHandler.setAttribute("fill", endHandlerColor);
105
106
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/legend/color/color.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAEjE,kCAAkC,EAAE,CAAC;AACrC,MAAM,OAAO,qBAAsB,SAAQ,UAAiC;IAsC1E,YAAY,UAAiC,EAAE,OAA0B;QACvE,KAAK,CAAC,CAAA,OAAO,aAAP,O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,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YACpD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAC1B,QAAQ,CAAC,IAAI,CAAC;oBACZ,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,KAAK;oBAC1C,KAAK,EAAE,IAAI,CAAC,KAAK;iBAClB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,QAAQ,CAAC,IAAI,CAAC;gBACZ,MAAM,EAAE,CAAC;gBACT,KAAK,EAAE,QAAQ;aAChB,CAAC,CAAC;YACH,KAAK,CAAC,YAAY,CAAC,MAAM,kCACnB,IAAI,CAAC,MAA0B,KACnC,KAAK,EAAE,QAAQ,IACf,CAAC;SACJ;IACH,CAAC;;AA5PM,uCAAiB,GAAG;IACzB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE;QAEL,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,mBAAmB;QAC1B,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,qBAAqB;SAC5B;KACF;IACD,WAAW,EAAE,EAAE;IACf,YAAY,EAAE;QACZ,IAAI,EAAE,IAAW;QACjB,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;QACd,WAAW,EAAE;YACX,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC;YACZ,MAAM,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"]}
1
+ {"version":3,"sources":["../src/legend/color/color.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAE,WAAW,EA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AAE;YACX,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC;YACZ,MAAM,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, attribute } = this._slider;\n const { startValue, endValue, startPos, endPos } = this._slider.currentValue;\n const handlerColor = attribute.handlerStyle?.fill;\n // 计算颜色\n if (startHandler && !handlerColor) {\n const startHandlerColor = this._colorScale.scale(startValue);\n startHandler.setAttribute('fill', startHandlerColor);\n }\n\n if (endHandler && !handlerColor) {\n const endHandlerColor = this._colorScale.scale(endValue);\n endHandler.setAttribute('fill', endHandlerColor);\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-components",
3
- "version": "0.19.9-beta.1",
3
+ "version": "0.19.10-beta.1",
4
4
  "description": "components library for dp visualization",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -12,8 +12,8 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@visactor/vrender-core": "0.19.9-beta.1",
16
- "@visactor/vrender-kits": "0.19.9-beta.1",
15
+ "@visactor/vrender-core": "0.19.10-beta.1",
16
+ "@visactor/vrender-kits": "0.19.10-beta.1",
17
17
  "@visactor/vutils": "~0.18.9",
18
18
  "@visactor/vscale": "~0.18.9"
19
19
  },
@@ -29,9 +29,9 @@
29
29
  "vite": "3.2.6",
30
30
  "typescript": "4.9.5",
31
31
  "cross-env": "^7.0.3",
32
- "@internal/bundler": "0.0.1",
33
32
  "@internal/ts-config": "0.0.1",
34
- "@internal/eslint-config": "0.0.1"
33
+ "@internal/eslint-config": "0.0.1",
34
+ "@internal/bundler": "0.0.1"
35
35
  },
36
36
  "keywords": [
37
37
  "VisActor",