@visactor/vgrammar-core 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/component/axis.js +1 -1
- package/cjs/component/axis.js.map +1 -1
- package/cjs/component/datazoom.js +23 -30
- package/cjs/component/datazoom.js.map +1 -1
- package/cjs/component/label.js +11 -11
- package/cjs/component/label.js.map +1 -1
- package/cjs/component/legend.js +4 -6
- package/cjs/component/legend.js.map +1 -1
- package/cjs/component/player.js +4 -12
- package/cjs/component/player.js.map +1 -1
- package/cjs/component/scrollbar.js +12 -24
- package/cjs/component/scrollbar.js.map +1 -1
- package/cjs/component/slider.js +1 -3
- package/cjs/component/slider.js.map +1 -1
- package/cjs/glyph/boxplot.js +34 -20
- package/cjs/glyph/boxplot.js.map +1 -1
- package/cjs/glyph/violin.js +18 -11
- package/cjs/glyph/violin.js.map +1 -1
- package/cjs/graph/animation/animation/clip.js +2 -2
- package/cjs/graph/animation/animation/clip.js.map +1 -1
- package/cjs/graph/animation/animation/grow-cartesian.js +11 -11
- package/cjs/graph/animation/animation/grow-cartesian.js.map +1 -1
- package/cjs/graph/animation/animation/grow-interval.js +18 -18
- package/cjs/graph/animation/animation/grow-interval.js.map +1 -1
- package/cjs/graph/animation/animation/grow-points.js +3 -3
- package/cjs/graph/animation/animation/grow-points.js.map +1 -1
- package/cjs/graph/animation/animation/grow-polar.js +8 -8
- package/cjs/graph/animation/animation/grow-polar.js.map +1 -1
- package/cjs/graph/animation/animation/move.js +12 -14
- package/cjs/graph/animation/animation/move.js.map +1 -1
- package/cjs/graph/animation/animation/update.js +1 -1
- package/cjs/graph/animation/animation/update.js.map +1 -1
- package/cjs/graph/animation/attribute.js +2 -2
- package/cjs/graph/animation/attribute.js.map +1 -1
- package/cjs/graph/attributes/helpers.js +9 -11
- package/cjs/graph/attributes/helpers.js.map +1 -1
- package/cjs/graph/attributes/transform.js +1 -1
- package/cjs/graph/attributes/transform.js.map +1 -1
- package/cjs/graph/element.js +1 -1
- package/cjs/graph/element.js.map +1 -1
- package/cjs/graph/layout/grid.js +1 -1
- package/cjs/graph/layout/grid.js.map +1 -1
- package/cjs/graph/mark/graphic.js +2 -2
- package/cjs/graph/mark/graphic.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interactions/brush-base.js +3 -5
- package/cjs/interactions/brush-base.js.map +1 -1
- package/cjs/interactions/view-navigation-base.js +3 -3
- package/cjs/interactions/view-navigation-base.js.map +1 -1
- package/cjs/interactions/view-roam.js +10 -10
- package/cjs/interactions/view-roam.js.map +1 -1
- package/cjs/interactions/view-scroll-mixin.js +1 -1
- package/cjs/interactions/view-scroll-mixin.js.map +1 -1
- package/cjs/interactions/view-zoom-mixin.js +2 -2
- package/cjs/interactions/view-zoom-mixin.js.map +1 -1
- package/cjs/parse/event.js +1 -2
- package/cjs/parse/event.js.map +1 -1
- package/cjs/parse/scale.js +5 -4
- package/cjs/parse/scale.js.map +1 -1
- package/cjs/parse/view.js +11 -10
- package/cjs/parse/view.js.map +1 -1
- package/cjs/view/View.js +12 -13
- package/cjs/view/View.js.map +1 -1
- package/cjs/view/animate.js +11 -11
- package/cjs/view/animate.js.map +1 -1
- package/cjs/view/mark.js +6 -10
- package/cjs/view/mark.js.map +1 -1
- package/es/component/axis.js +1 -1
- package/es/component/axis.js.map +1 -1
- package/es/component/datazoom.js +23 -26
- package/es/component/datazoom.js.map +1 -1
- package/es/component/label.js +11 -11
- package/es/component/label.js.map +1 -1
- package/es/component/legend.js +4 -6
- package/es/component/legend.js.map +1 -1
- package/es/component/player.js +4 -12
- package/es/component/player.js.map +1 -1
- package/es/component/scrollbar.js +7 -18
- package/es/component/scrollbar.js.map +1 -1
- package/es/component/slider.js +1 -3
- package/es/component/slider.js.map +1 -1
- package/es/glyph/boxplot.js +22 -19
- package/es/glyph/boxplot.js.map +1 -1
- package/es/glyph/violin.js +12 -10
- package/es/glyph/violin.js.map +1 -1
- package/es/graph/animation/animation/clip.js +2 -2
- package/es/graph/animation/animation/clip.js.map +1 -1
- package/es/graph/animation/animation/grow-cartesian.js +11 -11
- package/es/graph/animation/animation/grow-cartesian.js.map +1 -1
- package/es/graph/animation/animation/grow-interval.js +18 -18
- package/es/graph/animation/animation/grow-interval.js.map +1 -1
- package/es/graph/animation/animation/grow-points.js +3 -3
- package/es/graph/animation/animation/grow-points.js.map +1 -1
- package/es/graph/animation/animation/grow-polar.js +8 -8
- package/es/graph/animation/animation/grow-polar.js.map +1 -1
- package/es/graph/animation/animation/move.js +9 -9
- package/es/graph/animation/animation/move.js.map +1 -1
- package/es/graph/animation/animation/update.js +1 -1
- package/es/graph/animation/animation/update.js.map +1 -1
- package/es/graph/animation/attribute.js +2 -2
- package/es/graph/animation/attribute.js.map +1 -1
- package/es/graph/attributes/helpers.js +8 -11
- package/es/graph/attributes/helpers.js.map +1 -1
- package/es/graph/attributes/transform.js +1 -1
- package/es/graph/attributes/transform.js.map +1 -1
- package/es/graph/element.js +1 -1
- package/es/graph/element.js.map +1 -1
- package/es/graph/layout/grid.js +1 -1
- package/es/graph/layout/grid.js.map +1 -1
- package/es/graph/mark/graphic.js +2 -2
- package/es/graph/mark/graphic.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interactions/brush-base.js +3 -5
- package/es/interactions/brush-base.js.map +1 -1
- package/es/interactions/view-navigation-base.js +3 -3
- package/es/interactions/view-navigation-base.js.map +1 -1
- package/es/interactions/view-roam.js +10 -10
- package/es/interactions/view-roam.js.map +1 -1
- package/es/interactions/view-scroll-mixin.js +1 -1
- package/es/interactions/view-scroll-mixin.js.map +1 -1
- package/es/interactions/view-zoom-mixin.js +2 -2
- package/es/interactions/view-zoom-mixin.js.map +1 -1
- package/es/parse/event.js +1 -1
- package/es/parse/event.js.map +1 -1
- package/es/parse/scale.js +4 -4
- package/es/parse/scale.js.map +1 -1
- package/es/parse/view.js +11 -10
- package/es/parse/view.js.map +1 -1
- package/es/view/View.js +12 -13
- package/es/view/View.js.map +1 -1
- package/es/view/animate.js +11 -11
- package/es/view/animate.js.map +1 -1
- package/es/view/mark.js +6 -10
- package/es/view/mark.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/player.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AASnE,qEAAgF;AAYhF,oCAAqD;AAErD,iDAA8C;AAC9C,iDAAqD;AACrD,6CAA0C;AAC1C,iEAA6D;AAC7D,mDAA6D;AAEtD,MAAM,kCAAkC,GAAG,CAChD,IAAW,EACX,KAAc,EACd,QAAuD,EAC3B,EAAE;;IAC9B,MAAM,WAAW,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,gBAAgB,CAAC;IACxD,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;AACxE,CAAC,CAAC;AAPW,QAAA,kCAAkC,sCAO7C;AAEK,MAAM,gCAAgC,GAAG,CAC9C,IAAW,EACX,KAAc,EACd,QAAqD,EAC3B,EAAE;;IAC5B,MAAM,WAAW,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,cAAc,CAAC;IACtD,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;AACxE,CAAC,CAAC;AAPW,QAAA,gCAAgC,oCAO3C;AAEF,MAAa,MAAO,SAAQ,qBAAS;IAOnC,YAAY,IAAW,EAAE,KAAkB;QACzC,KAAK,CAAC,IAAI,EAAE,qB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M,cAAc,GAAG,GAAG,EAAE;IACjC,iBAAO,CAAC,wBAAwB,CAC9B,kBAAU,CAAC,gBAAgB,EAC3B,CAAC,KAAiC,EAAE,EAAE,CAAC,IAAI,qCAAgB,CAAC,KAAK,CAAwB,CAC1F,CAAC;IACF,iBAAO,CAAC,wBAAwB,CAC9B,kBAAU,CAAC,cAAc,EACzB,CAAC,KAA+B,EAAE,EAAE,CAAC,IAAI,mCAAc,CAAC,KAAK,CAAwB,CACtF,CAAC;IAEF,iBAAO,CAAC,iBAAiB,CAAC,qBAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExD,IAAA,cAAK,EAAC,eAAM,EAAE,oBAAW,CAAC,CAAC;IAC3B,iBAAO,CAAC,mBAAmB,CAAC,4BAAY,CAAC,IAAI,EAAE,4BAAY,CAAC,CAAC;AAC/D,CAAC,CAAC;AAdW,QAAA,cAAc,kBAczB","file":"player.js","sourcesContent":["import { isArray, isString, merge, mixin } from '@visactor/vutils';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type {\n ContinuousPlayerAttributes,\n DiscretePlayerAttributes,\n IDiscretePlayer\n} from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\n// eslint-disable-next-line no-duplicate-imports\nimport { ContinuousPlayer, DiscretePlayer } from '@visactor/vrender-components';\nimport type {\n BaseSingleEncodeSpec,\n IData,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum, PlayerEnum } from '../graph';\nimport type { IPlayer, PlayerFilterValue, PlayerSpec, PlayerType } from '../types/component';\nimport { Component } from '../view/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { Factory } from '../core/factory';\nimport { PlayerFilter } from '../interactions/player-filter';\nimport { Filter, FilterMixin } from '../interactions/filter';\n\nexport const generateContinuousPlayerAttributes = (\n data: any[],\n theme?: ITheme,\n addition?: RecursivePartial<ContinuousPlayerAttributes>\n): ContinuousPlayerAttributes => {\n const playerTheme = theme?.components?.continuousPlayer;\n return merge({}, playerTheme, { data, dataIndex: 0 }, addition ?? {});\n};\n\nexport const generateDiscretePlayerAttributes = (\n data: any[],\n theme?: ITheme,\n addition?: RecursivePartial<DiscretePlayerAttributes>\n): DiscretePlayerAttributes => {\n const playerTheme = theme?.components?.discretePlayer;\n return merge({}, playerTheme, { data, dataIndex: 0 }, addition ?? {});\n};\n\nexport class Player extends Component implements IPlayer {\n static readonly componentType: string = ComponentEnum.player;\n protected declare spec: PlayerSpec;\n protected declare _filterValue: PlayerFilterValue;\n\n private _playerComponentType: keyof typeof PlayerEnum;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.player, group);\n this.spec.componentType = ComponentEnum.player;\n this.spec.playerType = 'auto';\n }\n\n protected parseAddition(spec: PlayerSpec) {\n super.parseAddition(spec);\n this.playerType(spec.playerType);\n this.source(spec.source);\n return this;\n }\n\n playerType(playerType: PlayerType) {\n this.spec.playerType = playerType;\n // clear legend type when spec is changed\n this._playerComponentType = null;\n this._prepareRejoin();\n this.commit();\n return this;\n }\n\n source(source: IData | string | any[] | Nil) {\n if (this.spec.source) {\n const lastSource = this.spec?.source;\n const lastSourceDataGrammar = isArray(lastSource)\n ? null\n : isString(lastSource)\n ? this.view.getDataById(lastSource)\n : lastSource;\n this.detach(lastSourceDataGrammar);\n }\n this.spec.source = source;\n const sourceDataGrammar = isArray(source) ? null : isString(source) ? this.view.getDataById(source) : source;\n this.attach(sourceDataGrammar);\n this.commit();\n return this;\n }\n\n play() {\n // FIXME: unite IDiscretePlayer and IContinuousPlayer interface in vis-component\n const datazoom = this.elements[0]?.getGraphicItem?.() as unknown as IDiscretePlayer;\n datazoom.play();\n return this;\n }\n\n pause() {\n // FIXME: unite IDiscretePlayer and IContinuousPlayer interface in vis-component\n const datazoom = this.elements[0]?.getGraphicItem?.() as unknown as IDiscretePlayer;\n datazoom.pause();\n return this;\n }\n\n backward() {\n // FIXME: unite IDiscretePlayer and IContinuousPlayer interface in vis-component\n const datazoom = this.elements[0]?.getGraphicItem?.() as unknown as IDiscretePlayer;\n datazoom.backward();\n return this;\n }\n\n forward() {\n // FIXME: unite IDiscretePlayer and IContinuousPlayer interface in vis-component\n const datazoom = this.elements[0]?.getGraphicItem?.() as unknown as IDiscretePlayer;\n datazoom.forward();\n return this;\n }\n\n addGraphicItem(attrs: any, groupKey?: string, newGraphicItem?: any) {\n // FIXME: vis-component should handle the situation when handlerStyle is not set\n const defaultAttributes = { slider: { handlerStyle: { size: 16 } } };\n const initialAttributes = merge(defaultAttributes, attrs);\n const graphicItem =\n newGraphicItem ??\n Factory.createGraphicComponent(this._getPlayerComponentType(), initialAttributes, {\n skipDefault: this.spec.skipTheme\n });\n return super.addGraphicItem(initialAttributes, groupKey, graphicItem);\n }\n\n protected _updateComponentEncoders() {\n const encoders = Object.assign({ update: {} }, this.spec.encode);\n const componentEncoders: StateEncodeSpec = Object.keys(encoders).reduce((res, state) => {\n const encoder = encoders[state];\n if (encoder) {\n res[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const theme = this.spec.skipTheme ? null : this.view.getCurrentTheme();\n const addition = invokeEncoder(encoder as BaseSingleEncodeSpec, datum, element, parameters);\n const source = this.spec.source;\n const sourceDataGrammar = isArray(source)\n ? null\n : isString(source)\n ? this.view.getDataById(source)\n : source;\n const sourceData = isArray(source) ? source : sourceDataGrammar?.getValue() ?? [];\n switch (this._getPlayerComponentType()) {\n case 'continuousPlayer':\n return generateContinuousPlayerAttributes(sourceData, theme, addition);\n case 'discretePlayer':\n return generateDiscretePlayerAttributes(sourceData, theme, addition);\n }\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n\n private _getPlayerComponentType() {\n if (this._playerComponentType) {\n return this._playerComponentType;\n }\n\n // compute legend component type when needed\n if (!this.spec.playerType || this.spec.playerType === 'auto') {\n // const scaleGrammar = isString(this.spec.scale) ? this.view.getScaleById(this.spec.scale) : this.spec.scale;\n // const scaleType = scaleGrammar?.getScaleType?.();\n // if (scaleType && isContinuous(scaleType)) {\n // const range: any[] = scaleGrammar.getScale().range();\n // if (parseColor(range?.[0])) {\n // this._legendComponentType = LegendEnum.colorLegend;\n // } else {\n // this._legendComponentType = LegendEnum.sizeLegend;\n // }\n // } else {\n // this._legendComponentType = LegendEnum.discreteLegend;\n // }\n this._playerComponentType = 'discretePlayer';\n } else {\n this._playerComponentType =\n this.spec.playerType === 'discrete'\n ? 'discretePlayer'\n : this.spec.playerType === 'continuous'\n ? 'continuousPlayer'\n : 'discretePlayer';\n }\n return this._playerComponentType;\n }\n}\n\nexport const registerPlayer = () => {\n Factory.registerGraphicComponent(\n PlayerEnum.continuousPlayer,\n (attrs: ContinuousPlayerAttributes) => new ContinuousPlayer(attrs) as unknown as IGraphic\n );\n Factory.registerGraphicComponent(\n PlayerEnum.discretePlayer,\n (attrs: DiscretePlayerAttributes) => new DiscretePlayer(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.player, Player);\n\n mixin(Filter, FilterMixin);\n Factory.registerInteraction(PlayerFilter.type, PlayerFilter);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/player.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AASnE,qEAAgF;AAYhF,oCAAqD;AAErD,iDAA8C;AAC9C,iDAAqD;AACrD,6CAA0C;AAC1C,iEAA6D;AAC7D,mDAA6D;AAEtD,MAAM,kCAAkC,GAAG,CAChD,IAAW,EACX,KAAc,EACd,QAAuD,EAC3B,EAAE;;IAC9B,MAAM,WAAW,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,gBAAgB,CAAC;IACxD,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;AACxE,CAAC,CAAC;AAPW,QAAA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AC,UAAU,KAAK,UAAU;oBACjC,CAAC,CAAC,gBAAgB;oBAClB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,YAAY;wBACvC,CAAC,CAAC,kBAAkB;wBACpB,CAAC,CAAC,gBAAgB,CAAC;SACxB;QACD,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;;AAjJH,wBAkJC;AAjJiB,oBAAa,GAAW,qBAAa,CAAC,MAAM,CAAC;AAmJxD,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,iBAAO,CAAC,wBAAwB,CAC9B,kBAAU,CAAC,gBAAgB,EAC3B,CAAC,KAAiC,EAAE,EAAE,CAAC,IAAI,qCAAgB,CAAC,KAAK,CAAwB,CAC1F,CAAC;IACF,iBAAO,CAAC,wBAAwB,CAC9B,kBAAU,CAAC,cAAc,EACzB,CAAC,KAA+B,EAAE,EAAE,CAAC,IAAI,mCAAc,CAAC,KAAK,CAAwB,CACtF,CAAC;IAEF,iBAAO,CAAC,iBAAiB,CAAC,qBAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExD,IAAA,cAAK,EAAC,eAAM,EAAE,oBAAW,CAAC,CAAC;IAC3B,iBAAO,CAAC,mBAAmB,CAAC,4BAAY,CAAC,IAAI,EAAE,4BAAY,CAAC,CAAC;AAC/D,CAAC,CAAC;AAdW,QAAA,cAAc,kBAczB","file":"player.js","sourcesContent":["import { isArray, isString, merge, mixin } from '@visactor/vutils';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type {\n ContinuousPlayerAttributes,\n DiscretePlayerAttributes,\n IDiscretePlayer\n} from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\n// eslint-disable-next-line no-duplicate-imports\nimport { ContinuousPlayer, DiscretePlayer } from '@visactor/vrender-components';\nimport type {\n BaseSingleEncodeSpec,\n IData,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum, PlayerEnum } from '../graph';\nimport type { IPlayer, PlayerFilterValue, PlayerSpec, PlayerType } from '../types/component';\nimport { Component } from '../view/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { Factory } from '../core/factory';\nimport { PlayerFilter } from '../interactions/player-filter';\nimport { Filter, FilterMixin } from '../interactions/filter';\n\nexport const generateContinuousPlayerAttributes = (\n data: any[],\n theme?: ITheme,\n addition?: RecursivePartial<ContinuousPlayerAttributes>\n): ContinuousPlayerAttributes => {\n const playerTheme = theme?.components?.continuousPlayer;\n return merge({}, playerTheme, { data, dataIndex: 0 }, addition ?? {});\n};\n\nexport const generateDiscretePlayerAttributes = (\n data: any[],\n theme?: ITheme,\n addition?: RecursivePartial<DiscretePlayerAttributes>\n): DiscretePlayerAttributes => {\n const playerTheme = theme?.components?.discretePlayer;\n return merge({}, playerTheme, { data, dataIndex: 0 }, addition ?? {});\n};\n\nexport class Player extends Component implements IPlayer {\n static readonly componentType: string = ComponentEnum.player;\n protected declare spec: PlayerSpec;\n protected declare _filterValue: PlayerFilterValue;\n\n private _playerComponentType: keyof typeof PlayerEnum;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.player, group);\n this.spec.componentType = ComponentEnum.player;\n this.spec.playerType = 'auto';\n }\n\n protected parseAddition(spec: PlayerSpec) {\n super.parseAddition(spec);\n this.playerType(spec.playerType);\n this.source(spec.source);\n return this;\n }\n\n playerType(playerType: PlayerType) {\n this.spec.playerType = playerType;\n // clear legend type when spec is changed\n this._playerComponentType = null;\n this._prepareRejoin();\n this.commit();\n return this;\n }\n\n source(source: IData | string | any[] | Nil) {\n if (this.spec.source) {\n const lastSource = this.spec?.source;\n const lastSourceDataGrammar = isArray(lastSource)\n ? null\n : isString(lastSource)\n ? this.view.getDataById(lastSource)\n : lastSource;\n this.detach(lastSourceDataGrammar);\n }\n this.spec.source = source;\n const sourceDataGrammar = isArray(source) ? null : isString(source) ? this.view.getDataById(source) : source;\n this.attach(sourceDataGrammar);\n this.commit();\n return this;\n }\n\n play() {\n // FIXME: unite IDiscretePlayer and IContinuousPlayer interface in vis-component\n const player = this.getGroupGraphicItem() as unknown as IDiscretePlayer;\n player.play();\n return this;\n }\n\n pause() {\n // FIXME: unite IDiscretePlayer and IContinuousPlayer interface in vis-component\n const player = this.getGroupGraphicItem() as unknown as IDiscretePlayer;\n player.pause();\n return this;\n }\n\n backward() {\n // FIXME: unite IDiscretePlayer and IContinuousPlayer interface in vis-component\n const player = this.getGroupGraphicItem() as unknown as IDiscretePlayer;\n player.backward();\n return this;\n }\n\n forward() {\n // FIXME: unite IDiscretePlayer and IContinuousPlayer interface in vis-component\n const player = this.getGroupGraphicItem() as unknown as IDiscretePlayer;\n player.forward();\n return this;\n }\n\n addGraphicItem(attrs: any, groupKey?: string, newGraphicItem?: any) {\n // FIXME: vis-component should handle the situation when handlerStyle is not set\n const defaultAttributes = { slider: { handlerStyle: { size: 16 } } };\n const initialAttributes = merge(defaultAttributes, attrs);\n const graphicItem =\n newGraphicItem ??\n Factory.createGraphicComponent(this._getPlayerComponentType(), initialAttributes, {\n skipDefault: this.spec.skipTheme\n });\n return super.addGraphicItem(initialAttributes, groupKey, graphicItem);\n }\n\n protected _updateComponentEncoders() {\n const encoders = Object.assign({ update: {} }, this.spec.encode);\n const componentEncoders: StateEncodeSpec = Object.keys(encoders).reduce((res, state) => {\n const encoder = encoders[state];\n if (encoder) {\n res[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const theme = this.spec.skipTheme ? null : this.view.getCurrentTheme();\n const addition = invokeEncoder(encoder as BaseSingleEncodeSpec, datum, element, parameters);\n const source = this.spec.source;\n const sourceDataGrammar = isArray(source)\n ? null\n : isString(source)\n ? this.view.getDataById(source)\n : source;\n const sourceData = isArray(source) ? source : sourceDataGrammar?.getValue() ?? [];\n switch (this._getPlayerComponentType()) {\n case 'continuousPlayer':\n return generateContinuousPlayerAttributes(sourceData, theme, addition);\n case 'discretePlayer':\n return generateDiscretePlayerAttributes(sourceData, theme, addition);\n }\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n\n private _getPlayerComponentType() {\n if (this._playerComponentType) {\n return this._playerComponentType;\n }\n\n // compute legend component type when needed\n if (!this.spec.playerType || this.spec.playerType === 'auto') {\n // const scaleGrammar = isString(this.spec.scale) ? this.view.getScaleById(this.spec.scale) : this.spec.scale;\n // const scaleType = scaleGrammar?.getScaleType?.();\n // if (scaleType && isContinuous(scaleType)) {\n // const range: any[] = scaleGrammar.getScale().range();\n // if (parseColor(range?.[0])) {\n // this._legendComponentType = LegendEnum.colorLegend;\n // } else {\n // this._legendComponentType = LegendEnum.sizeLegend;\n // }\n // } else {\n // this._legendComponentType = LegendEnum.discreteLegend;\n // }\n this._playerComponentType = 'discretePlayer';\n } else {\n this._playerComponentType =\n this.spec.playerType === 'discrete'\n ? 'discretePlayer'\n : this.spec.playerType === 'continuous'\n ? 'continuousPlayer'\n : 'discretePlayer';\n }\n return this._playerComponentType;\n }\n}\n\nexport const registerPlayer = () => {\n Factory.registerGraphicComponent(\n PlayerEnum.continuousPlayer,\n (attrs: ContinuousPlayerAttributes) => new ContinuousPlayer(attrs) as unknown as IGraphic\n );\n Factory.registerGraphicComponent(\n PlayerEnum.discretePlayer,\n (attrs: DiscretePlayerAttributes) => new DiscretePlayer(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.player, Player);\n\n mixin(Filter, FilterMixin);\n Factory.registerInteraction(PlayerFilter.type, PlayerFilter);\n};\n"]}
|
|
@@ -4,33 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.registerScrollbar = exports.Scrollbar = exports.generateScrollbarAttributes = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), vrender_components_1 = require("@visactor/vrender-components"), enums_1 = require("../graph/enums"), encode_1 = require("../graph/mark/encode"), util_1 = require("../parse/util"), factory_1 = require("../core/factory"), scale_1 = require("./scale"), scrollbar_filter_1 = require("../interactions/scrollbar-filter"), filter_1 = require("../interactions/filter")
|
|
8
|
-
|
|
9
|
-
function isValidDirection(direction) {
|
|
10
|
-
return "vertical" === direction || "horizontal" === direction;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function isValidPosition(position) {
|
|
14
|
-
return "top" === position || "bottom" === position || "left" === position || "right" === position;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function isHorizontalPosition(position) {
|
|
18
|
-
return "top" === position || "bottom" === position;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const generateScrollbarAttributes = (groupSize, direction, position, theme, addition) => {
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), vrender_components_1 = require("@visactor/vrender-components"), enums_1 = require("../graph/enums"), encode_1 = require("../graph/mark/encode"), util_1 = require("../parse/util"), factory_1 = require("../core/factory"), scale_1 = require("./scale"), scrollbar_filter_1 = require("../interactions/scrollbar-filter"), filter_1 = require("../interactions/filter"), vgrammar_util_1 = require("@visactor/vgrammar-util"), generateScrollbarAttributes = (groupSize, direction, position, theme, addition) => {
|
|
22
8
|
var _a, _b, _c, _d, _e;
|
|
23
9
|
const scrollbarTheme = null === (_a = null == theme ? void 0 : theme.components) || void 0 === _a ? void 0 : _a.scrollbar;
|
|
24
10
|
let finalDirection = "horizontal", finalPosition = "bottom";
|
|
25
|
-
isValidDirection(direction) ||
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
(0, vgrammar_util_1.isValidDirection)(direction) || (0, vgrammar_util_1.isValidPosition)(position) ? !(0,
|
|
12
|
+
vgrammar_util_1.isValidDirection)(direction) && (0, vgrammar_util_1.isValidPosition)(position) ? (finalDirection = (0,
|
|
13
|
+
vgrammar_util_1.isHorizontalPosition)(position) ? "horizontal" : "vertical", finalPosition = position) : (0,
|
|
14
|
+
vgrammar_util_1.isValidDirection)(direction) && !(0, vgrammar_util_1.isValidPosition)(position) ? (finalDirection = direction,
|
|
15
|
+
finalPosition = (0, vgrammar_util_1.isHorizontal)(direction) ? "bottom" : "right") : (finalDirection = direction,
|
|
16
|
+
finalPosition = (0, vgrammar_util_1.isHorizontal)(direction) && !(0, vgrammar_util_1.isHorizontalPosition)(position) ? "bottom" : (0,
|
|
17
|
+
vgrammar_util_1.isVertical)(direction) && (0, vgrammar_util_1.isHorizontalPosition)(position) ? "right" : position) : (finalDirection = "horizontal",
|
|
29
18
|
finalPosition = "bottom");
|
|
30
19
|
const attributes = {
|
|
31
20
|
direction: finalDirection
|
|
32
21
|
};
|
|
33
|
-
if (
|
|
22
|
+
if ((0, vgrammar_util_1.isHorizontal)(finalDirection)) {
|
|
34
23
|
const size = null !== (_c = null !== (_b = addition.height) && void 0 !== _b ? _b : null == scrollbarTheme ? void 0 : scrollbarTheme.height) && void 0 !== _c ? _c : 12;
|
|
35
24
|
"top" === finalPosition ? Object.assign(attributes, {
|
|
36
25
|
width: groupSize.width,
|
|
@@ -88,8 +77,8 @@ class Scrollbar extends scale_1.ScaleComponent {
|
|
|
88
77
|
return this.setFunctionSpec(position, "position");
|
|
89
78
|
}
|
|
90
79
|
setScrollStart(start) {
|
|
91
|
-
var _a
|
|
92
|
-
const scrollbar =
|
|
80
|
+
var _a;
|
|
81
|
+
const scrollbar = this.getGroupGraphicItem(), range = null === (_a = null == scrollbar ? void 0 : scrollbar.attribute) || void 0 === _a ? void 0 : _a.range;
|
|
93
82
|
if (scrollbar && range) {
|
|
94
83
|
const nextRange = [ start, range[1] - range[0] + start ];
|
|
95
84
|
scrollbar.setScrollRange(nextRange);
|
|
@@ -97,8 +86,7 @@ class Scrollbar extends scale_1.ScaleComponent {
|
|
|
97
86
|
return this;
|
|
98
87
|
}
|
|
99
88
|
getScrollRange() {
|
|
100
|
-
|
|
101
|
-
const scrollbar = null === (_b = null === (_a = this.elements[0]) || void 0 === _a ? void 0 : _a.getGraphicItem) || void 0 === _b ? void 0 : _b.call(_a);
|
|
89
|
+
const scrollbar = this.getGroupGraphicItem();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SAAS,CAAC,MAAM,mCAAI,gBAAgB,CAAC,UAAU,CAAC,MAAM,EAAE;6BAClF;4BACH,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;wBAC7D,OAAO,IAAA,mCAA2B,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBACjF,CAAC;iBACF,CAAC;aACH;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,IAAI,CAAC,SAAS,GAAG,iBAAiB,CAAC;IACrC,CAAC;;AAnGH,8BAoGC;AAnGiB,uBAAa,GAAW,qBAAa,CAAC,SAAS,CAAC;AAqG3D,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,iBAAO,CAAC,wBAAwB,CAC9B,qBAAa,CAAC,SAAS,EACvB,CAAC,KAA0B,EAAE,EAAE,CAAC,IAAI,8BAAkB,CAAC,KAAK,CAAwB,CACrF,CAAC;IAEF,iBAAO,CAAC,iBAAiB,CAAC,qBAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAE9D,IAAA,cAAK,EAAC,eAAM,EAAE,oBAAW,CAAC,CAAC;IAC3B,iBAAO,CAAC,mBAAmB,CAAC,kCAAe,CAAC,IAAI,EAAE,kCAAe,CAAC,CAAC;AACrE,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B","file":"scrollbar.js","sourcesContent":["import { isString, merge, mixin } from '@visactor/vutils';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type { Direction, OrientType, ScrollBarAttributes } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { ScrollBar as ScrollbarComponent } from '@visactor/vrender-components';\nimport type {\n BaseSingleEncodeSpec,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n MarkFunctionType,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum, GrammarMarkType } from '../graph/enums';\nimport type { IScrollbar, ScrollbarSpec } from '../types/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { invokeFunctionType } from '../parse/util';\nimport { Factory } from '../core/factory';\nimport { ScaleComponent } from './scale';\nimport { ScrollbarFilter } from '../interactions/scrollbar-filter';\nimport { Filter, FilterMixin } from '../interactions/filter';\n\nfunction isValidDirection(direction: Direction) {\n return direction === 'vertical' || direction === 'horizontal';\n}\n\nfunction isValidPosition(position: OrientType) {\n return position === 'top' || position === 'bottom' || position === 'left' || position === 'right';\n}\n\nfunction isHorizontalPosition(position: OrientType) {\n return position === 'top' || position === 'bottom';\n}\n\nexport const generateScrollbarAttributes = (\n groupSize: { width: number; height: number },\n direction?: Direction,\n position?: OrientType,\n theme?: ITheme,\n addition?: RecursivePartial<ScrollBarAttributes>\n): ScrollBarAttributes => {\n const scrollbarTheme = theme?.components?.scrollbar;\n\n let finalDirection: Direction = 'horizontal';\n let finalPosition: OrientType = 'bottom';\n if (!isValidDirection(direction) && !isValidPosition(position)) {\n finalDirection = 'horizontal';\n finalPosition = 'bottom';\n } else if (!isValidDirection(direction) && isValidPosition(position)) {\n finalDirection = isHorizontalPosition(position) ? 'horizontal' : 'vertical';\n finalPosition = position;\n } else if (isValidDirection(direction) && !isValidPosition(position)) {\n finalDirection = direction;\n finalPosition = direction === 'horizontal' ? 'bottom' : 'right';\n } else {\n finalDirection = direction;\n finalPosition =\n direction === 'horizontal' && !isHorizontalPosition(position)\n ? 'bottom'\n : direction === 'vertical' && isHorizontalPosition(position)\n ? 'right'\n : position;\n }\n\n const attributes: RecursivePartial<ScrollBarAttributes> = { direction: finalDirection };\n if (finalDirection === 'horizontal') {\n const size = addition.height ?? scrollbarTheme?.height ?? 12;\n\n // top or bottom\n if (finalPosition === 'top') {\n Object.assign(attributes, {\n width: groupSize.width,\n height: size,\n x: 0,\n y: 0\n });\n } else {\n Object.assign(attributes, {\n width: groupSize.width,\n height: size,\n x: 0,\n y: groupSize.height - size\n });\n }\n } else {\n const size = addition.width ?? scrollbarTheme?.width ?? 12;\n\n // left or right\n if (finalPosition === 'left') {\n Object.assign(attributes, {\n width: size,\n height: groupSize.height,\n x: 0,\n y: 0\n });\n } else {\n Object.assign(attributes, {\n width: size,\n height: groupSize.height,\n x: groupSize.width - size,\n y: 0\n });\n }\n }\n\n return merge({}, scrollbarTheme, attributes, addition ?? {});\n};\n\nexport class Scrollbar extends ScaleComponent implements IScrollbar {\n static readonly componentType: string = ComponentEnum.scrollbar;\n protected declare spec: ScrollbarSpec;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.scrollbar, group);\n this.spec.componentType = ComponentEnum.scrollbar;\n }\n\n protected parseAddition(spec: ScrollbarSpec) {\n super.parseAddition(spec);\n this.container(spec.container);\n this.direction(spec.direction);\n this.position(spec.position);\n return this;\n }\n\n container(container: IGroupMark | string | Nil): this {\n if (this.spec.container) {\n const prevContainer = isString(this.spec.container)\n ? this.view.getMarkById(this.spec.container)\n : this.spec.container;\n this.detach(prevContainer);\n }\n this.spec.container = container;\n if (container) {\n const nextContainer = isString(container) ? this.view.getMarkById(container) : container;\n this.attach(nextContainer);\n }\n this.commit();\n return this;\n }\n\n direction(direction: MarkFunctionType<Direction> | Nil) {\n return this.setFunctionSpec(direction, 'direction');\n }\n\n position(position: MarkFunctionType<OrientType> | Nil) {\n return this.setFunctionSpec(position, 'position');\n }\n\n setScrollStart(start: number) {\n const scrollbar = this.elements[0]?.getGraphicItem?.() as unknown as ScrollbarComponent;\n const range = scrollbar?.attribute?.range;\n if (scrollbar && range) {\n const nextRange: [number, number] = [start, range[1] - range[0] + start];\n scrollbar.setScrollRange(nextRange);\n }\n return this;\n }\n\n getScrollRange() {\n const scrollbar = this.elements[0]?.getGraphicItem?.() as unknown as ScrollbarComponent;\n\n if (scrollbar) {\n return scrollbar.getScrollRange();\n }\n }\n\n addGraphicItem(attrs: any, groupKey?: string) {\n const defaultAttributes = { range: [0, 1] };\n const initialAttributes = merge(defaultAttributes, attrs);\n const graphicItem = Factory.createGraphicComponent(ComponentEnum.scrollbar, initialAttributes, {\n skipDefault: this.spec.skipTheme\n });\n return super.addGraphicItem(initialAttributes, groupKey, graphicItem);\n }\n\n protected _updateComponentEncoders() {\n const encoders = Object.assign({ update: {} }, this.spec.encode);\n const componentEncoders: StateEncodeSpec = Object.keys(encoders).reduce((res, state) => {\n const encoder = encoders[state];\n if (encoder) {\n res[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const theme = this.spec.skipTheme ? null : this.view.getCurrentTheme();\n const direction = invokeFunctionType(this.spec.direction, parameters, datum, element);\n const position = invokeFunctionType(this.spec.position, parameters, datum, element);\n const addition = invokeEncoder(encoder as BaseSingleEncodeSpec, datum, element, parameters);\n const targetMark = this.spec.container\n ? isString(this.spec.container)\n ? this.view.getMarkById(this.spec.container)\n : this.spec.container\n : null;\n const groupMark = targetMark && targetMark.markType === GrammarMarkType.group ? targetMark : this.group;\n const groupGraphicItem = groupMark.getGroupGraphicItem();\n const size = groupGraphicItem\n ? {\n width: groupGraphicItem.attribute.width ?? groupGraphicItem.AABBBounds.width(),\n height: groupGraphicItem.attribute.height ?? groupGraphicItem.AABBBounds.height()\n }\n : { width: this.view.width(), height: this.view.height() };\n return generateScrollbarAttributes(size, direction, position, theme, addition);\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n}\n\nexport const registerScrollbar = () => {\n Factory.registerGraphicComponent(\n ComponentEnum.scrollbar,\n (attrs: ScrollBarAttributes) => new ScrollbarComponent(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.scrollbar, Scrollbar);\n\n mixin(Filter, FilterMixin);\n Factory.registerInteraction(ScrollbarFilter.type, ScrollbarFilter);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/scrollbar.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAI1D,qEA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AAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,iBAAO,CAAC,wBAAwB,CAC9B,qBAAa,CAAC,SAAS,EACvB,CAAC,KAA0B,EAAE,EAAE,CAAC,IAAI,8BAAkB,CAAC,KAAK,CAAwB,CACrF,CAAC;IAEF,iBAAO,CAAC,iBAAiB,CAAC,qBAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAE9D,IAAA,cAAK,EAAC,eAAM,EAAE,oBAAW,CAAC,CAAC;IAC3B,iBAAO,CAAC,mBAAmB,CAAC,kCAAe,CAAC,IAAI,EAAE,kCAAe,CAAC,CAAC;AACrE,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B","file":"scrollbar.js","sourcesContent":["import { isString, merge, mixin } from '@visactor/vutils';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type { Direction, OrientType, ScrollBarAttributes } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { ScrollBar as ScrollbarComponent } from '@visactor/vrender-components';\nimport type {\n BaseSingleEncodeSpec,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n MarkFunctionType,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum, GrammarMarkType } from '../graph/enums';\nimport type { IScrollbar, ScrollbarSpec } from '../types/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { invokeFunctionType } from '../parse/util';\nimport { Factory } from '../core/factory';\nimport { ScaleComponent } from './scale';\nimport { ScrollbarFilter } from '../interactions/scrollbar-filter';\nimport { Filter, FilterMixin } from '../interactions/filter';\nimport {\n isHorizontal,\n isHorizontalPosition,\n isValidDirection,\n isValidPosition,\n isVertical\n} from '@visactor/vgrammar-util';\n\nexport const generateScrollbarAttributes = (\n groupSize: { width: number; height: number },\n direction?: Direction,\n position?: OrientType,\n theme?: ITheme,\n addition?: RecursivePartial<ScrollBarAttributes>\n): ScrollBarAttributes => {\n const scrollbarTheme = theme?.components?.scrollbar;\n\n let finalDirection: Direction = 'horizontal';\n let finalPosition: OrientType = 'bottom';\n if (!isValidDirection(direction) && !isValidPosition(position)) {\n finalDirection = 'horizontal';\n finalPosition = 'bottom';\n } else if (!isValidDirection(direction) && isValidPosition(position)) {\n finalDirection = isHorizontalPosition(position) ? 'horizontal' : 'vertical';\n finalPosition = position;\n } else if (isValidDirection(direction) && !isValidPosition(position)) {\n finalDirection = direction;\n finalPosition = isHorizontal(direction) ? 'bottom' : 'right';\n } else {\n finalDirection = direction;\n finalPosition =\n isHorizontal(direction) && !isHorizontalPosition(position)\n ? 'bottom'\n : isVertical(direction) && isHorizontalPosition(position)\n ? 'right'\n : position;\n }\n\n const attributes: RecursivePartial<ScrollBarAttributes> = { direction: finalDirection };\n if (isHorizontal(finalDirection)) {\n const size = addition.height ?? scrollbarTheme?.height ?? 12;\n\n // top or bottom\n if (finalPosition === 'top') {\n Object.assign(attributes, {\n width: groupSize.width,\n height: size,\n x: 0,\n y: 0\n });\n } else {\n Object.assign(attributes, {\n width: groupSize.width,\n height: size,\n x: 0,\n y: groupSize.height - size\n });\n }\n } else {\n const size = addition.width ?? scrollbarTheme?.width ?? 12;\n\n // left or right\n if (finalPosition === 'left') {\n Object.assign(attributes, {\n width: size,\n height: groupSize.height,\n x: 0,\n y: 0\n });\n } else {\n Object.assign(attributes, {\n width: size,\n height: groupSize.height,\n x: groupSize.width - size,\n y: 0\n });\n }\n }\n\n return merge({}, scrollbarTheme, attributes, addition ?? {});\n};\n\nexport class Scrollbar extends ScaleComponent implements IScrollbar {\n static readonly componentType: string = ComponentEnum.scrollbar;\n protected declare spec: ScrollbarSpec;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.scrollbar, group);\n this.spec.componentType = ComponentEnum.scrollbar;\n }\n\n protected parseAddition(spec: ScrollbarSpec) {\n super.parseAddition(spec);\n this.container(spec.container);\n this.direction(spec.direction);\n this.position(spec.position);\n return this;\n }\n\n container(container: IGroupMark | string | Nil): this {\n if (this.spec.container) {\n const prevContainer = isString(this.spec.container)\n ? this.view.getMarkById(this.spec.container)\n : this.spec.container;\n this.detach(prevContainer);\n }\n this.spec.container = container;\n if (container) {\n const nextContainer = isString(container) ? this.view.getMarkById(container) : container;\n this.attach(nextContainer);\n }\n this.commit();\n return this;\n }\n\n direction(direction: MarkFunctionType<Direction> | Nil) {\n return this.setFunctionSpec(direction, 'direction');\n }\n\n position(position: MarkFunctionType<OrientType> | Nil) {\n return this.setFunctionSpec(position, 'position');\n }\n\n setScrollStart(start: number) {\n const scrollbar = this.getGroupGraphicItem() as unknown as ScrollbarComponent;\n const range = scrollbar?.attribute?.range;\n if (scrollbar && range) {\n const nextRange: [number, number] = [start, range[1] - range[0] + start];\n scrollbar.setScrollRange(nextRange);\n }\n return this;\n }\n\n getScrollRange() {\n const scrollbar = this.getGroupGraphicItem() as unknown as ScrollbarComponent;\n\n if (scrollbar) {\n return scrollbar.getScrollRange();\n }\n }\n\n addGraphicItem(attrs: any, groupKey?: string) {\n const defaultAttributes = { range: [0, 1] };\n const initialAttributes = merge(defaultAttributes, attrs);\n const graphicItem = Factory.createGraphicComponent(ComponentEnum.scrollbar, initialAttributes, {\n skipDefault: this.spec.skipTheme\n });\n return super.addGraphicItem(initialAttributes, groupKey, graphicItem);\n }\n\n protected _updateComponentEncoders() {\n const encoders = Object.assign({ update: {} }, this.spec.encode);\n const componentEncoders: StateEncodeSpec = Object.keys(encoders).reduce((res, state) => {\n const encoder = encoders[state];\n if (encoder) {\n res[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const theme = this.spec.skipTheme ? null : this.view.getCurrentTheme();\n const direction = invokeFunctionType(this.spec.direction, parameters, datum, element);\n const position = invokeFunctionType(this.spec.position, parameters, datum, element);\n const addition = invokeEncoder(encoder as BaseSingleEncodeSpec, datum, element, parameters);\n const targetMark = this.spec.container\n ? isString(this.spec.container)\n ? this.view.getMarkById(this.spec.container)\n : this.spec.container\n : null;\n const groupMark = targetMark && targetMark.markType === GrammarMarkType.group ? targetMark : this.group;\n const groupGraphicItem = groupMark.getGroupGraphicItem();\n const size = groupGraphicItem\n ? {\n width: groupGraphicItem.attribute.width ?? groupGraphicItem.AABBBounds.width(),\n height: groupGraphicItem.attribute.height ?? groupGraphicItem.AABBBounds.height()\n }\n : { width: this.view.width(), height: this.view.height() };\n return generateScrollbarAttributes(size, direction, position, theme, addition);\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n}\n\nexport const registerScrollbar = () => {\n Factory.registerGraphicComponent(\n ComponentEnum.scrollbar,\n (attrs: ScrollBarAttributes) => new ScrollbarComponent(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.scrollbar, Scrollbar);\n\n mixin(Filter, FilterMixin);\n Factory.registerInteraction(ScrollbarFilter.type, ScrollbarFilter);\n};\n"]}
|
package/cjs/component/slider.js
CHANGED
|
@@ -30,9 +30,7 @@ class Slider extends component_1.Component {
|
|
|
30
30
|
return this.setFunctionSpec(max, "max");
|
|
31
31
|
}
|
|
32
32
|
setStartEndValue(start, end) {
|
|
33
|
-
|
|
34
|
-
return (null === (_b = null === (_a = this.elements[0]) || void 0 === _a ? void 0 : _a.getGraphicItem) || void 0 === _b ? void 0 : _b.call(_a)).setValue([ start, end ]),
|
|
35
|
-
this;
|
|
33
|
+
return this.getGroupGraphicItem().setValue([ start, end ]), this;
|
|
36
34
|
}
|
|
37
35
|
_updateComponentEncoders() {
|
|
38
36
|
const encoders = Object.assign({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/slider.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AAIvD,qEAAyE;AAYzE,0CAA+C;AAE/C,iDAA8C;AAC9C,iDAAqD;AACrD,wCAAmD;AACnD,6CAA0C;AAC1C,iEAA6D;AAC7D,mDAA6D;AAEtD,MAAM,wBAAwB,GAAG,CACtC,GAAW,EACX,GAAW,EACX,KAAc,EACd,QAA6C,EAC3B,EAAE;;IACpB,MAAM,WAAW,GAAG,MAA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AC;oBAC7D,CAAC;iBACF,CAAC;aACH;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,IAAI,CAAC,SAAS,GAAG,iBAAiB,CAAC;IACrC,CAAC;;AAhDH,wBAiDC;AAhDiB,oBAAa,GAAW,qBAAa,CAAC,MAAM,CAAC;AAkDxD,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,iBAAO,CAAC,wBAAwB,CAC9B,qBAAa,CAAC,MAAM,EACpB,CAAC,KAAuB,EAAE,EAAE,CAAC,IAAI,2BAAe,CAAC,KAAK,CAAwB,CAC/E,CAAC;IAEF,iBAAO,CAAC,iBAAiB,CAAC,qBAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExD,IAAA,cAAK,EAAC,eAAM,EAAE,oBAAW,CAAC,CAAC;IAC3B,iBAAO,CAAC,mBAAmB,CAAC,4BAAY,CAAC,IAAI,EAAE,4BAAY,CAAC,CAAC;AAC/D,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB","file":"slider.js","sourcesContent":["import { isNil, merge, mixin } from '@visactor/vutils';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type { SliderAttributes } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { Slider as SliderComponent } from '@visactor/vrender-components';\nimport type {\n BaseSingleEncodeSpec,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n MarkFunctionType,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum } from '../graph/enums';\nimport type { ISlider, SliderSpec } from '../types/component';\nimport { Component } from '../view/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { invokeFunctionType } from '../parse/util';\nimport { Factory } from '../core/factory';\nimport { SliderFilter } from '../interactions/slider-filter';\nimport { Filter, FilterMixin } from '../interactions/filter';\n\nexport const generateSliderAttributes = (\n min: number,\n max: number,\n theme?: ITheme,\n addition?: RecursivePartial<SliderAttributes>\n): SliderAttributes => {\n const sliderTheme = theme?.components?.slider;\n return merge({}, sliderTheme, { min, max, value: [min, max] }, addition ?? {});\n};\n\nexport class Slider extends Component implements ISlider {\n static readonly componentType: string = ComponentEnum.slider;\n protected declare spec: SliderSpec;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.slider, group);\n this.spec.componentType = ComponentEnum.slider;\n }\n\n protected parseAddition(spec: SliderSpec) {\n super.parseAddition(spec);\n this.min(spec.min);\n this.max(spec.max);\n return this;\n }\n\n min(min: MarkFunctionType<number> | Nil) {\n return this.setFunctionSpec(min, 'min');\n }\n\n max(max: MarkFunctionType<number> | Nil) {\n return this.setFunctionSpec(max, 'max');\n }\n\n setStartEndValue(start?: number, end?: number) {\n const slider = this.getGroupGraphicItem() as unknown as SliderComponent;\n slider.setValue([start, end]);\n return this;\n }\n\n protected _updateComponentEncoders() {\n const encoders = Object.assign({ update: {} }, this.spec.encode);\n const componentEncoders: StateEncodeSpec = Object.keys(encoders).reduce((res, state) => {\n const encoder = encoders[state];\n if (encoder) {\n res[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const min = !isNil(this.spec.min) ? invokeFunctionType(this.spec.min, parameters, datum, element) : 0;\n const max = !isNil(this.spec.max) ? invokeFunctionType(this.spec.max, parameters, datum, element) : 1;\n const theme = this.spec.skipTheme ? null : this.view.getCurrentTheme();\n const addition = invokeEncoder(encoder as BaseSingleEncodeSpec, datum, element, parameters);\n return generateSliderAttributes(min, max, theme, addition);\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n}\n\nexport const registerSlider = () => {\n Factory.registerGraphicComponent(\n ComponentEnum.slider,\n (attrs: SliderAttributes) => new SliderComponent(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.slider, Slider);\n\n mixin(Filter, FilterMixin);\n Factory.registerInteraction(SliderFilter.type, SliderFilter);\n};\n"]}
|
package/cjs/glyph/boxplot.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.registerBarBoxplotGlyph = exports.barBoxplotScaleOut = exports.barBoxplotScaleIn = exports.registerBoxplotGlyph = exports.boxplotScaleOut = exports.boxplotScaleIn = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), factory_1 = require("../core/factory"), graphic_1 = require("../graph/mark/graphic"), scaleIn = computeCenter => (element, options, animationParameters) => {
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), factory_1 = require("../core/factory"), graphic_1 = require("../graph/mark/graphic"), vgrammar_util_1 = require("@visactor/vgrammar-util"), scaleIn = computeCenter => (element, options, animationParameters) => {
|
|
8
8
|
var _a, _b, _c;
|
|
9
9
|
const direction = null !== (_c = null !== (_a = element.getGraphicAttribute("direction", !1)) && void 0 !== _a ? _a : null === (_b = element.mark.getGlyphConfig()) || void 0 === _b ? void 0 : _b.direction) && void 0 !== _c ? _c : "vertical", center = computeCenter(element, direction, options);
|
|
10
10
|
if (!(0, vutils_1.isValidNumber)(center)) return {};
|
|
@@ -46,9 +46,9 @@ const vutils_1 = require("@visactor/vutils"), factory_1 = require("../core/facto
|
|
|
46
46
|
animateAttributes;
|
|
47
47
|
}, computeBoxplotCenter = (glyphElement, direction, options) => {
|
|
48
48
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
49
|
-
if ((0, vutils_1.isValidNumber)(
|
|
49
|
+
if (options && (0, vutils_1.isValidNumber)(options.center)) return options.center;
|
|
50
50
|
let median, max, min, q1, q3;
|
|
51
|
-
if (
|
|
51
|
+
if ((0, vgrammar_util_1.isHorizontal)(direction)) {
|
|
52
52
|
median = null === (_b = null === (_a = glyphElement.getGraphicAttribute("points", !1, "median")) || void 0 === _a ? void 0 : _a[0]) || void 0 === _b ? void 0 : _b.x,
|
|
53
53
|
max = null === (_d = null === (_c = glyphElement.getGraphicAttribute("points", !1, "max")) || void 0 === _c ? void 0 : _c[0]) || void 0 === _d ? void 0 : _d.x,
|
|
54
54
|
min = null === (_f = null === (_e = glyphElement.getGraphicAttribute("points", !1, "min")) || void 0 === _e ? void 0 : _e[0]) || void 0 === _f ? void 0 : _f.x;
|
|
@@ -74,7 +74,7 @@ const vutils_1 = require("@visactor/vutils"), factory_1 = require("../core/facto
|
|
|
74
74
|
min: {},
|
|
75
75
|
median: {}
|
|
76
76
|
}, x = null !== (_a = encodeValues.x) && void 0 !== _a ? _a : element.getGraphicAttribute("x", !1), y = null !== (_b = encodeValues.y) && void 0 !== _b ? _b : element.getGraphicAttribute("y", !1), width = null !== (_c = encodeValues.width) && void 0 !== _c ? _c : element.getGraphicAttribute("width", !1), height = null !== (_d = encodeValues.height) && void 0 !== _d ? _d : element.getGraphicAttribute("height", !1), boxWidth = null !== (_e = encodeValues.boxWidth) && void 0 !== _e ? _e : element.getGraphicAttribute("boxWidth", !1), boxHeight = null !== (_f = encodeValues.boxHeight) && void 0 !== _f ? _f : element.getGraphicAttribute("boxHeight", !1), ruleWidth = null !== (_g = encodeValues.ruleWidth) && void 0 !== _g ? _g : element.getGraphicAttribute("ruleWidth", !1), ruleHeight = null !== (_h = encodeValues.ruleHeight) && void 0 !== _h ? _h : element.getGraphicAttribute("ruleHeight", !1);
|
|
77
|
-
return
|
|
77
|
+
return config && (0, vgrammar_util_1.isHorizontal)(config.direction) ? ((0, vutils_1.isValidNumber)(boxHeight) ? (Object.assign(attributes.box, {
|
|
78
78
|
y: y - boxHeight / 2,
|
|
79
79
|
y1: y + boxHeight / 2
|
|
80
80
|
}), Object.assign(attributes.median, {
|
|
@@ -132,17 +132,20 @@ function registerBoxplotGlyph() {
|
|
|
132
132
|
max: "rule",
|
|
133
133
|
min: "rule",
|
|
134
134
|
median: "rule"
|
|
135
|
-
}).registerProgressiveChannels([ "x", "y", "q1", "q3", "min", "max", "median", "angle", "width", "height", "boxWidth", "boxHeight", "ruleWidth", "ruleHeight" ]).registerFunctionEncoder(encodeBoxplotSize).registerChannelEncoder("x", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
135
|
+
}).registerProgressiveChannels([ "x", "y", "q1", "q3", "min", "max", "median", "angle", "width", "height", "boxWidth", "boxHeight", "ruleWidth", "ruleHeight" ]).registerFunctionEncoder(encodeBoxplotSize).registerChannelEncoder("x", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
136
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? null : {
|
|
136
137
|
shaft: {
|
|
137
138
|
x: encodeValue,
|
|
138
139
|
x1: encodeValue
|
|
139
140
|
}
|
|
140
|
-
})).registerChannelEncoder("y", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
141
|
+
})).registerChannelEncoder("y", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
142
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
141
143
|
shaft: {
|
|
142
144
|
y: encodeValue,
|
|
143
145
|
y1: encodeValue
|
|
144
146
|
}
|
|
145
|
-
})).registerChannelEncoder("q1", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
147
|
+
} : null)).registerChannelEncoder("q1", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
148
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
146
149
|
box: {
|
|
147
150
|
x: encodeValue
|
|
148
151
|
}
|
|
@@ -150,7 +153,8 @@ function registerBoxplotGlyph() {
|
|
|
150
153
|
box: {
|
|
151
154
|
y: encodeValue
|
|
152
155
|
}
|
|
153
|
-
})).registerChannelEncoder("q3", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
156
|
+
})).registerChannelEncoder("q3", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
157
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
154
158
|
box: {
|
|
155
159
|
x1: encodeValue
|
|
156
160
|
}
|
|
@@ -158,7 +162,8 @@ function registerBoxplotGlyph() {
|
|
|
158
162
|
box: {
|
|
159
163
|
y1: encodeValue
|
|
160
164
|
}
|
|
161
|
-
})).registerChannelEncoder("min", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
165
|
+
})).registerChannelEncoder("min", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
166
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
162
167
|
shaft: {
|
|
163
168
|
x: encodeValue
|
|
164
169
|
},
|
|
@@ -176,7 +181,8 @@ function registerBoxplotGlyph() {
|
|
|
176
181
|
y1: encodeValue,
|
|
177
182
|
visible: !0
|
|
178
183
|
}
|
|
179
|
-
})).registerChannelEncoder("max", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
184
|
+
})).registerChannelEncoder("max", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
185
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
180
186
|
shaft: {
|
|
181
187
|
x1: encodeValue
|
|
182
188
|
},
|
|
@@ -194,7 +200,8 @@ function registerBoxplotGlyph() {
|
|
|
194
200
|
y1: encodeValue,
|
|
195
201
|
visible: !0
|
|
196
202
|
}
|
|
197
|
-
})).registerChannelEncoder("median", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
203
|
+
})).registerChannelEncoder("median", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
204
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
198
205
|
median: {
|
|
199
206
|
x: encodeValue,
|
|
200
207
|
x1: encodeValue,
|
|
@@ -208,7 +215,7 @@ function registerBoxplotGlyph() {
|
|
|
208
215
|
}
|
|
209
216
|
})).registerChannelEncoder("angle", ((channel, encodeValue, encodeValues, datum, element, config) => {
|
|
210
217
|
var _a;
|
|
211
|
-
const defaultAnchor =
|
|
218
|
+
const defaultAnchor = config && (0, vgrammar_util_1.isHorizontal)(config.direction) ? [ (encodeValues.min + encodeValues.max) / 2, encodeValues.y ] : [ encodeValues.x, (encodeValues.min + encodeValues.max) / 2 ], anchor = null !== (_a = encodeValues.anchor) && void 0 !== _a ? _a : defaultAnchor;
|
|
212
219
|
return {
|
|
213
220
|
shaft: {
|
|
214
221
|
angle: encodeValue,
|
|
@@ -242,7 +249,9 @@ function registerBoxplotGlyph() {
|
|
|
242
249
|
visible: !1
|
|
243
250
|
}
|
|
244
251
|
}))), factory_1.Factory.registerAnimationType("boxplotScaleIn", exports.boxplotScaleIn),
|
|
245
|
-
factory_1.Factory.registerAnimationType("boxplotScaleOut", exports.boxplotScaleOut)
|
|
252
|
+
factory_1.Factory.registerAnimationType("boxplotScaleOut", exports.boxplotScaleOut),
|
|
253
|
+
(0, graphic_1.registerGlyphGraphic)(), (0, graphic_1.registerRectGraphic)(), (0,
|
|
254
|
+
graphic_1.registerRuleGraphic)();
|
|
246
255
|
}
|
|
247
256
|
|
|
248
257
|
exports.boxplotScaleIn = scaleIn(computeBoxplotCenter), exports.boxplotScaleOut = scaleOut(computeBoxplotCenter),
|
|
@@ -252,7 +261,7 @@ const computeBarBoxplotCenter = (glyphElement, direction, options) => {
|
|
|
252
261
|
var _a, _b, _c, _d;
|
|
253
262
|
if ((0, vutils_1.isValidNumber)(null == options ? void 0 : options.center)) return options.center;
|
|
254
263
|
let median, max, min, q1, q3;
|
|
255
|
-
if (
|
|
264
|
+
if ((0, vgrammar_util_1.isHorizontal)(direction)) {
|
|
256
265
|
median = null === (_b = null === (_a = glyphElement.getGraphicAttribute("points", !1, "median")) || void 0 === _a ? void 0 : _a[0]) || void 0 === _b ? void 0 : _b.x;
|
|
257
266
|
const minMaxBoxWidth = glyphElement.getGraphicAttribute("width", !1, "minMaxBox"), minMaxBoxBoxX = glyphElement.getGraphicAttribute("x", !1, "minMaxBox");
|
|
258
267
|
min = minMaxBoxBoxX, max = minMaxBoxBoxX + minMaxBoxWidth;
|
|
@@ -276,7 +285,7 @@ const computeBarBoxplotCenter = (glyphElement, direction, options) => {
|
|
|
276
285
|
q1q3Box: {},
|
|
277
286
|
median: {}
|
|
278
287
|
}, x = null !== (_a = encodeValues.x) && void 0 !== _a ? _a : element.getGraphicAttribute("x", !1), y = null !== (_b = encodeValues.y) && void 0 !== _b ? _b : element.getGraphicAttribute("y", !1), width = null !== (_c = encodeValues.width) && void 0 !== _c ? _c : element.getGraphicAttribute("width", !1), minMaxWidth = null !== (_d = encodeValues.minMaxWidth) && void 0 !== _d ? _d : element.getGraphicAttribute("minMaxWidth", !1), q1q3Width = null !== (_e = encodeValues.q1q3Width) && void 0 !== _e ? _e : element.getGraphicAttribute("q1q3Width", !1), height = null !== (_f = encodeValues.height) && void 0 !== _f ? _f : element.getGraphicAttribute("height", !1), minMaxHeight = null !== (_g = encodeValues.minMaxHeight) && void 0 !== _g ? _g : element.getGraphicAttribute("minMaxHeight", !1), q1q3Height = null !== (_h = encodeValues.q1q3Height) && void 0 !== _h ? _h : element.getGraphicAttribute("q1q3Height", !1);
|
|
279
|
-
return
|
|
288
|
+
return config && (0, vgrammar_util_1.isHorizontal)(config.direction) ? ((0, vutils_1.isValidNumber)(minMaxHeight) ? Object.assign(attributes.minMaxBox, {
|
|
280
289
|
y: y - minMaxHeight / 2,
|
|
281
290
|
y1: y + minMaxHeight / 2
|
|
282
291
|
}) : Object.assign(attributes.minMaxBox, {
|
|
@@ -320,7 +329,8 @@ function registerBarBoxplotGlyph() {
|
|
|
320
329
|
minMaxBox: "rect",
|
|
321
330
|
q1q3Box: "rect",
|
|
322
331
|
median: "rule"
|
|
323
|
-
}).registerProgressiveChannels([ "x", "y", "q1", "q3", "min", "max", "median", "angle", "width", "height", "minMaxWidth", "q1q3Width", "minMaxHeight", "q1q3Height" ]).registerFunctionEncoder(encodeBarBoxplotSize).registerChannelEncoder("q1", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
332
|
+
}).registerProgressiveChannels([ "x", "y", "q1", "q3", "min", "max", "median", "angle", "width", "height", "minMaxWidth", "q1q3Width", "minMaxHeight", "q1q3Height" ]).registerFunctionEncoder(encodeBarBoxplotSize).registerChannelEncoder("q1", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
333
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
324
334
|
q1q3Box: {
|
|
325
335
|
x: encodeValue
|
|
326
336
|
}
|
|
@@ -328,7 +338,8 @@ function registerBarBoxplotGlyph() {
|
|
|
328
338
|
q1q3Box: {
|
|
329
339
|
y: encodeValue
|
|
330
340
|
}
|
|
331
|
-
})).registerChannelEncoder("q3", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
341
|
+
})).registerChannelEncoder("q3", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
342
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
332
343
|
q1q3Box: {
|
|
333
344
|
x1: encodeValue
|
|
334
345
|
}
|
|
@@ -336,7 +347,8 @@ function registerBarBoxplotGlyph() {
|
|
|
336
347
|
q1q3Box: {
|
|
337
348
|
y1: encodeValue
|
|
338
349
|
}
|
|
339
|
-
})).registerChannelEncoder("min", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
350
|
+
})).registerChannelEncoder("min", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
351
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
340
352
|
minMaxBox: {
|
|
341
353
|
x: encodeValue
|
|
342
354
|
}
|
|
@@ -344,7 +356,8 @@ function registerBarBoxplotGlyph() {
|
|
|
344
356
|
minMaxBox: {
|
|
345
357
|
y: encodeValue
|
|
346
358
|
}
|
|
347
|
-
})).registerChannelEncoder("max", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
359
|
+
})).registerChannelEncoder("max", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
360
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
348
361
|
minMaxBox: {
|
|
349
362
|
x1: encodeValue
|
|
350
363
|
}
|
|
@@ -352,7 +365,8 @@ function registerBarBoxplotGlyph() {
|
|
|
352
365
|
minMaxBox: {
|
|
353
366
|
y1: encodeValue
|
|
354
367
|
}
|
|
355
|
-
})).registerChannelEncoder("median", ((channel, encodeValue, encodeValues, datum, element, config) =>
|
|
368
|
+
})).registerChannelEncoder("median", ((channel, encodeValue, encodeValues, datum, element, config) => config && (0,
|
|
369
|
+
vgrammar_util_1.isHorizontal)(config.direction) ? {
|
|
356
370
|
median: {
|
|
357
371
|
x: encodeValue,
|
|
358
372
|
x1: encodeValue,
|