@visactor/vchart 1.12.4 → 1.12.5
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/build/es5/index.js +1 -1
- package/build/index.js +196 -453
- package/build/index.min.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/base/base-chart-transformer.js +4 -4
- package/cjs/chart/base/base-chart-transformer.js.map +1 -1
- package/cjs/compile/mark/compilable-mark.d.ts +0 -3
- package/cjs/compile/mark/compilable-mark.js +2 -9
- package/cjs/compile/mark/compilable-mark.js.map +1 -1
- package/cjs/compile/mark/interface.d.ts +0 -2
- package/cjs/compile/mark/interface.js.map +1 -1
- package/cjs/component/axis/cartesian/axis.d.ts +1 -0
- package/cjs/component/axis/cartesian/axis.js +28 -1
- package/cjs/component/axis/cartesian/axis.js.map +1 -1
- package/cjs/component/axis/polar/axis.js +3 -17
- package/cjs/component/axis/polar/axis.js.map +1 -1
- package/cjs/component/axis/polar/util/common.js +1 -1
- package/cjs/component/axis/polar/util/common.js.map +1 -1
- package/cjs/component/brush/brush.js +2 -8
- package/cjs/component/brush/brush.js.map +1 -1
- package/cjs/component/crosshair/cartesian.js +2 -18
- package/cjs/component/crosshair/cartesian.js.map +1 -1
- package/cjs/component/crosshair/polar.js +2 -18
- package/cjs/component/crosshair/polar.js.map +1 -1
- package/cjs/component/custom-mark/custom-mark.d.ts +1 -3
- package/cjs/component/custom-mark/custom-mark.js +2 -16
- package/cjs/component/custom-mark/custom-mark.js.map +1 -1
- package/cjs/component/data-zoom/data-zoom/data-zoom.d.ts +0 -3
- package/cjs/component/data-zoom/data-zoom/data-zoom.js +0 -19
- package/cjs/component/data-zoom/data-zoom/data-zoom.js.map +1 -1
- package/cjs/component/data-zoom/scroll-bar/scroll-bar.d.ts +0 -3
- package/cjs/component/data-zoom/scroll-bar/scroll-bar.js +0 -19
- package/cjs/component/data-zoom/scroll-bar/scroll-bar.js.map +1 -1
- package/cjs/component/indicator/indicator.js +2 -18
- package/cjs/component/indicator/indicator.js.map +1 -1
- package/cjs/component/interface/common.d.ts +1 -1
- package/cjs/component/interface/common.js.map +1 -1
- package/cjs/component/label/interface.d.ts +2 -2
- package/cjs/component/label/interface.js.map +1 -1
- package/cjs/component/legend/continuous/legend.js +6 -18
- package/cjs/component/legend/continuous/legend.js.map +1 -1
- package/cjs/component/legend/discrete/legend.js +1 -17
- package/cjs/component/legend/discrete/legend.js.map +1 -1
- package/cjs/component/map-label/component.js +3 -8
- package/cjs/component/map-label/component.js.map +1 -1
- package/cjs/component/marker/base-marker.js +2 -18
- package/cjs/component/marker/base-marker.js.map +1 -1
- package/cjs/component/player/player.d.ts +1 -3
- package/cjs/component/player/player.js +0 -9
- package/cjs/component/player/player.js.map +1 -1
- package/cjs/component/title/title.js +2 -18
- package/cjs/component/title/title.js.map +1 -1
- package/cjs/component/tooltip/tooltip.d.ts +1 -3
- package/cjs/component/tooltip/tooltip.js +0 -19
- package/cjs/component/tooltip/tooltip.js.map +1 -1
- package/cjs/component/util.d.ts +3 -0
- package/cjs/component/util.js +16 -1
- package/cjs/component/util.js.map +1 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/event/event-dispatcher.js +1 -9
- package/cjs/event/event-dispatcher.js.map +1 -1
- package/cjs/series/base/base-series-transformer.js +7 -4
- package/cjs/series/base/base-series-transformer.js.map +1 -1
- package/cjs/series/base/base-series.js +3 -5
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/dot/dot.d.ts +0 -1
- package/cjs/series/dot/dot.js +0 -5
- package/cjs/series/dot/dot.js.map +1 -1
- package/cjs/series/polar/animation.d.ts +1 -0
- package/cjs/series/polar/animation.js +15 -17
- package/cjs/series/polar/animation.js.map +1 -1
- package/cjs/series/polar/polar.js +9 -2
- package/cjs/series/polar/polar.js.map +1 -1
- package/cjs/series/radar/radar.js +1 -0
- package/cjs/series/radar/radar.js.map +1 -1
- package/cjs/series/word-cloud/base.js +21 -10
- package/cjs/series/word-cloud/base.js.map +1 -1
- package/cjs/theme/builtin/common/mark.js +2 -0
- package/cjs/theme/builtin/common/mark.js.map +1 -1
- package/cjs/typings/spec/common.d.ts +1 -0
- package/cjs/typings/spec/common.js.map +1 -1
- package/cjs/util/math.d.ts +1 -0
- package/cjs/util/math.js +7 -2
- package/cjs/util/math.js.map +1 -1
- package/esm/chart/base/base-chart-transformer.js +5 -3
- package/esm/chart/base/base-chart-transformer.js.map +1 -1
- package/esm/compile/mark/compilable-mark.d.ts +0 -3
- package/esm/compile/mark/compilable-mark.js +2 -9
- package/esm/compile/mark/compilable-mark.js.map +1 -1
- package/esm/compile/mark/interface.d.ts +0 -2
- package/esm/compile/mark/interface.js.map +1 -1
- package/esm/component/axis/cartesian/axis.d.ts +1 -0
- package/esm/component/axis/cartesian/axis.js +28 -1
- package/esm/component/axis/cartesian/axis.js.map +1 -1
- package/esm/component/axis/polar/axis.js +3 -16
- package/esm/component/axis/polar/axis.js.map +1 -1
- package/esm/component/axis/polar/util/common.js +2 -2
- package/esm/component/axis/polar/util/common.js.map +1 -1
- package/esm/component/brush/brush.js +4 -8
- package/esm/component/brush/brush.js.map +1 -1
- package/esm/component/crosshair/cartesian.js +4 -18
- package/esm/component/crosshair/cartesian.js.map +1 -1
- package/esm/component/crosshair/polar.js +4 -18
- package/esm/component/crosshair/polar.js.map +1 -1
- package/esm/component/custom-mark/custom-mark.d.ts +1 -3
- package/esm/component/custom-mark/custom-mark.js +3 -17
- package/esm/component/custom-mark/custom-mark.js.map +1 -1
- package/esm/component/data-zoom/data-zoom/data-zoom.d.ts +0 -3
- package/esm/component/data-zoom/data-zoom/data-zoom.js +1 -20
- package/esm/component/data-zoom/data-zoom/data-zoom.js.map +1 -1
- package/esm/component/data-zoom/scroll-bar/scroll-bar.d.ts +0 -3
- package/esm/component/data-zoom/scroll-bar/scroll-bar.js +1 -20
- package/esm/component/data-zoom/scroll-bar/scroll-bar.js.map +1 -1
- package/esm/component/indicator/indicator.js +4 -18
- package/esm/component/indicator/indicator.js.map +1 -1
- package/esm/component/interface/common.d.ts +1 -1
- package/esm/component/interface/common.js.map +1 -1
- package/esm/component/label/interface.d.ts +2 -2
- package/esm/component/label/interface.js.map +1 -1
- package/esm/component/legend/continuous/legend.js +7 -18
- package/esm/component/legend/continuous/legend.js.map +1 -1
- package/esm/component/legend/discrete/legend.js +3 -19
- package/esm/component/legend/discrete/legend.js.map +1 -1
- package/esm/component/map-label/component.js +3 -7
- package/esm/component/map-label/component.js.map +1 -1
- package/esm/component/marker/base-marker.js +4 -18
- package/esm/component/marker/base-marker.js.map +1 -1
- package/esm/component/player/player.d.ts +1 -3
- package/esm/component/player/player.js +1 -10
- package/esm/component/player/player.js.map +1 -1
- package/esm/component/title/title.js +4 -18
- package/esm/component/title/title.js.map +1 -1
- package/esm/component/tooltip/tooltip.d.ts +1 -3
- package/esm/component/tooltip/tooltip.js +1 -20
- package/esm/component/tooltip/tooltip.js.map +1 -1
- package/esm/component/util.d.ts +3 -0
- package/esm/component/util.js +14 -1
- package/esm/component/util.js.map +1 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/event/event-dispatcher.js +1 -9
- package/esm/event/event-dispatcher.js.map +1 -1
- package/esm/series/base/base-series-transformer.js +7 -4
- package/esm/series/base/base-series-transformer.js.map +1 -1
- package/esm/series/base/base-series.js +3 -5
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/dot/dot.d.ts +0 -1
- package/esm/series/dot/dot.js +0 -5
- package/esm/series/dot/dot.js.map +1 -1
- package/esm/series/polar/animation.d.ts +1 -0
- package/esm/series/polar/animation.js +15 -16
- package/esm/series/polar/animation.js.map +1 -1
- package/esm/series/polar/polar.js +9 -1
- package/esm/series/polar/polar.js.map +1 -1
- package/esm/series/radar/radar.js +1 -0
- package/esm/series/radar/radar.js.map +1 -1
- package/esm/series/word-cloud/base.js +20 -10
- package/esm/series/word-cloud/base.js.map +1 -1
- package/esm/theme/builtin/common/mark.js +2 -0
- package/esm/theme/builtin/common/mark.js.map +1 -1
- package/esm/typings/spec/common.d.ts +1 -0
- package/esm/typings/spec/common.js.map +1 -1
- package/esm/util/math.d.ts +1 -0
- package/esm/util/math.js +4 -0
- package/esm/util/math.js.map +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/data-zoom/scroll-bar/scroll-bar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAGxE,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIhD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,OAAO,SAAqD,SAAQ,uBAA0B;IAelG,MAAM,CAAC,WAAW,CAAC,SAAc;QAC/B,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE;YACnB,OAAO,SAAS,CAAC;SAClB;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACtB,OAAO;gBACL;oB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,OAAO,GAAG,YAAY,CAAC;SAC9B;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,EAAE;YACzB,KAAK,CAAC,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAqC,CAAC;SACtF;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,EAAE;YAC3B,KAAK,CAAC,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAqC,CAAC;SAC1F;QACD,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;IAES,8BAA8B;QACtC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAwB,CAAC;IAClD,CAAC;;AAxMM,cAAI,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAInC,iBAAO,GAAG,WAAW,CAAC;AAuM/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC,CAAC","file":"scroll-bar.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\nimport { isArray, isBoolean, isEmpty, isFunction, isNil, isNumber, isValid } from '@visactor/vutils';\nimport type { IComponentOption } from '../../interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../../interface/type';\nimport { DataFilterBaseComponent } from '../data-filter-base-component';\nimport type { ScrollBarAttributes } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { ScrollBar as ScrollBarComponent } from '@visactor/vrender-components';\nimport { transformToGraphic } from '../../../util/style';\nimport type { IRectGraphicAttribute, INode, IGroup, IGraphic } from '@visactor/vrender-core';\nimport { LayoutLevel, LayoutZIndex } from '../../../constant/layout';\nimport { ChartEvent } from '../../../constant/event';\nimport { SCROLL_BAR_DEFAULT_SIZE } from '../../../constant/scroll-bar';\nimport type { IScrollBarSpec } from './interface';\nimport { IFilterMode } from '../interface';\nimport { Factory } from '../../../core/factory';\nimport type { IZoomable } from '../../../interaction/zoom';\nimport type { ILayoutType } from '../../../typings/layout';\nimport type { IModelSpecInfo } from '../../../model/interface';\nimport { isClose } from '../../../util';\n\nexport class ScrollBar<T extends IScrollBarSpec = IScrollBarSpec> extends DataFilterBaseComponent<T> {\n static type = ComponentTypeEnum.scrollBar;\n type = ComponentTypeEnum.scrollBar;\n name: string = ComponentTypeEnum.scrollBar;\n\n static specKey = 'scrollBar';\n specKey = 'scrollBar';\n\n layoutZIndex: number = LayoutZIndex.DataZoom;\n layoutLevel: number = LayoutLevel.DataZoom;\n layoutType: ILayoutType = 'region-relative';\n\n // datazoom组件\n protected _component!: ScrollBarComponent;\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n const compSpec = chartSpec[this.specKey];\n if (isNil(compSpec)) {\n return undefined;\n }\n if (!isArray(compSpec)) {\n return [\n {\n spec: compSpec,\n specPath: [this.specKey],\n specInfoPath: ['component', this.specKey, 0],\n type: ComponentTypeEnum.scrollBar\n }\n ];\n }\n const specInfos: IModelSpecInfo[] = [];\n compSpec.forEach((s, i: number) => {\n specInfos.push({\n spec: s,\n specPath: [this.specKey, i],\n specInfoPath: ['component', this.specKey, i],\n type: ComponentTypeEnum.scrollBar\n });\n });\n return specInfos;\n }\n\n constructor(spec: T, options: IComponentOption) {\n super(spec as any, options);\n this._filterMode = spec.filterMode ?? 'axis';\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n // roam兼容逻辑\n if (isBoolean((this._spec as any).roam)) {\n this._zoomAttr.enable = false; // 对于之前的逻辑而言,只要配置了roam,zoom始终不打开\n this._dragAttr.enable = (this._spec as any).roam;\n this._scrollAttr.enable = (this._spec as any).roam;\n }\n if (this._zoomAttr.enable || this._dragAttr.enable || this._scrollAttr.enable) {\n (this as unknown as IZoomable).initZoomable(this.event, this._option.mode);\n }\n }\n\n /** LifeCycle API**/\n onLayoutEnd(ctx: any): void {\n this._updateScaleRange();\n this.effect.onZoomChange?.();\n super.onLayoutEnd(ctx);\n }\n\n protected _updateScaleRange() {\n if (this._component) {\n this._component.setAttributes({\n x: this.getLayoutStartPoint().x,\n y: this.getLayoutStartPoint().y,\n width: this.getLayoutRect().width,\n height: this.getLayoutRect().height\n });\n }\n }\n\n protected _computeWidth(): number {\n if (isNumber(this._spec.width)) {\n return this._spec.width;\n }\n\n if (this._isHorizontal) {\n return this.getLayoutRect().width;\n }\n // default value\n return SCROLL_BAR_DEFAULT_SIZE;\n }\n\n protected _computeHeight(): number {\n if (isNumber(this._spec.height)) {\n return this._spec.height;\n }\n\n // default value\n if (!this._isHorizontal) {\n return this.getLayoutRect().height;\n }\n\n return SCROLL_BAR_DEFAULT_SIZE;\n }\n\n private _getAttrs() {\n return {\n zIndex: this.layoutZIndex,\n x: this.getLayoutStartPoint().x,\n y: this.getLayoutStartPoint().y,\n width: this.getLayoutRect().width,\n height: this.getLayoutRect().height,\n range: [this._start, this._end],\n direction: this._isHorizontal ? 'horizontal' : 'vertical',\n delayType: this._spec?.delayType,\n delayTime: isValid(this._spec?.delayType) ? this._spec?.delayTime ?? 30 : 0,\n realTime: this._spec?.realTime ?? true,\n ...this._getComponentAttrs()\n } as ScrollBarAttributes;\n }\n\n protected _createOrUpdateComponent() {\n const attrs = this._getAttrs();\n if (this._component) {\n this._component.setAttributes(attrs);\n } else {\n const container = this.getContainer();\n this._component = new ScrollBarComponent(attrs);\n // 绑定事件,防抖,防止频繁触发\n this._component.addEventListener('scrollDrag', (e: any) => {\n const value = e.detail.value;\n this._handleChange(value[0], value[1]);\n });\n container.add(this._component as unknown as INode);\n }\n }\n\n protected _handleChange(start: number, end: number, updateComponent?: boolean) {\n super._handleChange(start, end, updateComponent);\n // filter out scroll event with same scroll value\n const isSameScrollValue = isClose(this._start, start) && isClose(this._end, end);\n if (this._shouldChange && !isSameScrollValue) {\n if (updateComponent && this._component) {\n this._component.setAttribute('range', [start, end]);\n }\n\n this._start = start;\n this._end = end;\n const startValue = this._statePointToData(start);\n const endValue = this._statePointToData(end);\n const hasChange = isFunction(this._spec.updateDataAfterChange)\n ? this._spec.updateDataAfterChange(start, end, startValue, endValue)\n : this._handleStateChange(this._statePointToData(start), this._statePointToData(end));\n if (hasChange) {\n this.event.emit(ChartEvent.scrollBarChange, {\n model: this,\n value: {\n filterData: this._filterMode !== 'axis',\n start: this._start,\n end: this._end,\n startValue: this._startValue,\n endValue: this._endValue,\n newDomain: this._newDomain\n }\n });\n }\n }\n }\n\n protected _handleDataCollectionChange() {\n // do nothing\n }\n\n protected _initCommonEvent() {\n super._initCommonEvent();\n if (this._component) {\n this._component.on('scrollDrag', (e: any) => {\n const value = e.detail.value;\n this._handleChange(value[0], value[1]);\n });\n }\n }\n\n protected _getComponentAttrs() {\n const { rail, slider, innerPadding } = this._spec;\n const attrs: Partial<ScrollBarAttributes> = {};\n\n if (!isNil(innerPadding)) {\n attrs.padding = innerPadding;\n }\n\n if (!isEmpty(rail?.style)) {\n attrs.railStyle = transformToGraphic(rail.style) as unknown as IRectGraphicAttribute;\n }\n if (!isEmpty(slider?.style)) {\n attrs.sliderStyle = transformToGraphic(slider.style) as unknown as IRectGraphicAttribute;\n }\n attrs.disableTriggerEvent = this._option.disableTriggerEvent;\n return attrs;\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._component] as unknown as IGroup[];\n }\n}\n\nexport const registerScrollBar = () => {\n Factory.registerComponent(ScrollBar.type, ScrollBar);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/data-zoom/scroll-bar/scroll-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG5F,OAAO,EAAE,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AK,CAAC,EAAE;YACzB,KAAK,CAAC,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAqC,CAAC;SACtF;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,EAAE;YAC3B,KAAK,CAAC,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAqC,CAAC;SAC1F;QACD,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;IAES,8BAA8B;QACtC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAwB,CAAC;IAClD,CAAC;;AA7KM,cAAI,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAInC,iBAAO,GAAG,WAAW,CAAC;AA4K/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC,CAAC","file":"scroll-bar.js","sourcesContent":["import { isBoolean, isEmpty, isFunction, isNil, isNumber, isValid } from '@visactor/vutils';\nimport type { IComponentOption } from '../../interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../../interface/type';\nimport { DataFilterBaseComponent } from '../data-filter-base-component';\nimport type { ScrollBarAttributes } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { ScrollBar as ScrollBarComponent } from '@visactor/vrender-components';\nimport { transformToGraphic } from '../../../util/style';\nimport type { IRectGraphicAttribute, INode, IGroup, IGraphic } from '@visactor/vrender-core';\nimport { LayoutLevel, LayoutZIndex } from '../../../constant/layout';\nimport { ChartEvent } from '../../../constant/event';\nimport { SCROLL_BAR_DEFAULT_SIZE } from '../../../constant/scroll-bar';\nimport type { IScrollBarSpec } from './interface';\nimport { Factory } from '../../../core/factory';\nimport type { IZoomable } from '../../../interaction/zoom';\nimport type { ILayoutType } from '../../../typings/layout';\nimport { isClose } from '../../../util';\n\nexport class ScrollBar<T extends IScrollBarSpec = IScrollBarSpec> extends DataFilterBaseComponent<T> {\n static type = ComponentTypeEnum.scrollBar;\n type = ComponentTypeEnum.scrollBar;\n name: string = ComponentTypeEnum.scrollBar;\n\n static specKey = 'scrollBar';\n specKey = 'scrollBar';\n\n layoutZIndex: number = LayoutZIndex.DataZoom;\n layoutLevel: number = LayoutLevel.DataZoom;\n layoutType: ILayoutType = 'region-relative';\n\n // datazoom组件\n protected _component!: ScrollBarComponent;\n\n constructor(spec: T, options: IComponentOption) {\n super(spec as any, options);\n this._filterMode = spec.filterMode ?? 'axis';\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n // roam兼容逻辑\n if (isBoolean((this._spec as any).roam)) {\n this._zoomAttr.enable = false; // 对于之前的逻辑而言,只要配置了roam,zoom始终不打开\n this._dragAttr.enable = (this._spec as any).roam;\n this._scrollAttr.enable = (this._spec as any).roam;\n }\n if (this._zoomAttr.enable || this._dragAttr.enable || this._scrollAttr.enable) {\n (this as unknown as IZoomable).initZoomable(this.event, this._option.mode);\n }\n }\n\n /** LifeCycle API**/\n onLayoutEnd(ctx: any): void {\n this._updateScaleRange();\n this.effect.onZoomChange?.();\n super.onLayoutEnd(ctx);\n }\n\n protected _updateScaleRange() {\n if (this._component) {\n this._component.setAttributes({\n x: this.getLayoutStartPoint().x,\n y: this.getLayoutStartPoint().y,\n width: this.getLayoutRect().width,\n height: this.getLayoutRect().height\n });\n }\n }\n\n protected _computeWidth(): number {\n if (isNumber(this._spec.width)) {\n return this._spec.width;\n }\n\n if (this._isHorizontal) {\n return this.getLayoutRect().width;\n }\n // default value\n return SCROLL_BAR_DEFAULT_SIZE;\n }\n\n protected _computeHeight(): number {\n if (isNumber(this._spec.height)) {\n return this._spec.height;\n }\n\n // default value\n if (!this._isHorizontal) {\n return this.getLayoutRect().height;\n }\n\n return SCROLL_BAR_DEFAULT_SIZE;\n }\n\n private _getAttrs() {\n return {\n zIndex: this.layoutZIndex,\n x: this.getLayoutStartPoint().x,\n y: this.getLayoutStartPoint().y,\n width: this.getLayoutRect().width,\n height: this.getLayoutRect().height,\n range: [this._start, this._end],\n direction: this._isHorizontal ? 'horizontal' : 'vertical',\n delayType: this._spec?.delayType,\n delayTime: isValid(this._spec?.delayType) ? this._spec?.delayTime ?? 30 : 0,\n realTime: this._spec?.realTime ?? true,\n ...this._getComponentAttrs()\n } as ScrollBarAttributes;\n }\n\n protected _createOrUpdateComponent() {\n const attrs = this._getAttrs();\n if (this._component) {\n this._component.setAttributes(attrs);\n } else {\n const container = this.getContainer();\n this._component = new ScrollBarComponent(attrs);\n // 绑定事件,防抖,防止频繁触发\n this._component.addEventListener('scrollDrag', (e: any) => {\n const value = e.detail.value;\n this._handleChange(value[0], value[1]);\n });\n container.add(this._component as unknown as INode);\n }\n }\n\n protected _handleChange(start: number, end: number, updateComponent?: boolean) {\n super._handleChange(start, end, updateComponent);\n // filter out scroll event with same scroll value\n const isSameScrollValue = isClose(this._start, start) && isClose(this._end, end);\n if (this._shouldChange && !isSameScrollValue) {\n if (updateComponent && this._component) {\n this._component.setAttribute('range', [start, end]);\n }\n\n this._start = start;\n this._end = end;\n const startValue = this._statePointToData(start);\n const endValue = this._statePointToData(end);\n const hasChange = isFunction(this._spec.updateDataAfterChange)\n ? this._spec.updateDataAfterChange(start, end, startValue, endValue)\n : this._handleStateChange(this._statePointToData(start), this._statePointToData(end));\n if (hasChange) {\n this.event.emit(ChartEvent.scrollBarChange, {\n model: this,\n value: {\n filterData: this._filterMode !== 'axis',\n start: this._start,\n end: this._end,\n startValue: this._startValue,\n endValue: this._endValue,\n newDomain: this._newDomain\n }\n });\n }\n }\n }\n\n protected _handleDataCollectionChange() {\n // do nothing\n }\n\n protected _initCommonEvent() {\n super._initCommonEvent();\n if (this._component) {\n this._component.on('scrollDrag', (e: any) => {\n const value = e.detail.value;\n this._handleChange(value[0], value[1]);\n });\n }\n }\n\n protected _getComponentAttrs() {\n const { rail, slider, innerPadding } = this._spec;\n const attrs: Partial<ScrollBarAttributes> = {};\n\n if (!isNil(innerPadding)) {\n attrs.padding = innerPadding;\n }\n\n if (!isEmpty(rail?.style)) {\n attrs.railStyle = transformToGraphic(rail.style) as unknown as IRectGraphicAttribute;\n }\n if (!isEmpty(slider?.style)) {\n attrs.sliderStyle = transformToGraphic(slider.style) as unknown as IRectGraphicAttribute;\n }\n attrs.disableTriggerEvent = this._option.disableTriggerEvent;\n return attrs;\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._component] as unknown as IGroup[];\n }\n}\n\nexport const registerScrollBar = () => {\n Factory.registerComponent(ScrollBar.type, ScrollBar);\n};\n"]}
|
|
@@ -22,7 +22,7 @@ import { transformIndicatorStyle } from "../../util/style";
|
|
|
22
22
|
|
|
23
23
|
import { getActualNumValue } from "../../util/space";
|
|
24
24
|
|
|
25
|
-
import { isEqual, isValid, isFunction, array,
|
|
25
|
+
import { isEqual, isValid, isFunction, array, pickWithout } from "@visactor/vutils";
|
|
26
26
|
|
|
27
27
|
import { indicatorMapper } from "./util";
|
|
28
28
|
|
|
@@ -34,6 +34,8 @@ import { Indicator as IndicatorComponents } from "@visactor/vrender-components";
|
|
|
34
34
|
|
|
35
35
|
import { Factory } from "../../core/factory";
|
|
36
36
|
|
|
37
|
+
import { getSpecInfo } from "../util";
|
|
38
|
+
|
|
37
39
|
export class Indicator extends BaseComponent {
|
|
38
40
|
constructor() {
|
|
39
41
|
super(...arguments), this.type = ComponentTypeEnum.indicator, this.name = ComponentTypeEnum.indicator,
|
|
@@ -41,23 +43,7 @@ export class Indicator extends BaseComponent {
|
|
|
41
43
|
this.layoutLevel = LayoutLevel.Indicator, this._gap = 0, this._activeDatum = null;
|
|
42
44
|
}
|
|
43
45
|
static getSpecInfo(chartSpec) {
|
|
44
|
-
|
|
45
|
-
const indicatorSpec = chartSpec[this.specKey];
|
|
46
|
-
if (!isArray(indicatorSpec)) return !1 === indicatorSpec.visible ? [] : [ {
|
|
47
|
-
spec: indicatorSpec,
|
|
48
|
-
specPath: [ this.specKey ],
|
|
49
|
-
specInfoPath: [ "component", this.specKey, 0 ],
|
|
50
|
-
type: ComponentTypeEnum.indicator
|
|
51
|
-
} ];
|
|
52
|
-
const specInfos = [];
|
|
53
|
-
return indicatorSpec.forEach(((s, i) => {
|
|
54
|
-
s && !1 !== s.visible && specInfos.push({
|
|
55
|
-
spec: s,
|
|
56
|
-
specPath: [ this.specKey, i ],
|
|
57
|
-
specInfoPath: [ "component", this.specKey, i ],
|
|
58
|
-
type: ComponentTypeEnum.indicator
|
|
59
|
-
});
|
|
60
|
-
})), specInfos;
|
|
46
|
+
return getSpecInfo(chartSpec, this.specKey, this.type, (s => s && !1 !== s.visible));
|
|
61
47
|
}
|
|
62
48
|
created() {
|
|
63
49
|
super.created(), this.initData(), this.initEvent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/indicator/indicator.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,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B,CAAC;IAEO,oBAAoB;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;IAEO,eAAe,CAAC,QAAgB;QACtC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAES,8BAA8B;QACtC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAwB,CAAC;IAC3D,CAAC;IAED,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;;AA/QM,cAAI,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAInC,iBAAO,GAAG,WAAW,CAAC;AA8Q/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC,CAAC","file":"indicator.js","sourcesContent":["import { DataView } from '@visactor/vdataset';\nimport { LayoutLevel, LayoutZIndex } from '../../constant/layout';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../interface/type';\nimport { BaseComponent } from '../base/base-component';\nimport type { IRegion } from '../../region/interface';\nimport type { IIndicator, IIndicatorItemSpec, IIndicatorSpec } from './interface';\nimport type { Maybe } from '../../typings';\nimport { mergeSpec } from '@visactor/vutils-extension';\nimport { transformIndicatorStyle } from '../../util/style';\nimport { getActualNumValue } from '../../util/space';\nimport { isEqual, isValid, isFunction, array, isArray, pickWithout } from '@visactor/vutils';\nimport { indicatorMapper } from './util';\nimport type { IModelSpecInfo } from '../../model/interface';\nimport { registerDataSetInstanceTransform } from '../../data/register';\nimport { CompilableData } from '../../compile/data/compilable-data';\nimport { Indicator as IndicatorComponents } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IndicatorAttributes } from '@visactor/vrender-components';\nimport type { IGraphic, INode, IGroup } from '@visactor/vrender-core';\nimport type { FunctionType } from '../../typings/visual';\nimport { Factory } from '../../core/factory';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IRichTextCharacter } from '@visactor/vrender-core';\n\nexport class Indicator<T extends IIndicatorSpec> extends BaseComponent<T> implements IIndicator {\n static type = ComponentTypeEnum.indicator;\n type = ComponentTypeEnum.indicator;\n name: string = ComponentTypeEnum.indicator;\n\n static specKey = 'indicator';\n specKey = 'indicator';\n\n layoutType: 'none' = 'none';\n layoutZIndex: number = LayoutZIndex.Indicator;\n layoutLevel: number = LayoutLevel.Indicator;\n\n private _gap: number = 0;\n\n private _activeDatum: any = null;\n private _displayData!: CompilableData;\n\n private _title: IIndicatorItemSpec;\n private _content: IIndicatorItemSpec[];\n\n private _indicatorComponent: IndicatorComponents;\n private _cacheAttrs: IndicatorAttributes;\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n if (this.type !== Indicator.type) {\n return null;\n }\n const indicatorSpec = chartSpec[this.specKey];\n if (!isArray(indicatorSpec)) {\n if (indicatorSpec.visible === false) {\n return [];\n }\n return [\n {\n spec: indicatorSpec,\n specPath: [this.specKey],\n specInfoPath: ['component', this.specKey, 0],\n type: ComponentTypeEnum.indicator\n }\n ];\n }\n\n const specInfos: IModelSpecInfo[] = [];\n indicatorSpec.forEach((s, i) => {\n if (s && s.visible !== false) {\n specInfos.push({\n spec: s,\n specPath: [this.specKey, i],\n specInfoPath: ['component', this.specKey, i],\n type: ComponentTypeEnum.indicator\n });\n }\n });\n return specInfos;\n }\n\n created() {\n super.created();\n // data\n this.initData();\n // event\n this.initEvent();\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n this._gap = this._spec.gap || 0;\n this._title = this._spec.title;\n this._content = array(this._spec.content);\n this._regions = this._option.getRegionsInUserIdOrIndex(array(this._spec.regionId), array(this._spec.regionIndex));\n }\n\n onRender(ctx: any): void {\n // do nothing\n }\n\n // region\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n // event\n protected initEvent() {\n if (this._option.disableTriggerEvent) {\n return;\n }\n const trigger = this._spec.trigger;\n if (trigger === 'none') {\n return;\n }\n\n const view = this.getCompiler()?.getVGrammarView();\n\n if (!view) {\n return;\n }\n\n if (this._spec.trigger === 'hover') {\n view.addEventListener('element-highlight:start', (params: any) => {\n if (this.isRelativeModel(params.options.regionId)) {\n this.updateDatum(params.elements[0].getDatum());\n }\n });\n view.addEventListener('element-highlight:reset', (params: any) => {\n if (this.isRelativeModel(params.options.regionId)) {\n this.updateDatum(null);\n }\n });\n } else {\n view.addEventListener('element-select:start', (params: any) => {\n if (this.isRelativeModel(params.options.regionId)) {\n this.updateDatum(params.elements[0].getDatum());\n }\n });\n view.addEventListener('element-select:reset', (params: any) => {\n if (this.isRelativeModel(params.options.regionId)) {\n this.updateDatum(null);\n }\n });\n }\n }\n\n updateDatum(datum: any) {\n this._activeDatum = datum;\n this._displayData.updateData();\n const attrs = this._getIndicatorAttrs();\n this._createOrUpdateIndicatorComponent(attrs);\n }\n\n // data\n private initData() {\n registerDataSetInstanceTransform(this._option.dataSet, 'indicatorFilter', indicatorMapper);\n const displayData = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` });\n displayData.transform({\n type: 'indicatorFilter',\n options: {\n title: this._title,\n content: this._content,\n datum: () => this._activeDatum\n }\n });\n\n displayData.target.addListener('change', this.updateDatum.bind(this));\n\n this._displayData = new CompilableData(this._option, displayData);\n }\n\n updateLayoutAttribute(): void {\n const attrs = this._getIndicatorAttrs();\n this._createOrUpdateIndicatorComponent(attrs);\n\n super.updateLayoutAttribute();\n }\n\n private _getIndicatorAttrs() {\n if (this._spec.visible === false || (this._spec.fixed === false && this._activeDatum === null)) {\n return {\n visible: false\n } as IndicatorAttributes;\n }\n\n const region = this._regions[0];\n const { width, height } = region.getLayoutRect();\n const { x, y } = region.getLayoutStartPoint();\n const { content, offsetX, offsetY, limitRatio, title, ...restSpec } = this._spec;\n\n const contentComponentSpec: IIndicatorItemSpec[] = [];\n array(content).forEach((eachItem: IIndicatorItemSpec) => {\n const contentSpec = mergeSpec({}, this._theme.content, eachItem);\n contentComponentSpec.push({\n visible: contentSpec.visible !== false && (contentSpec.field ? this._activeDatum !== null : true),\n space: contentSpec.space || this._gap,\n autoLimit: contentSpec.autoLimit,\n autoFit: contentSpec.autoFit,\n fitPercent: contentSpec.fitPercent,\n fitStrategy: contentSpec.fitStrategy,\n style: {\n ...transformIndicatorStyle(pickWithout(contentSpec.style, ['text']), this._activeDatum),\n text: this._createText(contentSpec.field, contentSpec.style.text)\n }\n });\n });\n\n return {\n visible: true,\n size: {\n width: width,\n height: height\n },\n zIndex: this.layoutZIndex,\n x: x,\n y: y,\n dx: offsetX ? getActualNumValue(offsetX, this._computeLayoutRadius()) : 0,\n dy: offsetY ? getActualNumValue(offsetY, this._computeLayoutRadius()) : 0,\n limitRatio: limitRatio || Infinity,\n title: {\n visible: title.visible !== false && (!isValid(title.field) || this._activeDatum !== null),\n space: title.space || this._gap,\n autoLimit: title.autoLimit,\n autoFit: title.autoFit,\n fitPercent: title.fitPercent,\n fitStrategy: title.fitStrategy,\n style: {\n ...transformIndicatorStyle(pickWithout(title.style, ['text']), this._activeDatum),\n text: this._createText(title.field, title.style.text as any) // FIXME: type\n }\n },\n content: contentComponentSpec,\n ...(restSpec as unknown as IndicatorAttributes)\n } as IndicatorAttributes;\n }\n\n private _createOrUpdateIndicatorComponent(attrs: IndicatorAttributes): IndicatorComponents {\n if (this._indicatorComponent) {\n if (!isEqual(attrs, this._cacheAttrs)) {\n this._indicatorComponent.setAttributes(attrs);\n }\n } else {\n const container = this.getContainer();\n //FIXME:类型“IndicatorAttributes”的参数不能赋给类型“Required<IndicatorAttributes>”的参数\n const indicator = new IndicatorComponents(attrs as any);\n indicator.name = 'indicator';\n container.add(indicator as unknown as INode);\n this._indicatorComponent = indicator;\n this._indicatorComponent.on('*', (event: any, type: string) =>\n this._delegateEvent(this._indicatorComponent as unknown as IGraphic, event, type)\n );\n }\n this._cacheAttrs = attrs;\n return this._indicatorComponent;\n }\n\n private _createText(\n field: string | undefined,\n text:\n | string\n | number\n | string[]\n | number[]\n | IRichTextCharacter[]\n | FunctionType<number | number[] | string | string[] | IRichTextCharacter[]>\n ) {\n if (field) {\n return this._activeDatum ? this._activeDatum[field] : '';\n }\n if (isFunction(text)) {\n return text(this._activeDatum, undefined) ?? '';\n }\n return text ?? '';\n }\n\n private _computeLayoutRadius() {\n const region = this._regions[0];\n const { width, height } = region.getLayoutRect();\n return Math.min(width / 2, height / 2);\n }\n\n private isRelativeModel(regionId: number) {\n return this._regions.some(region => region.id === regionId);\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._indicatorComponent] as unknown as IGroup[];\n }\n\n clear(): void {\n this._cacheAttrs = null;\n super.clear();\n }\n\n getIndicatorComponent(): IndicatorComponents {\n return this._indicatorComponent;\n }\n}\n\nexport const registerIndicator = () => {\n Factory.registerComponent(Indicator.type, Indicator);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/indicator/indicator.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD,OAAO,EAAE,SAAS,EAAE,MAAM,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;IAES,8BAA8B;QACtC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAwB,CAAC;IAC3D,CAAC;IAED,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;;AApPM,cAAI,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAInC,iBAAO,GAAG,WAAW,CAAC;AAmP/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC,CAAC","file":"indicator.js","sourcesContent":["import { DataView } from '@visactor/vdataset';\nimport { LayoutLevel, LayoutZIndex } from '../../constant/layout';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../interface/type';\nimport { BaseComponent } from '../base/base-component';\nimport type { IRegion } from '../../region/interface';\nimport type { IIndicator, IIndicatorItemSpec, IIndicatorSpec } from './interface';\nimport type { Maybe } from '../../typings';\nimport { mergeSpec } from '@visactor/vutils-extension';\nimport { transformIndicatorStyle } from '../../util/style';\nimport { getActualNumValue } from '../../util/space';\nimport { isEqual, isValid, isFunction, array, pickWithout } from '@visactor/vutils';\nimport { indicatorMapper } from './util';\nimport type { IModelSpecInfo } from '../../model/interface';\nimport { registerDataSetInstanceTransform } from '../../data/register';\nimport { CompilableData } from '../../compile/data/compilable-data';\nimport { Indicator as IndicatorComponents } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IndicatorAttributes } from '@visactor/vrender-components';\nimport type { IGraphic, INode, IGroup } from '@visactor/vrender-core';\nimport type { FunctionType } from '../../typings/visual';\nimport { Factory } from '../../core/factory';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IRichTextCharacter } from '@visactor/vrender-core';\nimport { getSpecInfo } from '../util';\n\nexport class Indicator<T extends IIndicatorSpec> extends BaseComponent<T> implements IIndicator {\n static type = ComponentTypeEnum.indicator;\n type = ComponentTypeEnum.indicator;\n name: string = ComponentTypeEnum.indicator;\n\n static specKey = 'indicator';\n specKey = 'indicator';\n\n layoutType: 'none' = 'none';\n layoutZIndex: number = LayoutZIndex.Indicator;\n layoutLevel: number = LayoutLevel.Indicator;\n\n private _gap: number = 0;\n\n private _activeDatum: any = null;\n private _displayData!: CompilableData;\n\n private _title: IIndicatorItemSpec;\n private _content: IIndicatorItemSpec[];\n\n private _indicatorComponent: IndicatorComponents;\n private _cacheAttrs: IndicatorAttributes;\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n return getSpecInfo<IIndicatorSpec>(chartSpec, this.specKey, this.type, (s: IIndicatorSpec) => {\n return s && s.visible !== false;\n });\n }\n\n created() {\n super.created();\n // data\n this.initData();\n // event\n this.initEvent();\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n this._gap = this._spec.gap || 0;\n this._title = this._spec.title;\n this._content = array(this._spec.content);\n this._regions = this._option.getRegionsInUserIdOrIndex(array(this._spec.regionId), array(this._spec.regionIndex));\n }\n\n onRender(ctx: any): void {\n // do nothing\n }\n\n // region\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n // event\n protected initEvent() {\n if (this._option.disableTriggerEvent) {\n return;\n }\n const trigger = this._spec.trigger;\n if (trigger === 'none') {\n return;\n }\n\n const view = this.getCompiler()?.getVGrammarView();\n\n if (!view) {\n return;\n }\n\n if (this._spec.trigger === 'hover') {\n view.addEventListener('element-highlight:start', (params: any) => {\n if (this.isRelativeModel(params.options.regionId)) {\n this.updateDatum(params.elements[0].getDatum());\n }\n });\n view.addEventListener('element-highlight:reset', (params: any) => {\n if (this.isRelativeModel(params.options.regionId)) {\n this.updateDatum(null);\n }\n });\n } else {\n view.addEventListener('element-select:start', (params: any) => {\n if (this.isRelativeModel(params.options.regionId)) {\n this.updateDatum(params.elements[0].getDatum());\n }\n });\n view.addEventListener('element-select:reset', (params: any) => {\n if (this.isRelativeModel(params.options.regionId)) {\n this.updateDatum(null);\n }\n });\n }\n }\n\n updateDatum(datum: any) {\n this._activeDatum = datum;\n this._displayData.updateData();\n const attrs = this._getIndicatorAttrs();\n this._createOrUpdateIndicatorComponent(attrs);\n }\n\n // data\n private initData() {\n registerDataSetInstanceTransform(this._option.dataSet, 'indicatorFilter', indicatorMapper);\n const displayData = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` });\n displayData.transform({\n type: 'indicatorFilter',\n options: {\n title: this._title,\n content: this._content,\n datum: () => this._activeDatum\n }\n });\n\n displayData.target.addListener('change', this.updateDatum.bind(this));\n\n this._displayData = new CompilableData(this._option, displayData);\n }\n\n updateLayoutAttribute(): void {\n const attrs = this._getIndicatorAttrs();\n this._createOrUpdateIndicatorComponent(attrs);\n\n super.updateLayoutAttribute();\n }\n\n private _getIndicatorAttrs() {\n if (this._spec.visible === false || (this._spec.fixed === false && this._activeDatum === null)) {\n return {\n visible: false\n } as IndicatorAttributes;\n }\n\n const region = this._regions[0];\n const { width, height } = region.getLayoutRect();\n const { x, y } = region.getLayoutStartPoint();\n const { content, offsetX, offsetY, limitRatio, title, ...restSpec } = this._spec;\n\n const contentComponentSpec: IIndicatorItemSpec[] = [];\n array(content).forEach((eachItem: IIndicatorItemSpec) => {\n const contentSpec = mergeSpec({}, this._theme.content, eachItem);\n contentComponentSpec.push({\n visible: contentSpec.visible !== false && (contentSpec.field ? this._activeDatum !== null : true),\n space: contentSpec.space || this._gap,\n autoLimit: contentSpec.autoLimit,\n autoFit: contentSpec.autoFit,\n fitPercent: contentSpec.fitPercent,\n fitStrategy: contentSpec.fitStrategy,\n style: {\n ...transformIndicatorStyle(pickWithout(contentSpec.style, ['text']), this._activeDatum),\n text: this._createText(contentSpec.field, contentSpec.style.text)\n }\n });\n });\n\n return {\n visible: true,\n size: {\n width: width,\n height: height\n },\n zIndex: this.layoutZIndex,\n x: x,\n y: y,\n dx: offsetX ? getActualNumValue(offsetX, this._computeLayoutRadius()) : 0,\n dy: offsetY ? getActualNumValue(offsetY, this._computeLayoutRadius()) : 0,\n limitRatio: limitRatio || Infinity,\n title: {\n visible: title.visible !== false && (!isValid(title.field) || this._activeDatum !== null),\n space: title.space || this._gap,\n autoLimit: title.autoLimit,\n autoFit: title.autoFit,\n fitPercent: title.fitPercent,\n fitStrategy: title.fitStrategy,\n style: {\n ...transformIndicatorStyle(pickWithout(title.style, ['text']), this._activeDatum),\n text: this._createText(title.field, title.style.text as any) // FIXME: type\n }\n },\n content: contentComponentSpec,\n ...(restSpec as unknown as IndicatorAttributes)\n } as IndicatorAttributes;\n }\n\n private _createOrUpdateIndicatorComponent(attrs: IndicatorAttributes): IndicatorComponents {\n if (this._indicatorComponent) {\n if (!isEqual(attrs, this._cacheAttrs)) {\n this._indicatorComponent.setAttributes(attrs);\n }\n } else {\n const container = this.getContainer();\n //FIXME:类型“IndicatorAttributes”的参数不能赋给类型“Required<IndicatorAttributes>”的参数\n const indicator = new IndicatorComponents(attrs as any);\n indicator.name = 'indicator';\n container.add(indicator as unknown as INode);\n this._indicatorComponent = indicator;\n this._indicatorComponent.on('*', (event: any, type: string) =>\n this._delegateEvent(this._indicatorComponent as unknown as IGraphic, event, type)\n );\n }\n this._cacheAttrs = attrs;\n return this._indicatorComponent;\n }\n\n private _createText(\n field: string | undefined,\n text:\n | string\n | number\n | string[]\n | number[]\n | IRichTextCharacter[]\n | FunctionType<number | number[] | string | string[] | IRichTextCharacter[]>\n ) {\n if (field) {\n return this._activeDatum ? this._activeDatum[field] : '';\n }\n if (isFunction(text)) {\n return text(this._activeDatum, undefined) ?? '';\n }\n return text ?? '';\n }\n\n private _computeLayoutRadius() {\n const region = this._regions[0];\n const { width, height } = region.getLayoutRect();\n return Math.min(width / 2, height / 2);\n }\n\n private isRelativeModel(regionId: number) {\n return this._regions.some(region => region.id === regionId);\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._indicatorComponent] as unknown as IGroup[];\n }\n\n clear(): void {\n this._cacheAttrs = null;\n super.clear();\n }\n\n getIndicatorComponent(): IndicatorComponents {\n return this._indicatorComponent;\n }\n}\n\nexport const registerIndicator = () => {\n Factory.registerComponent(Indicator.type, Indicator);\n};\n"]}
|
|
@@ -33,7 +33,7 @@ export interface IComponent extends ILayoutModel {
|
|
|
33
33
|
export interface IComponentConstructor extends IModelConstructor {
|
|
34
34
|
type: string;
|
|
35
35
|
specKey?: string;
|
|
36
|
-
getSpecInfo
|
|
36
|
+
getSpecInfo?: (chartSpec: any, chartSpecInfo?: IChartSpecInfo) => Maybe<IModelSpecInfo[]>;
|
|
37
37
|
createComponent: (specInfo: IModelSpecInfo, options: IComponentOption) => IComponent;
|
|
38
38
|
new (spec: any, options: IComponentOption): IComponent;
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/interface/common.ts"],"names":[],"mappings":"","file":"common.js","sourcesContent":["import type { ISeriesFilter } from '../../region/interface';\nimport type { IAnimate } from '../../animation/interface';\nimport type { ILayoutModel, IModelConstructor, IModelOption, IModelSpecInfo } from '../../model/interface';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IRegion } from '../../region/interface';\nimport type { ISeries } from '../../series/interface';\nimport type { Maybe, StringOrNumber } from '../../typings';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type { IChartSpecInfo } from '../../chart/interface';\n/**\n * 组件作为图表辅助阅读等功能的模块,除了model提供的能力之外,还有以下功能特点\n * 支持对多region的绑定。\n * 能够在resize时正常的重新对内部元素布局。\n * 保持数据独立,模块间的依赖关系,能从数据上处理的应当从数据上处理。\n */\n\nexport interface IComponentOption extends IModelOption {\n // 区域\n getAllRegions: () => IRegion[];\n getRegionsInIndex: (index?: number[]) => IRegion[];\n getRegionsInIds: (ids: number[]) => IRegion[];\n getRegionsInUserIdOrIndex: (user_ids?: StringOrNumber[], index?: number[]) => IRegion[];\n // series\n getAllSeries: () => ISeries[];\n getSeriesInIndex: (index?: number[]) => ISeries[];\n getSeriesInIds: (ids?: number[]) => ISeries[];\n getSeriesInUserIdOrIndex: (user_ids?: StringOrNumber[], index?: number[]) => ISeries[];\n // component\n getAllComponents: () => IComponent[];\n getComponentByIndex: (key: string, index: number) => IComponent | undefined;\n getComponentByUserId: (userId: StringOrNumber) => IComponent | undefined;\n getComponentsByKey: (key: string) => IComponent[];\n getComponentsByType: (type: string) => IComponent[];\n}\n\nexport interface IComponent extends ILayoutModel {\n readonly name: string;\n readonly animate?: IAnimate;\n\n // 区域\n getRegions: () => IRegion[];\n getBindSeriesFilter?: () => ISeriesFilter;\n changeRegions: (regions: IRegion[]) => void;\n getVRenderComponents: () => IGraphic[];\n\n // 清空,用于更新等场景\n clear: () => void;\n}\n\nexport interface IComponentConstructor extends IModelConstructor {\n type: string;\n specKey?: string;\n getSpecInfo
|
|
1
|
+
{"version":3,"sources":["../src/component/interface/common.ts"],"names":[],"mappings":"","file":"common.js","sourcesContent":["import type { ISeriesFilter } from '../../region/interface';\nimport type { IAnimate } from '../../animation/interface';\nimport type { ILayoutModel, IModelConstructor, IModelOption, IModelSpecInfo } from '../../model/interface';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IRegion } from '../../region/interface';\nimport type { ISeries } from '../../series/interface';\nimport type { Maybe, StringOrNumber } from '../../typings';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type { IChartSpecInfo } from '../../chart/interface';\n/**\n * 组件作为图表辅助阅读等功能的模块,除了model提供的能力之外,还有以下功能特点\n * 支持对多region的绑定。\n * 能够在resize时正常的重新对内部元素布局。\n * 保持数据独立,模块间的依赖关系,能从数据上处理的应当从数据上处理。\n */\n\nexport interface IComponentOption extends IModelOption {\n // 区域\n getAllRegions: () => IRegion[];\n getRegionsInIndex: (index?: number[]) => IRegion[];\n getRegionsInIds: (ids: number[]) => IRegion[];\n getRegionsInUserIdOrIndex: (user_ids?: StringOrNumber[], index?: number[]) => IRegion[];\n // series\n getAllSeries: () => ISeries[];\n getSeriesInIndex: (index?: number[]) => ISeries[];\n getSeriesInIds: (ids?: number[]) => ISeries[];\n getSeriesInUserIdOrIndex: (user_ids?: StringOrNumber[], index?: number[]) => ISeries[];\n // component\n getAllComponents: () => IComponent[];\n getComponentByIndex: (key: string, index: number) => IComponent | undefined;\n getComponentByUserId: (userId: StringOrNumber) => IComponent | undefined;\n getComponentsByKey: (key: string) => IComponent[];\n getComponentsByType: (type: string) => IComponent[];\n}\n\nexport interface IComponent extends ILayoutModel {\n readonly name: string;\n readonly animate?: IAnimate;\n\n // 区域\n getRegions: () => IRegion[];\n getBindSeriesFilter?: () => ISeriesFilter;\n changeRegions: (regions: IRegion[]) => void;\n getVRenderComponents: () => IGraphic[];\n\n // 清空,用于更新等场景\n clear: () => void;\n}\n\nexport interface IComponentConstructor extends IModelConstructor {\n type: string;\n specKey?: string;\n getSpecInfo?: (chartSpec: any, chartSpecInfo?: IChartSpecInfo) => Maybe<IModelSpecInfo[]>;\n createComponent: (specInfo: IModelSpecInfo, options: IComponentOption) => IComponent;\n new (spec: any, options: IComponentOption): IComponent;\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import type { ISeries } from '../../series';
|
|
|
6
6
|
export interface ILabelFormatMethodContext {
|
|
7
7
|
series?: ISeries;
|
|
8
8
|
}
|
|
9
|
-
export interface ILabelSpec extends IComponentSpec {
|
|
9
|
+
export interface ILabelSpec extends IComponentSpec, ILabelAnimationSpec {
|
|
10
10
|
visible?: boolean;
|
|
11
11
|
interactive?: boolean;
|
|
12
12
|
textType?: 'text' | 'rich';
|
|
@@ -18,7 +18,6 @@ export interface ILabelSpec extends IComponentSpec {
|
|
|
18
18
|
state?: LabelStateStyle<Partial<IComposedTextMarkSpec>>;
|
|
19
19
|
overlap?: BaseLabelAttrs['overlap'];
|
|
20
20
|
smartInvert?: BaseLabelAttrs['smartInvert'];
|
|
21
|
-
animation?: BaseLabelAttrs['animation'];
|
|
22
21
|
stackDataFilterType?: 'min' | 'max';
|
|
23
22
|
dataFilter?: BaseLabelAttrs['dataFilter'];
|
|
24
23
|
customLayoutFunc?: BaseLabelAttrs['customLayoutFunc'];
|
|
@@ -27,6 +26,7 @@ export interface ILabelSpec extends IComponentSpec {
|
|
|
27
26
|
support3d?: boolean;
|
|
28
27
|
syncState?: boolean;
|
|
29
28
|
}
|
|
29
|
+
export type ILabelAnimationSpec = Pick<BaseLabelAttrs, 'animation' | 'animationEnter' | 'animationUpdate' | 'animationExit'>;
|
|
30
30
|
export type IMultiLabelSpec<T extends Omit<ILabelSpec, 'position'>> = T | T[];
|
|
31
31
|
type LabelStateStyle<T> = {
|
|
32
32
|
hover?: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/label/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { BaseLabelAttrs } from '@visactor/vrender-components';\nimport type { ConvertToMarkStyleSpec, Datum, IComposedTextMarkSpec, IFormatMethod, ITextMarkSpec } from '../../typings';\nimport type { IComponentSpec } from '../base/interface';\nimport type { ILabelMark } from '../../mark/label';\nimport type { ISeries } from '../../series';\n\nexport interface ILabelFormatMethodContext {\n series?: ISeries;\n}\n\nexport interface ILabelSpec extends IComponentSpec {\n /** 默认不显示标签 */\n visible?: boolean;\n /**\n * 是否支持交互。\n * @default false\n */\n interactive?: boolean;\n /**\n * 文本类型:text, rich,\n * @since 1.7.0\n * @deprecated\n */\n textType?: 'text' | 'rich';\n /**\n * 格式化函数\n * @since 1.10.0 支持返回结构 `{type:'rich', text: [{text:'some text', fill:'black', fontSize: 20}]}\n */\n formatMethod?: IFormatMethod<[text: string | string[], datum?: Datum, ctx?: ILabelFormatMethodContext]>;\n /**\n * 字符串模版\n * 用{}包裹变量名的字符串模版, 变量名取自数据属性值\n * eg: 'type={type},value={value}'\n * @since 1.7.0\n */\n formatter?: string | string[];\n /** 标签与其对应数据图元的间距 */\n offset?: number;\n /** 标签位置 */\n position?: string;\n /** 标签样式配置 */\n style?: ConvertToMarkStyleSpec<IComposedTextMarkSpec>;\n /** 交互样式配置 */\n state?: LabelStateStyle<Partial<IComposedTextMarkSpec>>;\n /** 标签防重叠配置 */\n overlap?: BaseLabelAttrs['overlap'];\n /** 标签智能反色配置 */\n smartInvert?: BaseLabelAttrs['smartInvert'];\n
|
|
1
|
+
{"version":3,"sources":["../src/component/label/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { BaseLabelAttrs } from '@visactor/vrender-components';\nimport type { ConvertToMarkStyleSpec, Datum, IComposedTextMarkSpec, IFormatMethod, ITextMarkSpec } from '../../typings';\nimport type { IComponentSpec } from '../base/interface';\nimport type { ILabelMark } from '../../mark/label';\nimport type { ISeries } from '../../series';\n\nexport interface ILabelFormatMethodContext {\n series?: ISeries;\n}\n\nexport interface ILabelSpec extends IComponentSpec, ILabelAnimationSpec {\n /** 默认不显示标签 */\n visible?: boolean;\n /**\n * 是否支持交互。\n * @default false\n */\n interactive?: boolean;\n /**\n * 文本类型:text, rich,\n * @since 1.7.0\n * @deprecated\n */\n textType?: 'text' | 'rich';\n /**\n * 格式化函数\n * @since 1.10.0 支持返回结构 `{type:'rich', text: [{text:'some text', fill:'black', fontSize: 20}]}\n */\n formatMethod?: IFormatMethod<[text: string | string[], datum?: Datum, ctx?: ILabelFormatMethodContext]>;\n /**\n * 字符串模版\n * 用{}包裹变量名的字符串模版, 变量名取自数据属性值\n * eg: 'type={type},value={value}'\n * @since 1.7.0\n */\n formatter?: string | string[];\n /** 标签与其对应数据图元的间距 */\n offset?: number;\n /** 标签位置 */\n position?: string;\n /** 标签样式配置 */\n style?: ConvertToMarkStyleSpec<IComposedTextMarkSpec>;\n /** 交互样式配置 */\n state?: LabelStateStyle<Partial<IComposedTextMarkSpec>>;\n /** 标签防重叠配置 */\n overlap?: BaseLabelAttrs['overlap'];\n /** 标签智能反色配置 */\n smartInvert?: BaseLabelAttrs['smartInvert'];\n /**\n * 堆积数据过滤类型\n * @since 1.12.0\n */\n stackDataFilterType?: 'min' | 'max';\n /** 自定义标签数据筛选和排序\n * @since 1.3.0\n */\n dataFilter?: BaseLabelAttrs['dataFilter'];\n /** 自定义标签布局函数。\n * @description 当配置了 customLayoutFunc 后,默认布局和防重叠逻辑将不再生效。(overlap/position/offset不生效)\n * @since 1.3.0\n */\n customLayoutFunc?: BaseLabelAttrs['customLayoutFunc'];\n /** 自定义标签躲避函数\n * @description 当配置了 customOverlapFunc 后,会根据 position 和 offset 进行初始布局。配置的防重叠逻辑(overlap)不生效。\n * @since 1.3.0\n */\n customOverlapFunc?: BaseLabelAttrs['customOverlapFunc'];\n /** 标签布局 */\n labelLayout?: 'series' | 'region';\n /** 是否支持3D */\n support3d?: boolean;\n /**\n * 是否同步数据图元的状态变化\n * @default false\n * @since 1.9.0\n */\n syncState?: boolean;\n}\n\nexport type ILabelAnimationSpec = Pick<\n BaseLabelAttrs,\n 'animation' | 'animationEnter' | 'animationUpdate' | 'animationExit'\n>;\nexport type IMultiLabelSpec<T extends Omit<ILabelSpec, 'position'>> = T | T[];\n\ntype LabelStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n};\n\nexport type ITotalLabelSpec = Pick<\n ILabelSpec,\n 'visible' | 'formatMethod' | 'interactive' | 'offset' | 'style' | 'state' | 'textType' | 'overlap'\n>;\n\nexport interface ITotalLabelTheme\n extends Pick<ILabelSpec, 'visible' | 'interactive' | 'offset' | 'overlap' | 'smartInvert' | 'animation'> {\n style?: ITextMarkSpec;\n}\n\n// 内部处理转换后的标签配置\nexport type TransformedLabelSpec = ILabelSpec & {\n getStyleHandler: (series: ISeries) => (mark?: ILabelMark, spec?: any) => void;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { debounce, isEmpty, isNil,
|
|
1
|
+
import { debounce, isEmpty, isNil, get } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { DataView } from "@visactor/vdataset";
|
|
4
4
|
|
|
@@ -24,27 +24,16 @@ import { Factory } from "../../../core/factory";
|
|
|
24
24
|
|
|
25
25
|
import { TransformLevel } from "../../../data/initialize";
|
|
26
26
|
|
|
27
|
+
import { getSpecInfo } from "../../util";
|
|
28
|
+
|
|
27
29
|
const SINGLE_SEQUENCE = [ "#C4E7FF", "#98CAFF", "#75ACFF", "#518FF9", "#2775DC", "#005CBE", "#00429F", "#00287E" ], SIZE = [ 2, 10 ];
|
|
28
30
|
|
|
29
31
|
export class ContinuousLegend extends BaseLegend {
|
|
30
32
|
static getSpecInfo(chartSpec) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
specPath: [ this.specKey ],
|
|
36
|
-
specInfoPath: [ "component", this.specKey, 0 ],
|
|
37
|
-
type: "color" === legendSpec.type ? ComponentTypeEnum.colorLegend : ComponentTypeEnum.sizeLegend
|
|
38
|
-
} ] : void 0;
|
|
39
|
-
const specInfos = [];
|
|
40
|
-
return legendSpec.forEach(((s, i) => {
|
|
41
|
-
isContinuousLegend(s.type) && specInfos.push({
|
|
42
|
-
spec: s,
|
|
43
|
-
specPath: [ this.specKey, i ],
|
|
44
|
-
specInfoPath: [ "component", this.specKey, i ],
|
|
45
|
-
type: "color" === s.type ? ComponentTypeEnum.colorLegend : ComponentTypeEnum.sizeLegend
|
|
46
|
-
});
|
|
47
|
-
})), specInfos;
|
|
33
|
+
const infos = getSpecInfo(chartSpec, this.specKey, this.type, (s => isContinuousLegend(s.type)));
|
|
34
|
+
return infos && infos.forEach((info => {
|
|
35
|
+
info.type = "color" === info.spec.type ? ComponentTypeEnum.colorLegend : ComponentTypeEnum.sizeLegend;
|
|
36
|
+
})), infos;
|
|
48
37
|
}
|
|
49
38
|
constructor(spec, options) {
|
|
50
39
|
super(spec, options), this.type = ComponentTypeEnum.colorLegend, this.name = ComponentTypeEnum.colorLegend;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/legend/continuous/legend.ts"],"names":[],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C3C,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AACrE,CAAC,CAAC","file":"legend.js","sourcesContent":["/**\n * @description color legend component\n */\nimport type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { debounce, isEmpty, isNil, isArray, get } from '@visactor/vutils';\nimport { DataView } from '@visactor/vdataset';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IModelInitOption, IModelSpecInfo } from '../../../model/interface';\nimport type { IComponentOption } from '../../interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../../interface/type';\n// eslint-disable-next-line no-duplicate-imports\nimport { registerDataSetInstanceTransform } from '../../../data/register';\nimport { eachSeries, getSeries } from '../../../util/model';\nimport { getFieldAlias } from '../../../util/data';\nimport { isDataDomainSpec } from '../../../util/type';\nimport type { IColorLegendSpec, ISizeLegendSpec } from './interface';\nimport {\n continuousLegendDataMake,\n continuousLegendFilter\n} from '../../../data/transforms/legend-data/continuous/continuous';\nimport { ContinuousLegendMap, getContinuousLegendAttributes, isContinuousLegend } from './util';\nimport { BaseLegend } from '../base-legend';\nimport { ChartEvent } from '../../../constant/event';\nimport { Factory } from '../../../core/factory';\nimport { TransformLevel } from '../../../data/initialize';\nimport type { ILayoutRect } from '../../../typings/layout';\n\nconst SINGLE_SEQUENCE = ['#C4E7FF', '#98CAFF', '#75ACFF', '#518FF9', '#2775DC', '#005CBE', '#00429F', '#00287E'];\nconst SIZE = [2, 10];\n\nexport class ContinuousLegend<\n T extends IColorLegendSpec | ISizeLegendSpec = IColorLegendSpec | ISizeLegendSpec\n> extends BaseLegend<T> {\n static specKey = 'legends';\n\n static type = ComponentTypeEnum.continuousLegend;\n type = ComponentTypeEnum.colorLegend;\n name: string = ComponentTypeEnum.colorLegend;\n\n private _field: string | undefined;\n private _legendType: string;\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n const legendSpec = chartSpec[this.specKey];\n if (!legendSpec) {\n return undefined;\n }\n if (!isArray(legendSpec)) {\n if (isContinuousLegend(legendSpec.type)) {\n return [\n {\n spec: legendSpec,\n specPath: [this.specKey],\n specInfoPath: ['component', this.specKey, 0],\n type: legendSpec.type === 'color' ? ComponentTypeEnum.colorLegend : ComponentTypeEnum.sizeLegend\n }\n ];\n }\n return undefined;\n }\n const specInfos: IModelSpecInfo[] = [];\n legendSpec.forEach((s: IColorLegendSpec | ISizeLegendSpec, i: number) => {\n if (isContinuousLegend(s.type)) {\n specInfos.push({\n spec: s,\n specPath: [this.specKey, i],\n specInfoPath: ['component', this.specKey, i],\n type: s.type === 'color' ? ComponentTypeEnum.colorLegend : ComponentTypeEnum.sizeLegend\n });\n }\n });\n return specInfos;\n }\n\n constructor(spec: T, options: IComponentOption) {\n super(spec, options);\n\n // 这里需要区分下是 colorLegend 还是 sizeLegend\n const legendName = this._spec.type === 'color' ? ComponentTypeEnum.colorLegend : ComponentTypeEnum.sizeLegend;\n this.type = legendName;\n this.name = legendName;\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n this._field = this._spec.field;\n this._legendType = this._spec.type;\n }\n\n init(option: IModelInitOption): void {\n super.init(option);\n eachSeries(\n this._regions,\n s => {\n s.addViewDataFilter({\n type: 'continuousLegendFilter',\n options: {\n selected: () => this._selectedData,\n field: () => this._field,\n data: () => this._legendData.getLatestData(),\n isHierarchyData: s.isHierarchyData\n },\n level: TransformLevel.legendFilter\n });\n },\n {\n userId: this._seriesUserId,\n specIndex: this._seriesIndex\n }\n );\n }\n\n private _getScaleInGlobal() {\n const globalScale = this._option.globalScale;\n let scaleKey = this._spec.scale;\n if (!scaleKey) {\n scaleKey = this._legendType;\n }\n return globalScale.getScale(scaleKey);\n }\n\n protected _initLegendData(): DataView {\n registerDataSetInstanceTransform(this._option.dataSet, 'continuousLegendFilter', continuousLegendFilter);\n registerDataSetInstanceTransform(this._option.dataSet, 'continuousLegendDataMake', continuousLegendDataMake);\n const legendData = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` });\n legendData.transform({\n type: 'continuousLegendDataMake',\n options: {\n series: () => {\n return getSeries(this._regions, {\n userId: this._seriesUserId,\n specIndex: this._seriesIndex\n });\n },\n field: () => this._field,\n scale: this._getScaleInGlobal.bind(this)\n }\n });\n return legendData;\n }\n\n protected _initSelectedData(): void {\n if (this._spec.defaultSelected) {\n this._selectedData = this._spec.defaultSelected.slice();\n } else {\n this._selectedData = this._legendData.getLatestData();\n }\n }\n\n private _addDefaultTitleText(attrs: any) {\n if (attrs.title?.visible && isNil(attrs.title.text) && isNil(attrs.title.style?.text)) {\n const field = this._field;\n if (field) {\n // 默认使用第0个系列的对应别名\n const series = this._regions?.[0]?.getSeries()[0];\n if (!series) {\n return;\n }\n // 如果没有别名继续保持 空字符串\n attrs.title.text = getFieldAlias(series.getRawData(), field);\n return;\n }\n let scaleKey = this._spec.scale;\n if (!scaleKey) {\n scaleKey = this._legendType;\n }\n const scaleSpec = this._option.globalScale.getScaleSpec(scaleKey);\n if (!isDataDomainSpec(scaleSpec?.domain)) {\n return;\n }\n const dataInfo = scaleSpec.domain[0];\n if (dataInfo.fields.length === 0) {\n return;\n }\n // 如果没有别名继续保持 空字符串\n attrs.title.text = getFieldAlias(this._option.dataSet.getDataView(dataInfo.dataId), dataInfo.fields[0]);\n return;\n }\n }\n\n protected _getLegendAttributes(rect: ILayoutRect) {\n const layout = this.layoutOrient === 'bottom' || this.layoutOrient === 'top' ? 'horizontal' : 'vertical';\n const align = layout === 'horizontal' ? 'bottom' : this.layoutOrient;\n\n // 获取关联的 scale 以获取 colors / size\n let visualMappingRange = [];\n const scale = this._getScaleInGlobal();\n if (scale && scale.type === 'linear') {\n visualMappingRange = scale.range();\n }\n if (isEmpty(visualMappingRange)) {\n visualMappingRange = this._legendType === 'color' ? SINGLE_SEQUENCE : SIZE;\n }\n let min = this._legendData.getLatestData()[0] ?? 0;\n let max = this._legendData.getLatestData()[1] ?? 1;\n\n const isSame = this._legendData.getLatestData()[0] === this._legendData.getLatestData()[1];\n if (isSame) {\n min = Math.min(0, this._legendData.getLatestData()[0]);\n max = this._legendData.getLatestData()[0] === 0 ? 1 : Math.max(0, this._legendData.getLatestData()[0]);\n }\n\n const attrs: any = {\n layout,\n align,\n zIndex: this.layoutZIndex,\n min,\n max,\n value: this._spec.defaultSelected,\n [this._legendType === 'color' ? 'colors' : 'sizeRange']: visualMappingRange,\n ...getContinuousLegendAttributes(this._spec)\n };\n this._addDefaultTitleText(attrs);\n return attrs;\n }\n\n protected _getLegendConstructor() {\n return ContinuousLegendMap[this._legendType];\n }\n\n protected _initEvent() {\n if (this._legendComponent) {\n const doFilter = this._spec.filter !== false;\n this._legendComponent.addEventListener(\n 'change',\n debounce((e: any) => {\n const selectedData = get(e, 'detail.value');\n if (doFilter) {\n this.setSelectedData(selectedData);\n }\n this.event.emit(ChartEvent.legendFilter, { model: this, value: selectedData, event: e });\n }, 30)\n );\n }\n }\n}\n\nexport const registerContinuousLegend = () => {\n Factory.registerComponent(ContinuousLegend.type, ContinuousLegend);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/legend/continuous/legend.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,4DAA4D,CAAC;AACpE,OAAO,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AS,CAAC;AAEpB,qBAAI,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;AA6LnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AACrE,CAAC,CAAC","file":"legend.js","sourcesContent":["/**\n * @description color legend component\n */\nimport type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { debounce, isEmpty, isNil, get } from '@visactor/vutils';\nimport { DataView } from '@visactor/vdataset';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IModelInitOption, IModelSpecInfo } from '../../../model/interface';\nimport type { IComponentOption } from '../../interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../../interface/type';\n// eslint-disable-next-line no-duplicate-imports\nimport { registerDataSetInstanceTransform } from '../../../data/register';\nimport { eachSeries, getSeries } from '../../../util/model';\nimport { getFieldAlias } from '../../../util/data';\nimport { isDataDomainSpec } from '../../../util/type';\nimport type { IColorLegendSpec, ISizeLegendSpec } from './interface';\nimport {\n continuousLegendDataMake,\n continuousLegendFilter\n} from '../../../data/transforms/legend-data/continuous/continuous';\nimport { ContinuousLegendMap, getContinuousLegendAttributes, isContinuousLegend } from './util';\nimport { BaseLegend } from '../base-legend';\nimport { ChartEvent } from '../../../constant/event';\nimport { Factory } from '../../../core/factory';\nimport { TransformLevel } from '../../../data/initialize';\nimport type { ILayoutRect } from '../../../typings/layout';\nimport { getSpecInfo } from '../../util';\n\nconst SINGLE_SEQUENCE = ['#C4E7FF', '#98CAFF', '#75ACFF', '#518FF9', '#2775DC', '#005CBE', '#00429F', '#00287E'];\nconst SIZE = [2, 10];\n\nexport class ContinuousLegend<\n T extends IColorLegendSpec | ISizeLegendSpec = IColorLegendSpec | ISizeLegendSpec\n> extends BaseLegend<T> {\n static specKey = 'legends';\n\n static type = ComponentTypeEnum.continuousLegend;\n type = ComponentTypeEnum.colorLegend;\n name: string = ComponentTypeEnum.colorLegend;\n\n private _field: string | undefined;\n private _legendType: string;\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n const infos = getSpecInfo<IColorLegendSpec | ISizeLegendSpec>(\n chartSpec,\n this.specKey,\n this.type,\n (s: IColorLegendSpec | ISizeLegendSpec) => {\n return isContinuousLegend(s.type);\n }\n );\n\n if (infos) {\n infos.forEach(info => {\n info.type = info.spec.type === 'color' ? ComponentTypeEnum.colorLegend : ComponentTypeEnum.sizeLegend;\n });\n }\n\n return infos;\n }\n\n constructor(spec: T, options: IComponentOption) {\n super(spec, options);\n\n // 这里需要区分下是 colorLegend 还是 sizeLegend\n const legendName = this._spec.type === 'color' ? ComponentTypeEnum.colorLegend : ComponentTypeEnum.sizeLegend;\n this.type = legendName;\n this.name = legendName;\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n this._field = this._spec.field;\n this._legendType = this._spec.type;\n }\n\n init(option: IModelInitOption): void {\n super.init(option);\n eachSeries(\n this._regions,\n s => {\n s.addViewDataFilter({\n type: 'continuousLegendFilter',\n options: {\n selected: () => this._selectedData,\n field: () => this._field,\n data: () => this._legendData.getLatestData(),\n isHierarchyData: s.isHierarchyData\n },\n level: TransformLevel.legendFilter\n });\n },\n {\n userId: this._seriesUserId,\n specIndex: this._seriesIndex\n }\n );\n }\n\n private _getScaleInGlobal() {\n const globalScale = this._option.globalScale;\n let scaleKey = this._spec.scale;\n if (!scaleKey) {\n scaleKey = this._legendType;\n }\n return globalScale.getScale(scaleKey);\n }\n\n protected _initLegendData(): DataView {\n registerDataSetInstanceTransform(this._option.dataSet, 'continuousLegendFilter', continuousLegendFilter);\n registerDataSetInstanceTransform(this._option.dataSet, 'continuousLegendDataMake', continuousLegendDataMake);\n const legendData = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` });\n legendData.transform({\n type: 'continuousLegendDataMake',\n options: {\n series: () => {\n return getSeries(this._regions, {\n userId: this._seriesUserId,\n specIndex: this._seriesIndex\n });\n },\n field: () => this._field,\n scale: this._getScaleInGlobal.bind(this)\n }\n });\n return legendData;\n }\n\n protected _initSelectedData(): void {\n if (this._spec.defaultSelected) {\n this._selectedData = this._spec.defaultSelected.slice();\n } else {\n this._selectedData = this._legendData.getLatestData();\n }\n }\n\n private _addDefaultTitleText(attrs: any) {\n if (attrs.title?.visible && isNil(attrs.title.text) && isNil(attrs.title.style?.text)) {\n const field = this._field;\n if (field) {\n // 默认使用第0个系列的对应别名\n const series = this._regions?.[0]?.getSeries()[0];\n if (!series) {\n return;\n }\n // 如果没有别名继续保持 空字符串\n attrs.title.text = getFieldAlias(series.getRawData(), field);\n return;\n }\n let scaleKey = this._spec.scale;\n if (!scaleKey) {\n scaleKey = this._legendType;\n }\n const scaleSpec = this._option.globalScale.getScaleSpec(scaleKey);\n if (!isDataDomainSpec(scaleSpec?.domain)) {\n return;\n }\n const dataInfo = scaleSpec.domain[0];\n if (dataInfo.fields.length === 0) {\n return;\n }\n // 如果没有别名继续保持 空字符串\n attrs.title.text = getFieldAlias(this._option.dataSet.getDataView(dataInfo.dataId), dataInfo.fields[0]);\n return;\n }\n }\n\n protected _getLegendAttributes(rect: ILayoutRect) {\n const layout = this.layoutOrient === 'bottom' || this.layoutOrient === 'top' ? 'horizontal' : 'vertical';\n const align = layout === 'horizontal' ? 'bottom' : this.layoutOrient;\n\n // 获取关联的 scale 以获取 colors / size\n let visualMappingRange = [];\n const scale = this._getScaleInGlobal();\n if (scale && scale.type === 'linear') {\n visualMappingRange = scale.range();\n }\n if (isEmpty(visualMappingRange)) {\n visualMappingRange = this._legendType === 'color' ? SINGLE_SEQUENCE : SIZE;\n }\n let min = this._legendData.getLatestData()[0] ?? 0;\n let max = this._legendData.getLatestData()[1] ?? 1;\n\n const isSame = this._legendData.getLatestData()[0] === this._legendData.getLatestData()[1];\n if (isSame) {\n min = Math.min(0, this._legendData.getLatestData()[0]);\n max = this._legendData.getLatestData()[0] === 0 ? 1 : Math.max(0, this._legendData.getLatestData()[0]);\n }\n\n const attrs: any = {\n layout,\n align,\n zIndex: this.layoutZIndex,\n min,\n max,\n value: this._spec.defaultSelected,\n [this._legendType === 'color' ? 'colors' : 'sizeRange']: visualMappingRange,\n ...getContinuousLegendAttributes(this._spec)\n };\n this._addDefaultTitleText(attrs);\n return attrs;\n }\n\n protected _getLegendConstructor() {\n return ContinuousLegendMap[this._legendType];\n }\n\n protected _initEvent() {\n if (this._legendComponent) {\n const doFilter = this._spec.filter !== false;\n this._legendComponent.addEventListener(\n 'change',\n debounce((e: any) => {\n const selectedData = get(e, 'detail.value');\n if (doFilter) {\n this.setSelectedData(selectedData);\n }\n this.event.emit(ChartEvent.legendFilter, { model: this, value: selectedData, event: e });\n }, 30)\n );\n }\n }\n}\n\nexport const registerContinuousLegend = () => {\n Factory.registerComponent(ContinuousLegend.type, ContinuousLegend);\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction, isNil, isValidNumber,
|
|
1
|
+
import { isFunction, isNil, isValidNumber, get } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { DataView } from "@visactor/vdataset";
|
|
4
4
|
|
|
@@ -28,30 +28,14 @@ import { Factory } from "../../../core/factory";
|
|
|
28
28
|
|
|
29
29
|
import { TransformLevel } from "../../../data/initialize";
|
|
30
30
|
|
|
31
|
-
import { getFormatFunction } from "../../util";
|
|
31
|
+
import { getFormatFunction, getSpecInfo } from "../../util";
|
|
32
32
|
|
|
33
33
|
export class DiscreteLegend extends BaseLegend {
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments), this.type = ComponentTypeEnum.discreteLegend, this.name = ComponentTypeEnum.discreteLegend;
|
|
36
36
|
}
|
|
37
37
|
static getSpecInfo(chartSpec) {
|
|
38
|
-
|
|
39
|
-
if (!legendSpec) return;
|
|
40
|
-
if (!isArray(legendSpec)) return legendSpec.type && "discrete" !== legendSpec.type ? void 0 : [ {
|
|
41
|
-
spec: legendSpec,
|
|
42
|
-
specPath: [ this.specKey ],
|
|
43
|
-
specInfoPath: [ "component", this.specKey, 0 ],
|
|
44
|
-
type: ComponentTypeEnum.discreteLegend
|
|
45
|
-
} ];
|
|
46
|
-
const specInfos = [];
|
|
47
|
-
return legendSpec.forEach(((s, i) => {
|
|
48
|
-
s.type && "discrete" !== s.type || specInfos.push({
|
|
49
|
-
spec: s,
|
|
50
|
-
specPath: [ this.specKey, i ],
|
|
51
|
-
specInfoPath: [ "component", this.specKey, i ],
|
|
52
|
-
type: ComponentTypeEnum.discreteLegend
|
|
53
|
-
});
|
|
54
|
-
})), specInfos;
|
|
38
|
+
return getSpecInfo(chartSpec, this.specKey, this.type, (s => !s.type || "discrete" === s.type));
|
|
55
39
|
}
|
|
56
40
|
init(option) {
|
|
57
41
|
super.init(option), eachSeries(this._regions, (s => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/legend/discrete/legend.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAM9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAA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Y,EAAE,iBAAiB,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,MAAA,MAAA,IAAI,CAAC,KAAK,CAAC,IAAI,0CAAE,KAAK,mCAAI,EAAE,CAAC;QAEpG,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;QAC7F,IAAI,cAAc,IAAI,CAAC,iBAAiB,IAAI,eAAe,EAAE;YAC3D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,KAAa,EAAE,KAAU,EAAE,EAAE;gBAC5D,OAAO,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;YACvD,CAAC,CAAC;SACH;QACD,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;QAC7F,IAAI,cAAc,IAAI,CAAC,iBAAiB,IAAI,eAAe,EAAE;YAC3D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,KAAa,EAAE,KAAU,EAAE,EAAE;gBAC5D,OAAO,eAAe,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;YACvE,CAAC,CAAC;SACH;IACH,CAAC;;AA3QM,sBAAO,GAAG,SAAS,CAAC;AAEpB,mBAAI,GAAG,iBAAiB,CAAC,cAAc,CAAC;AA4QjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AACjE,CAAC,CAAC","file":"legend.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isFunction, isNil, isValidNumber, isArray, get } from '@visactor/vutils';\nimport { DataView } from '@visactor/vdataset';\nimport type { IDiscreteLegendSpec } from './interface';\n// eslint-disable-next-line no-duplicate-imports\nimport type { ISeries } from '../../../series/interface';\nimport type { IModelInitOption, IModelSpecInfo } from '../../../model/interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../../interface/type';\n// eslint-disable-next-line no-duplicate-imports\nimport { getLegendAttributes } from './util';\nimport { registerDataSetInstanceTransform } from '../../../data/register';\nimport { eachSeries } from '../../../util/model';\nimport { getFieldAlias } from '../../../util/data';\nimport { isDataDomainSpec } from '../../../util/type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { LegendItemDatum } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { LegendEvent } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { DiscreteLegend as LegendComponent } from '@visactor/vrender-components';\nimport { discreteLegendDataMake, discreteLegendFilter } from '../../../data/transforms/legend-data/discrete/discrete';\nimport { BaseLegend } from '../base-legend';\nimport { ChartEvent } from '../../../constant/event';\nimport { Factory } from '../../../core/factory';\nimport { TransformLevel } from '../../../data/initialize';\nimport type { ILayoutRect } from '../../../typings/layout';\nimport type { StringOrNumber } from '../../../typings';\nimport { getFormatFunction } from '../../util';\nimport type { IDiscreteLegendData } from '../../../data/transforms/legend-data/discrete';\n\nexport class DiscreteLegend extends BaseLegend<IDiscreteLegendSpec> {\n static specKey = 'legends';\n\n static type = ComponentTypeEnum.discreteLegend;\n type = ComponentTypeEnum.discreteLegend;\n name: string = ComponentTypeEnum.discreteLegend;\n\n protected _unselectedData: StringOrNumber[];\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n const legendSpec = chartSpec[this.specKey];\n if (!legendSpec) {\n return undefined;\n }\n if (!isArray(legendSpec)) {\n if (!legendSpec.type || legendSpec.type === 'discrete') {\n return [\n {\n spec: legendSpec,\n specPath: [this.specKey],\n specInfoPath: ['component', this.specKey, 0],\n type: ComponentTypeEnum.discreteLegend\n }\n ];\n }\n return undefined;\n }\n const specInfos: IModelSpecInfo[] = [];\n legendSpec.forEach((s: IDiscreteLegendSpec, i: number) => {\n if (!s.type || s.type === 'discrete') {\n specInfos.push({\n spec: s,\n specPath: [this.specKey, i],\n specInfoPath: ['component', this.specKey, i],\n type: ComponentTypeEnum.discreteLegend\n });\n }\n });\n return specInfos;\n }\n\n init(option: IModelInitOption): void {\n super.init(option);\n eachSeries(\n this._regions,\n s => {\n s.addViewDataFilter({\n type: 'discreteLegendFilter',\n options: {\n series: s,\n selected: () => this._selectedData,\n field: () => this._getSeriesLegendField(s),\n data: () => this.getLegendDefaultData()\n },\n level: TransformLevel.legendFilter\n });\n },\n {\n userId: this._seriesUserId,\n specIndex: this._seriesIndex\n }\n );\n }\n\n protected _initLegendData(): DataView {\n registerDataSetInstanceTransform(this._option.dataSet, 'discreteLegendFilter', discreteLegendFilter);\n registerDataSetInstanceTransform(this._option.dataSet, 'discreteLegendDataMake', discreteLegendDataMake);\n const legendData = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` });\n legendData.transform({\n type: 'discreteLegendDataMake',\n options: {\n series: () => {\n const result: ISeries[] = [];\n eachSeries(\n this._regions,\n s => {\n result.push(s);\n },\n {\n specIndex: this._spec.seriesIndex,\n userId: this._spec.seriesId\n }\n );\n return result;\n },\n seriesField: (s: ISeries) => this._getSeriesLegendField(s)\n }\n });\n\n return legendData;\n }\n\n protected _getSeriesLegendField(s: ISeries) {\n const defaultField = s.getSeriesField();\n const specifyScaleId = this._spec.scaleName ?? this._spec.scale;\n\n if (isNil(specifyScaleId)) {\n return defaultField;\n }\n if (!s.getRawData()) {\n return defaultField;\n }\n const scaleSpec = this._option.globalScale.getScaleSpec(specifyScaleId);\n if (!scaleSpec) {\n return defaultField;\n }\n\n // field是只在图例指定了scale的情况下生效\n if (this._spec.field) {\n return this._spec.field;\n }\n\n if (!isDataDomainSpec(scaleSpec.domain)) {\n return defaultField;\n }\n const seriesData = scaleSpec.domain.find(d => d.dataId === s.getRawData().name);\n if (!seriesData) {\n return defaultField;\n }\n return seriesData.fields?.[0] ?? defaultField;\n }\n\n protected _initSelectedData(): void {\n const fullSelectedData = this.getLegendDefaultData();\n\n if (this._unselectedData) {\n const selected: StringOrNumber[] = [];\n const unselected: StringOrNumber[] = [];\n\n fullSelectedData.forEach((entry: StringOrNumber) => {\n if (this._unselectedData.includes(entry)) {\n unselected.push(entry);\n } else {\n selected.push(entry);\n }\n });\n this._selectedData = selected;\n this._unselectedData = unselected;\n } else if (this._spec.defaultSelected) {\n this._selectedData = [...this._spec.defaultSelected];\n } else {\n this._selectedData = fullSelectedData;\n }\n }\n\n getLegendDefaultData(originalData?: boolean) {\n if (isFunction(this._spec.data)) {\n return this._getLegendItems().map((obj: LegendItemDatum) => obj.label);\n }\n\n return this._legendData\n .getLatestData()\n .map(originalData ? (obj: IDiscreteLegendData) => obj.originalKey : (obj: IDiscreteLegendData) => obj.key);\n }\n\n private _addDefaultTitleText(attrs: any) {\n if (attrs.title?.visible && isNil(attrs.title.text) && isNil(attrs.title.style?.text)) {\n // 默认使用第0个系列的 seriesField 别名\n const series = this._regions?.[0]?.getSeries()[0];\n if (!series) {\n return;\n }\n // 如果没有别名继续保持 空字符串\n attrs.title.text = getFieldAlias(series.getRawData(), series.getSeriesField());\n }\n }\n\n protected _getLegendAttributes(rect: ILayoutRect) {\n const layout = this.layoutOrient === 'bottom' || this.layoutOrient === 'top' ? 'horizontal' : 'vertical';\n const attrs = {\n layout,\n items: this._getLegendItems(),\n zIndex: this.layoutZIndex,\n ...getLegendAttributes(this._spec, rect),\n // maxWidth 和 maxHeight 已经在布局模块处理了,所以 rect 的优先级最高\n maxWidth: rect.width,\n maxHeight: rect.height\n };\n this._addDefaultTitleText(attrs);\n this._addLegendItemFormatMethods(attrs);\n return attrs;\n }\n\n protected _getLegendConstructor() {\n return LegendComponent;\n }\n\n setSelectedData(selectedData: StringOrNumber[]) {\n if (selectedData) {\n this._unselectedData = this.getLegendDefaultData().filter(\n (entry: StringOrNumber) => !selectedData.includes(entry)\n );\n }\n\n super.setSelectedData(selectedData);\n }\n\n protected _initEvent() {\n if (this._legendComponent) {\n const doFilter = this._spec.filter !== false;\n this._legendComponent.addEventListener(LegendEvent.legendItemClick, (e: any) => {\n const selectedData = get(e, 'detail.currentSelected');\n doFilter && this.setSelectedData(selectedData);\n this.event.emit(ChartEvent.legendItemClick, { model: this, value: selectedData, event: e });\n });\n\n this._legendComponent.addEventListener(LegendEvent.legendItemHover, (e: any) => {\n const detail = get(e, 'detail');\n this.event.emit(ChartEvent.legendItemHover, { model: this, value: detail, event: e });\n });\n\n this._legendComponent.addEventListener(LegendEvent.legendItemUnHover, (e: any) => {\n const detail = get(e, 'detail');\n this.event.emit(ChartEvent.legendItemUnHover, { model: this, value: detail, event: e });\n });\n }\n }\n\n private _getLegendItems() {\n const originData = (this._legendData.getLatestData() || []).map((datum: any) => {\n const fillOpacity = datum.style('fillOpacity');\n const strokeOpacity = datum.style('strokeOpacity');\n const opacity = datum.style('opacity');\n const texture = datum.style('texture');\n\n return {\n label: datum.key,\n shape: {\n symbolType: datum.style('symbolType') ?? datum.shapeType ?? 'circle',\n fillOpacity: isValidNumber(fillOpacity) ? fillOpacity : 1,\n strokeOpacity: isValidNumber(strokeOpacity) ? strokeOpacity : 1,\n opacity: isValidNumber(opacity) ? opacity : 1,\n texturePadding: texture ? 1 : null,\n textureSize: texture ? 4 : null,\n texture,\n fill: datum.style('fill'),\n stroke: datum.style('stroke'),\n textureColor: datum.style('textureColor'),\n innerBorder: datum.style('innerBorder'),\n outerBorder: datum.style('outerBorder'),\n lineDash: datum.style('lineDash'),\n lineDashOffset: datum.style('lineDashOffset'),\n lineWidth: datum.style('lineWidth')\n }\n };\n });\n const legendItems = isFunction(this._spec.data)\n ? this._spec.data(originData, this._option.globalScale.getScale('color'), this._option.globalScale)\n : originData;\n return legendItems;\n }\n\n private _addLegendItemFormatMethods(attrs: any) {\n const { formatMethod: labelFormatMethod, formatter: labelFormatter } = this._spec.item?.label ?? {};\n const { formatMethod: valueFormatMethod, formatter: valueFormatter } = this._spec.item?.value ?? {};\n\n const { formatFunc: labelFormatFunc } = getFormatFunction(labelFormatMethod, labelFormatter);\n if (labelFormatter && !labelFormatMethod && labelFormatFunc) {\n attrs.item.label.formatMethod = (value: string, datum: any) => {\n return labelFormatFunc(value, datum, labelFormatter);\n };\n }\n const { formatFunc: valueFormatFunc } = getFormatFunction(valueFormatMethod, valueFormatter);\n if (valueFormatter && !valueFormatMethod && valueFormatFunc) {\n attrs.item.value.formatMethod = (value: string, datum: any) => {\n return valueFormatFunc(valueFormatter, value, datum, labelFormatter);\n };\n }\n }\n}\n\nexport const registerDiscreteLegend = () => {\n Factory.registerComponent(DiscreteLegend.type, DiscreteLegend);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/legend/discrete/legend.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAM9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,C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AAC,cAAc,CAAC;AAkPjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AACjE,CAAC,CAAC","file":"legend.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isFunction, isNil, isValidNumber, get } from '@visactor/vutils';\nimport { DataView } from '@visactor/vdataset';\nimport type { IDiscreteLegendSpec } from './interface';\n// eslint-disable-next-line no-duplicate-imports\nimport type { ISeries } from '../../../series/interface';\nimport type { IModelInitOption, IModelSpecInfo } from '../../../model/interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../../interface/type';\n// eslint-disable-next-line no-duplicate-imports\nimport { getLegendAttributes } from './util';\nimport { registerDataSetInstanceTransform } from '../../../data/register';\nimport { eachSeries } from '../../../util/model';\nimport { getFieldAlias } from '../../../util/data';\nimport { isDataDomainSpec } from '../../../util/type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { LegendItemDatum } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { LegendEvent } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { DiscreteLegend as LegendComponent } from '@visactor/vrender-components';\nimport { discreteLegendDataMake, discreteLegendFilter } from '../../../data/transforms/legend-data/discrete/discrete';\nimport { BaseLegend } from '../base-legend';\nimport { ChartEvent } from '../../../constant/event';\nimport { Factory } from '../../../core/factory';\nimport { TransformLevel } from '../../../data/initialize';\nimport type { ILayoutRect } from '../../../typings/layout';\nimport type { StringOrNumber } from '../../../typings';\nimport { getFormatFunction, getSpecInfo } from '../../util';\nimport type { IDiscreteLegendData } from '../../../data/transforms/legend-data/discrete';\n\nexport class DiscreteLegend extends BaseLegend<IDiscreteLegendSpec> {\n static specKey = 'legends';\n\n static type = ComponentTypeEnum.discreteLegend;\n type = ComponentTypeEnum.discreteLegend;\n name: string = ComponentTypeEnum.discreteLegend;\n\n protected _unselectedData: StringOrNumber[];\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n return getSpecInfo<IDiscreteLegendSpec>(chartSpec, this.specKey, this.type, (s: IDiscreteLegendSpec) => {\n return !s.type || s.type === 'discrete';\n });\n }\n\n init(option: IModelInitOption): void {\n super.init(option);\n eachSeries(\n this._regions,\n s => {\n s.addViewDataFilter({\n type: 'discreteLegendFilter',\n options: {\n series: s,\n selected: () => this._selectedData,\n field: () => this._getSeriesLegendField(s),\n data: () => this.getLegendDefaultData()\n },\n level: TransformLevel.legendFilter\n });\n },\n {\n userId: this._seriesUserId,\n specIndex: this._seriesIndex\n }\n );\n }\n\n protected _initLegendData(): DataView {\n registerDataSetInstanceTransform(this._option.dataSet, 'discreteLegendFilter', discreteLegendFilter);\n registerDataSetInstanceTransform(this._option.dataSet, 'discreteLegendDataMake', discreteLegendDataMake);\n const legendData = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` });\n legendData.transform({\n type: 'discreteLegendDataMake',\n options: {\n series: () => {\n const result: ISeries[] = [];\n eachSeries(\n this._regions,\n s => {\n result.push(s);\n },\n {\n specIndex: this._spec.seriesIndex,\n userId: this._spec.seriesId\n }\n );\n return result;\n },\n seriesField: (s: ISeries) => this._getSeriesLegendField(s)\n }\n });\n\n return legendData;\n }\n\n protected _getSeriesLegendField(s: ISeries) {\n const defaultField = s.getSeriesField();\n const specifyScaleId = this._spec.scaleName ?? this._spec.scale;\n\n if (isNil(specifyScaleId)) {\n return defaultField;\n }\n if (!s.getRawData()) {\n return defaultField;\n }\n const scaleSpec = this._option.globalScale.getScaleSpec(specifyScaleId);\n if (!scaleSpec) {\n return defaultField;\n }\n\n // field是只在图例指定了scale的情况下生效\n if (this._spec.field) {\n return this._spec.field;\n }\n\n if (!isDataDomainSpec(scaleSpec.domain)) {\n return defaultField;\n }\n const seriesData = scaleSpec.domain.find(d => d.dataId === s.getRawData().name);\n if (!seriesData) {\n return defaultField;\n }\n return seriesData.fields?.[0] ?? defaultField;\n }\n\n protected _initSelectedData(): void {\n const fullSelectedData = this.getLegendDefaultData();\n\n if (this._unselectedData) {\n const selected: StringOrNumber[] = [];\n const unselected: StringOrNumber[] = [];\n\n fullSelectedData.forEach((entry: StringOrNumber) => {\n if (this._unselectedData.includes(entry)) {\n unselected.push(entry);\n } else {\n selected.push(entry);\n }\n });\n this._selectedData = selected;\n this._unselectedData = unselected;\n } else if (this._spec.defaultSelected) {\n this._selectedData = [...this._spec.defaultSelected];\n } else {\n this._selectedData = fullSelectedData;\n }\n }\n\n getLegendDefaultData(originalData?: boolean) {\n if (isFunction(this._spec.data)) {\n return this._getLegendItems().map((obj: LegendItemDatum) => obj.label);\n }\n\n return this._legendData\n .getLatestData()\n .map(originalData ? (obj: IDiscreteLegendData) => obj.originalKey : (obj: IDiscreteLegendData) => obj.key);\n }\n\n private _addDefaultTitleText(attrs: any) {\n if (attrs.title?.visible && isNil(attrs.title.text) && isNil(attrs.title.style?.text)) {\n // 默认使用第0个系列的 seriesField 别名\n const series = this._regions?.[0]?.getSeries()[0];\n if (!series) {\n return;\n }\n // 如果没有别名继续保持 空字符串\n attrs.title.text = getFieldAlias(series.getRawData(), series.getSeriesField());\n }\n }\n\n protected _getLegendAttributes(rect: ILayoutRect) {\n const layout = this.layoutOrient === 'bottom' || this.layoutOrient === 'top' ? 'horizontal' : 'vertical';\n const attrs = {\n layout,\n items: this._getLegendItems(),\n zIndex: this.layoutZIndex,\n ...getLegendAttributes(this._spec, rect),\n // maxWidth 和 maxHeight 已经在布局模块处理了,所以 rect 的优先级最高\n maxWidth: rect.width,\n maxHeight: rect.height\n };\n this._addDefaultTitleText(attrs);\n this._addLegendItemFormatMethods(attrs);\n return attrs;\n }\n\n protected _getLegendConstructor() {\n return LegendComponent;\n }\n\n setSelectedData(selectedData: StringOrNumber[]) {\n if (selectedData) {\n this._unselectedData = this.getLegendDefaultData().filter(\n (entry: StringOrNumber) => !selectedData.includes(entry)\n );\n }\n\n super.setSelectedData(selectedData);\n }\n\n protected _initEvent() {\n if (this._legendComponent) {\n const doFilter = this._spec.filter !== false;\n this._legendComponent.addEventListener(LegendEvent.legendItemClick, (e: any) => {\n const selectedData = get(e, 'detail.currentSelected');\n doFilter && this.setSelectedData(selectedData);\n this.event.emit(ChartEvent.legendItemClick, { model: this, value: selectedData, event: e });\n });\n\n this._legendComponent.addEventListener(LegendEvent.legendItemHover, (e: any) => {\n const detail = get(e, 'detail');\n this.event.emit(ChartEvent.legendItemHover, { model: this, value: detail, event: e });\n });\n\n this._legendComponent.addEventListener(LegendEvent.legendItemUnHover, (e: any) => {\n const detail = get(e, 'detail');\n this.event.emit(ChartEvent.legendItemUnHover, { model: this, value: detail, event: e });\n });\n }\n }\n\n private _getLegendItems() {\n const originData = (this._legendData.getLatestData() || []).map((datum: any) => {\n const fillOpacity = datum.style('fillOpacity');\n const strokeOpacity = datum.style('strokeOpacity');\n const opacity = datum.style('opacity');\n const texture = datum.style('texture');\n\n return {\n label: datum.key,\n shape: {\n symbolType: datum.style('symbolType') ?? datum.shapeType ?? 'circle',\n fillOpacity: isValidNumber(fillOpacity) ? fillOpacity : 1,\n strokeOpacity: isValidNumber(strokeOpacity) ? strokeOpacity : 1,\n opacity: isValidNumber(opacity) ? opacity : 1,\n texturePadding: texture ? 1 : null,\n textureSize: texture ? 4 : null,\n texture,\n fill: datum.style('fill'),\n stroke: datum.style('stroke'),\n textureColor: datum.style('textureColor'),\n innerBorder: datum.style('innerBorder'),\n outerBorder: datum.style('outerBorder'),\n lineDash: datum.style('lineDash'),\n lineDashOffset: datum.style('lineDashOffset'),\n lineWidth: datum.style('lineWidth')\n }\n };\n });\n const legendItems = isFunction(this._spec.data)\n ? this._spec.data(originData, this._option.globalScale.getScale('color'), this._option.globalScale)\n : originData;\n return legendItems;\n }\n\n private _addLegendItemFormatMethods(attrs: any) {\n const { formatMethod: labelFormatMethod, formatter: labelFormatter } = this._spec.item?.label ?? {};\n const { formatMethod: valueFormatMethod, formatter: valueFormatter } = this._spec.item?.value ?? {};\n\n const { formatFunc: labelFormatFunc } = getFormatFunction(labelFormatMethod, labelFormatter);\n if (labelFormatter && !labelFormatMethod && labelFormatFunc) {\n attrs.item.label.formatMethod = (value: string, datum: any) => {\n return labelFormatFunc(value, datum, labelFormatter);\n };\n }\n const { formatFunc: valueFormatFunc } = getFormatFunction(valueFormatMethod, valueFormatter);\n if (valueFormatter && !valueFormatMethod && valueFormatFunc) {\n attrs.item.value.formatMethod = (value: string, datum: any) => {\n return valueFormatFunc(valueFormatter, value, datum, labelFormatter);\n };\n }\n }\n}\n\nexport const registerDiscreteLegend = () => {\n Factory.registerComponent(DiscreteLegend.type, DiscreteLegend);\n};\n"]}
|
|
@@ -24,6 +24,8 @@ import { Factory } from "../../core/factory";
|
|
|
24
24
|
|
|
25
25
|
import { TransformLevel } from "../../data/initialize";
|
|
26
26
|
|
|
27
|
+
import { getSpecInfo } from "../util";
|
|
28
|
+
|
|
27
29
|
export class MapLabelComponent extends BaseComponent {
|
|
28
30
|
constructor() {
|
|
29
31
|
super(...arguments), this.type = ComponentTypeEnum.mapLabel, this.name = ComponentTypeEnum.mapLabel,
|
|
@@ -31,13 +33,7 @@ export class MapLabelComponent extends BaseComponent {
|
|
|
31
33
|
this._activeDatum = [];
|
|
32
34
|
}
|
|
33
35
|
static getSpecInfo(chartSpec) {
|
|
34
|
-
|
|
35
|
-
return labelSpec && labelSpec.visible && !isValid(labelSpec.series) ? [ {
|
|
36
|
-
spec: labelSpec,
|
|
37
|
-
specPath: [ this.specKey ],
|
|
38
|
-
specInfoPath: [ "component", this.specKey, 0 ],
|
|
39
|
-
type: ComponentTypeEnum.mapLabel
|
|
40
|
-
} ] : null;
|
|
36
|
+
return getSpecInfo(chartSpec, this.specKey, this.type, (s => s.visible && isValid(s.seriesId)));
|
|
41
37
|
}
|
|
42
38
|
setAttrFromSpec() {
|
|
43
39
|
var _a, _b, _c, _d;
|