@visactor/vgrammar-core 0.14.0-alpha.0 → 0.14.0-alpha.2

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.
Files changed (195) hide show
  1. package/cjs/component/axis.d.ts +0 -2
  2. package/cjs/component/axis.js +1 -15
  3. package/cjs/component/axis.js.map +1 -1
  4. package/cjs/component/grid.d.ts +0 -2
  5. package/cjs/component/grid.js +1 -15
  6. package/cjs/component/grid.js.map +1 -1
  7. package/cjs/component/index.d.ts +2 -2
  8. package/cjs/component/index.js +1 -21
  9. package/cjs/component/index.js.map +1 -1
  10. package/cjs/core/factory.d.ts +1 -8
  11. package/cjs/core/factory.js +1 -8
  12. package/cjs/core/factory.js.map +1 -1
  13. package/cjs/glyph/boxplot.js +5 -5
  14. package/cjs/glyph/boxplot.js.map +1 -1
  15. package/cjs/glyph/link-path.js +2 -2
  16. package/cjs/glyph/link-path.js.map +1 -1
  17. package/cjs/glyph/ripple.js +2 -3
  18. package/cjs/glyph/ripple.js.map +1 -1
  19. package/cjs/glyph/tree-path.js +2 -2
  20. package/cjs/glyph/tree-path.js.map +1 -1
  21. package/cjs/glyph/violin.js +4 -4
  22. package/cjs/glyph/violin.js.map +1 -1
  23. package/cjs/glyph/wave.js +2 -3
  24. package/cjs/glyph/wave.js.map +1 -1
  25. package/cjs/graph/animation/animation/fade.js +4 -4
  26. package/cjs/graph/animation/animation/fade.js.map +1 -1
  27. package/cjs/graph/animation/animation/grow-cartesian.js +14 -14
  28. package/cjs/graph/animation/animation/grow-cartesian.js.map +1 -1
  29. package/cjs/graph/animation/animation/grow-interval.js +9 -9
  30. package/cjs/graph/animation/animation/grow-interval.js.map +1 -1
  31. package/cjs/graph/animation/animation/grow-points.js +9 -9
  32. package/cjs/graph/animation/animation/grow-points.js.map +1 -1
  33. package/cjs/graph/animation/animation/grow-polar.js +24 -24
  34. package/cjs/graph/animation/animation/grow-polar.js.map +1 -1
  35. package/cjs/graph/animation/animation/move.js +6 -6
  36. package/cjs/graph/animation/animation/move.js.map +1 -1
  37. package/cjs/graph/animation/animation/rotate.js +5 -5
  38. package/cjs/graph/animation/animation/rotate.js.map +1 -1
  39. package/cjs/graph/animation/animation/scale.js +5 -5
  40. package/cjs/graph/animation/animation/scale.js.map +1 -1
  41. package/cjs/graph/animation/animation/update.js +2 -2
  42. package/cjs/graph/animation/animation/update.js.map +1 -1
  43. package/cjs/graph/animation/animator.js +6 -1
  44. package/cjs/graph/animation/animator.js.map +1 -1
  45. package/cjs/graph/attributes/line.js.map +1 -1
  46. package/cjs/graph/canvas-renderer.d.ts +1 -1
  47. package/cjs/graph/canvas-renderer.js +4 -4
  48. package/cjs/graph/canvas-renderer.js.map +1 -1
  49. package/cjs/graph/element.d.ts +2 -0
  50. package/cjs/graph/element.js +14 -7
  51. package/cjs/graph/element.js.map +1 -1
  52. package/cjs/graph/glyph-element.js +2 -3
  53. package/cjs/graph/glyph-element.js.map +1 -1
  54. package/cjs/graph/layout/layout.d.ts +0 -1
  55. package/cjs/graph/layout/layout.js +2 -8
  56. package/cjs/graph/layout/layout.js.map +1 -1
  57. package/cjs/graph/mark/graphic.js +8 -14
  58. package/cjs/graph/mark/graphic.js.map +1 -1
  59. package/cjs/graph/util/element.d.ts +2 -0
  60. package/cjs/graph/util/element.js +10 -0
  61. package/cjs/graph/util/element.js.map +1 -0
  62. package/cjs/graph/util/point.js +26 -10
  63. package/cjs/graph/util/point.js.map +1 -1
  64. package/cjs/index.d.ts +1 -6
  65. package/cjs/index.js +2 -51
  66. package/cjs/index.js.map +1 -1
  67. package/cjs/parse/event.d.ts +2 -0
  68. package/cjs/parse/event.js +10 -4
  69. package/cjs/parse/event.js.map +1 -1
  70. package/cjs/types/animate.d.ts +1 -0
  71. package/cjs/types/animate.js.map +1 -1
  72. package/cjs/types/element.d.ts +5 -1
  73. package/cjs/types/element.js.map +1 -1
  74. package/cjs/types/renderer.d.ts +1 -6
  75. package/cjs/types/renderer.js.map +1 -1
  76. package/cjs/view/View.d.ts +4 -2
  77. package/cjs/view/View.js +76 -21
  78. package/cjs/view/View.js.map +1 -1
  79. package/cjs/view/constants.d.ts +0 -2
  80. package/cjs/view/constants.js +2 -3
  81. package/cjs/view/constants.js.map +1 -1
  82. package/cjs/view/events.d.ts +1 -0
  83. package/cjs/view/events.js +17 -3
  84. package/cjs/view/events.js.map +1 -1
  85. package/cjs/view/glyph.d.ts +0 -4
  86. package/cjs/view/glyph.js +3 -12
  87. package/cjs/view/glyph.js.map +1 -1
  88. package/cjs/view/grammar-record.js +2 -3
  89. package/cjs/view/grammar-record.js.map +1 -1
  90. package/cjs/view/group.js +3 -3
  91. package/cjs/view/group.js.map +1 -1
  92. package/cjs/view/mark.d.ts +0 -2
  93. package/cjs/view/mark.js +16 -15
  94. package/cjs/view/mark.js.map +1 -1
  95. package/es/component/axis.d.ts +0 -2
  96. package/es/component/axis.js +0 -10
  97. package/es/component/axis.js.map +1 -1
  98. package/es/component/grid.d.ts +0 -2
  99. package/es/component/grid.js +0 -10
  100. package/es/component/grid.js.map +1 -1
  101. package/es/component/index.d.ts +2 -2
  102. package/es/component/index.js +2 -2
  103. package/es/component/index.js.map +1 -1
  104. package/es/core/factory.d.ts +1 -8
  105. package/es/core/factory.js +1 -8
  106. package/es/core/factory.js.map +1 -1
  107. package/es/glyph/boxplot.js +2 -4
  108. package/es/glyph/boxplot.js.map +1 -1
  109. package/es/glyph/link-path.js +2 -4
  110. package/es/glyph/link-path.js.map +1 -1
  111. package/es/glyph/ripple.js +1 -3
  112. package/es/glyph/ripple.js.map +1 -1
  113. package/es/glyph/tree-path.js +2 -4
  114. package/es/glyph/tree-path.js.map +1 -1
  115. package/es/glyph/violin.js +2 -4
  116. package/es/glyph/violin.js.map +1 -1
  117. package/es/glyph/wave.js +1 -3
  118. package/es/glyph/wave.js.map +1 -1
  119. package/es/graph/animation/animation/fade.js +4 -4
  120. package/es/graph/animation/animation/fade.js.map +1 -1
  121. package/es/graph/animation/animation/grow-cartesian.js +14 -14
  122. package/es/graph/animation/animation/grow-cartesian.js.map +1 -1
  123. package/es/graph/animation/animation/grow-interval.js +9 -9
  124. package/es/graph/animation/animation/grow-interval.js.map +1 -1
  125. package/es/graph/animation/animation/grow-points.js +9 -9
  126. package/es/graph/animation/animation/grow-points.js.map +1 -1
  127. package/es/graph/animation/animation/grow-polar.js +24 -24
  128. package/es/graph/animation/animation/grow-polar.js.map +1 -1
  129. package/es/graph/animation/animation/move.js +6 -6
  130. package/es/graph/animation/animation/move.js.map +1 -1
  131. package/es/graph/animation/animation/rotate.js +4 -4
  132. package/es/graph/animation/animation/rotate.js.map +1 -1
  133. package/es/graph/animation/animation/scale.js +5 -5
  134. package/es/graph/animation/animation/scale.js.map +1 -1
  135. package/es/graph/animation/animation/update.js +3 -1
  136. package/es/graph/animation/animation/update.js.map +1 -1
  137. package/es/graph/animation/animator.js +6 -1
  138. package/es/graph/animation/animator.js.map +1 -1
  139. package/es/graph/attributes/line.js.map +1 -1
  140. package/es/graph/canvas-renderer.d.ts +1 -1
  141. package/es/graph/canvas-renderer.js +5 -5
  142. package/es/graph/canvas-renderer.js.map +1 -1
  143. package/es/graph/element.d.ts +2 -0
  144. package/es/graph/element.js +14 -5
  145. package/es/graph/element.js.map +1 -1
  146. package/es/graph/glyph-element.js +4 -2
  147. package/es/graph/glyph-element.js.map +1 -1
  148. package/es/graph/layout/layout.d.ts +0 -1
  149. package/es/graph/layout/layout.js +0 -6
  150. package/es/graph/layout/layout.js.map +1 -1
  151. package/es/graph/mark/graphic.js +7 -13
  152. package/es/graph/mark/graphic.js.map +1 -1
  153. package/es/graph/util/element.d.ts +2 -0
  154. package/es/graph/util/element.js +8 -0
  155. package/es/graph/util/element.js.map +1 -0
  156. package/es/graph/util/point.js +26 -10
  157. package/es/graph/util/point.js.map +1 -1
  158. package/es/index.d.ts +1 -6
  159. package/es/index.js +1 -19
  160. package/es/index.js.map +1 -1
  161. package/es/parse/event.d.ts +2 -0
  162. package/es/parse/event.js +7 -3
  163. package/es/parse/event.js.map +1 -1
  164. package/es/types/animate.d.ts +1 -0
  165. package/es/types/animate.js.map +1 -1
  166. package/es/types/element.d.ts +5 -1
  167. package/es/types/element.js.map +1 -1
  168. package/es/types/renderer.d.ts +1 -6
  169. package/es/types/renderer.js.map +1 -1
  170. package/es/view/View.d.ts +4 -2
  171. package/es/view/View.js +82 -20
  172. package/es/view/View.js.map +1 -1
  173. package/es/view/constants.d.ts +0 -2
  174. package/es/view/constants.js +0 -4
  175. package/es/view/constants.js.map +1 -1
  176. package/es/view/events.d.ts +1 -0
  177. package/es/view/events.js +15 -1
  178. package/es/view/events.js.map +1 -1
  179. package/es/view/glyph.d.ts +0 -4
  180. package/es/view/glyph.js +0 -11
  181. package/es/view/glyph.js.map +1 -1
  182. package/es/view/grammar-record.js +2 -3
  183. package/es/view/grammar-record.js.map +1 -1
  184. package/es/view/group.js +4 -2
  185. package/es/view/group.js.map +1 -1
  186. package/es/view/mark.d.ts +0 -2
  187. package/es/view/mark.js +16 -16
  188. package/es/view/mark.js.map +1 -1
  189. package/package.json +12 -12
  190. package/cjs/view/view-event-mixin.d.ts +0 -1
  191. package/cjs/view/view-event-mixin.js +0 -92
  192. package/cjs/view/view-event-mixin.js.map +0 -1
  193. package/es/view/view-event-mixin.d.ts +0 -1
  194. package/es/view/view-event-mixin.js +0 -90
  195. package/es/view/view-event-mixin.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { IGraphic, ACustomAnimate, EasingType } from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { MarkFunctionCallback, MarkFunctionType } from './mark';\nimport type { IMark } from './grammar';\nimport type { IElement } from './element';\nimport type { FunctionCallback } from './signal';\n\nexport type TypeAnimation<T extends IElement> = (\n element: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IClipAnimationOptions {\n clipDimension?: 'x' | 'y' | 'auto' | 'default';\n}\n\nexport interface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nexport interface IGrowPointsAnimationOptions {\n orient?: 'positive' | 'negative';\n}\n\nexport interface IGrowPointsOverallAnimationOptions extends IGrowPointsAnimationOptions {\n center?: IPointLike;\n}\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n}\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\n/** VGrammar 层提供的图元text上的图形属性,现在暂时会和VRender不一致 */\nexport interface TextItemAttributes {\n fontSize?: number;\n lineHeight?: number;\n font?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string | number;\n lineBreak?: string;\n text?: string | string[];\n limit?: number;\n align?: string;\n baseline?: string;\n ellipsis?: string | boolean;\n dir?: string;\n}\n\n/** animation */\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n\n/**\n * state动画,暂时只支持简单配置\n */\nexport interface IStateAnimationConfig {\n duration?: number;\n easing?: EasingType;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n duration?: MarkFunctionValueType<number>;\n oneByOne?: MarkFunctionValueType<boolean | number>;\n startTime?: MarkFunctionValueType<number>;\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IElement, elementB: IElement, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\nexport interface IAnimationTimeSlice {\n effects: IAnimationEffect | IAnimationEffect[];\n duration?: MarkFunctionValueType<number>;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IElement,\n parameters: IAnimationParameters\n) => boolean | void;\n\n// TODO: fix ACustomAnimate<any>\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n}\n\n/**\n * Animation timeline should be parsed into animation units,\n * which record all necessary configs for animator to execute animation.\n *\n * animation unit time:\n * |<--initialDelay-->| |<--loopDelay--><--Slices--><--looDelayAfter-->| |<--loopDuration-->|\n * |<-----------------loopDuration--------------->|\n */\nexport interface IAnimationUnit {\n /**\n * initial delay time before any animation loop\n */\n initialDelay: number;\n /**\n * total time for one animation loop\n */\n loopDuration: number;\n /**\n * delay time before time slices\n */\n loopDelay: number;\n /**\n * delay time after time slices\n */\n loopDelayAfter: number;\n /**\n * animating time in one animation loop\n */\n loopAnimateDuration: number;\n loopCount: number;\n totalTime: number;\n timeSlices: IAnimationTimeSlice[];\n}\n\nexport interface IAnimationRecord {\n start: IGraphic;\n end: IGraphic;\n changes: any[];\n}\n\nexport interface IAnimationParameters {\n width: number;\n height: number;\n mark: IMark;\n group: IMark | null;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\nexport interface IParsedAnimationConfig {\n state: string;\n timeline: IAnimationTimeline;\n originConfig: IAnimationConfig;\n id: string;\n}\n\nexport interface IParsedAnimationAttrs {\n from?: any;\n to?: any;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: any;\n}\n\n// animate structure\n\nexport interface IAnimatorOptions {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n}\n\nexport interface IAnimator {\n id: number;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean;\n\n /** execute animation */\n animate: (animationParameters: IAnimationParameters, parameters: any) => this;\n /** set animation callback */\n callback: (callbackFunction: (...args: any[]) => void) => this;\n\n // animation control\n stop: (stopState?: 'start' | 'end', invokeCallback?: boolean) => this;\n pause: () => this;\n resume: () => this;\n\n /** set additional initial animation delay */\n startAt: (startTime: number) => this;\n /** get total animation execution time */\n getTotalAnimationTime: () => number;\n\n getEndAttributes: () => Record<string, any>;\n}\n\nexport interface IAnimateArranger {\n // animation control api\n parallel: (arranger: IAnimateArranger) => this;\n after: (arranger: IAnimateArranger) => this;\n\n // internal properties\n afterArranger: IAnimateArranger;\n parallelArrangers: IAnimateArranger[];\n animators: IAnimator[];\n totalTime: number;\n startTime: number;\n endTime: number;\n arrangeTime: () => void;\n}\n\nexport interface IBaseAnimate {\n // animation control\n stop: () => this;\n pause: () => this;\n resume: () => this;\n\n // internal animation process api\n animate: () => this;\n enable: () => this;\n disable: () => this;\n enableAnimationState: (state: string | string[]) => this;\n disableAnimationState: (state: string | string[]) => this;\n isAnimating: () => boolean;\n\n release: () => void;\n}\n\nexport interface IViewAnimate extends IBaseAnimate {\n animateAddition: (mark: IMark) => this;\n}\n\nexport interface IAnimate extends IBaseAnimate {\n mark: IMark;\n\n // additional animation control\n run: (config: IAnimationConfig | IAnimationConfig[]) => IAnimateArranger;\n runAnimationByState: (animationState: string) => IAnimateArranger;\n stopAnimationByState: (animationState: string) => this;\n pauseAnimationByState: (animationState: string) => this;\n resumeAnimationByState: (animationState: string) => this;\n reverse: () => this;\n restart: () => this;\n record: () => this;\n recordEnd: () => this;\n\n // internal animation process api\n getAnimationConfigs: (animationState: string) => IParsedAnimationConfig[];\n updateConfig: (config: Record<string, IAnimationConfig | IAnimationConfig[]>) => void;\n updateState: (state: MarkFunctionType<string> | null) => void;\n isElementAnimating: (element: IElement) => boolean;\n getAnimatorCount: () => number;\n getElementAnimators: (element: IElement | IElement[], animationState?: string) => IAnimator[];\n release: () => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/types/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { IGraphic, ACustomAnimate, EasingType } from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { MarkFunctionCallback, MarkFunctionType } from './mark';\nimport type { IMark } from './grammar';\nimport type { IElement } from './element';\nimport type { FunctionCallback } from './signal';\n\nexport type TypeAnimation<T extends IElement> = (\n element: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IClipAnimationOptions {\n clipDimension?: 'x' | 'y' | 'auto' | 'default';\n}\n\nexport interface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nexport interface IGrowPointsAnimationOptions {\n orient?: 'positive' | 'negative';\n}\n\nexport interface IGrowPointsOverallAnimationOptions extends IGrowPointsAnimationOptions {\n center?: IPointLike;\n}\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\n}\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\n/** VGrammar 层提供的图元text上的图形属性,现在暂时会和VRender不一致 */\nexport interface TextItemAttributes {\n fontSize?: number;\n lineHeight?: number;\n font?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string | number;\n lineBreak?: string;\n text?: string | string[];\n limit?: number;\n align?: string;\n baseline?: string;\n ellipsis?: string | boolean;\n dir?: string;\n}\n\n/** animation */\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n\n/**\n * state动画,暂时只支持简单配置\n */\nexport interface IStateAnimationConfig {\n duration?: number;\n easing?: EasingType;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n duration?: MarkFunctionValueType<number>;\n oneByOne?: MarkFunctionValueType<boolean | number>;\n startTime?: MarkFunctionValueType<number>;\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IElement, elementB: IElement, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\nexport interface IAnimationTimeSlice {\n effects: IAnimationEffect | IAnimationEffect[];\n duration?: MarkFunctionValueType<number>;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IElement,\n parameters: IAnimationParameters\n) => boolean | void;\n\n// TODO: fix ACustomAnimate<any>\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n}\n\n/**\n * Animation timeline should be parsed into animation units,\n * which record all necessary configs for animator to execute animation.\n *\n * animation unit time:\n * |<--initialDelay-->| |<--loopDelay--><--Slices--><--looDelayAfter-->| |<--loopDuration-->|\n * |<-----------------loopDuration--------------->|\n */\nexport interface IAnimationUnit {\n /**\n * initial delay time before any animation loop\n */\n initialDelay: number;\n /**\n * total time for one animation loop\n */\n loopDuration: number;\n /**\n * delay time before time slices\n */\n loopDelay: number;\n /**\n * delay time after time slices\n */\n loopDelayAfter: number;\n /**\n * animating time in one animation loop\n */\n loopAnimateDuration: number;\n loopCount: number;\n totalTime: number;\n timeSlices: IAnimationTimeSlice[];\n}\n\nexport interface IAnimationRecord {\n start: IGraphic;\n end: IGraphic;\n changes: any[];\n}\n\nexport interface IAnimationParameters {\n width: number;\n height: number;\n mark: IMark;\n group: IMark | null;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\nexport interface IParsedAnimationConfig {\n state: string;\n timeline: IAnimationTimeline;\n originConfig: IAnimationConfig;\n id: string;\n}\n\nexport interface IParsedAnimationAttrs {\n from?: any;\n to?: any;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: any;\n}\n\n// animate structure\n\nexport interface IAnimatorOptions {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n}\n\nexport interface IAnimator {\n id: number;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean;\n\n /** execute animation */\n animate: (animationParameters: IAnimationParameters, parameters: any) => this;\n /** set animation callback */\n callback: (callbackFunction: (...args: any[]) => void) => this;\n\n // animation control\n stop: (stopState?: 'start' | 'end', invokeCallback?: boolean) => this;\n pause: () => this;\n resume: () => this;\n\n /** set additional initial animation delay */\n startAt: (startTime: number) => this;\n /** get total animation execution time */\n getTotalAnimationTime: () => number;\n\n getEndAttributes: () => Record<string, any>;\n}\n\nexport interface IAnimateArranger {\n // animation control api\n parallel: (arranger: IAnimateArranger) => this;\n after: (arranger: IAnimateArranger) => this;\n\n // internal properties\n afterArranger: IAnimateArranger;\n parallelArrangers: IAnimateArranger[];\n animators: IAnimator[];\n totalTime: number;\n startTime: number;\n endTime: number;\n arrangeTime: () => void;\n}\n\nexport interface IBaseAnimate {\n // animation control\n stop: () => this;\n pause: () => this;\n resume: () => this;\n\n // internal animation process api\n animate: () => this;\n enable: () => this;\n disable: () => this;\n enableAnimationState: (state: string | string[]) => this;\n disableAnimationState: (state: string | string[]) => this;\n isAnimating: () => boolean;\n\n release: () => void;\n}\n\nexport interface IViewAnimate extends IBaseAnimate {\n animateAddition: (mark: IMark) => this;\n}\n\nexport interface IAnimate extends IBaseAnimate {\n mark: IMark;\n\n // additional animation control\n run: (config: IAnimationConfig | IAnimationConfig[]) => IAnimateArranger;\n runAnimationByState: (animationState: string) => IAnimateArranger;\n stopAnimationByState: (animationState: string) => this;\n pauseAnimationByState: (animationState: string) => this;\n resumeAnimationByState: (animationState: string) => this;\n reverse: () => this;\n restart: () => this;\n record: () => this;\n recordEnd: () => this;\n\n // internal animation process api\n getAnimationConfigs: (animationState: string) => IParsedAnimationConfig[];\n updateConfig: (config: Record<string, IAnimationConfig | IAnimationConfig[]>) => void;\n updateState: (state: MarkFunctionType<string> | null) => void;\n isElementAnimating: (element: IElement) => boolean;\n getAnimatorCount: () => number;\n getElementAnimators: (element: IElement | IElement[], animationState?: string) => IAnimator[];\n release: () => void;\n}\n"]}
@@ -69,7 +69,7 @@ export interface IElement {
69
69
  setItemAttributes: (attributes: {
70
70
  [channel: string]: any;
71
71
  } | any[]) => void;
72
- updateData: (groupKey: string, data: any[], keyGenerator: MarkKeySpec) => void;
72
+ updateData: (groupKey: string, data: any[], keyGenerator: MarkKeySpec, view: any) => void;
73
73
  state: (markState: MarkFunctionType<string | string[]>, parameters?: any) => void;
74
74
  encodeItems: (items: MarkElementItem[], encoders: BaseEncodeSpec, isReentered?: boolean, parameters?: any) => void;
75
75
  encodeGraphic: (attributes?: any) => void;
@@ -85,6 +85,10 @@ export interface IElement {
85
85
  getNextGraphicAttributes: () => {
86
86
  [key: string]: any;
87
87
  };
88
+ getFinalAnimationAttribute: (channel: string) => any;
89
+ getFinalAnimationAttributes: () => {
90
+ [key: string]: any;
91
+ };
88
92
  clearChangedGraphicAttributes: () => void;
89
93
  clearGraphicAttributes: () => void;
90
94
  getStates: () => string[];
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/element.ts"],"names":[],"mappings":"","file":"element.js","sourcesContent":["import type {\n IArc,\n IArc3d,\n IArea,\n ICircle,\n IGlyph,\n IGraphic,\n IGroup,\n IImage,\n ILine,\n IPath,\n IPolygon,\n IPyramid3d,\n IRect,\n IRect3d,\n IRichText,\n ISymbol,\n IText\n} from '@visactor/vrender-core';\nimport type { DiffState } from '../graph/enums';\nimport type { IMark, IGlyphMark } from './grammar';\nimport type {\n BaseEncodeSpec,\n BaseSingleEncodeSpec,\n IMarkConfig,\n MarkFunctionType,\n MarkKeySpec,\n MarkType\n} from './mark';\n\nexport interface ElementGraphicMap {\n circle: ICircle;\n arc: IArc;\n area: IArea;\n image: IImage;\n line: ILine;\n path: IPath;\n rule: ILine;\n shape: IPath;\n symbol: ISymbol;\n text: IText;\n richtext: IRichText;\n polygon: IPolygon;\n cell: ISymbol;\n interval: IGraphic;\n rect: IRect;\n rect3d: IRect3d;\n arc3d: IArc3d;\n pyramid3d: IPyramid3d;\n group: IGroup;\n glyph: IGlyph;\n linkPath: IGlyph;\n treePath: IGlyph;\n wave: IGlyph;\n ripplePoint: IGlyph;\n barBoxplot: IGlyph;\n boxPlot: IGlyph;\n component: IGroup;\n axis: IGroup;\n legend: IGroup;\n corsshair: IGroup;\n slider: IGroup;\n datazoom: IGroup;\n label: IGroup;\n player: IGroup;\n}\n\nexport type GetGraphicByType<T> = T extends keyof ElementGraphicMap ? ElementGraphicMap[T] : IGraphic;\n\n/**\n * 保存graphicItem状态\n */\nexport interface MarkElementItem {\n /** 唯一key */\n key: string;\n /** 原始数据 */\n datum: any;\n /** VGrammar view */\n view: any;\n /** 当前渲染帧下graphicItem对应的最新属性 */\n nextAttrs?: any;\n /** 是否初始化过,用于解决collection mark对应的item,可能跳过enter状态的问题 */\n // hasEntered: boolean;\n}\nexport interface IElement {\n mark: IMark;\n isReserved: boolean;\n diffState: DiffState;\n key: string;\n groupKey?: string;\n data?: any[];\n /**\n * 不推荐使用,但是collection图元暂时可能回涉及到相关修改\n */\n items: MarkElementItem[];\n\n initGraphicItem: (attrs?: any) => void;\n updateGraphicItem: () => void;\n\n getDatum: () => any;\n getBounds: () => any;\n getGraphicItem: () => IGraphic;\n removeGraphicItem: () => void;\n resetGraphicItem: () => void;\n\n /**\n * 获取 graphic 视觉通道属性\n * @param channel 视觉通道\n * @param prev 是否从之前的 graphic 属性上获取,默认为 false\n * @returns 视觉通道值\n */\n getGraphicAttribute: (channel: string, prev?: boolean) => any;\n /**\n * 设置 graphic 视觉通道属性\n * @param channel 视觉通道\n * @param value 视觉通道属性\n * @param final 是否更新 graphic 最终变更的视觉通道结果,默认为 false\n */\n setGraphicAttribute: (channel: string, value: any, final?: boolean) => void;\n /**\n * 设置一系列 graphic 视觉通道属性\n * @param attributes 视觉通道键值对\n * @param final 是否更新 graphic 最终变更的视觉通道结果,默认为 false\n */\n setGraphicAttributes: (attributes: { [channel: string]: any }, final?: boolean) => void;\n\n /**\n * 【慎重使用】获取 VGrammar 自身的视觉通道属性\n * 只有在 'afterEncodeItems' 时机的mark transform中才能调用\n */\n getItemAttribute: (channel?: string) => any;\n /**\n * 【慎重使用】设置 VGrammar 自身的视觉通道\n * 只有在 'afterEncodeItems' 时机的mark transform中才能调用\n * @param attributes\n * @returns\n */\n setItemAttributes: (attributes: { [channel: string]: any } | any[]) => void;\n\n // element 执行流程相关接口\n updateData: (groupKey: string, data: any[], keyGenerator: MarkKeySpec) => void;\n state: (markState: MarkFunctionType<string | string[]>, parameters?: any) => void;\n encodeItems: (items: MarkElementItem[], encoders: BaseEncodeSpec, isReentered?: boolean, parameters?: any) => void;\n encodeGraphic: (attributes?: any) => void;\n transformElementItems: (items: MarkElementItem[], markType: MarkType, computePoints?: boolean) => Record<string, any>;\n remove: () => void;\n release: () => void;\n\n // 动画相关接口\n\n getFinalGraphicAttributes: () => { [key: string]: any };\n getPrevGraphicAttributes: () => { [key: string]: any };\n getNextGraphicAttributes: () => { [key: string]: any };\n clearChangedGraphicAttributes: () => void;\n clearGraphicAttributes: () => void;\n\n // state相关接口\n getStates: () => string[];\n hasState: (state: string) => boolean;\n clearStates: (noAnimation?: boolean) => void;\n addState: (state: string | string[], attrs?: any) => boolean;\n removeState: (state: string | string[]) => boolean;\n useStates: (states: string[], noAnimation?: boolean) => boolean;\n updateStates: (states: Record<string, boolean | BaseSingleEncodeSpec>) => any;\n}\n\nexport interface IGlyphElement<P = any> extends IElement {\n mark: IGlyphMark;\n\n getGlyphGraphicItems: () => { [markName: string]: any };\n\n getGraphicAttribute: (channel: string, prev?: boolean, markName?: any) => any;\n setGraphicAttribute: (channel: string, value: any, final?: boolean, markName?: any) => void;\n setGraphicAttributes: (attributes: { [channel: string]: any }, final?: boolean, markName?: any) => void;\n\n getFinalGraphicAttributes: (markName?: string) => { [key: string]: any };\n getPrevGraphicAttributes: (markName?: string) => { [key: string]: any };\n getNextGraphicAttributes: (markName?: string) => { [key: string]: any };\n\n encodeCustom: (nextAttrs?: any) => { [markName: string]: any };\n}\n"]}
1
+ {"version":3,"sources":["../src/types/element.ts"],"names":[],"mappings":"","file":"element.js","sourcesContent":["import type {\n IArc,\n IArc3d,\n IArea,\n ICircle,\n IGlyph,\n IGraphic,\n IGroup,\n IImage,\n ILine,\n IPath,\n IPolygon,\n IPyramid3d,\n IRect,\n IRect3d,\n IRichText,\n ISymbol,\n IText\n} from '@visactor/vrender-core';\nimport type { DiffState } from '../graph/enums';\nimport type { IMark, IGlyphMark } from './grammar';\nimport type {\n BaseEncodeSpec,\n BaseSingleEncodeSpec,\n IMarkConfig,\n MarkFunctionType,\n MarkKeySpec,\n MarkType\n} from './mark';\n\nexport interface ElementGraphicMap {\n circle: ICircle;\n arc: IArc;\n area: IArea;\n image: IImage;\n line: ILine;\n path: IPath;\n rule: ILine;\n shape: IPath;\n symbol: ISymbol;\n text: IText;\n richtext: IRichText;\n polygon: IPolygon;\n cell: ISymbol;\n interval: IGraphic;\n rect: IRect;\n rect3d: IRect3d;\n arc3d: IArc3d;\n pyramid3d: IPyramid3d;\n group: IGroup;\n glyph: IGlyph;\n linkPath: IGlyph;\n treePath: IGlyph;\n wave: IGlyph;\n ripplePoint: IGlyph;\n barBoxplot: IGlyph;\n boxPlot: IGlyph;\n component: IGroup;\n axis: IGroup;\n legend: IGroup;\n corsshair: IGroup;\n slider: IGroup;\n datazoom: IGroup;\n label: IGroup;\n player: IGroup;\n}\n\nexport type GetGraphicByType<T> = T extends keyof ElementGraphicMap ? ElementGraphicMap[T] : IGraphic;\n\n/**\n * 保存graphicItem状态\n */\nexport interface MarkElementItem {\n /** 唯一key */\n key: string;\n /** 原始数据 */\n datum: any;\n /** VGrammar view */\n view: any;\n /** 当前渲染帧下graphicItem对应的最新属性 */\n nextAttrs?: any;\n /** 是否初始化过,用于解决collection mark对应的item,可能跳过enter状态的问题 */\n // hasEntered: boolean;\n}\nexport interface IElement {\n mark: IMark;\n isReserved: boolean;\n diffState: DiffState;\n key: string;\n groupKey?: string;\n data?: any[];\n /**\n * 不推荐使用,但是collection图元暂时可能回涉及到相关修改\n */\n items: MarkElementItem[];\n\n initGraphicItem: (attrs?: any) => void;\n updateGraphicItem: () => void;\n\n getDatum: () => any;\n getBounds: () => any;\n getGraphicItem: () => IGraphic;\n removeGraphicItem: () => void;\n resetGraphicItem: () => void;\n\n /**\n * 获取 graphic 视觉通道属性\n * @param channel 视觉通道\n * @param prev 是否从之前的 graphic 属性上获取,默认为 false\n * @returns 视觉通道值\n */\n getGraphicAttribute: (channel: string, prev?: boolean) => any;\n /**\n * 设置 graphic 视觉通道属性\n * @param channel 视觉通道\n * @param value 视觉通道属性\n * @param final 是否更新 graphic 最终变更的视觉通道结果,默认为 false\n */\n setGraphicAttribute: (channel: string, value: any, final?: boolean) => void;\n /**\n * 设置一系列 graphic 视觉通道属性\n * @param attributes 视觉通道键值对\n * @param final 是否更新 graphic 最终变更的视觉通道结果,默认为 false\n */\n setGraphicAttributes: (attributes: { [channel: string]: any }, final?: boolean) => void;\n\n /**\n * 【慎重使用】获取 VGrammar 自身的视觉通道属性\n * 只有在 'afterEncodeItems' 时机的mark transform中才能调用\n */\n getItemAttribute: (channel?: string) => any;\n /**\n * 【慎重使用】设置 VGrammar 自身的视觉通道\n * 只有在 'afterEncodeItems' 时机的mark transform中才能调用\n * @param attributes\n * @returns\n */\n setItemAttributes: (attributes: { [channel: string]: any } | any[]) => void;\n\n // element 执行流程相关接口\n updateData: (groupKey: string, data: any[], keyGenerator: MarkKeySpec, view: any) => void;\n state: (markState: MarkFunctionType<string | string[]>, parameters?: any) => void;\n encodeItems: (items: MarkElementItem[], encoders: BaseEncodeSpec, isReentered?: boolean, parameters?: any) => void;\n encodeGraphic: (attributes?: any) => void;\n transformElementItems: (items: MarkElementItem[], markType: MarkType, computePoints?: boolean) => Record<string, any>;\n remove: () => void;\n release: () => void;\n\n // 动画相关接口\n\n getFinalGraphicAttributes: () => { [key: string]: any };\n getPrevGraphicAttributes: () => { [key: string]: any };\n getNextGraphicAttributes: () => { [key: string]: any };\n getFinalAnimationAttribute: (channel: string) => any;\n getFinalAnimationAttributes: () => { [key: string]: any };\n clearChangedGraphicAttributes: () => void;\n clearGraphicAttributes: () => void;\n\n // state相关接口\n getStates: () => string[];\n hasState: (state: string) => boolean;\n clearStates: (noAnimation?: boolean) => void;\n addState: (state: string | string[], attrs?: any) => boolean;\n removeState: (state: string | string[]) => boolean;\n useStates: (states: string[], noAnimation?: boolean) => boolean;\n updateStates: (states: Record<string, boolean | BaseSingleEncodeSpec>) => any;\n}\n\nexport interface IGlyphElement<P = any> extends IElement {\n mark: IGlyphMark;\n\n getGlyphGraphicItems: () => { [markName: string]: any };\n\n getGraphicAttribute: (channel: string, prev?: boolean, markName?: any) => any;\n setGraphicAttribute: (channel: string, value: any, final?: boolean, markName?: any) => void;\n setGraphicAttributes: (attributes: { [channel: string]: any }, final?: boolean, markName?: any) => void;\n\n getFinalGraphicAttributes: (markName?: string) => { [key: string]: any };\n getPrevGraphicAttributes: (markName?: string) => { [key: string]: any };\n getNextGraphicAttributes: (markName?: string) => { [key: string]: any };\n\n encodeCustom: (nextAttrs?: any) => { [markName: string]: any };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { IBoundsLike } from '@visactor/vutils';
2
- import type { IColor, IEventTarget, Stage } from '@visactor/vrender-core';
2
+ import type { IColor, Stage } from '@visactor/vrender-core';
3
3
  import type { IViewEventConfig, IViewOptions } from './view';
4
4
  export interface IRenderer {
5
5
  initialize: (width: number, height: number, options: IViewOptions, eventConfig: IViewEventConfig) => this;
@@ -18,8 +18,3 @@ export interface IRenderer {
18
18
  toCanvas: () => HTMLCanvasElement;
19
19
  release: () => void;
20
20
  }
21
- export interface IStageEventPlugin<T> {
22
- new (taget: IEventTarget, cfg?: T): {
23
- release: () => void;
24
- };
25
- }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/renderer.ts"],"names":[],"mappings":"","file":"renderer.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport type { IColor, IEventTarget, Stage } from '@visactor/vrender-core';\nimport type { IViewEventConfig, IViewOptions } from './view';\n\nexport interface IRenderer {\n initialize: (width: number, height: number, options: IViewOptions, eventConfig: IViewEventConfig) => this;\n\n render: (immediately?: boolean) => this;\n renderNextFrame: () => this;\n resize: (width: number, height: number) => this;\n shouldResize: (width: number, height: number) => boolean;\n combineIncrementalLayers: () => this;\n preventRender: (tag: boolean) => void;\n\n setDpr: (resolution: number, redraw: boolean) => this;\n background: (color: IColor) => this;\n setViewBox: (viewBox: IBoundsLike, rerender: boolean) => this;\n\n stage: () => Stage;\n canvas: () => HTMLCanvasElement;\n context: () => CanvasRenderingContext2D;\n\n toCanvas: () => HTMLCanvasElement;\n // toImageData: () => Promise<ImageData | undefined>;\n\n release: () => void;\n}\n\nexport interface IStageEventPlugin<T> {\n new (taget: IEventTarget, cfg?: T): {\n release: () => void;\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/types/renderer.ts"],"names":[],"mappings":"","file":"renderer.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport type { IColor, Stage } from '@visactor/vrender-core';\nimport type { IViewEventConfig, IViewOptions } from './view';\n\nexport interface IRenderer {\n initialize: (width: number, height: number, options: IViewOptions, eventConfig: IViewEventConfig) => this;\n\n render: (immediately?: boolean) => this;\n renderNextFrame: () => this;\n resize: (width: number, height: number) => this;\n shouldResize: (width: number, height: number) => boolean;\n combineIncrementalLayers: () => this;\n preventRender: (tag: boolean) => void;\n\n setDpr: (resolution: number, redraw: boolean) => this;\n background: (color: IColor) => this;\n setViewBox: (viewBox: IBoundsLike, rerender: boolean) => this;\n\n stage: () => Stage;\n canvas: () => HTMLCanvasElement;\n context: () => CanvasRenderingContext2D;\n\n toCanvas: () => HTMLCanvasElement;\n // toImageData: () => Promise<ImageData | undefined>;\n\n release: () => void;\n}\n"]}
package/es/view/View.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { IBounds, ILogger } from '@visactor/vutils';
2
2
  import { EventEmitter } from '@visactor/vutils';
3
3
  import type { IColor } from '@visactor/vrender-core';
4
4
  import type { CoordinateType } from '@visactor/vgrammar-coordinate';
5
- import type { IData, ISignal, ViewSpec, IView, IViewOptions, IViewThemeConfig, Hooks, IMark, MarkType, GrammarScaleType, SignalFunctionType, IScale, IGrammarBase, IGroupMark, IGlyphMark, ICoordinate, BaseEventHandler, IRecordedGrammars, IComponent, IRunningConfig, IViewAnimate, ITheme, InteractionSpec, IInteraction } from '../types/';
5
+ import type { IData, ISignal, ViewSpec, IView, IViewOptions, IViewThemeConfig, Hooks, IMark, EventSpec, MarkType, GrammarScaleType, SignalFunctionType, IScale, IGrammarBase, IGroupMark, IGlyphMark, ICoordinate, BaseEventHandler, IRecordedGrammars, IComponent, IRunningConfig, IViewAnimate, ITheme, InteractionSpec, IInteraction } from '../types/';
6
6
  import type { IRenderer } from '../types/renderer';
7
7
  import { LayoutState } from '../graph/enums';
8
8
  import type { IAxis, IDatazoom, IGrid, ILabel, ILegend, IPlayer, IScrollbar, ISlider, ITitle } from '../types/component';
@@ -28,6 +28,7 @@ export default class View extends EventEmitter implements IView {
28
28
  private _layoutState?;
29
29
  private _layoutMarks?;
30
30
  private _background?;
31
+ private _eventCache;
31
32
  private _progressiveMarks?;
32
33
  private _progressiveRafId?;
33
34
  private _observer;
@@ -121,10 +122,11 @@ export default class View extends EventEmitter implements IView {
121
122
  private _onResize;
122
123
  resize(width: number, height: number, render?: boolean): this;
123
124
  private _resizeRenderer;
125
+ private bindEvents;
126
+ event(eventSpec: EventSpec): void;
124
127
  interaction(type: string, spec: Partial<InteractionSpec>): IInteraction<any>;
125
128
  removeInteraction(type: string | IInteraction, id?: string): this;
126
129
  removeAllInteractions(): this;
127
- initializeEventConfig(config: any): any;
128
130
  private initEvent;
129
131
  private releaseStageEvent;
130
132
  private delegateEvent;
package/es/view/View.js CHANGED
@@ -1,9 +1,11 @@
1
- import { EventEmitter, debounce, isString, getContainerSize, Logger, array, isNil, isArray } from "@visactor/vutils";
1
+ import { EventEmitter, debounce, isObject, isString, getContainerSize, Logger, array, isNil } from "@visactor/vutils";
2
2
 
3
3
  import { vglobal } from "@visactor/vrender-core";
4
4
 
5
5
  import { Data } from "./data";
6
6
 
7
+ import { initializeEventConfig, permit, prevent } from "./events";
8
+
7
9
  import Dataflow from "./dataflow";
8
10
 
9
11
  import { traverseMarkTree } from "../graph/mark-tree";
@@ -14,13 +16,15 @@ import CanvasRenderer from "../graph/canvas-renderer";
14
16
 
15
17
  import getExtendedEvents from "../graph/util/events-extend";
16
18
 
17
- import { BROWSER, SIGNAL_WIDTH, SIGNAL_HEIGHT, SIGNAL_PADDING, SIGNAL_AUTOFIT, SIGNAL_VIEW_WIDTH, SIGNAL_VIEW_HEIGHT, EVENT_SOURCE_VIEW, SIGNAL_VIEW_BOX, ID_PREFIX, NAME_PREFIX, EVENT_SOURCE_WINDOW } from "./constants";
19
+ import { BROWSER, NO_TRAP, SIGNAL_WIDTH, SIGNAL_HEIGHT, SIGNAL_PADDING, SIGNAL_AUTOFIT, SIGNAL_VIEW_WIDTH, SIGNAL_VIEW_HEIGHT, EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW, SIGNAL_VIEW_BOX } from "./constants";
18
20
 
19
21
  import { Signal } from "./signal";
20
22
 
21
23
  import { BuiltInSignalID, builtInSignals, normalizeMarkTree, normalizeRunningConfig, normalizePadding } from "../parse/view";
22
24
 
23
- import { isGrammar } from "../parse/util";
25
+ import { parseHandler, parseEventSelector, generateFilterByMark, ID_PREFIX, NAME_PREFIX } from "../parse/event";
26
+
27
+ import { isGrammar, parseReference } from "../parse/util";
24
28
 
25
29
  import { configureEnvironment } from "../graph/util/env";
26
30
 
@@ -28,6 +32,10 @@ import { GroupMark } from "./group";
28
32
 
29
33
  import { Mark } from "./mark";
30
34
 
35
+ import { defaultDoLayout } from "../graph/layout/layout";
36
+
37
+ import { GlyphMark } from "./glyph";
38
+
31
39
  import { Morph } from "../graph/animation/morph";
32
40
 
33
41
  import { RecordedGrammars, RecordedTreeGrammars } from "./grammar-record";
@@ -146,8 +154,7 @@ export default class View extends EventEmitter {
146
154
  break;
147
155
 
148
156
  case GrammarMarkType.glyph:
149
- const GlyphMark = Factory.getMark(GrammarMarkType.glyph);
150
- GlyphMark && (mark = new GlyphMark(this, null == markOptions ? void 0 : markOptions.glyphType, groupMark));
157
+ mark = new GlyphMark(this, null == markOptions ? void 0 : markOptions.glyphType, groupMark);
151
158
  break;
152
159
 
153
160
  case GrammarMarkType.component:
@@ -281,8 +288,7 @@ export default class View extends EventEmitter {
281
288
  })), spec.marks && spec.marks.length && spec.marks.forEach((mark => {
282
289
  this.parseMarkSpec(mark);
283
290
  })), spec.events && spec.events.length && spec.events.forEach((eventConfig => {
284
- var _b;
285
- null === (_b = this.event) || void 0 === _b || _b.call(this, eventConfig);
291
+ this.event(eventConfig);
286
292
  })), spec.interactions && spec.interactions.length && spec.interactions.forEach((interaction => {
287
293
  this.interaction(interaction.type, interaction);
288
294
  })), !1 === spec.animation ? this.animate.disable() : this.animate.enable(), this.emit(HOOK_EVENT.AFTER_PARSE_VIEW),
@@ -406,7 +412,7 @@ export default class View extends EventEmitter {
406
412
  }
407
413
  doLayout() {
408
414
  var _a;
409
- const doLayout = this._options.doLayout || Factory.getDefaultLayout();
415
+ const doLayout = this._options.doLayout || defaultDoLayout;
410
416
  doLayout && (null === (_a = this._layoutMarks) || void 0 === _a ? void 0 : _a.length) && (this.emit(HOOK_EVENT.BEFORE_DO_LAYOUT),
411
417
  doLayout(this._layoutMarks, this._options, this), this.emit(HOOK_EVENT.AFTER_DO_LAYOUT));
412
418
  }
@@ -562,6 +568,73 @@ export default class View extends EventEmitter {
562
568
  height: height
563
569
  }), !0);
564
570
  }
571
+ bindEvents(eventSpec) {
572
+ if (this._eventConfig.disable) return;
573
+ const {type: evtType, filter: filter, callback: callback, throttle: throttle, debounce: debounce, consume: consume, target: target, dependency: dependency} = eventSpec, eventSelector = parseEventSelector(evtType);
574
+ if (!eventSelector) return;
575
+ const {source: source, type: type} = eventSelector, markFilter = generateFilterByMark(eventSelector), validateSignals = (Array.isArray(target) && target.length ? target.map((entry => ({
576
+ signal: this.getSignalById(entry.target),
577
+ callback: entry.callback
578
+ }))) : [ {
579
+ signal: isString(target) ? this.getSignalById(target) : null,
580
+ callback: callback
581
+ } ]).filter((entry => entry.signal || entry.callback)), refs = parseReference(dependency, this), send = parseHandler(((evt, element) => {
582
+ const needPreventDefault = source === EVENT_SOURCE_VIEW && prevent(this._eventConfig, type) || consume && (void 0 === evt.cancelable || evt.cancelable);
583
+ source === EVENT_SOURCE_WINDOW && (evt = getExtendedEvents(this, evt, element, type, EVENT_SOURCE_WINDOW));
584
+ let hasCommitted = !1;
585
+ if ((!filter || filter(evt)) && (!markFilter || markFilter(element)) && validateSignals.length) {
586
+ const params = refs.reduce(((params, ref) => (params[ref.id()] = ref.output(), params)), {});
587
+ validateSignals.forEach((entry => {
588
+ if (entry.callback && entry.signal) {
589
+ entry.signal.set(entry.callback(evt, params)) && (this.commit(entry.signal), hasCommitted = !0);
590
+ } else entry.callback ? entry.callback(evt, params) : (this.commit(entry.signal),
591
+ hasCommitted = !0);
592
+ }));
593
+ }
594
+ needPreventDefault && evt.preventDefault(), consume && evt.stopPropagation(), hasCommitted && this.run();
595
+ }), {
596
+ throttle: throttle,
597
+ debounce: debounce
598
+ });
599
+ if (source === EVENT_SOURCE_VIEW) {
600
+ if (permit(this._eventConfig, EVENT_SOURCE_VIEW, type)) return this.addEventListener(type, send, NO_TRAP),
601
+ () => {
602
+ this.removeEventListener(type, send);
603
+ };
604
+ } else if (source === EVENT_SOURCE_WINDOW) return vglobal.addEventListener(type, send),
605
+ this._eventListeners.push({
606
+ type: type,
607
+ source: vglobal,
608
+ handler: send
609
+ }), () => {
610
+ vglobal.removeEventListener(type, send);
611
+ const index = this._eventListeners.findIndex((entry => entry.type === type && entry.source === vglobal && entry.handler === send));
612
+ index >= 0 && this._eventListeners.splice(index, 1);
613
+ };
614
+ }
615
+ event(eventSpec) {
616
+ if ("between" in eventSpec) {
617
+ const [starEvent, endEvent] = eventSpec.between, id = `${starEvent.type}-${eventSpec.type}-${endEvent.type}`;
618
+ let unbindEndEvent;
619
+ this.bindEvents(Object.assign({}, starEvent, {
620
+ callback: () => {
621
+ if (this._eventCache || (this._eventCache = {}), !this._eventCache[id]) {
622
+ const unbindEvent = this.bindEvents(eventSpec);
623
+ this._eventCache[id] = unbindEvent;
624
+ }
625
+ unbindEndEvent || (unbindEndEvent = this.bindEvents(Object.assign({}, endEvent, {
626
+ callback: () => {
627
+ this._eventCache[id] && (this._eventCache[id](), this._eventCache[id] = null);
628
+ }
629
+ })));
630
+ }
631
+ }));
632
+ } else "merge" in eventSpec ? eventSpec.merge.forEach((entry => {
633
+ const singleEvent = Object.assign({}, eventSpec);
634
+ isString(entry) ? singleEvent.type = entry : isObject(entry) && Object.assign(singleEvent, entry),
635
+ singleEvent.debounce = 50, this.bindEvents(singleEvent);
636
+ })) : this.bindEvents(eventSpec);
637
+ }
565
638
  interaction(type, spec) {
566
639
  const interaction = Factory.createInteraction(type, this, spec);
567
640
  return interaction && (interaction.bind(), this._boundInteractions || (this._boundInteractions = []),
@@ -584,17 +657,6 @@ export default class View extends EventEmitter {
584
657
  instance.unbind();
585
658
  })), this._boundInteractions = null), this;
586
659
  }
587
- initializeEventConfig(config) {
588
- const eventsConfig = Object.assign({
589
- defaults: {}
590
- }, config), unpack = (obj, keys) => {
591
- keys.forEach((k => {
592
- isArray(obj[k]) && (obj[k] = obj[k].reduce(((set, key) => (set[key] = !0, set)), {}));
593
- }));
594
- };
595
- return unpack(eventsConfig.defaults, [ "prevent", "allow" ]), unpack(eventsConfig, [ EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW ]),
596
- eventsConfig;
597
- }
598
660
  initEvent() {
599
661
  const stage = this.renderer.stage();
600
662
  stage && stage.on("*", this.delegateEvent);
@@ -625,7 +687,7 @@ export default class View extends EventEmitter {
625
687
  this._options.hooks && (Object.keys(this._options.hooks).forEach((key => {
626
688
  this.on(key, this._options.hooks[key]);
627
689
  })), this.hooks = this._options.hooks), this.container = null, this.renderer = null,
628
- this._eventListeners = [], this._eventConfig = this.initializeEventConfig(this._options.eventConfig),
690
+ this._eventListeners = [], this._eventConfig = initializeEventConfig(this._options.eventConfig),
629
691
  this._theme = this._options.disableTheme ? null : ThemeManager.getDefaultTheme(),
630
692
  this.parseBuiltIn(), configureEnvironment(this._options), this.initializeRenderer(),
631
693
  this._eventConfig.disable || this.initEvent(), this._bindResizeEvent(), this._needBuildLayoutTree = !0,