@visactor/vrender-components 0.17.6 → 0.17.8-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/axis/line.js CHANGED
@@ -85,11 +85,11 @@ export class LineAxis extends AxisBase {
85
85
  labelLength += space;
86
86
  const layerCount = Object.keys(this.axisLabelLayerSize).length;
87
87
  if (0 === axisVector[1]) {
88
- const labelBoundsHeight = this.axisLabelsContainer.AABBBounds.height();
88
+ const labelBoundsHeight = this.axisLabelsContainer ? this.axisLabelsContainer.AABBBounds.height() : 0;
89
89
  isFinite(labelBoundsHeight) ? labelLength += labelBoundsHeight + (layerCount - 1) * space : labelLength = 0;
90
90
  } else {
91
91
  if (0 === axisVector[0]) {
92
- const boundsWidth = this.axisLabelsContainer.AABBBounds.width();
92
+ const boundsWidth = this.axisLabelsContainer ? this.axisLabelsContainer.AABBBounds.width() : 0;
93
93
  isFinite(boundsWidth) ? labelLength += boundsWidth + (layerCount - 1) * space : labelLength = 0;
94
94
  } else Object.keys(this.axisLabelLayerSize).forEach(((layer, index) => {
95
95
  labelLength += this.axisLabelLayerSize[layer].width + (index > 0 ? space : 0);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/line.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA,OAAO,EACL,GAAG,EACH,KAAK,EACL,KAAK,EACL,aAAa,EACb,OAAO,EACP,UAAU,EACV,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,KAAK,EACL,IAAI,IAAI,IAAI,EACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAKxD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC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,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;SACjH;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;;AA1eM,0BAAiB,GAAG,kBAAkB,CAAC;AA6ehD,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC","file":"line.js","sourcesContent":["/**\n * @description 直线型坐标轴\n */\n// eslint-disable-next-line no-duplicate-imports\nimport {\n get,\n isNil,\n merge,\n isNumberClose,\n isEmpty,\n isFunction,\n isValidNumber,\n isValid,\n normalizePadding,\n mixin,\n last as peek\n} from '@visactor/vutils';\nimport { graphicCreator } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TextAlignType, IGroup, INode, IText, TextBaselineType } from '@visactor/vrender-core';\nimport type { SegmentAttributes } from '../segment';\n// eslint-disable-next-line no-duplicate-imports\nimport { Segment } from '../segment';\nimport { angleTo } from '../util/matrix';\nimport type { TagAttributes } from '../tag';\nimport type { LineAttributes, LineAxisAttributes, TitleAttributes, AxisItem } from './type';\nimport { AxisBase } from './base';\nimport { DEFAULT_AXIS_THEME } from './config';\nimport { AXIS_ELEMENT_NAME, DEFAULT_STATES } from './constant';\nimport { measureTextSize } from '../util';\nimport { autoHide as autoHideFunc } from './overlap/auto-hide';\nimport { autoRotate as autoRotateFunc, getXAxisLabelAlign, getYAxisLabelAlign } from './overlap/auto-rotate';\nimport { autoLimit as autoLimitFunc } from './overlap/auto-limit';\nimport { alignAxisLabels } from '../util/align';\nimport { LineAxisMixin } from './mixin/line';\nimport type { ComponentOptions } from '../interface';\nimport { loadLineAxisComponent } from './register';\n\nloadLineAxisComponent();\nexport interface LineAxis\n extends Pick<LineAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector' | 'getRelativeVector'>,\n AxisBase<LineAxisAttributes> {}\n\nexport class LineAxis extends AxisBase<LineAxisAttributes> {\n static defaultAttributes = DEFAULT_AXIS_THEME;\n\n constructor(attributes: LineAxisAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, LineAxis.defaultAttributes, attributes), options);\n }\n\n protected _renderInner(container: IGroup) {\n super._renderInner(container);\n const { panel } = this.attribute;\n\n // TODO: 目前是通过包围盒绘制,在一些情况下会有那问题,比如圆弧轴、带了箭头的坐标轴等\n // 坐标轴主体 panel\n if (panel && panel.visible) {\n const axisContainer = this.axisContainer;\n const axisContainerBounds = axisContainer.AABBBounds;\n const bgRect = graphicCreator.rect({\n x: axisContainerBounds.x1,\n y: axisContainerBounds.y1,\n width: axisContainerBounds.width(),\n height: axisContainerBounds.height(),\n ...panel.style\n });\n bgRect.name = AXIS_ELEMENT_NAME.background;\n bgRect.id = this._getNodeId('background');\n\n bgRect.states = merge({}, DEFAULT_STATES, panel.state ?? {});\n axisContainer.insertBefore(bgRect, axisContainer.firstChild);\n }\n }\n\n // TODO: break\n protected renderLine(container: IGroup): void {\n const { start, end, line } = this.attribute as LineAxisAttributes;\n const { startSymbol, endSymbol, style, breakRange, breakShape, breakShapeStyle, state, ...restLineAttrs } =\n line as LineAttributes;\n const lineAttrs = {\n points: [start, end],\n startSymbol,\n endSymbol,\n lineStyle: style,\n ...restLineAttrs\n } as SegmentAttributes;\n\n if (!isEmpty(state)) {\n lineAttrs.state = {\n line: merge({}, DEFAULT_STATES, state),\n symbol: merge({}, DEFAULT_STATES, state)\n };\n }\n\n const axisLineGroup = new Segment(lineAttrs);\n axisLineGroup.name = AXIS_ELEMENT_NAME.line;\n axisLineGroup.id = this._getNodeId('line');\n container.add(axisLineGroup as unknown as INode);\n }\n\n // TODO: 太 hack 了,需要静心优化\n protected getTitleAttribute() {\n const {\n position = 'middle',\n space = 4,\n textStyle = {},\n autoRotate = true,\n shape,\n background,\n state,\n ...restAttrs\n } = this.attribute.title as TitleAttributes;\n let percent = 0.5;\n if (position === 'start') {\n percent = 0;\n } else if (position === 'end') {\n percent = 1;\n }\n const { verticalFactor = 1 } = this.attribute;\n const factor = -1 * verticalFactor;\n const point = this.getTickCoord(percent);\n const axisVector = this.getRelativeVector();\n // HACK;\n let labelLength = 0;\n if (this.attribute.label?.visible && this.attribute.label?.inside === false) {\n const space = +get(this.attribute, 'label.space', 4);\n labelLength += space;\n const layerCount = Object.keys(this.axisLabelLayerSize).length;\n if (axisVector[1] === 0) {\n const labelBoundsHeight = this.axisLabelsContainer.AABBBounds.height();\n if (isFinite(labelBoundsHeight)) {\n labelLength += labelBoundsHeight + (layerCount - 1) * space;\n } else {\n labelLength = 0;\n }\n } else {\n if (axisVector[0] === 0) {\n const boundsWidth = this.axisLabelsContainer.AABBBounds.width();\n if (isFinite(boundsWidth)) {\n labelLength += boundsWidth + (layerCount - 1) * space;\n } else {\n labelLength = 0;\n }\n } else {\n // 发生了旋转\n Object.keys(this.axisLabelLayerSize).forEach((layer, index) => {\n labelLength += this.axisLabelLayerSize[layer].width + (index > 0 ? space : 0);\n });\n }\n\n const textAlign = this.axisLabelLayerSize[0].textAlign;\n const isTextAlignStart = textAlign === 'start' || textAlign === 'left';\n const isTextCenter = textAlign === 'center';\n const isReverse = axisVector[1] > 0;\n if (factor === 1) {\n labelLength = isReverse\n ? isTextAlignStart\n ? labelLength\n : isTextCenter\n ? labelLength / 2\n : space\n : isTextAlignStart\n ? space\n : isTextCenter\n ? labelLength / 2\n : labelLength;\n } else {\n labelLength = isReverse\n ? isTextAlignStart\n ? space\n : isTextCenter\n ? labelLength / 2\n : labelLength\n : isTextAlignStart\n ? labelLength\n : isTextCenter\n ? labelLength / 2\n : space;\n }\n }\n }\n\n // 标题都默认朝外\n let tickLength = 0;\n if (this.attribute.tick?.visible && this.attribute.tick?.inside === false) {\n tickLength = this.attribute.tick?.length || 4;\n }\n if (this.attribute.subTick?.visible && this.attribute.subTick?.inside === false) {\n tickLength = Math.max(tickLength, this.attribute.subTick?.length || 2);\n }\n\n const offset = tickLength + labelLength + space;\n const titlePoint = this.getVerticalCoord(point, offset, false); // 标题的点\n const vector = this.getVerticalVector(offset, false, { x: 0, y: 0 });\n\n let { angle } = restAttrs; // 用户设置的是角度\n let textAlign;\n if (position === 'start') {\n textAlign = 'start';\n } else if (position === 'end') {\n textAlign = 'end';\n } else {\n textAlign = 'center';\n }\n let textBaseline;\n if (isNil(angle) && autoRotate) {\n const v1: [number, number] = [1, 0]; // 水平方向的向量\n const radian = angleTo(axisVector, v1, true);\n angle = radian;\n const { verticalFactor = 1 } = this.attribute;\n const factor = -1 * verticalFactor;\n if (factor === 1) {\n textBaseline = 'bottom';\n } else {\n textBaseline = 'top';\n }\n } else {\n // if (isValid(angle)) {\n // angle = degreeToRadian(angle);\n // }\n textAlign = this.getTextAlign(vector as number[]);\n textBaseline = this.getTextBaseline(vector as number[], false);\n }\n\n const attrs: TagAttributes = {\n ...titlePoint,\n ...restAttrs,\n textStyle: {\n // @ts-ignore\n textAlign,\n // @ts-ignore\n textBaseline,\n ...textStyle\n },\n state: {\n text: merge({}, DEFAULT_STATES, state?.text),\n shape: merge({}, DEFAULT_STATES, state?.shape),\n panel: merge({}, DEFAULT_STATES, state?.background)\n }\n };\n attrs.angle = angle;\n\n if (shape && shape.visible) {\n attrs.shape = {\n visible: true,\n ...shape.style\n };\n if (shape.space) {\n attrs.space = shape.space;\n }\n }\n\n if (background && background.visible) {\n attrs.panel = {\n visible: true,\n ...background.style\n };\n }\n\n return attrs;\n }\n\n protected getTextBaseline(vector: number[], inside?: boolean): TextBaselineType {\n let base: TextBaselineType = 'middle';\n const { verticalFactor = 1 } = this.attribute;\n const factor = (inside ? 1 : -1) * verticalFactor;\n if (isNumberClose(vector[1], 0)) {\n if (isNumberClose(vector[0], 0) && !Object.is(vector[0], -0) && !Object.is(vector[1], -0)) {\n base = factor === 1 ? 'bottom' : 'top';\n } else {\n base = 'middle';\n }\n } else if (vector[1] > 0) {\n base = 'top';\n } else if (vector[1] < 0) {\n base = 'bottom';\n }\n return base;\n }\n\n protected getLabelAlign(\n vector: [number, number],\n inside?: boolean,\n angle?: number\n ): { textAlign: TextAlignType; textBaseline: TextBaselineType } {\n const orient = this.attribute.orient;\n if (isValidNumber(angle)) {\n if (orient === 'top' || orient === 'bottom') {\n return getXAxisLabelAlign(orient, angle);\n }\n if (orient === 'left' || orient === 'right') {\n return getYAxisLabelAlign(orient, angle);\n }\n }\n\n return {\n textAlign: this.getTextAlign(vector),\n textBaseline: this.getTextBaseline(vector, inside)\n };\n }\n\n protected beforeLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n const { flush = false } = this.attribute.label || {};\n if (flush && labelShapes.length) {\n // 首尾标签向内偏移\n const { orient, start: axisStart, end: axisEnd } = this.attribute;\n const isX = orient === 'bottom' || orient === 'top';\n const first = labelShapes[0];\n const last = peek(labelShapes);\n const isInverse = isX ? first.attribute.x > last.attribute.x : first.attribute.y < last.attribute.y;\n if (isX) {\n if (isInverse) {\n const start = axisEnd.x;\n const end = axisStart.x;\n const startBound = first.AABBBounds.x2;\n const endBound = last.AABBBounds.x1;\n\n if (startBound > start) {\n first.setAttributes({\n x: start,\n textAlign: 'right'\n });\n }\n\n if (endBound < end) {\n last.setAttributes({\n x: end,\n textAlign: 'left'\n });\n }\n } else {\n const start = axisStart.x;\n const end = axisEnd.x;\n const startBound = first.AABBBounds.x1;\n const endBound = last.AABBBounds.x2;\n if (startBound < start) {\n first.setAttributes({\n x: start,\n textAlign: 'left'\n });\n }\n\n if (endBound > end) {\n last.setAttributes({\n x: end,\n textAlign: 'right'\n });\n }\n }\n } else {\n if (isInverse) {\n const startBound = first.AABBBounds.y1;\n const endBound = last.AABBBounds.y2;\n const start = axisStart.y;\n const end = axisEnd.y;\n\n if (startBound < start) {\n first.setAttributes({\n y: start,\n textBaseline: 'top'\n });\n }\n\n if (endBound > end) {\n last.setAttributes({\n y: end,\n textBaseline: 'bottom'\n });\n }\n } else {\n const start = axisEnd.y;\n const end = axisStart.y;\n const startBound = first.AABBBounds.y2;\n const endBound = last.AABBBounds.y1;\n\n if (startBound > start) {\n first.setAttributes({\n y: start,\n textBaseline: 'bottom'\n });\n }\n\n if (endBound < end) {\n last.setAttributes({\n y: end,\n textBaseline: 'top'\n });\n }\n }\n }\n }\n\n return;\n }\n protected handleLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n if (isEmpty(labelShapes)) {\n return;\n }\n\n const { verticalLimitSize, label, orient } = this.attribute;\n const limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount);\n\n const {\n layoutFunc,\n autoRotate,\n autoRotateAngle,\n autoLimit,\n limitEllipsis,\n autoHide,\n autoHideMethod,\n autoHideSeparation\n } = label;\n\n if (isFunction(layoutFunc)) {\n // 自定义布局\n layoutFunc(labelShapes, labelData, layer, this);\n } else {\n // order: autoRotate -> autoLimit -> autoHide\n if (autoRotate) {\n autoRotateFunc(labelShapes, {\n labelRotateAngle: autoRotateAngle,\n orient\n });\n }\n if (autoLimit && isValidNumber(limitLength) && limitLength > 0) {\n autoLimitFunc(labelShapes, {\n limitLength,\n ellipsis: limitEllipsis,\n orient\n });\n }\n if (autoHide) {\n autoHideFunc(labelShapes, {\n orient,\n method: autoHideMethod,\n separation: autoHideSeparation\n });\n }\n }\n }\n\n protected afterLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ) {\n const { verticalLimitSize, orient } = this.attribute;\n\n // 处理 verticalMinSize,根据 verticalMinSize 调整 labelContainer 的大小\n const isHorizontal = orient === 'bottom' || orient === 'top';\n const axisLabelContainerBounds = labelContainer.AABBBounds;\n let axisLabelContainerSize = isHorizontal ? axisLabelContainerBounds.height() : axisLabelContainerBounds.width();\n const { verticalMinSize } = this.attribute;\n\n if (isValidNumber(verticalMinSize) && (!isValidNumber(verticalLimitSize) || verticalMinSize <= verticalLimitSize)) {\n const minSize = this._getAxisLabelLimitLength(verticalMinSize, layerCount);\n axisLabelContainerSize = Math.max(axisLabelContainerSize, minSize);\n\n let x;\n let y;\n if (orient === 'left') {\n x = axisLabelContainerBounds.x2 - axisLabelContainerSize;\n y = axisLabelContainerBounds.y1;\n } else if (orient === 'right') {\n x = axisLabelContainerBounds.x1;\n y = axisLabelContainerBounds.y1;\n } else if (orient === 'top') {\n x = axisLabelContainerBounds.x1;\n y = axisLabelContainerBounds.y2 - axisLabelContainerSize;\n } else if (orient === 'bottom') {\n x = axisLabelContainerBounds.x1;\n y = axisLabelContainerBounds.y1;\n }\n\n const bgRect = graphicCreator.rect({\n x,\n y,\n width: isHorizontal ? axisLabelContainerBounds.width() : axisLabelContainerSize,\n height: isHorizontal ? axisLabelContainerSize : axisLabelContainerBounds.height(),\n pickable: false\n });\n bgRect.name = AXIS_ELEMENT_NAME.axisLabelBackground;\n bgRect.id = this._getNodeId('axis-label-background');\n labelContainer.insertBefore(bgRect, labelContainer.firstChild);\n }\n\n // 处理 align,进行整体的对齐操作\n if (isValid(this.attribute.label.containerAlign)) {\n let start;\n if (orient === 'left') {\n start = axisLabelContainerBounds.x2;\n } else if (orient === 'right') {\n start = axisLabelContainerBounds.x1;\n } else if (orient === 'top') {\n start = axisLabelContainerBounds.y2;\n } else if (orient === 'bottom') {\n start = axisLabelContainerBounds.y1;\n }\n\n alignAxisLabels(labelShapes, start, axisLabelContainerSize, orient, this.attribute.label.containerAlign);\n }\n }\n\n private _getAxisLabelLimitLength(limitSize: number, layerCount: number): number {\n const { label, title, line, tick } = this.attribute;\n const labelSpace = label.space ?? 4;\n let limitLength = limitSize;\n let titleHeight = 0;\n let titleSpacing = 0;\n const axisLineWidth = line?.visible ? line.style.lineWidth ?? 1 : 0;\n const tickLength = tick?.visible ? tick.length ?? 4 : 0;\n if (title?.visible && typeof title.text === 'string') {\n titleHeight = measureTextSize(title.text, title.textStyle).height;\n const padding = normalizePadding(title.padding);\n titleSpacing = title.space + padding[0] + padding[2];\n }\n if (limitLength) {\n limitLength = (limitLength - labelSpace - titleSpacing - titleHeight - axisLineWidth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I,CAAC,KAAK,CAAC,SAAS,mCAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,MAAM,UAAU,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,EAAC,CAAC,CAAC,MAAA,IAAI,CAAC,MAAM,mCAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;YACpD,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;YAClE,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAChD,YAAY,GAAG,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;SACtD;QACD,IAAI,WAAW,EAAE;YACf,WAAW,GAAG,CAAC,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;SACjH;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;;AA1eM,0BAAiB,GAAG,kBAAkB,CAAC;AA6ehD,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC","file":"line.js","sourcesContent":["/**\n * @description 直线型坐标轴\n */\n// eslint-disable-next-line no-duplicate-imports\nimport {\n get,\n isNil,\n merge,\n isNumberClose,\n isEmpty,\n isFunction,\n isValidNumber,\n isValid,\n normalizePadding,\n mixin,\n last as peek\n} from '@visactor/vutils';\nimport { graphicCreator } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TextAlignType, IGroup, INode, IText, TextBaselineType } from '@visactor/vrender-core';\nimport type { SegmentAttributes } from '../segment';\n// eslint-disable-next-line no-duplicate-imports\nimport { Segment } from '../segment';\nimport { angleTo } from '../util/matrix';\nimport type { TagAttributes } from '../tag';\nimport type { LineAttributes, LineAxisAttributes, TitleAttributes, AxisItem } from './type';\nimport { AxisBase } from './base';\nimport { DEFAULT_AXIS_THEME } from './config';\nimport { AXIS_ELEMENT_NAME, DEFAULT_STATES } from './constant';\nimport { measureTextSize } from '../util';\nimport { autoHide as autoHideFunc } from './overlap/auto-hide';\nimport { autoRotate as autoRotateFunc, getXAxisLabelAlign, getYAxisLabelAlign } from './overlap/auto-rotate';\nimport { autoLimit as autoLimitFunc } from './overlap/auto-limit';\nimport { alignAxisLabels } from '../util/align';\nimport { LineAxisMixin } from './mixin/line';\nimport type { ComponentOptions } from '../interface';\nimport { loadLineAxisComponent } from './register';\n\nloadLineAxisComponent();\nexport interface LineAxis\n extends Pick<LineAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector' | 'getRelativeVector'>,\n AxisBase<LineAxisAttributes> {}\n\nexport class LineAxis extends AxisBase<LineAxisAttributes> {\n static defaultAttributes = DEFAULT_AXIS_THEME;\n\n constructor(attributes: LineAxisAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, LineAxis.defaultAttributes, attributes), options);\n }\n\n protected _renderInner(container: IGroup) {\n super._renderInner(container);\n const { panel } = this.attribute;\n\n // TODO: 目前是通过包围盒绘制,在一些情况下会有那问题,比如圆弧轴、带了箭头的坐标轴等\n // 坐标轴主体 panel\n if (panel && panel.visible) {\n const axisContainer = this.axisContainer;\n const axisContainerBounds = axisContainer.AABBBounds;\n const bgRect = graphicCreator.rect({\n x: axisContainerBounds.x1,\n y: axisContainerBounds.y1,\n width: axisContainerBounds.width(),\n height: axisContainerBounds.height(),\n ...panel.style\n });\n bgRect.name = AXIS_ELEMENT_NAME.background;\n bgRect.id = this._getNodeId('background');\n\n bgRect.states = merge({}, DEFAULT_STATES, panel.state ?? {});\n axisContainer.insertBefore(bgRect, axisContainer.firstChild);\n }\n }\n\n // TODO: break\n protected renderLine(container: IGroup): void {\n const { start, end, line } = this.attribute as LineAxisAttributes;\n const { startSymbol, endSymbol, style, breakRange, breakShape, breakShapeStyle, state, ...restLineAttrs } =\n line as LineAttributes;\n const lineAttrs = {\n points: [start, end],\n startSymbol,\n endSymbol,\n lineStyle: style,\n ...restLineAttrs\n } as SegmentAttributes;\n\n if (!isEmpty(state)) {\n lineAttrs.state = {\n line: merge({}, DEFAULT_STATES, state),\n symbol: merge({}, DEFAULT_STATES, state)\n };\n }\n\n const axisLineGroup = new Segment(lineAttrs);\n axisLineGroup.name = AXIS_ELEMENT_NAME.line;\n axisLineGroup.id = this._getNodeId('line');\n container.add(axisLineGroup as unknown as INode);\n }\n\n // TODO: 太 hack 了,需要静心优化\n protected getTitleAttribute() {\n const {\n position = 'middle',\n space = 4,\n textStyle = {},\n autoRotate = true,\n shape,\n background,\n state,\n ...restAttrs\n } = this.attribute.title as TitleAttributes;\n let percent = 0.5;\n if (position === 'start') {\n percent = 0;\n } else if (position === 'end') {\n percent = 1;\n }\n const { verticalFactor = 1 } = this.attribute;\n const factor = -1 * verticalFactor;\n const point = this.getTickCoord(percent);\n const axisVector = this.getRelativeVector();\n // HACK;\n let labelLength = 0;\n if (this.attribute.label?.visible && this.attribute.label?.inside === false) {\n const space = +get(this.attribute, 'label.space', 4);\n labelLength += space;\n const layerCount = Object.keys(this.axisLabelLayerSize).length;\n if (axisVector[1] === 0) {\n const labelBoundsHeight = this.axisLabelsContainer ? this.axisLabelsContainer.AABBBounds.height() : 0;\n if (isFinite(labelBoundsHeight)) {\n labelLength += labelBoundsHeight + (layerCount - 1) * space;\n } else {\n labelLength = 0;\n }\n } else {\n if (axisVector[0] === 0) {\n const boundsWidth = this.axisLabelsContainer ? this.axisLabelsContainer.AABBBounds.width() : 0;\n if (isFinite(boundsWidth)) {\n labelLength += boundsWidth + (layerCount - 1) * space;\n } else {\n labelLength = 0;\n }\n } else {\n // 发生了旋转\n Object.keys(this.axisLabelLayerSize).forEach((layer, index) => {\n labelLength += this.axisLabelLayerSize[layer].width + (index > 0 ? space : 0);\n });\n }\n\n const textAlign = this.axisLabelLayerSize[0].textAlign;\n const isTextAlignStart = textAlign === 'start' || textAlign === 'left';\n const isTextCenter = textAlign === 'center';\n const isReverse = axisVector[1] > 0;\n if (factor === 1) {\n labelLength = isReverse\n ? isTextAlignStart\n ? labelLength\n : isTextCenter\n ? labelLength / 2\n : space\n : isTextAlignStart\n ? space\n : isTextCenter\n ? labelLength / 2\n : labelLength;\n } else {\n labelLength = isReverse\n ? isTextAlignStart\n ? space\n : isTextCenter\n ? labelLength / 2\n : labelLength\n : isTextAlignStart\n ? labelLength\n : isTextCenter\n ? labelLength / 2\n : space;\n }\n }\n }\n\n // 标题都默认朝外\n let tickLength = 0;\n if (this.attribute.tick?.visible && this.attribute.tick?.inside === false) {\n tickLength = this.attribute.tick?.length || 4;\n }\n if (this.attribute.subTick?.visible && this.attribute.subTick?.inside === false) {\n tickLength = Math.max(tickLength, this.attribute.subTick?.length || 2);\n }\n\n const offset = tickLength + labelLength + space;\n const titlePoint = this.getVerticalCoord(point, offset, false); // 标题的点\n const vector = this.getVerticalVector(offset, false, { x: 0, y: 0 });\n\n let { angle } = restAttrs; // 用户设置的是角度\n let textAlign;\n if (position === 'start') {\n textAlign = 'start';\n } else if (position === 'end') {\n textAlign = 'end';\n } else {\n textAlign = 'center';\n }\n let textBaseline;\n if (isNil(angle) && autoRotate) {\n const v1: [number, number] = [1, 0]; // 水平方向的向量\n const radian = angleTo(axisVector, v1, true);\n angle = radian;\n const { verticalFactor = 1 } = this.attribute;\n const factor = -1 * verticalFactor;\n if (factor === 1) {\n textBaseline = 'bottom';\n } else {\n textBaseline = 'top';\n }\n } else {\n // if (isValid(angle)) {\n // angle = degreeToRadian(angle);\n // }\n textAlign = this.getTextAlign(vector as number[]);\n textBaseline = this.getTextBaseline(vector as number[], false);\n }\n\n const attrs: TagAttributes = {\n ...titlePoint,\n ...restAttrs,\n textStyle: {\n // @ts-ignore\n textAlign,\n // @ts-ignore\n textBaseline,\n ...textStyle\n },\n state: {\n text: merge({}, DEFAULT_STATES, state?.text),\n shape: merge({}, DEFAULT_STATES, state?.shape),\n panel: merge({}, DEFAULT_STATES, state?.background)\n }\n };\n attrs.angle = angle;\n\n if (shape && shape.visible) {\n attrs.shape = {\n visible: true,\n ...shape.style\n };\n if (shape.space) {\n attrs.space = shape.space;\n }\n }\n\n if (background && background.visible) {\n attrs.panel = {\n visible: true,\n ...background.style\n };\n }\n\n return attrs;\n }\n\n protected getTextBaseline(vector: number[], inside?: boolean): TextBaselineType {\n let base: TextBaselineType = 'middle';\n const { verticalFactor = 1 } = this.attribute;\n const factor = (inside ? 1 : -1) * verticalFactor;\n if (isNumberClose(vector[1], 0)) {\n if (isNumberClose(vector[0], 0) && !Object.is(vector[0], -0) && !Object.is(vector[1], -0)) {\n base = factor === 1 ? 'bottom' : 'top';\n } else {\n base = 'middle';\n }\n } else if (vector[1] > 0) {\n base = 'top';\n } else if (vector[1] < 0) {\n base = 'bottom';\n }\n return base;\n }\n\n protected getLabelAlign(\n vector: [number, number],\n inside?: boolean,\n angle?: number\n ): { textAlign: TextAlignType; textBaseline: TextBaselineType } {\n const orient = this.attribute.orient;\n if (isValidNumber(angle)) {\n if (orient === 'top' || orient === 'bottom') {\n return getXAxisLabelAlign(orient, angle);\n }\n if (orient === 'left' || orient === 'right') {\n return getYAxisLabelAlign(orient, angle);\n }\n }\n\n return {\n textAlign: this.getTextAlign(vector),\n textBaseline: this.getTextBaseline(vector, inside)\n };\n }\n\n protected beforeLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n const { flush = false } = this.attribute.label || {};\n if (flush && labelShapes.length) {\n // 首尾标签向内偏移\n const { orient, start: axisStart, end: axisEnd } = this.attribute;\n const isX = orient === 'bottom' || orient === 'top';\n const first = labelShapes[0];\n const last = peek(labelShapes);\n const isInverse = isX ? first.attribute.x > last.attribute.x : first.attribute.y < last.attribute.y;\n if (isX) {\n if (isInverse) {\n const start = axisEnd.x;\n const end = axisStart.x;\n const startBound = first.AABBBounds.x2;\n const endBound = last.AABBBounds.x1;\n\n if (startBound > start) {\n first.setAttributes({\n x: start,\n textAlign: 'right'\n });\n }\n\n if (endBound < end) {\n last.setAttributes({\n x: end,\n textAlign: 'left'\n });\n }\n } else {\n const start = axisStart.x;\n const end = axisEnd.x;\n const startBound = first.AABBBounds.x1;\n const endBound = last.AABBBounds.x2;\n if (startBound < start) {\n first.setAttributes({\n x: start,\n textAlign: 'left'\n });\n }\n\n if (endBound > end) {\n last.setAttributes({\n x: end,\n textAlign: 'right'\n });\n }\n }\n } else {\n if (isInverse) {\n const startBound = first.AABBBounds.y1;\n const endBound = last.AABBBounds.y2;\n const start = axisStart.y;\n const end = axisEnd.y;\n\n if (startBound < start) {\n first.setAttributes({\n y: start,\n textBaseline: 'top'\n });\n }\n\n if (endBound > end) {\n last.setAttributes({\n y: end,\n textBaseline: 'bottom'\n });\n }\n } else {\n const start = axisEnd.y;\n const end = axisStart.y;\n const startBound = first.AABBBounds.y2;\n const endBound = last.AABBBounds.y1;\n\n if (startBound > start) {\n first.setAttributes({\n y: start,\n textBaseline: 'bottom'\n });\n }\n\n if (endBound < end) {\n last.setAttributes({\n y: end,\n textBaseline: 'top'\n });\n }\n }\n }\n }\n\n return;\n }\n protected handleLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n if (isEmpty(labelShapes)) {\n return;\n }\n\n const { verticalLimitSize, label, orient } = this.attribute;\n const limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount);\n\n const {\n layoutFunc,\n autoRotate,\n autoRotateAngle,\n autoLimit,\n limitEllipsis,\n autoHide,\n autoHideMethod,\n autoHideSeparation\n } = label;\n\n if (isFunction(layoutFunc)) {\n // 自定义布局\n layoutFunc(labelShapes, labelData, layer, this);\n } else {\n // order: autoRotate -> autoLimit -> autoHide\n if (autoRotate) {\n autoRotateFunc(labelShapes, {\n labelRotateAngle: autoRotateAngle,\n orient\n });\n }\n if (autoLimit && isValidNumber(limitLength) && limitLength > 0) {\n autoLimitFunc(labelShapes, {\n limitLength,\n ellipsis: limitEllipsis,\n orient\n });\n }\n if (autoHide) {\n autoHideFunc(labelShapes, {\n orient,\n method: autoHideMethod,\n separation: autoHideSeparation\n });\n }\n }\n }\n\n protected afterLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ) {\n const { verticalLimitSize, orient } = this.attribute;\n\n // 处理 verticalMinSize,根据 verticalMinSize 调整 labelContainer 的大小\n const isHorizontal = orient === 'bottom' || orient === 'top';\n const axisLabelContainerBounds = labelContainer.AABBBounds;\n let axisLabelContainerSize = isHorizontal ? axisLabelContainerBounds.height() : axisLabelContainerBounds.width();\n const { verticalMinSize } = this.attribute;\n\n if (isValidNumber(verticalMinSize) && (!isValidNumber(verticalLimitSize) || verticalMinSize <= verticalLimitSize)) {\n const minSize = this._getAxisLabelLimitLength(verticalMinSize, layerCount);\n axisLabelContainerSize = Math.max(axisLabelContainerSize, minSize);\n\n let x;\n let y;\n if (orient === 'left') {\n x = axisLabelContainerBounds.x2 - axisLabelContainerSize;\n y = axisLabelContainerBounds.y1;\n } else if (orient === 'right') {\n x = axisLabelContainerBounds.x1;\n y = axisLabelContainerBounds.y1;\n } else if (orient === 'top') {\n x = axisLabelContainerBounds.x1;\n y = axisLabelContainerBounds.y2 - axisLabelContainerSize;\n } else if (orient === 'bottom') {\n x = axisLabelContainerBounds.x1;\n y = axisLabelContainerBounds.y1;\n }\n\n const bgRect = graphicCreator.rect({\n x,\n y,\n width: isHorizontal ? axisLabelContainerBounds.width() : axisLabelContainerSize,\n height: isHorizontal ? axisLabelContainerSize : axisLabelContainerBounds.height(),\n pickable: false\n });\n bgRect.name = AXIS_ELEMENT_NAME.axisLabelBackground;\n bgRect.id = this._getNodeId('axis-label-background');\n labelContainer.insertBefore(bgRect, labelContainer.firstChild);\n }\n\n // 处理 align,进行整体的对齐操作\n if (isValid(this.attribute.label.containerAlign)) {\n let start;\n if (orient === 'left') {\n start = axisLabelContainerBounds.x2;\n } else if (orient === 'right') {\n start = axisLabelContainerBounds.x1;\n } else if (orient === 'top') {\n start = axisLabelContainerBounds.y2;\n } else if (orient === 'bottom') {\n start = axisLabelContainerBounds.y1;\n }\n\n alignAxisLabels(labelShapes, start, axisLabelContainerSize, orient, this.attribute.label.containerAlign);\n }\n }\n\n private _getAxisLabelLimitLength(limitSize: number, layerCount: number): number {\n const { label, title, line, tick } = this.attribute;\n const labelSpace = label.space ?? 4;\n let limitLength = limitSize;\n let titleHeight = 0;\n let titleSpacing = 0;\n const axisLineWidth = line?.visible ? line.style.lineWidth ?? 1 : 0;\n const tickLength = tick?.visible ? tick.length ?? 4 : 0;\n if (title?.visible && typeof title.text === 'string') {\n titleHeight = measureTextSize(title.text, title.textStyle).height;\n const padding = normalizePadding(title.padding);\n titleSpacing = title.space + padding[0] + padding[2];\n }\n if (limitLength) {\n limitLength = (limitLength - labelSpace - titleSpacing - titleHeight - axisLineWidth - tickLength) / layerCount;\n }\n return limitLength;\n }\n}\n\nmixin(LineAxis, LineAxisMixin);\n"]}
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.17.6";
1
+ export declare const version = "0.17.8-alpha.0";
2
2
  export * from './core/base';
3
3
  export * from './scrollbar';
4
4
  export * from './tag';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.17.6";
1
+ export const version = "0.17.8-alpha.0";
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,QAAQ,CAAC;AAEhC,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","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.17.6\";\n\nexport * from './core/base';\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';\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,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","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.17.8-alpha.0\";\n\nexport * from './core/base';\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';\n"]}
@@ -55,7 +55,7 @@ export class ScrollBar extends AbstractComponent {
55
55
  }), this.attribute.delayTime), this._onSliderPointerUp = e => {
56
56
  e.preventDefault();
57
57
  const {realTime: realTime = !0, range: preRange, limitRange: limitRange = [ 0, 1 ]} = this.attribute, preScrollRange = this.getScrollRange(), [currentPos, currentScrollValue] = this._computeScrollValue(e), range = [ preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue ];
58
- realTime || this._dispatchEvent("scroll", {
58
+ this._dispatchEvent("scrollUp", {
59
59
  pre: preRange,
60
60
  value: clampRange(range, limitRange[0], limitRange[1])
61
61
  }), "browser" === vglobal.env ? (vglobal.removeEventListener("pointermove", this._onSliderPointerMove, {
@@ -73,7 +73,7 @@ export class ScrollBar extends AbstractComponent {
73
73
  this._slider && ("horizontal" === direction ? this._slider.setAttribute("x", sliderPos[0], !0) : this._slider.setAttribute("y", sliderPos[0], !0),
74
74
  (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.autoRender) || null === (_b = this.stage) || void 0 === _b || _b.renderNextFrame());
75
75
  }
76
- this.attribute.range = currScrollRange, realTime && this._dispatchEvent("scroll", {
76
+ this.attribute.range = currScrollRange, realTime && this._dispatchEvent("scrollDrag", {
77
77
  pre: preRange,
78
78
  value: currScrollRange
79
79
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAWpD,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,sBAAsB,EAAE,CAAC;AAEzB,MAAM,OAAO,SAAU,SAAQ,iBAAgD;IAmC7E,YAAY,UAA+B,EAAE,OAA0B;QACrE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnChG,SAAI,GAAG,WAAW,CAAC;QAuOX,uBAAkB,GAAG,CAAC,CAAwB,EAAE,EAAE;;YAGxD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YAC3B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,SAAgC,CAAC;YAClF,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;YACpC,MAAM,CAAC,GAAG,EAA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ederatedPointerEvent, IGroup, IRect } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { vglobal } from '@visactor/vrender-core';\nimport { merge, normalizePadding, clamp, clampRange, debounce, throttle } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\n\nimport type { ScrollBarAttributes } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadScrollbarComponent } from './register';\n\ntype ComponentBounds = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n width: number;\n height: number;\n};\n\nconst delayMap = {\n debounce: debounce,\n throttle: throttle\n};\n\nloadScrollbarComponent();\n\nexport class ScrollBar extends AbstractComponent<Required<ScrollBarAttributes>> {\n name = 'scrollbar';\n\n static defaultAttributes = {\n direction: 'horizontal',\n round: true,\n sliderSize: 20,\n sliderStyle: {\n fill: 'rgba(0, 0, 0, .5)'\n },\n railStyle: {\n fill: 'rgba(0, 0, 0, .0)'\n },\n padding: 2,\n scrollRange: [0, 1],\n delayType: 'throttle',\n delayTime: 0,\n realTime: true\n };\n\n private _container!: IGroup;\n // 滚动条滑块\n private _slider!: IRect;\n // 滚动条滑轨\n private _rail!: IRect;\n // 滑块可渲染的区域包围盒\n private _sliderRenderBounds!: ComponentBounds | null;\n // 滑块滑动的范围\n private _sliderLimitRange!: [number, number] | null;\n // 保留滑块上一次的位置\n private _prePos!: number;\n // TODO: 临时方案\n private _viewPosition!: { x: number; y: number };\n private _sliderSize!: number;\n\n constructor(attributes: ScrollBarAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, ScrollBar.defaultAttributes, attributes));\n }\n\n setScrollRange(range: [number, number], render = true) {\n const {\n direction = 'horizontal',\n limitRange = [0, 1],\n range: preRange,\n realTime = true\n } = this.attribute as ScrollBarAttributes;\n\n const currScrollRange = clampRange(range, limitRange[0], limitRange[1]);\n if (render) {\n // 更新图形\n const sliderPos = this._getSliderPos(currScrollRange);\n if (this._slider) {\n if (direction === 'horizontal') {\n this._slider.setAttribute('x', sliderPos[0], true);\n } else {\n this._slider.setAttribute('y', sliderPos[0], true);\n }\n\n if (!this.stage?.autoRender) {\n this.stage?.renderNextFrame();\n }\n }\n }\n (this.attribute as ScrollBarAttributes).range = currScrollRange;\n // 发射 change 事件\n if (realTime) {\n this._dispatchEvent('scroll', {\n pre: preRange,\n value: currScrollRange\n });\n }\n }\n\n getScrollRange(): [number, number] {\n return (this.attribute as ScrollBarAttributes).range;\n }\n\n // public setLocation(point: PointLocationCfg) {\n // this.translateTo(point.x, point.y);\n // }\n\n // 绑定事件\n protected bindEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n const { delayType = 'throttle', delayTime = 0 } = this.attribute as ScrollBarAttributes;\n // TODO: wheel 事件支持\n if (this._rail) {\n this._rail.addEventListener(\n 'pointerdown',\n delayMap[delayType](this._onRailPointerDown, delayTime) as EventListener\n );\n }\n if (this._slider) {\n this._slider.addEventListener('pointerdown', this._onSliderPointerDown as EventListener);\n }\n }\n\n protected render() {\n this._reset();\n const {\n direction = 'horizontal',\n width,\n height,\n range,\n limitRange = [0, 1],\n // sliderSize = 20,\n // scrollValue = 0,\n // scrollRange = [0, 1],\n railStyle,\n sliderStyle,\n padding = 2\n } = this.attribute as ScrollBarAttributes;\n\n const group = this.createOrUpdateChild('scrollbar-container', {}, 'group') as IGroup;\n // 绘制轨道\n\n const rail = group.createOrUpdateChild(\n 'scrollbar-rail',\n {\n x: 0,\n y: 0,\n width,\n height,\n ...railStyle\n },\n 'rect'\n ) as IRect;\n this._rail = rail;\n\n // 滑块\n const sliderRenderBounds = this._getSliderRenderBounds();\n const sliderPos = this._getSliderPos(clampRange(range, limitRange[0], limitRange[1]));\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n // const sliderRangePos = this._getScrollRange();\n\n let sliderAttribute: IRectGraphicAttribute;\n if (direction === 'horizontal') {\n sliderAttribute = {\n x: sliderPos[0],\n y: sliderRenderBounds.y1,\n width: sliderSize,\n height: sliderRenderBounds.height\n };\n } else {\n sliderAttribute = {\n x: sliderRenderBounds.x1,\n y: sliderPos[0],\n width: sliderRenderBounds.width,\n height: sliderSize\n };\n }\n\n const slider = group.createOrUpdateChild(\n 'slider',\n {\n ...sliderAttribute,\n cornerRadius: this._getDefaultSliderCornerRadius(),\n ...sliderStyle,\n boundsPadding: normalizePadding(padding),\n pickMode: 'imprecise'\n },\n 'rect'\n ) as IRect;\n this._slider = slider;\n this._container = group;\n\n const containerAABBBounds = this._container.AABBBounds;\n this._viewPosition = {\n x: containerAABBBounds.x1,\n y: containerAABBBounds.y1\n };\n }\n\n // 获取滑块渲染的包围盒区域\n private _getSliderRenderBounds() {\n if (this._sliderRenderBounds) {\n return this._sliderRenderBounds;\n }\n const { width, height, padding = 2 } = this.attribute as ScrollBarAttributes;\n const [top, right, bottom, left] = normalizePadding(padding);\n const renderBounds = {\n x1: left,\n y1: top,\n x2: width - right,\n y2: height - bottom,\n width: Math.max(0, width - (left + right)),\n height: Math.max(0, height - (top + bottom))\n };\n this._sliderRenderBounds = renderBounds;\n return renderBounds;\n }\n\n // 获取默认的滑块圆角\n private _getDefaultSliderCornerRadius() {\n const { direction, round } = this.attribute as ScrollBarAttributes;\n\n if (round) {\n const { width, height } = this._getSliderRenderBounds();\n return direction === 'horizontal' ? height : width;\n }\n\n return 0;\n }\n\n // 计算滑块在轨道的位置\n private _getSliderPos(range: [number, number]) {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { width, height, x1, y1 } = this._getSliderRenderBounds();\n\n if (direction === 'horizontal') {\n return [width * range[0] + x1, width * range[1] + x1];\n }\n return [height * range[0] + y1, height * range[1] + y1];\n }\n\n private _getScrollRange() {\n if (this._sliderLimitRange) {\n return this._sliderLimitRange;\n }\n const { limitRange = [0, 1], direction } = this.attribute as ScrollBarAttributes;\n const [min, max] = clampRange(limitRange, 0, 1);\n const { width, height, x1, y1 } = this._getSliderRenderBounds();\n const sliderSize = this._sliderSize;\n\n return direction === 'horizontal'\n ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)\n : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);\n }\n\n private _onRailPointerDown = (e: FederatedPointerEvent) => {\n // 将事件坐标转换为实际的滑块位置\n // TODO: 这里有问题,应该拿 viewX viewY,同时 graphic 要提供接口获取它的 相对 view 的坐标\n const { viewX, viewY } = e;\n const { direction, width, height, range } = this.attribute as ScrollBarAttributes;\n const sliderSize = this._sliderSize;\n const [min, max] = this._getScrollRange();\n let currentScrollValue;\n if (direction === 'vertical') {\n const relativeY = viewY - this._viewPosition.y;\n const currentYPos = clamp(relativeY - sliderSize / 2, min, max);\n currentScrollValue = relativeY / height;\n this._slider.setAttribute('y', currentYPos, true);\n } else {\n const relativeX = viewX - this._viewPosition.x;\n const currentXPos = clamp(relativeX - sliderSize / 2, min, max);\n currentScrollValue = relativeX / width;\n this._slider.setAttribute('x', currentXPos, true);\n }\n\n this.setScrollRange(\n [currentScrollValue - (range[1] - range[0]) / 2, currentScrollValue + (range[1] - range[0]) / 2],\n false\n );\n\n if (!this.stage?.autoRender) {\n this.stage?.renderNextFrame();\n }\n };\n\n private _onSliderPointerDown = (e: FederatedPointerEvent) => {\n e.stopPropagation();\n const { direction } = this.attribute as ScrollBarAttributes;\n this._prePos = direction === 'horizontal' ? e.clientX : e.clientY;\n this._dispatchEvent('scrollDown', {\n pos: this._prePos,\n event: e\n });\n if (vglobal.env === 'browser') {\n vglobal.addEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n vglobal.addEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.addEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n this.stage.addEventListener('pointerup', this._onSliderPointerUp);\n this.stage.addEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _computeScrollValue = (e: any) => {\n const { direction } = this.attribute as ScrollBarAttributes;\n let currentScrollValue;\n let currentPos;\n let delta = 0;\n\n const { width, height } = this._getSliderRenderBounds();\n if (direction === 'vertical') {\n currentPos = e.clientY;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / height;\n } else {\n currentPos = e.clientX;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / width;\n }\n return [currentPos, currentScrollValue];\n };\n\n private _onSliderPointerMove = delayMap[this.attribute.delayType]((e: any) => {\n e.stopPropagation();\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n this.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);\n this._prePos = currentPos;\n }, this.attribute.delayTime);\n\n private _onSliderPointerUp = (e: any) => {\n e.preventDefault();\n const { realTime = true, range: preRange, limitRange = [0, 1] } = this.attribute as ScrollBarAttributes;\n // 发射 change 事件\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n const range: [number, number] = [preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue];\n if (!realTime) {\n this._dispatchEvent('scroll', {\n pre: preRange,\n value: clampRange(range, limitRange[0], limitRange[1])\n });\n }\n if (vglobal.env === 'browser') {\n vglobal.removeEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n vglobal.removeEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.removeEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n this.stage.removeEventListener('pointerup', this._onSliderPointerUp);\n this.stage.removeEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _reset() {\n this._sliderRenderBounds = null;\n this._sliderLimitRange = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO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CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,MAAM,EAAE,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;IAClF,CAAC;IAkGO,MAAM;QACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;;AAxUM,2BAAiB,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,EAAE;IACd,WAAW,EAAE;QACX,IAAI,EAAE,mBAAmB;KAC1B;IACD,SAAS,EAAE;QACT,IAAI,EAAE,mBAAmB;KAC1B;IACD,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACnB,SAAS,EAAE,UAAU;IACrB,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC","file":"scrollbar.js","sourcesContent":["/**\n * @description 滚动条组件\n */\nimport type { IRectGraphicAttribute, FederatedPointerEvent, IGroup, IRect } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { vglobal } from '@visactor/vrender-core';\nimport { merge, normalizePadding, clamp, clampRange, debounce, throttle } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\n\nimport type { ScrollBarAttributes } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadScrollbarComponent } from './register';\n\ntype ComponentBounds = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n width: number;\n height: number;\n};\n\nconst delayMap = {\n debounce: debounce,\n throttle: throttle\n};\n\nloadScrollbarComponent();\n\nexport class ScrollBar extends AbstractComponent<Required<ScrollBarAttributes>> {\n name = 'scrollbar';\n\n static defaultAttributes = {\n direction: 'horizontal',\n round: true,\n sliderSize: 20,\n sliderStyle: {\n fill: 'rgba(0, 0, 0, .5)'\n },\n railStyle: {\n fill: 'rgba(0, 0, 0, .0)'\n },\n padding: 2,\n scrollRange: [0, 1],\n delayType: 'throttle',\n delayTime: 0,\n realTime: true\n };\n\n private _container!: IGroup;\n // 滚动条滑块\n private _slider!: IRect;\n // 滚动条滑轨\n private _rail!: IRect;\n // 滑块可渲染的区域包围盒\n private _sliderRenderBounds!: ComponentBounds | null;\n // 滑块滑动的范围\n private _sliderLimitRange!: [number, number] | null;\n // 保留滑块上一次的位置\n private _prePos!: number;\n // TODO: 临时方案\n private _viewPosition!: { x: number; y: number };\n private _sliderSize!: number;\n\n constructor(attributes: ScrollBarAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, ScrollBar.defaultAttributes, attributes));\n }\n\n setScrollRange(range: [number, number], render = true) {\n const {\n direction = 'horizontal',\n limitRange = [0, 1],\n range: preRange,\n realTime = true\n } = this.attribute as ScrollBarAttributes;\n\n const currScrollRange = clampRange(range, limitRange[0], limitRange[1]);\n if (render) {\n // 更新图形\n const sliderPos = this._getSliderPos(currScrollRange);\n if (this._slider) {\n if (direction === 'horizontal') {\n this._slider.setAttribute('x', sliderPos[0], true);\n } else {\n this._slider.setAttribute('y', sliderPos[0], true);\n }\n\n if (!this.stage?.autoRender) {\n this.stage?.renderNextFrame();\n }\n }\n }\n (this.attribute as ScrollBarAttributes).range = currScrollRange;\n // 发射 change 事件\n if (realTime) {\n this._dispatchEvent('scrollDrag', {\n pre: preRange,\n value: currScrollRange\n });\n }\n }\n\n getScrollRange(): [number, number] {\n return (this.attribute as ScrollBarAttributes).range;\n }\n\n // public setLocation(point: PointLocationCfg) {\n // this.translateTo(point.x, point.y);\n // }\n\n // 绑定事件\n protected bindEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n const { delayType = 'throttle', delayTime = 0 } = this.attribute as ScrollBarAttributes;\n // TODO: wheel 事件支持\n if (this._rail) {\n this._rail.addEventListener(\n 'pointerdown',\n delayMap[delayType](this._onRailPointerDown, delayTime) as EventListener\n );\n }\n if (this._slider) {\n this._slider.addEventListener('pointerdown', this._onSliderPointerDown as EventListener);\n }\n }\n\n protected render() {\n this._reset();\n const {\n direction = 'horizontal',\n width,\n height,\n range,\n limitRange = [0, 1],\n // sliderSize = 20,\n // scrollValue = 0,\n // scrollRange = [0, 1],\n railStyle,\n sliderStyle,\n padding = 2\n } = this.attribute as ScrollBarAttributes;\n\n const group = this.createOrUpdateChild('scrollbar-container', {}, 'group') as IGroup;\n // 绘制轨道\n\n const rail = group.createOrUpdateChild(\n 'scrollbar-rail',\n {\n x: 0,\n y: 0,\n width,\n height,\n ...railStyle\n },\n 'rect'\n ) as IRect;\n this._rail = rail;\n\n // 滑块\n const sliderRenderBounds = this._getSliderRenderBounds();\n const sliderPos = this._getSliderPos(clampRange(range, limitRange[0], limitRange[1]));\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n // const sliderRangePos = this._getScrollRange();\n\n let sliderAttribute: IRectGraphicAttribute;\n if (direction === 'horizontal') {\n sliderAttribute = {\n x: sliderPos[0],\n y: sliderRenderBounds.y1,\n width: sliderSize,\n height: sliderRenderBounds.height\n };\n } else {\n sliderAttribute = {\n x: sliderRenderBounds.x1,\n y: sliderPos[0],\n width: sliderRenderBounds.width,\n height: sliderSize\n };\n }\n\n const slider = group.createOrUpdateChild(\n 'slider',\n {\n ...sliderAttribute,\n cornerRadius: this._getDefaultSliderCornerRadius(),\n ...sliderStyle,\n boundsPadding: normalizePadding(padding),\n pickMode: 'imprecise'\n },\n 'rect'\n ) as IRect;\n this._slider = slider;\n this._container = group;\n\n const containerAABBBounds = this._container.AABBBounds;\n this._viewPosition = {\n x: containerAABBBounds.x1,\n y: containerAABBBounds.y1\n };\n }\n\n // 获取滑块渲染的包围盒区域\n private _getSliderRenderBounds() {\n if (this._sliderRenderBounds) {\n return this._sliderRenderBounds;\n }\n const { width, height, padding = 2 } = this.attribute as ScrollBarAttributes;\n const [top, right, bottom, left] = normalizePadding(padding);\n const renderBounds = {\n x1: left,\n y1: top,\n x2: width - right,\n y2: height - bottom,\n width: Math.max(0, width - (left + right)),\n height: Math.max(0, height - (top + bottom))\n };\n this._sliderRenderBounds = renderBounds;\n return renderBounds;\n }\n\n // 获取默认的滑块圆角\n private _getDefaultSliderCornerRadius() {\n const { direction, round } = this.attribute as ScrollBarAttributes;\n\n if (round) {\n const { width, height } = this._getSliderRenderBounds();\n return direction === 'horizontal' ? height : width;\n }\n\n return 0;\n }\n\n // 计算滑块在轨道的位置\n private _getSliderPos(range: [number, number]) {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { width, height, x1, y1 } = this._getSliderRenderBounds();\n\n if (direction === 'horizontal') {\n return [width * range[0] + x1, width * range[1] + x1];\n }\n return [height * range[0] + y1, height * range[1] + y1];\n }\n\n private _getScrollRange() {\n if (this._sliderLimitRange) {\n return this._sliderLimitRange;\n }\n const { limitRange = [0, 1], direction } = this.attribute as ScrollBarAttributes;\n const [min, max] = clampRange(limitRange, 0, 1);\n const { width, height, x1, y1 } = this._getSliderRenderBounds();\n const sliderSize = this._sliderSize;\n\n return direction === 'horizontal'\n ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)\n : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);\n }\n\n private _onRailPointerDown = (e: FederatedPointerEvent) => {\n // 将事件坐标转换为实际的滑块位置\n // TODO: 这里有问题,应该拿 viewX viewY,同时 graphic 要提供接口获取它的 相对 view 的坐标\n const { viewX, viewY } = e;\n const { direction, width, height, range } = this.attribute as ScrollBarAttributes;\n const sliderSize = this._sliderSize;\n const [min, max] = this._getScrollRange();\n let currentScrollValue;\n if (direction === 'vertical') {\n const relativeY = viewY - this._viewPosition.y;\n const currentYPos = clamp(relativeY - sliderSize / 2, min, max);\n currentScrollValue = relativeY / height;\n this._slider.setAttribute('y', currentYPos, true);\n } else {\n const relativeX = viewX - this._viewPosition.x;\n const currentXPos = clamp(relativeX - sliderSize / 2, min, max);\n currentScrollValue = relativeX / width;\n this._slider.setAttribute('x', currentXPos, true);\n }\n\n this.setScrollRange(\n [currentScrollValue - (range[1] - range[0]) / 2, currentScrollValue + (range[1] - range[0]) / 2],\n false\n );\n\n if (!this.stage?.autoRender) {\n this.stage?.renderNextFrame();\n }\n };\n\n private _onSliderPointerDown = (e: FederatedPointerEvent) => {\n e.stopPropagation();\n const { direction } = this.attribute as ScrollBarAttributes;\n this._prePos = direction === 'horizontal' ? e.clientX : e.clientY;\n this._dispatchEvent('scrollDown', {\n pos: this._prePos,\n event: e\n });\n if (vglobal.env === 'browser') {\n vglobal.addEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n vglobal.addEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.addEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n this.stage.addEventListener('pointerup', this._onSliderPointerUp);\n this.stage.addEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _computeScrollValue = (e: any) => {\n const { direction } = this.attribute as ScrollBarAttributes;\n let currentScrollValue;\n let currentPos;\n let delta = 0;\n\n const { width, height } = this._getSliderRenderBounds();\n if (direction === 'vertical') {\n currentPos = e.clientY;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / height;\n } else {\n currentPos = e.clientX;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / width;\n }\n return [currentPos, currentScrollValue];\n };\n\n private _onSliderPointerMove = delayMap[this.attribute.delayType]((e: any) => {\n e.stopPropagation();\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n this.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);\n this._prePos = currentPos;\n }, this.attribute.delayTime);\n\n private _onSliderPointerUp = (e: any) => {\n e.preventDefault();\n const { realTime = true, range: preRange, limitRange = [0, 1] } = this.attribute as ScrollBarAttributes;\n // 发射 change 事件\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n const range: [number, number] = [preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue];\n this._dispatchEvent('scrollUp', {\n pre: preRange,\n value: clampRange(range, limitRange[0], limitRange[1])\n });\n if (vglobal.env === 'browser') {\n vglobal.removeEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n vglobal.removeEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.removeEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n this.stage.removeEventListener('pointerup', this._onSliderPointerUp);\n this.stage.removeEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _reset() {\n this._sliderRenderBounds = null;\n this._sliderLimitRange = null;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-components",
3
- "version": "0.17.6",
3
+ "version": "0.17.8-alpha.0",
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.17.6",
16
- "@visactor/vrender-kits": "0.17.6",
15
+ "@visactor/vrender-core": "0.17.8-alpha.0",
16
+ "@visactor/vrender-kits": "0.17.8-alpha.0",
17
17
  "@visactor/vutils": "~0.17.0",
18
18
  "@visactor/vscale": "~0.17.0"
19
19
  },
@@ -28,9 +28,9 @@
28
28
  "eslint": "~8.18.0",
29
29
  "vite": "3.2.6",
30
30
  "typescript": "4.9.5",
31
- "@internal/ts-config": "0.0.1",
32
31
  "@internal/bundler": "0.0.1",
33
- "@internal/eslint-config": "0.0.1"
32
+ "@internal/eslint-config": "0.0.1",
33
+ "@internal/ts-config": "0.0.1"
34
34
  },
35
35
  "keywords": [
36
36
  "VisActor",