@visactor/vgrammar-core 0.8.1 → 0.8.3-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/cjs/component/axis.js +9 -9
  2. package/cjs/component/axis.js.map +1 -1
  3. package/cjs/component/datazoom.js +5 -5
  4. package/cjs/component/datazoom.js.map +1 -1
  5. package/cjs/component/grid.js +18 -18
  6. package/cjs/component/grid.js.map +1 -1
  7. package/cjs/component/label.js +16 -16
  8. package/cjs/component/label.js.map +1 -1
  9. package/cjs/component/legend.js +13 -13
  10. package/cjs/component/legend.js.map +1 -1
  11. package/cjs/component/scrollbar.js +7 -7
  12. package/cjs/component/scrollbar.js.map +1 -1
  13. package/cjs/component/slider.js +5 -5
  14. package/cjs/component/slider.js.map +1 -1
  15. package/cjs/component/title.js +5 -5
  16. package/cjs/component/title.js.map +1 -1
  17. package/cjs/core/factory.d.ts +5 -1
  18. package/cjs/core/factory.js +13 -3
  19. package/cjs/core/factory.js.map +1 -1
  20. package/cjs/graph/animation/animation/move.js +10 -8
  21. package/cjs/graph/animation/animation/move.js.map +1 -1
  22. package/cjs/graph/attributes/common.js +2 -10
  23. package/cjs/graph/attributes/common.js.map +1 -1
  24. package/cjs/graph/attributes/helpers.d.ts +2 -2
  25. package/cjs/graph/attributes/helpers.js +50 -17
  26. package/cjs/graph/attributes/helpers.js.map +1 -1
  27. package/cjs/graph/attributes/index.d.ts +4 -10
  28. package/cjs/graph/attributes/index.js +16 -251
  29. package/cjs/graph/attributes/index.js.map +1 -1
  30. package/cjs/graph/attributes/line.d.ts +3 -0
  31. package/cjs/graph/attributes/line.js +46 -0
  32. package/cjs/graph/attributes/line.js.map +1 -0
  33. package/cjs/graph/attributes/transform.d.ts +5 -0
  34. package/cjs/graph/attributes/transform.js +167 -0
  35. package/cjs/graph/attributes/transform.js.map +1 -0
  36. package/cjs/graph/canvas-renderer.d.ts +1 -0
  37. package/cjs/graph/canvas-renderer.js +7 -3
  38. package/cjs/graph/canvas-renderer.js.map +1 -1
  39. package/cjs/graph/constants.d.ts +0 -1
  40. package/cjs/graph/constants.js +2 -3
  41. package/cjs/graph/constants.js.map +1 -1
  42. package/cjs/graph/element.js +5 -5
  43. package/cjs/graph/element.js.map +1 -1
  44. package/cjs/graph/glyph-element.js +4 -4
  45. package/cjs/graph/glyph-element.js.map +1 -1
  46. package/cjs/graph/layout/relative.js.map +1 -1
  47. package/cjs/graph/mark/encode.js +4 -4
  48. package/cjs/graph/mark/encode.js.map +1 -1
  49. package/cjs/index.d.ts +3 -1
  50. package/cjs/index.js +3 -2
  51. package/cjs/index.js.map +1 -1
  52. package/cjs/interactions/base.js.map +1 -1
  53. package/cjs/interactions/brush-base.js +2 -2
  54. package/cjs/interactions/brush-base.js.map +1 -1
  55. package/cjs/interactions/brush-filter.js +2 -2
  56. package/cjs/interactions/brush-filter.js.map +1 -1
  57. package/cjs/interactions/crosshair.d.ts +1 -1
  58. package/cjs/interactions/crosshair.js +15 -15
  59. package/cjs/interactions/crosshair.js.map +1 -1
  60. package/cjs/interactions/datazoom-filter.js +3 -3
  61. package/cjs/interactions/datazoom-filter.js.map +1 -1
  62. package/cjs/interactions/drill-down.js +2 -2
  63. package/cjs/interactions/drill-down.js.map +1 -1
  64. package/cjs/interactions/legend-filter.js +3 -3
  65. package/cjs/interactions/legend-filter.js.map +1 -1
  66. package/cjs/interactions/player-filter.js +3 -3
  67. package/cjs/interactions/player-filter.js.map +1 -1
  68. package/cjs/interactions/roll-up.js +2 -2
  69. package/cjs/interactions/roll-up.js.map +1 -1
  70. package/cjs/interactions/scrollbar-filter.js +3 -3
  71. package/cjs/interactions/scrollbar-filter.js.map +1 -1
  72. package/cjs/interactions/slider-filter.js +3 -3
  73. package/cjs/interactions/slider-filter.js.map +1 -1
  74. package/cjs/parse/view.js +1 -1
  75. package/cjs/parse/view.js.map +1 -1
  76. package/cjs/semantic-marks/cell.d.ts +3 -1
  77. package/cjs/semantic-marks/cell.js +10 -4
  78. package/cjs/semantic-marks/cell.js.map +1 -1
  79. package/cjs/semantic-marks/interval.d.ts +2 -0
  80. package/cjs/semantic-marks/interval.js +10 -4
  81. package/cjs/semantic-marks/interval.js.map +1 -1
  82. package/cjs/semantic-marks/text.d.ts +1 -0
  83. package/cjs/semantic-marks/text.js +3 -3
  84. package/cjs/semantic-marks/text.js.map +1 -1
  85. package/cjs/types/animate.d.ts +5 -1
  86. package/cjs/types/animate.js.map +1 -1
  87. package/cjs/types/grammar.d.ts +1 -1
  88. package/cjs/types/grammar.js.map +1 -1
  89. package/cjs/types/mark.d.ts +5 -1
  90. package/cjs/types/mark.js.map +1 -1
  91. package/cjs/types/renderer.d.ts +1 -0
  92. package/cjs/types/renderer.js.map +1 -1
  93. package/cjs/types/view.d.ts +2 -0
  94. package/cjs/types/view.js.map +1 -1
  95. package/cjs/util/grammar-heap.js +1 -1
  96. package/cjs/util/grammar-heap.js.map +1 -1
  97. package/cjs/view/View.d.ts +2 -1
  98. package/cjs/view/View.js +53 -51
  99. package/cjs/view/View.js.map +1 -1
  100. package/cjs/view/animate.d.ts +1 -0
  101. package/cjs/view/animate.js +12 -12
  102. package/cjs/view/animate.js.map +1 -1
  103. package/cjs/view/constants.d.ts +0 -3
  104. package/cjs/view/constants.js +2 -3
  105. package/cjs/view/constants.js.map +1 -1
  106. package/cjs/view/dataflow.d.ts +1 -0
  107. package/cjs/view/dataflow.js +7 -5
  108. package/cjs/view/dataflow.js.map +1 -1
  109. package/cjs/view/grammar-record.js +5 -5
  110. package/cjs/view/grammar-record.js.map +1 -1
  111. package/cjs/view/mark.js +3 -3
  112. package/cjs/view/mark.js.map +1 -1
  113. package/es/component/axis.js +1 -1
  114. package/es/component/axis.js.map +1 -1
  115. package/es/component/datazoom.js +1 -1
  116. package/es/component/datazoom.js.map +1 -1
  117. package/es/component/grid.js +1 -1
  118. package/es/component/grid.js.map +1 -1
  119. package/es/component/label.js +1 -1
  120. package/es/component/label.js.map +1 -1
  121. package/es/component/legend.js +1 -1
  122. package/es/component/legend.js.map +1 -1
  123. package/es/component/scrollbar.js +1 -1
  124. package/es/component/scrollbar.js.map +1 -1
  125. package/es/component/slider.js +1 -1
  126. package/es/component/slider.js.map +1 -1
  127. package/es/component/title.js +1 -1
  128. package/es/component/title.js.map +1 -1
  129. package/es/core/factory.d.ts +5 -1
  130. package/es/core/factory.js +11 -1
  131. package/es/core/factory.js.map +1 -1
  132. package/es/graph/animation/animation/move.js +5 -5
  133. package/es/graph/animation/animation/move.js.map +1 -1
  134. package/es/graph/attributes/common.js +2 -7
  135. package/es/graph/attributes/common.js.map +1 -1
  136. package/es/graph/attributes/helpers.d.ts +2 -2
  137. package/es/graph/attributes/helpers.js +46 -12
  138. package/es/graph/attributes/helpers.js.map +1 -1
  139. package/es/graph/attributes/index.d.ts +4 -10
  140. package/es/graph/attributes/index.js +4 -227
  141. package/es/graph/attributes/index.js.map +1 -1
  142. package/es/graph/attributes/line.d.ts +3 -0
  143. package/es/graph/attributes/line.js +42 -0
  144. package/es/graph/attributes/line.js.map +1 -0
  145. package/es/graph/attributes/transform.d.ts +5 -0
  146. package/es/graph/attributes/transform.js +153 -0
  147. package/es/graph/attributes/transform.js.map +1 -0
  148. package/es/graph/canvas-renderer.d.ts +1 -0
  149. package/es/graph/canvas-renderer.js +7 -3
  150. package/es/graph/canvas-renderer.js.map +1 -1
  151. package/es/graph/constants.d.ts +0 -1
  152. package/es/graph/constants.js +0 -2
  153. package/es/graph/constants.js.map +1 -1
  154. package/es/graph/element.js +4 -2
  155. package/es/graph/element.js.map +1 -1
  156. package/es/graph/glyph-element.js +1 -1
  157. package/es/graph/glyph-element.js.map +1 -1
  158. package/es/graph/layout/relative.js.map +1 -1
  159. package/es/graph/mark/encode.js +1 -1
  160. package/es/graph/mark/encode.js.map +1 -1
  161. package/es/index.d.ts +3 -1
  162. package/es/index.js +5 -1
  163. package/es/index.js.map +1 -1
  164. package/es/interactions/base.js.map +1 -1
  165. package/es/interactions/brush-base.js +1 -1
  166. package/es/interactions/brush-base.js.map +1 -1
  167. package/es/interactions/brush-filter.js +3 -2
  168. package/es/interactions/brush-filter.js.map +1 -1
  169. package/es/interactions/crosshair.d.ts +1 -1
  170. package/es/interactions/crosshair.js +1 -1
  171. package/es/interactions/crosshair.js.map +1 -1
  172. package/es/interactions/datazoom-filter.js +1 -1
  173. package/es/interactions/datazoom-filter.js.map +1 -1
  174. package/es/interactions/drill-down.js +1 -1
  175. package/es/interactions/drill-down.js.map +1 -1
  176. package/es/interactions/element-highlight-by-group.js +1 -2
  177. package/es/interactions/index.js +2 -1
  178. package/es/interactions/legend-filter.js +2 -2
  179. package/es/interactions/legend-filter.js.map +1 -1
  180. package/es/interactions/player-filter.js +2 -2
  181. package/es/interactions/player-filter.js.map +1 -1
  182. package/es/interactions/roll-up.js +2 -2
  183. package/es/interactions/roll-up.js.map +1 -1
  184. package/es/interactions/scrollbar-filter.js +2 -2
  185. package/es/interactions/scrollbar-filter.js.map +1 -1
  186. package/es/interactions/slider-filter.js +2 -2
  187. package/es/interactions/slider-filter.js.map +1 -1
  188. package/es/interactions/tooltip.js +1 -1
  189. package/es/interactions/view-drag-mixin.js +1 -1
  190. package/es/parse/coordinate.js +1 -1
  191. package/es/parse/event.js +1 -1
  192. package/es/parse/mark.js +1 -1
  193. package/es/parse/option.js +1 -1
  194. package/es/parse/scale.js +1 -2
  195. package/es/parse/transform.js +1 -1
  196. package/es/parse/util.js +1 -1
  197. package/es/parse/view.js +2 -2
  198. package/es/parse/view.js.map +1 -1
  199. package/es/semantic-marks/cell.d.ts +3 -1
  200. package/es/semantic-marks/cell.js +11 -1
  201. package/es/semantic-marks/cell.js.map +1 -1
  202. package/es/semantic-marks/interval.d.ts +2 -0
  203. package/es/semantic-marks/interval.js +9 -1
  204. package/es/semantic-marks/interval.js.map +1 -1
  205. package/es/semantic-marks/text.d.ts +1 -0
  206. package/es/semantic-marks/text.js +3 -1
  207. package/es/semantic-marks/text.js.map +1 -1
  208. package/es/types/animate.d.ts +5 -1
  209. package/es/types/animate.js.map +1 -1
  210. package/es/types/grammar.d.ts +1 -1
  211. package/es/types/grammar.js.map +1 -1
  212. package/es/types/mark.d.ts +5 -1
  213. package/es/types/mark.js.map +1 -1
  214. package/es/types/renderer.d.ts +1 -0
  215. package/es/types/renderer.js.map +1 -1
  216. package/es/types/view.d.ts +2 -0
  217. package/es/types/view.js.map +1 -1
  218. package/es/util/grammar-heap.js +1 -1
  219. package/es/util/grammar-heap.js.map +1 -1
  220. package/es/view/View.d.ts +2 -1
  221. package/es/view/View.js +52 -53
  222. package/es/view/View.js.map +1 -1
  223. package/es/view/animate.d.ts +1 -0
  224. package/es/view/animate.js +6 -6
  225. package/es/view/animate.js.map +1 -1
  226. package/es/view/constants.d.ts +0 -3
  227. package/es/view/constants.js +0 -6
  228. package/es/view/constants.js.map +1 -1
  229. package/es/view/dataflow.d.ts +1 -0
  230. package/es/view/dataflow.js +7 -5
  231. package/es/view/dataflow.js.map +1 -1
  232. package/es/view/grammar-record.js +1 -1
  233. package/es/view/grammar-record.js.map +1 -1
  234. package/es/view/mark.js +3 -3
  235. package/es/view/mark.js.map +1 -1
  236. package/package.json +11 -11
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.registerLegend = exports.Legend = exports.generateSizeLegendAttributes = exports.generateColorLegendAttributes = exports.generateDiscreteLegendAttributes = void 0;
6
6
 
7
- const vscale_1 = require("@visactor/vscale"), vrender_components_1 = require("@visactor/vrender-components"), vutils_1 = require("@visactor/vutils"), graph_1 = require("../graph"), util_1 = require("../parse/util"), scale_1 = require("./scale"), encode_1 = require("../graph/mark/encode"), factory_1 = require("../core/factory"), legend_filter_1 = require("../interactions/legend-filter"), filter_1 = require("../interactions/filter"), generateDiscreteLegendAttributes = (scale, theme, addition, shapeScale) => {
7
+ const vscale_1 = require("@visactor/vscale"), vrender_components_1 = require("@visactor/vrender-components"), vutils_1 = require("@visactor/vutils"), enums_1 = require("../graph/enums"), util_1 = require("../parse/util"), scale_1 = require("./scale"), encode_1 = require("../graph/mark/encode"), factory_1 = require("../core/factory"), legend_filter_1 = require("../interactions/legend-filter"), filter_1 = require("../interactions/filter"), generateDiscreteLegendAttributes = (scale, theme, addition, shapeScale) => {
8
8
  var _a;
9
9
  const legendTheme = null === (_a = null == theme ? void 0 : theme.components) || void 0 === _a ? void 0 : _a.discreteLegend;
10
10
  if (!scale) return (0, vutils_1.merge)({}, legendTheme, null != addition ? addition : {});
@@ -60,7 +60,7 @@ exports.generateSizeLegendAttributes = generateSizeLegendAttributes;
60
60
 
61
61
  class Legend extends scale_1.ScaleComponent {
62
62
  constructor(view, group) {
63
- super(view, graph_1.ComponentEnum.legend, group), this.spec.componentType = graph_1.ComponentEnum.legend,
63
+ super(view, enums_1.ComponentEnum.legend, group), this.spec.componentType = enums_1.ComponentEnum.legend,
64
64
  this.spec.legendType = "auto";
65
65
  }
66
66
  parseAddition(spec) {
@@ -84,7 +84,7 @@ class Legend extends scale_1.ScaleComponent {
84
84
  this.commit(), this;
85
85
  }
86
86
  isContinuousLegend() {
87
- return this._getLegendComponentType() !== graph_1.LegendEnum.discreteLegend;
87
+ return this._getLegendComponentType() !== enums_1.LegendEnum.discreteLegend;
88
88
  }
89
89
  setSelected(selectedValues) {
90
90
  var _a, _b;
@@ -106,13 +106,13 @@ class Legend extends scale_1.ScaleComponent {
106
106
  var _a, _b;
107
107
  const theme = this.view.getCurrentTheme(), addition = (0, encode_1.invokeEncoder)(encoder, datum, element, parameters), scale = null === (_a = null == scaleGrammar ? void 0 : scaleGrammar.getScale) || void 0 === _a ? void 0 : _a.call(scaleGrammar);
108
108
  switch (this._getLegendComponentType()) {
109
- case graph_1.LegendEnum.discreteLegend:
109
+ case enums_1.LegendEnum.discreteLegend:
110
110
  return (0, exports.generateDiscreteLegendAttributes)(scale, theme, addition, null === (_b = null == shapeScaleGrammar ? void 0 : shapeScaleGrammar.getScale) || void 0 === _b ? void 0 : _b.call(shapeScaleGrammar));
111
111
 
112
- case graph_1.LegendEnum.colorLegend:
112
+ case enums_1.LegendEnum.colorLegend:
113
113
  return (0, exports.generateColorLegendAttributes)(scale, theme, addition);
114
114
 
115
- case graph_1.LegendEnum.sizeLegend:
115
+ case enums_1.LegendEnum.sizeLegend:
116
116
  return (0, exports.generateSizeLegendAttributes)(scale, theme, addition);
117
117
  }
118
118
  return addition;
@@ -128,20 +128,20 @@ class Legend extends scale_1.ScaleComponent {
128
128
  const scaleGrammar = (0, vutils_1.isString)(this.spec.scale) ? this.view.getScaleById(this.spec.scale) : this.spec.scale, scaleType = null === (_a = null == scaleGrammar ? void 0 : scaleGrammar.getScaleType) || void 0 === _a ? void 0 : _a.call(scaleGrammar);
129
129
  if (scaleType && (0, vscale_1.isContinuous)(scaleType)) {
130
130
  const range = scaleGrammar.getScale().range();
131
- (0, util_1.parseColor)(null == range ? void 0 : range[0]) ? this._legendComponentType = graph_1.LegendEnum.colorLegend : this._legendComponentType = graph_1.LegendEnum.sizeLegend;
132
- } else this._legendComponentType = graph_1.LegendEnum.discreteLegend;
131
+ (0, util_1.parseColor)(null == range ? void 0 : range[0]) ? this._legendComponentType = enums_1.LegendEnum.colorLegend : this._legendComponentType = enums_1.LegendEnum.sizeLegend;
132
+ } else this._legendComponentType = enums_1.LegendEnum.discreteLegend;
133
133
  }
134
134
  return this._legendComponentType;
135
135
  }
136
136
  }
137
137
 
138
- exports.Legend = Legend, Legend.componentType = graph_1.ComponentEnum.legend;
138
+ exports.Legend = Legend, Legend.componentType = enums_1.ComponentEnum.legend;
139
139
 
140
140
  const registerLegend = () => {
141
- factory_1.Factory.registerGraphicComponent(graph_1.LegendEnum.discreteLegend, (attrs => new vrender_components_1.DiscreteLegend(attrs))),
142
- factory_1.Factory.registerGraphicComponent(graph_1.LegendEnum.colorLegend, (attrs => new vrender_components_1.ColorContinuousLegend(attrs))),
143
- factory_1.Factory.registerGraphicComponent(graph_1.LegendEnum.sizeLegend, (attrs => new vrender_components_1.SizeContinuousLegend(attrs))),
144
- factory_1.Factory.registerComponent(graph_1.ComponentEnum.legend, Legend), (0, vutils_1.mixin)(filter_1.Filter, filter_1.FilterMixin),
141
+ factory_1.Factory.registerGraphicComponent(enums_1.LegendEnum.discreteLegend, (attrs => new vrender_components_1.DiscreteLegend(attrs))),
142
+ factory_1.Factory.registerGraphicComponent(enums_1.LegendEnum.colorLegend, (attrs => new vrender_components_1.ColorContinuousLegend(attrs))),
143
+ factory_1.Factory.registerGraphicComponent(enums_1.LegendEnum.sizeLegend, (attrs => new vrender_components_1.SizeContinuousLegend(attrs))),
144
+ factory_1.Factory.registerComponent(enums_1.ComponentEnum.legend, Legend), (0, vutils_1.mixin)(filter_1.Filter, filter_1.FilterMixin),
145
145
  factory_1.Factory.registerInteraction(legend_filter_1.LegendFilter.type, legend_filter_1.LegendFilter);
146
146
  };
147
147
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/legend.ts"],"names":[],"mappings":";;;AAGA,6CAAgD;AAGhD,qEAA2G;AAC3G,6CAAuE;AACvE,oCAAqD;AAarD,wCAA2C;AAC3C,mCAAyC;AACzC,iDAAqD;AACrD,6CAA0C;AAC1C,iEAA6D;AAC7D,mDAA6D;AAEtD,MAAM,gCAAgC,GAAG,CAC9C,KAAiB,EACjB,KAAc,EACd,QAAgD,EAChD,UAAuB,EACF,EAAE;;IACvB,MAAM,WAAW,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,cAAc,CAAC;IACtD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;KAC/C;IAED,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAA,cAAK,EAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,KAAK,G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or/vscale';\n// eslint-disable-next-line no-duplicate-imports\nimport { isContinuous } from '@visactor/vscale';\nimport type { DiscreteLegendAttrs, ColorLegendAttributes, SizeLegendAttributes } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { DiscreteLegend, ColorContinuousLegend, SizeContinuousLegend } from '@visactor/vrender-components';\nimport { array, isString, merge, last, mixin } from '@visactor/vutils';\nimport { ComponentEnum, LegendEnum } from '../graph';\nimport type {\n BaseSignleEncodeSpec,\n IElement,\n IGroupMark,\n IScale,\n ITheme,\n IView,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport type { ILegend, LegendSpec, LegendType } from '../types/component';\nimport { parseColor } from '../parse/util';\nimport { ScaleComponent } from './scale';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { Factory } from '../core/factory';\nimport { LegendFilter } from '../interactions/legend-filter';\nimport { Filter, FilterMixin } from '../interactions/filter';\n\nexport const generateDiscreteLegendAttributes = (\n scale: IBaseScale,\n theme?: ITheme,\n addition?: RecursivePartial<DiscreteLegendAttrs>,\n shapeScale?: IBaseScale\n): DiscreteLegendAttrs => {\n const legendTheme = theme?.components?.discreteLegend;\n if (!scale) {\n return merge({}, legendTheme, addition ?? {});\n }\n // get domain items without repetitions\n const domainItems = Array.from(new Set(array(scale.domain())));\n const items = domainItems.map((item, index) => {\n const value = scale.scale(item);\n const color = parseColor(value);\n const shape = color\n ? {\n ...(theme?.components?.discreteLegend?.items?.[0]?.shape ?? {}),\n fill: color,\n stroke: color\n }\n : theme?.components?.discreteLegend?.items?.[0]?.shape ?? {};\n\n if (shapeScale) {\n Object.assign(shape, { symbolType: shapeScale.scale(item) });\n }\n\n return {\n label: item.toString(),\n id: item,\n shape,\n index\n };\n });\n return merge({}, legendTheme, { items }, addition ?? {});\n};\n\nexport const generateColorLegendAttributes = (\n scale: IBaseScale,\n theme?: ITheme,\n addition?: RecursivePartial<ColorLegendAttributes>\n): ColorLegendAttributes => {\n const legendTheme = theme?.components?.colorLegend;\n if (!scale) {\n return merge({}, legendTheme, addition ?? {});\n }\n const domain = scale.domain();\n return merge({}, legendTheme, { colors: scale.range().slice(), min: domain[0], max: last(domain) }, addition ?? {});\n};\n\nexport const generateSizeLegendAttributes = (\n scale: IBaseScale,\n theme?: ITheme,\n addition?: RecursivePartial<SizeLegendAttributes>\n): SizeLegendAttributes => {\n const legendTheme = theme?.components?.sizeLegend;\n if (!scale) {\n return merge({}, legendTheme, addition ?? {});\n }\n const domain = scale.domain();\n const attributes = {\n min: domain[0],\n max: domain[domain.length - 1],\n value: [domain[0], domain[domain.length - 1]]\n };\n return merge({}, legendTheme, attributes, addition ?? {});\n};\n\nexport class Legend extends ScaleComponent implements ILegend {\n static readonly componentType: string = ComponentEnum.legend;\n protected declare spec: LegendSpec;\n\n private _legendComponentType: keyof typeof LegendEnum;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.legend, group);\n this.spec.componentType = ComponentEnum.legend;\n this.spec.legendType = 'auto';\n }\n\n protected parseAddition(spec: LegendSpec) {\n this.shapeScale(spec.shapeScale);\n super.parseAddition(spec);\n this.legendType(spec.legendType);\n return this;\n }\n\n scale(scale?: IScale | string | Nil) {\n super.scale(scale);\n this._legendComponentType = null;\n return this;\n }\n\n shapeScale(shapeScale: LegendSpec['shapeScale']) {\n if (this.spec.shapeScale) {\n const lastScaleGrammar = isString(this.spec.shapeScale)\n ? this.view.getScaleById(this.spec.shapeScale)\n : this.spec.shapeScale;\n this.detach(lastScaleGrammar);\n this.spec.shapeScale = undefined;\n }\n const scaleGrammar = isString(shapeScale) ? this.view.getScaleById(shapeScale) : shapeScale;\n this.spec.shapeScale = scaleGrammar;\n this.attach(scaleGrammar);\n\n this.commit();\n return this;\n }\n\n legendType(legendType: LegendType | Nil) {\n this.spec.legendType = legendType;\n // clear legend type when spec is changed\n this._legendComponentType = null;\n this._prepareRejoin();\n this.commit();\n return this;\n }\n\n isContinuousLegend() {\n return this._getLegendComponentType() !== LegendEnum.discreteLegend;\n }\n\n setSelected(selectedValues: any[]) {\n // FIXME: provide ILegend interface in vis-component\n const legend = this.elements[0]?.getGraphicItem?.() as unknown as DiscreteLegend;\n legend.setSelected(selectedValues);\n return this;\n }\n\n addGraphicItem(attrs: any, groupKey?: string) {\n const graphicItem = Factory.createGraphicComponent(this._getLegendComponentType(), attrs);\n return super.addGraphicItem(attrs, groupKey, graphicItem);\n }\n\n protected _updateComponentEncoders() {\n const scaleGrammar = isString(this.spec.scale) ? this.view.getScaleById(this.spec.scale) : this.spec.scale;\n const shapeScaleGrammar = isString(this.spec.shapeScale)\n ? this.view.getScaleById(this.spec.shapeScale)\n : this.spec.shapeScale;\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.view.getCurrentTheme();\n const addition = invokeEncoder(encoder as BaseSignleEncodeSpec, datum, element, parameters);\n const scale = scaleGrammar?.getScale?.();\n switch (this._getLegendComponentType()) {\n case LegendEnum.discreteLegend:\n return generateDiscreteLegendAttributes(scale, theme, addition, shapeScaleGrammar?.getScale?.());\n case LegendEnum.colorLegend:\n return generateColorLegendAttributes(scale, theme, addition);\n case LegendEnum.sizeLegend:\n return generateSizeLegendAttributes(scale, theme, addition);\n }\n return addition;\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n\n private _getLegendComponentType() {\n if (this._legendComponentType) {\n return this._legendComponentType;\n }\n\n // compute legend component type when needed\n if (!this.spec.legendType || this.spec.legendType === '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 } else {\n this._legendComponentType =\n this.spec.legendType === 'color'\n ? 'colorLegend'\n : this.spec.legendType === 'size'\n ? 'sizeLegend'\n : 'discreteLegend';\n }\n return this._legendComponentType;\n }\n}\n\nexport const registerLegend = () => {\n Factory.registerGraphicComponent(\n LegendEnum.discreteLegend,\n (attrs: DiscreteLegendAttrs) => new DiscreteLegend(attrs) as unknown as IGraphic\n );\n Factory.registerGraphicComponent(\n LegendEnum.colorLegend,\n (attrs: ColorLegendAttributes) => new ColorContinuousLegend(attrs) as unknown as IGraphic\n );\n Factory.registerGraphicComponent(\n LegendEnum.sizeLegend,\n (attrs: SizeLegendAttributes) => new SizeContinuousLegend(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.legend, Legend);\n\n mixin(Filter, FilterMixin);\n Factory.registerInteraction(LegendFilter.type, LegendFilter);\n};\n"]}
1
+ {"version":3,"sources":["../src/component/legend.ts"],"names":[],"mappings":";;;AAGA,6CAAgD;AAGhD,qEAA2G;AAC3G,6CAAuE;AACvE,0CAA2D;AAa3D,wCAA2C;AAC3C,mCAAyC;AACzC,iDAAqD;AACrD,6CAA0C;AAC1C,iEAA6D;AAC7D,mDAA6D;AAEtD,MAAM,gCAAgC,GAAG,CAC9C,KAAiB,EACjB,KAAc,EACd,QAAgD,EAChD,UAAuB,EACF,EAAE;;IACvB,MAAM,WAAW,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,cAAc,CAAC;IACtD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;KAC/C;IAED,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAA,cAAK,EAAC,KAAK,CAAC,MA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esContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IBaseScale } from '@visactor/vscale';\n// eslint-disable-next-line no-duplicate-imports\nimport { isContinuous } from '@visactor/vscale';\nimport type { DiscreteLegendAttrs, ColorLegendAttributes, SizeLegendAttributes } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { DiscreteLegend, ColorContinuousLegend, SizeContinuousLegend } from '@visactor/vrender-components';\nimport { array, isString, merge, last, mixin } from '@visactor/vutils';\nimport { ComponentEnum, LegendEnum } from '../graph/enums';\nimport type {\n BaseSignleEncodeSpec,\n IElement,\n IGroupMark,\n IScale,\n ITheme,\n IView,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport type { ILegend, LegendSpec, LegendType } from '../types/component';\nimport { parseColor } from '../parse/util';\nimport { ScaleComponent } from './scale';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { Factory } from '../core/factory';\nimport { LegendFilter } from '../interactions/legend-filter';\nimport { Filter, FilterMixin } from '../interactions/filter';\n\nexport const generateDiscreteLegendAttributes = (\n scale: IBaseScale,\n theme?: ITheme,\n addition?: RecursivePartial<DiscreteLegendAttrs>,\n shapeScale?: IBaseScale\n): DiscreteLegendAttrs => {\n const legendTheme = theme?.components?.discreteLegend;\n if (!scale) {\n return merge({}, legendTheme, addition ?? {});\n }\n // get domain items without repetitions\n const domainItems = Array.from(new Set(array(scale.domain())));\n const items = domainItems.map((item, index) => {\n const value = scale.scale(item);\n const color = parseColor(value);\n const shape = color\n ? {\n ...(theme?.components?.discreteLegend?.items?.[0]?.shape ?? {}),\n fill: color,\n stroke: color\n }\n : theme?.components?.discreteLegend?.items?.[0]?.shape ?? {};\n\n if (shapeScale) {\n Object.assign(shape, { symbolType: shapeScale.scale(item) });\n }\n\n return {\n label: item.toString(),\n id: item,\n shape,\n index\n };\n });\n return merge({}, legendTheme, { items }, addition ?? {});\n};\n\nexport const generateColorLegendAttributes = (\n scale: IBaseScale,\n theme?: ITheme,\n addition?: RecursivePartial<ColorLegendAttributes>\n): ColorLegendAttributes => {\n const legendTheme = theme?.components?.colorLegend;\n if (!scale) {\n return merge({}, legendTheme, addition ?? {});\n }\n const domain = scale.domain();\n return merge({}, legendTheme, { colors: scale.range().slice(), min: domain[0], max: last(domain) }, addition ?? {});\n};\n\nexport const generateSizeLegendAttributes = (\n scale: IBaseScale,\n theme?: ITheme,\n addition?: RecursivePartial<SizeLegendAttributes>\n): SizeLegendAttributes => {\n const legendTheme = theme?.components?.sizeLegend;\n if (!scale) {\n return merge({}, legendTheme, addition ?? {});\n }\n const domain = scale.domain();\n const attributes = {\n min: domain[0],\n max: domain[domain.length - 1],\n value: [domain[0], domain[domain.length - 1]]\n };\n return merge({}, legendTheme, attributes, addition ?? {});\n};\n\nexport class Legend extends ScaleComponent implements ILegend {\n static readonly componentType: string = ComponentEnum.legend;\n protected declare spec: LegendSpec;\n\n private _legendComponentType: keyof typeof LegendEnum;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.legend, group);\n this.spec.componentType = ComponentEnum.legend;\n this.spec.legendType = 'auto';\n }\n\n protected parseAddition(spec: LegendSpec) {\n this.shapeScale(spec.shapeScale);\n super.parseAddition(spec);\n this.legendType(spec.legendType);\n return this;\n }\n\n scale(scale?: IScale | string | Nil) {\n super.scale(scale);\n this._legendComponentType = null;\n return this;\n }\n\n shapeScale(shapeScale: LegendSpec['shapeScale']) {\n if (this.spec.shapeScale) {\n const lastScaleGrammar = isString(this.spec.shapeScale)\n ? this.view.getScaleById(this.spec.shapeScale)\n : this.spec.shapeScale;\n this.detach(lastScaleGrammar);\n this.spec.shapeScale = undefined;\n }\n const scaleGrammar = isString(shapeScale) ? this.view.getScaleById(shapeScale) : shapeScale;\n this.spec.shapeScale = scaleGrammar;\n this.attach(scaleGrammar);\n\n this.commit();\n return this;\n }\n\n legendType(legendType: LegendType | Nil) {\n this.spec.legendType = legendType;\n // clear legend type when spec is changed\n this._legendComponentType = null;\n this._prepareRejoin();\n this.commit();\n return this;\n }\n\n isContinuousLegend() {\n return this._getLegendComponentType() !== LegendEnum.discreteLegend;\n }\n\n setSelected(selectedValues: any[]) {\n // FIXME: provide ILegend interface in vis-component\n const legend = this.elements[0]?.getGraphicItem?.() as unknown as DiscreteLegend;\n legend.setSelected(selectedValues);\n return this;\n }\n\n addGraphicItem(attrs: any, groupKey?: string) {\n const graphicItem = Factory.createGraphicComponent(this._getLegendComponentType(), attrs);\n return super.addGraphicItem(attrs, groupKey, graphicItem);\n }\n\n protected _updateComponentEncoders() {\n const scaleGrammar = isString(this.spec.scale) ? this.view.getScaleById(this.spec.scale) : this.spec.scale;\n const shapeScaleGrammar = isString(this.spec.shapeScale)\n ? this.view.getScaleById(this.spec.shapeScale)\n : this.spec.shapeScale;\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.view.getCurrentTheme();\n const addition = invokeEncoder(encoder as BaseSignleEncodeSpec, datum, element, parameters);\n const scale = scaleGrammar?.getScale?.();\n switch (this._getLegendComponentType()) {\n case LegendEnum.discreteLegend:\n return generateDiscreteLegendAttributes(scale, theme, addition, shapeScaleGrammar?.getScale?.());\n case LegendEnum.colorLegend:\n return generateColorLegendAttributes(scale, theme, addition);\n case LegendEnum.sizeLegend:\n return generateSizeLegendAttributes(scale, theme, addition);\n }\n return addition;\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n\n private _getLegendComponentType() {\n if (this._legendComponentType) {\n return this._legendComponentType;\n }\n\n // compute legend component type when needed\n if (!this.spec.legendType || this.spec.legendType === '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 } else {\n this._legendComponentType =\n this.spec.legendType === 'color'\n ? 'colorLegend'\n : this.spec.legendType === 'size'\n ? 'sizeLegend'\n : 'discreteLegend';\n }\n return this._legendComponentType;\n }\n}\n\nexport const registerLegend = () => {\n Factory.registerGraphicComponent(\n LegendEnum.discreteLegend,\n (attrs: DiscreteLegendAttrs) => new DiscreteLegend(attrs) as unknown as IGraphic\n );\n Factory.registerGraphicComponent(\n LegendEnum.colorLegend,\n (attrs: ColorLegendAttributes) => new ColorContinuousLegend(attrs) as unknown as IGraphic\n );\n Factory.registerGraphicComponent(\n LegendEnum.sizeLegend,\n (attrs: SizeLegendAttributes) => new SizeContinuousLegend(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.legend, Legend);\n\n mixin(Filter, FilterMixin);\n Factory.registerInteraction(LegendFilter.type, LegendFilter);\n};\n"]}
@@ -4,7 +4,7 @@ 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"), graph_1 = require("../graph"), 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");
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
8
 
9
9
  function isValidDirection(direction) {
10
10
  return "vertical" === direction || "horizontal" === direction;
@@ -64,7 +64,7 @@ exports.generateScrollbarAttributes = generateScrollbarAttributes;
64
64
 
65
65
  class Scrollbar extends scale_1.ScaleComponent {
66
66
  constructor(view, group) {
67
- super(view, graph_1.ComponentEnum.scrollbar, group), this.spec.componentType = graph_1.ComponentEnum.scrollbar;
67
+ super(view, enums_1.ComponentEnum.scrollbar, group), this.spec.componentType = enums_1.ComponentEnum.scrollbar;
68
68
  }
69
69
  parseAddition(spec) {
70
70
  return super.parseAddition(spec), this.container(spec.container), this.direction(spec.direction),
@@ -104,7 +104,7 @@ class Scrollbar extends scale_1.ScaleComponent {
104
104
  addGraphicItem(attrs, groupKey) {
105
105
  const initialAttributes = (0, vutils_1.merge)({
106
106
  range: [ 0, 1 ]
107
- }, attrs), graphicItem = factory_1.Factory.createGraphicComponent(graph_1.ComponentEnum.scrollbar, initialAttributes);
107
+ }, attrs), graphicItem = factory_1.Factory.createGraphicComponent(enums_1.ComponentEnum.scrollbar, initialAttributes);
108
108
  return super.addGraphicItem(initialAttributes, groupKey, graphicItem);
109
109
  }
110
110
  _updateComponentEncoders() {
@@ -118,7 +118,7 @@ class Scrollbar extends scale_1.ScaleComponent {
118
118
  const theme = this.view.getCurrentTheme(), direction = (0, util_1.invokeFunctionType)(this.spec.direction, parameters, datum, element), position = (0,
119
119
  util_1.invokeFunctionType)(this.spec.position, parameters, datum, element), addition = (0,
120
120
  encode_1.invokeEncoder)(encoder, datum, element, parameters), targetMark = this.spec.container ? (0,
121
- vutils_1.isString)(this.spec.container) ? this.view.getMarkById(this.spec.container) : this.spec.container : null, groupGraphicItem = (targetMark && targetMark.markType === graph_1.GrammarMarkType.group ? targetMark : this.group).getGroupGraphicItem(), size = groupGraphicItem ? {
121
+ vutils_1.isString)(this.spec.container) ? this.view.getMarkById(this.spec.container) : this.spec.container : null, groupGraphicItem = (targetMark && targetMark.markType === enums_1.GrammarMarkType.group ? targetMark : this.group).getGroupGraphicItem(), size = groupGraphicItem ? {
122
122
  width: null !== (_a = groupGraphicItem.attribute.width) && void 0 !== _a ? _a : groupGraphicItem.AABBBounds.width(),
123
123
  height: null !== (_b = groupGraphicItem.attribute.height) && void 0 !== _b ? _b : groupGraphicItem.AABBBounds.height()
124
124
  } : {
@@ -133,11 +133,11 @@ class Scrollbar extends scale_1.ScaleComponent {
133
133
  }
134
134
  }
135
135
 
136
- exports.Scrollbar = Scrollbar, Scrollbar.componentType = graph_1.ComponentEnum.scrollbar;
136
+ exports.Scrollbar = Scrollbar, Scrollbar.componentType = enums_1.ComponentEnum.scrollbar;
137
137
 
138
138
  const registerScrollbar = () => {
139
- factory_1.Factory.registerGraphicComponent(graph_1.ComponentEnum.scrollbar, (attrs => new vrender_components_1.ScrollBar(attrs))),
140
- factory_1.Factory.registerComponent(graph_1.ComponentEnum.scrollbar, Scrollbar),
139
+ factory_1.Factory.registerGraphicComponent(enums_1.ComponentEnum.scrollbar, (attrs => new vrender_components_1.ScrollBar(attrs))),
140
+ factory_1.Factory.registerComponent(enums_1.ComponentEnum.scrollbar, Scrollbar),
141
141
  (0, vutils_1.mixin)(filter_1.Filter, filter_1.FilterMixin), factory_1.Factory.registerInteraction(scrollbar_filter_1.ScrollbarFilter.type, scrollbar_filter_1.ScrollbarFilter);
142
142
  };
143
143
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/scrollbar.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAI1D,qEAA+E;AAY/E,oCAA0D;AAE1D,iDAAqD;AACrD,wCAAmD;AACnD,6CAA0C;AAC1C,mCAAyC;AACzC,uEAAmE;AACnE,mDAA6D;AAE7D,SAAS,gBAAgB,CAAC,SAAoB;IAC5C,OAAO,SAAS,KAAK,UAAU,IAAI,SAAS,KAAK,YAAY,CAAC;AAChE,CAAC;AAED,SAAS,eAAe,CAAC,QAAoB;IAC3C,OAAO,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO,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B,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 BaseSignleEncodeSpec,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n MarkFunctionType,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum, GrammarMarkType } from '../graph';\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 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.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 BaseSignleEncodeSpec, 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,qEAA+E;AAY/E,0CAAgE;AAEhE,iDAAqD;AACrD,wCAAmD;AACnD,6CAA0C;AAC1C,mCAAyC;AACzC,uEAAmE;AACnE,mDAA6D;AAE7D,SAAS,gBAAgB,CAAC,SAAoB;IAC5C,OAAO,SAAS,KAAK,UAAU,IAAI,SAAS,KAAK,YAAY,CAAC;AAChE,CAAC;AAED,SAAS,eAAe,CAAC,QAAoB;IAC3C,OAAO,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO,CAAC;AACpG,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAoB;IAChD,OAAO,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,QAAQ,CAAC;AACrD,CAAC;AAEM,MAAM,2BAA2B,GAAG,CACzC,SAA4C,EAC5C,SAAqB,EACrB,QAAqB,EACrB,KAAc,EACd,QAAgD,EAC3B,EAAE;;IACvB,MAAM,cAAc,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,SAAS,CAAC;IAEpD,IAAI,cAAc,GAAc,YAAY,CAAC;IAC7C,IAAI,aAAa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AgB;4BAC3B,CAAC,CAAC;gCACE,KAAK,EAAE,MAAA,gBAAgB,CAAC,SAAS,CAAC,KAAK,mCAAI,gBAAgB,CAAC,UAAU,CAAC,KAAK,EAAE;gCAC9E,MAAM,EAAE,MAAA,gBAAgB,CAAC,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;;AAjGH,8BAkGC;AAjGiB,uBAAa,GAAW,qBAAa,CAAC,SAAS,CAAC;AAmG3D,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 BaseSignleEncodeSpec,\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 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.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 BaseSignleEncodeSpec, 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"]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.registerSlider = exports.Slider = exports.generateSliderAttributes = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), vrender_components_1 = require("@visactor/vrender-components"), graph_1 = require("../graph"), component_1 = require("../view/component"), encode_1 = require("../graph/mark/encode"), util_1 = require("../parse/util"), factory_1 = require("../core/factory"), slider_filter_1 = require("../interactions/slider-filter"), filter_1 = require("../interactions/filter"), generateSliderAttributes = (min, max, theme, addition) => {
7
+ const vutils_1 = require("@visactor/vutils"), vrender_components_1 = require("@visactor/vrender-components"), enums_1 = require("../graph/enums"), component_1 = require("../view/component"), encode_1 = require("../graph/mark/encode"), util_1 = require("../parse/util"), factory_1 = require("../core/factory"), slider_filter_1 = require("../interactions/slider-filter"), filter_1 = require("../interactions/filter"), generateSliderAttributes = (min, max, theme, addition) => {
8
8
  var _a;
9
9
  const sliderTheme = null === (_a = null == theme ? void 0 : theme.components) || void 0 === _a ? void 0 : _a.slider;
10
10
  return (0, vutils_1.merge)({}, sliderTheme, {
@@ -18,7 +18,7 @@ exports.generateSliderAttributes = generateSliderAttributes;
18
18
 
19
19
  class Slider extends component_1.Component {
20
20
  constructor(view, group) {
21
- super(view, graph_1.ComponentEnum.slider, group), this.spec.componentType = graph_1.ComponentEnum.slider;
21
+ super(view, enums_1.ComponentEnum.slider, group), this.spec.componentType = enums_1.ComponentEnum.slider;
22
22
  }
23
23
  parseAddition(spec) {
24
24
  return super.parseAddition(spec), this.min(spec.min), this.max(spec.max), this;
@@ -52,11 +52,11 @@ class Slider extends component_1.Component {
52
52
  }
53
53
  }
54
54
 
55
- exports.Slider = Slider, Slider.componentType = graph_1.ComponentEnum.slider;
55
+ exports.Slider = Slider, Slider.componentType = enums_1.ComponentEnum.slider;
56
56
 
57
57
  const registerSlider = () => {
58
- factory_1.Factory.registerGraphicComponent(graph_1.ComponentEnum.slider, (attrs => new vrender_components_1.Slider(attrs))),
59
- factory_1.Factory.registerComponent(graph_1.ComponentEnum.slider, Slider), (0, vutils_1.mixin)(filter_1.Filter, filter_1.FilterMixin),
58
+ factory_1.Factory.registerGraphicComponent(enums_1.ComponentEnum.slider, (attrs => new vrender_components_1.Slider(attrs))),
59
+ factory_1.Factory.registerComponent(enums_1.ComponentEnum.slider, Slider), (0, vutils_1.mixin)(filter_1.Filter, filter_1.FilterMixin),
60
60
  factory_1.Factory.registerInteraction(slider_filter_1.SliderFilter.type, slider_filter_1.SliderFilter);
61
61
  };
62
62
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/slider.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AAIvD,qEAAyE;AAYzE,oCAAyC;AAEzC,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,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,MAAM,CAAC;IAC9C,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC;AARW,QAAA,wBAAwB,4BAQnC;AAEF,MAAa,MAAO,SAAQ,qBAAS;IAInC,YAAY,IAAW,EAAE,KAAkB;QACzC,KAAK,CAAC,IAAI,EAAE,qBAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,qBAAa,CAAC,MAAM,CAAC;IACjD,CAAC;IAES,aAAa,CAAC,IAAgB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"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 BaseSignleEncodeSpec,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n MarkFunctionType,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum } from '../graph';\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.elements[0]?.getGraphicItem?.() 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.view.getCurrentTheme();\n const addition = invokeEncoder(encoder as BaseSignleEncodeSpec, 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"]}
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,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,MAAM,CAAC;IAC9C,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC;AARW,QAAA,wBAAwB,4BAQnC;AAEF,MAAa,MAAO,SAAQ,qBAAS;IAInC,YAAY,IAAW,EAAE,KAAkB;QACzC,KAAK,CAAC,IAAI,EAAE,qBAAa,CAAC,MAAM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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 BaseSignleEncodeSpec,\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.elements[0]?.getGraphicItem?.() 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.view.getCurrentTheme();\n const addition = invokeEncoder(encoder as BaseSignleEncodeSpec, 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"]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.registerTitle = exports.Title = exports.generateTitleAttributes = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), vrender_components_1 = require("@visactor/vrender-components"), graph_1 = require("../graph"), component_1 = require("../view/component"), encode_1 = require("../graph/mark/encode"), util_1 = require("../parse/util"), factory_1 = require("../core/factory"), generateTitleAttributes = (title, subTitle, theme, addition) => {
7
+ const vutils_1 = require("@visactor/vutils"), vrender_components_1 = require("@visactor/vrender-components"), enums_1 = require("../graph/enums"), component_1 = require("../view/component"), encode_1 = require("../graph/mark/encode"), util_1 = require("../parse/util"), factory_1 = require("../core/factory"), generateTitleAttributes = (title, subTitle, theme, addition) => {
8
8
  var _a;
9
9
  const titleTheme = null === (_a = null == theme ? void 0 : theme.components) || void 0 === _a ? void 0 : _a.title, attributes = {};
10
10
  return (0, vutils_1.isValid)(title) && (attributes.text = title), (0, vutils_1.isValid)(subTitle) && (attributes.subtext = subTitle),
@@ -15,7 +15,7 @@ exports.generateTitleAttributes = generateTitleAttributes;
15
15
 
16
16
  class Title extends component_1.Component {
17
17
  constructor(view, group) {
18
- super(view, graph_1.ComponentEnum.title, group), this.spec.componentType = graph_1.ComponentEnum.title;
18
+ super(view, enums_1.ComponentEnum.title, group), this.spec.componentType = enums_1.ComponentEnum.title;
19
19
  }
20
20
  parseAddition(spec) {
21
21
  return super.parseAddition(spec), this.title(spec.title), this.subTitle(spec.subTitle),
@@ -45,11 +45,11 @@ class Title extends component_1.Component {
45
45
  }
46
46
  }
47
47
 
48
- exports.Title = Title, Title.componentType = graph_1.ComponentEnum.title;
48
+ exports.Title = Title, Title.componentType = enums_1.ComponentEnum.title;
49
49
 
50
50
  const registerTitle = () => {
51
- factory_1.Factory.registerGraphicComponent(graph_1.ComponentEnum.title, (attrs => new vrender_components_1.Title(attrs))),
52
- factory_1.Factory.registerComponent(graph_1.ComponentEnum.title, Title);
51
+ factory_1.Factory.registerGraphicComponent(enums_1.ComponentEnum.title, (attrs => new vrender_components_1.Title(attrs))),
52
+ factory_1.Factory.registerComponent(enums_1.ComponentEnum.title, Title);
53
53
  };
54
54
 
55
55
  exports.registerTitle = registerTitle;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/title.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAIlD,qEAAuE;AAYvE,oCAAyC;AAEzC,iDAA8C;AAC9C,iDAAqD;AACrD,wCAAmD;AACnD,6CAA0C;AAEnC,MAAM,uBAAuB,GAAG,CACrC,KAA6C,EAC7C,QAAgD,EAChD,KAAc,EACd,QAAuC,EAC3B,EAAE;;IACd,MAAM,UAAU,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,KAAK,CAAC;IAC5C,MAAM,UAAU,GAAiC,EAAE,CAAC;IACpD,IAAI,IAAA,gBAAO,EAAC,KAAK,CAAC,EAAE;QAClB,U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/vutils';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type { TitleAttrs } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { Title as TitleComponent } from '@visactor/vrender-components';\nimport type {\n BaseSignleEncodeSpec,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n MarkFunctionType,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum } from '../graph';\nimport type { ITitle, TitleSpec } from '../types/component';\nimport { Component } from '../view/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { invokeFunctionType } from '../parse/util';\nimport { Factory } from '../core/factory';\n\nexport const generateTitleAttributes = (\n title?: string | number | number[] | string[],\n subTitle?: string | number | number[] | string[],\n theme?: ITheme,\n addition?: RecursivePartial<TitleAttrs>\n): TitleAttrs => {\n const titleTheme = theme?.components?.title;\n const attributes: RecursivePartial<TitleAttrs> = {};\n if (isValid(title)) {\n attributes.text = title;\n }\n if (isValid(subTitle)) {\n attributes.subtext = subTitle;\n }\n return merge({}, titleTheme, attributes, addition ?? {});\n};\n\nexport class Title extends Component implements ITitle {\n static readonly componentType: string = ComponentEnum.title;\n protected declare spec: TitleSpec;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.title, group);\n this.spec.componentType = ComponentEnum.title;\n }\n\n protected parseAddition(spec: TitleSpec) {\n super.parseAddition(spec);\n this.title(spec.title);\n this.subTitle(spec.subTitle);\n return this;\n }\n\n title(text: MarkFunctionType<string | number | number[] | string[]> | Nil) {\n return this.setFunctionSpec(text, 'title');\n }\n\n subTitle(text: MarkFunctionType<string | number | number[] | string[]> | Nil) {\n return this.setFunctionSpec(text, 'subTitle');\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.view.getCurrentTheme();\n const title = invokeFunctionType(this.spec.title, parameters, datum, element);\n const subTitle = invokeFunctionType(this.spec.subTitle, parameters, datum, element);\n const addition = invokeEncoder(encoder as BaseSignleEncodeSpec, datum, element, parameters);\n return generateTitleAttributes(title, subTitle, theme, addition);\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerGraphicComponent(\n ComponentEnum.title,\n (attrs: TitleAttrs) => new TitleComponent(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.title, Title);\n};\n"]}
1
+ {"version":3,"sources":["../src/component/title.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAIlD,qEAAuE;AAYvE,0CAA+C;AAE/C,iDAA8C;AAC9C,iDAAqD;AACrD,wCAAmD;AACnD,6CAA0C;AAEnC,MAAM,uBAAuB,GAAG,CACrC,KAA6C,EAC7C,QAAgD,EAChD,KAAc,EACd,QAAuC,EAC3B,EAAE;;IACd,MAAM,UAAU,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,KAAK,CAAC;IAC5C,MAAM,UAAU,GAAiC,EAAE,CAAC;IACpD,IAAI,IAAA,gBAAO,EAAC,KAAK,CAAC,EAAE;QAClB,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC;KACzB;IACD,IAAI,IAAA,gBAAO,EAAC,QAAQ,CAAC,EAAE;QACrB,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC;KAC/B;IACD,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;AAC3D,CAAC,CAAC;AAfW,QAAA,uBAAuB,2BAelC;AAEF,MAAa,KAAM,SAAQ,qBAAS;IAIlC,YAAY,IAAW,EAAE,KAAkB;QACzC,KAAK,CAAC,IAAI,EAAE,qBAAa,CAAC,KAAK,EAAE,KAAK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AI,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;wBACpF,MAAM,QAAQ,GAAG,IAAA,sBAAa,EAAC,OAA+B,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;wBAC5F,OAAO,IAAA,+BAAuB,EAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBACnE,CAAC;iBACF,CAAC;aACH;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,IAAI,CAAC,SAAS,GAAG,iBAAiB,CAAC;IACrC,CAAC;;AA1CH,sBA2CC;AA1CiB,mBAAa,GAAW,qBAAa,CAAC,KAAK,CAAC;AA4CvD,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,iBAAO,CAAC,wBAAwB,CAC9B,qBAAa,CAAC,KAAK,EACnB,CAAC,KAAiB,EAAE,EAAE,CAAC,IAAI,0BAAc,CAAC,KAAK,CAAwB,CACxE,CAAC;IAEF,iBAAO,CAAC,iBAAiB,CAAC,qBAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC,CAAC;AAPW,QAAA,aAAa,iBAOxB","file":"title.js","sourcesContent":["import { isValid, merge } from '@visactor/vutils';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type { TitleAttrs } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { Title as TitleComponent } from '@visactor/vrender-components';\nimport type {\n BaseSignleEncodeSpec,\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 { ITitle, TitleSpec } from '../types/component';\nimport { Component } from '../view/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { invokeFunctionType } from '../parse/util';\nimport { Factory } from '../core/factory';\n\nexport const generateTitleAttributes = (\n title?: string | number | number[] | string[],\n subTitle?: string | number | number[] | string[],\n theme?: ITheme,\n addition?: RecursivePartial<TitleAttrs>\n): TitleAttrs => {\n const titleTheme = theme?.components?.title;\n const attributes: RecursivePartial<TitleAttrs> = {};\n if (isValid(title)) {\n attributes.text = title;\n }\n if (isValid(subTitle)) {\n attributes.subtext = subTitle;\n }\n return merge({}, titleTheme, attributes, addition ?? {});\n};\n\nexport class Title extends Component implements ITitle {\n static readonly componentType: string = ComponentEnum.title;\n protected declare spec: TitleSpec;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.title, group);\n this.spec.componentType = ComponentEnum.title;\n }\n\n protected parseAddition(spec: TitleSpec) {\n super.parseAddition(spec);\n this.title(spec.title);\n this.subTitle(spec.subTitle);\n return this;\n }\n\n title(text: MarkFunctionType<string | number | number[] | string[]> | Nil) {\n return this.setFunctionSpec(text, 'title');\n }\n\n subTitle(text: MarkFunctionType<string | number | number[] | string[]> | Nil) {\n return this.setFunctionSpec(text, 'subTitle');\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.view.getCurrentTheme();\n const title = invokeFunctionType(this.spec.title, parameters, datum, element);\n const subTitle = invokeFunctionType(this.spec.subTitle, parameters, datum, element);\n const addition = invokeEncoder(encoder as BaseSignleEncodeSpec, datum, element, parameters);\n return generateTitleAttributes(title, subTitle, theme, addition);\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerGraphicComponent(\n ComponentEnum.title,\n (attrs: TitleAttrs) => new TitleComponent(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.title, Title);\n};\n"]}
@@ -1,7 +1,8 @@
1
1
  import type { IGraphic } from '@visactor/vrender-core';
2
- import type { GlyphChannelEncoder, GlyphDefaultEncoder, IComponentConstructor, IElement, IGlyphElement, IGlyphMeta, IGrammarBaseConstructor, IGroupMark, IInteractionConstructor, IPlotMarkConstructor, ISemanticMark, ITransform, IView, MarkType, TypeAnimation } from '../types';
2
+ import type { GlyphChannelEncoder, GlyphDefaultEncoder, IComponentConstructor, IElement, IGlyphElement, IGlyphMeta, IGrammarBaseConstructor, IGroupMark, IInteractionConstructor, IMark, IMarkConstructor, IPlotMarkConstructor, ISemanticMark, ITransform, IView, MarkType, TypeAnimation } from '../types';
3
3
  export declare class Factory {
4
4
  private static _plotMarks;
5
+ private static _marks;
5
6
  private static _components;
6
7
  private static _graphicComponents;
7
8
  private static _transforms;
@@ -11,6 +12,9 @@ export declare class Factory {
11
12
  private static _interactions;
12
13
  static registerPlotMarks(key: string, mark: IPlotMarkConstructor): void;
13
14
  static createPlotMark(type: string, id?: string): ISemanticMark<any, any> | null;
15
+ static registerMark(key: string, mark: IMarkConstructor): void;
16
+ static createMark(type: string, view: IView, group?: IGroupMark): IMark | null;
17
+ static hasMark(type: string): boolean;
14
18
  static registerComponent(key: string, component: IComponentConstructor): void;
15
19
  static createComponent(componentType: string, view: IView, group?: IGroupMark, mode?: '2d' | '3d'): import("../types").IComponent;
16
20
  static hasComponent(componentType: string): boolean;
@@ -14,6 +14,16 @@ class Factory {
14
14
  if (!Factory._plotMarks[type]) return null;
15
15
  return new (0, Factory._plotMarks[type])(id);
16
16
  }
17
+ static registerMark(key, mark) {
18
+ Factory._marks[key] = mark;
19
+ }
20
+ static createMark(type, view, group) {
21
+ if (!Factory._marks[type]) return null;
22
+ return new (0, Factory._marks[type])(view, type, group);
23
+ }
24
+ static hasMark(type) {
25
+ return !!Factory._marks[type];
26
+ }
17
27
  static registerComponent(key, component) {
18
28
  Factory._components[key] = component;
19
29
  }
@@ -68,9 +78,9 @@ class Factory {
68
78
  }
69
79
  }
70
80
 
71
- exports.Factory = Factory, Factory._plotMarks = {}, Factory._components = {}, Factory._graphicComponents = {},
72
- Factory._transforms = {}, Factory._grammars = {}, Factory._glyphs = {}, Factory._animations = {},
73
- Factory._interactions = {}, Factory.registerGlyph = (glyphType, marks, encoders, defaultEncoder, progressiveChannels) => (Factory._glyphs[glyphType] = new glyph_meta_1.GlyphMeta(marks, encoders, defaultEncoder, progressiveChannels),
81
+ exports.Factory = Factory, Factory._plotMarks = {}, Factory._marks = {}, Factory._components = {},
82
+ Factory._graphicComponents = {}, Factory._transforms = {}, Factory._grammars = {},
83
+ Factory._glyphs = {}, Factory._animations = {}, Factory._interactions = {}, Factory.registerGlyph = (glyphType, marks, encoders, defaultEncoder, progressiveChannels) => (Factory._glyphs[glyphType] = new glyph_meta_1.GlyphMeta(marks, encoders, defaultEncoder, progressiveChannels),
74
84
  Factory._glyphs[glyphType]), Factory.registerAnimationType = (animationType, animation) => {
75
85
  Factory._animations[animationType] = animation;
76
86
  }, Factory.getAnimationType = animationType => Factory._animations[animationType],
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/factory.ts"],"names":[],"mappings":";;;AAkBA,mDAA+C;AAE/C,MAAa,OAAO;IAUlB,MAAM,CAAC,iBAAiB,CAAC,GAAW,EAAE,IAA0B;QAC9D,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,IAAY,EAAE,EAAW;QAC7C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC;SACb;QACD,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjD,OAAO,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,GAAW,EAAE,SAAgC;QACpE,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,aAAqB,EAAE,I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7C,iBAAS,GAA+E,EAAE,CAAC;AAC3F,eAAO,GAAyC,EAAE,CAAC;AACnD,mBAAW,GAA2E,EAAE,CAAC;AACzF,qBAAa,GAA4C,EAAE,CAAC;AAkFpE,qBAAa,GAAG,CACrB,SAAiB,EACjB,KAAuC,EACvC,QAA8F,EAC9F,cAAoC,EACpC,mBAAuC,EACQ,EAAE;IACjD,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,sBAAS,CACxC,KAAK,EACL,QAAQ,EACR,cAAc,EACd,mBAAmB,CACpB,CAAC;IACF,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC,CAAC;AAMK,6BAAqB,GAAG,CAC7B,aAAqB,EACrB,SAAiE,EAC3D,EAAE;IACR,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC;AACjD,CAAC,CAAC;AAEK,wBAAgB,GAAG,CAAC,aAAqB,EAAE,EAAE;IAClD,OAAO,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEK,2BAAmB,GAAG,CAAC,eAAuB,EAAE,WAAoC,EAAE,EAAE;IAC7F,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC;AACvD,CAAC,CAAC","file":"factory.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type {\n GlyphChannelEncoder,\n GlyphDefaultEncoder,\n IComponentConstructor,\n IElement,\n IGlyphElement,\n IGlyphMeta,\n IGrammarBaseConstructor,\n IGroupMark,\n IInteractionConstructor,\n IPlotMarkConstructor,\n ISemanticMark,\n ITransform,\n IView,\n MarkType,\n TypeAnimation\n} from '../types';\nimport { GlyphMeta } from '../view/glyph-meta';\n\nexport class Factory {\n private static _plotMarks: Record<string, IPlotMarkConstructor> = {};\n private static _components: Record<string, IComponentConstructor> = {};\n private static _graphicComponents: Record<string, (attrs: any, mode?: '2d' | '3d') => IGraphic> = {};\n private static _transforms: Record<string, ITransform> = {};\n private static _grammars: Record<string, { grammarClass: IGrammarBaseConstructor; specKey: string }> = {};\n private static _glyphs: Record<string, IGlyphMeta<any, any>> = {};\n private static _animations: Record<string, TypeAnimation<IGlyphElement> | TypeAnimation<IElement>> = {};\n private static _interactions: Record<string, IInteractionConstructor> = {};\n\n static registerPlotMarks(key: string, mark: IPlotMarkConstructor) {\n Factory._plotMarks[key] = mark;\n }\n\n static createPlotMark(type: string, id?: string): ISemanticMark<any, any> | null {\n if (!Factory._plotMarks[type]) {\n return null;\n }\n const MarkConstructor = Factory._plotMarks[type];\n return new MarkConstructor(id);\n }\n\n static registerComponent(key: string, component: IComponentConstructor) {\n Factory._components[key] = component;\n }\n\n static createComponent(componentType: string, view: IView, group?: IGroupMark, mode?: '2d' | '3d') {\n const Ctor = Factory._components[componentType];\n if (!Ctor) {\n return null;\n }\n\n return new Ctor(view, group, mode);\n }\n\n static hasComponent(componentType: string) {\n return !!Factory._components[componentType];\n }\n\n static registerGraphicComponent(key: string, creator: (attrs: any, mode?: '2d' | '3d') => IGraphic) {\n Factory._graphicComponents[key] = creator;\n }\n\n static createGraphicComponent(componentType: string, attrs: any, mode?: '2d' | '3d') {\n const compCreator = Factory._graphicComponents[componentType];\n\n if (!compCreator) {\n return null;\n }\n\n return compCreator(attrs, mode);\n }\n\n static registerTransform(type: string, transform: Omit<ITransform, 'type'>, isBuiltIn?: boolean) {\n Factory._transforms[type] = Object.assign(transform, { type, isBuiltIn: !!isBuiltIn });\n }\n\n static getTransform(type: string) {\n return Factory._transforms[type];\n }\n\n static unregisterRuntimeTransforms() {\n Object.keys(Factory._transforms).forEach(type => {\n if (Factory._transforms[type] && !Factory._transforms[type].isBuiltIn) {\n Factory._transforms[type] = null;\n }\n });\n }\n\n static registerGrammar(type: string, grammarClass: IGrammarBaseConstructor, specKey?: string) {\n Factory._grammars[type] = {\n grammarClass: grammarClass,\n specKey: specKey ?? type\n };\n }\n\n static createGrammar(type: string, view: IView) {\n const Ctor = Factory._grammars[type]?.grammarClass;\n\n if (!Ctor) {\n return null;\n }\n\n return new Ctor(view);\n }\n\n static getGrammars() {\n return this._grammars;\n }\n\n static registerGlyph = <EncodeValuesType = any, GlyphConfigType = any>(\n glyphType: string,\n marks: { [markName: string]: MarkType },\n encoders?: { [markName: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType> },\n defaultEncoder?: GlyphDefaultEncoder,\n progressiveChannels?: string | string[]\n ): IGlyphMeta<EncodeValuesType, GlyphConfigType> => {\n Factory._glyphs[glyphType] = new GlyphMeta<EncodeValuesType, GlyphConfigType>(\n marks,\n encoders,\n defaultEncoder,\n progressiveChannels\n );\n return Factory._glyphs[glyphType];\n };\n\n static getGlyph(glyphType: string): IGlyphMeta {\n return Factory._glyphs[glyphType];\n }\n\n static registerAnimationType = (\n animationType: string,\n animation: TypeAnimation<IGlyphElement> | TypeAnimation<IElement>\n ): void => {\n Factory._animations[animationType] = animation;\n };\n\n static getAnimationType = (animationType: string) => {\n return Factory._animations[animationType];\n };\n\n static registerInteraction = (interactionType: string, interaction: IInteractionConstructor) => {\n Factory._interactions[interactionType] = interaction;\n };\n\n static createInteraction(interactionType: string, view: IView, options?: any) {\n const Ctor = Factory._interactions[interactionType];\n if (!Ctor) {\n return null;\n }\n\n return new Ctor(view, options);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/core/factory.ts"],"names":[],"mappings":";;;AAoBA,mDAA+C;AAE/C,MAAa,OAAO;IAWlB,MAAM,CAAC,iBAAiB,CAAC,GAAW,EAAE,IAA0B;QAC9D,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,IAAY,EAAE,EAAW;QAC7C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC;SACb;QACD,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,IAA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AMK,6BAAqB,GAAG,CAC7B,aAAqB,EACrB,SAAiE,EAC3D,EAAE;IACR,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC;AACjD,CAAC,CAAC;AAEK,wBAAgB,GAAG,CAAC,aAAqB,EAAE,EAAE;IAClD,OAAO,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEK,2BAAmB,GAAG,CAAC,eAAuB,EAAE,WAAoC,EAAE,EAAE;IAC7F,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC;AACvD,CAAC,CAAC","file":"factory.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type {\n GlyphChannelEncoder,\n GlyphDefaultEncoder,\n IComponentConstructor,\n IElement,\n IGlyphElement,\n IGlyphMeta,\n IGrammarBaseConstructor,\n IGroupMark,\n IInteractionConstructor,\n IMark,\n IMarkConstructor,\n IPlotMarkConstructor,\n ISemanticMark,\n ITransform,\n IView,\n MarkType,\n TypeAnimation\n} from '../types';\nimport { GlyphMeta } from '../view/glyph-meta';\n\nexport class Factory {\n private static _plotMarks: Record<string, IPlotMarkConstructor> = {};\n private static _marks: Record<string, IMarkConstructor> = {};\n private static _components: Record<string, IComponentConstructor> = {};\n private static _graphicComponents: Record<string, (attrs: any, mode?: '2d' | '3d') => IGraphic> = {};\n private static _transforms: Record<string, ITransform> = {};\n private static _grammars: Record<string, { grammarClass: IGrammarBaseConstructor; specKey: string }> = {};\n private static _glyphs: Record<string, IGlyphMeta<any, any>> = {};\n private static _animations: Record<string, TypeAnimation<IGlyphElement> | TypeAnimation<IElement>> = {};\n private static _interactions: Record<string, IInteractionConstructor> = {};\n\n static registerPlotMarks(key: string, mark: IPlotMarkConstructor) {\n Factory._plotMarks[key] = mark;\n }\n\n static createPlotMark(type: string, id?: string): ISemanticMark<any, any> | null {\n if (!Factory._plotMarks[type]) {\n return null;\n }\n const MarkConstructor = Factory._plotMarks[type];\n return new MarkConstructor(id);\n }\n\n static registerMark(key: string, mark: IMarkConstructor) {\n Factory._marks[key] = mark;\n }\n\n static createMark(type: string, view: IView, group?: IGroupMark): IMark | null {\n if (!Factory._marks[type]) {\n return null;\n }\n const MarkConstructor = Factory._marks[type];\n return new MarkConstructor(view, type, group);\n }\n\n static hasMark(type: string) {\n return !!Factory._marks[type];\n }\n\n static registerComponent(key: string, component: IComponentConstructor) {\n Factory._components[key] = component;\n }\n\n static createComponent(componentType: string, view: IView, group?: IGroupMark, mode?: '2d' | '3d') {\n const Ctor = Factory._components[componentType];\n if (!Ctor) {\n return null;\n }\n\n return new Ctor(view, group, mode);\n }\n\n static hasComponent(componentType: string) {\n return !!Factory._components[componentType];\n }\n\n static registerGraphicComponent(key: string, creator: (attrs: any, mode?: '2d' | '3d') => IGraphic) {\n Factory._graphicComponents[key] = creator;\n }\n\n static createGraphicComponent(componentType: string, attrs: any, mode?: '2d' | '3d') {\n const compCreator = Factory._graphicComponents[componentType];\n\n if (!compCreator) {\n return null;\n }\n\n return compCreator(attrs, mode);\n }\n\n static registerTransform(type: string, transform: Omit<ITransform, 'type'>, isBuiltIn?: boolean) {\n Factory._transforms[type] = Object.assign(transform, { type, isBuiltIn: !!isBuiltIn });\n }\n\n static getTransform(type: string) {\n return Factory._transforms[type];\n }\n\n static unregisterRuntimeTransforms() {\n Object.keys(Factory._transforms).forEach(type => {\n if (Factory._transforms[type] && !Factory._transforms[type].isBuiltIn) {\n Factory._transforms[type] = null;\n }\n });\n }\n\n static registerGrammar(type: string, grammarClass: IGrammarBaseConstructor, specKey?: string) {\n Factory._grammars[type] = {\n grammarClass: grammarClass,\n specKey: specKey ?? type\n };\n }\n\n static createGrammar(type: string, view: IView) {\n const Ctor = Factory._grammars[type]?.grammarClass;\n\n if (!Ctor) {\n return null;\n }\n\n return new Ctor(view);\n }\n\n static getGrammars() {\n return this._grammars;\n }\n\n static registerGlyph = <EncodeValuesType = any, GlyphConfigType = any>(\n glyphType: string,\n marks: { [markName: string]: MarkType },\n encoders?: { [markName: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType> },\n defaultEncoder?: GlyphDefaultEncoder,\n progressiveChannels?: string | string[]\n ): IGlyphMeta<EncodeValuesType, GlyphConfigType> => {\n Factory._glyphs[glyphType] = new GlyphMeta<EncodeValuesType, GlyphConfigType>(\n marks,\n encoders,\n defaultEncoder,\n progressiveChannels\n );\n return Factory._glyphs[glyphType];\n };\n\n static getGlyph(glyphType: string): IGlyphMeta {\n return Factory._glyphs[glyphType];\n }\n\n static registerAnimationType = (\n animationType: string,\n animation: TypeAnimation<IGlyphElement> | TypeAnimation<IElement>\n ): void => {\n Factory._animations[animationType] = animation;\n };\n\n static getAnimationType = (animationType: string) => {\n return Factory._animations[animationType];\n };\n\n static registerInteraction = (interactionType: string, interaction: IInteractionConstructor) => {\n Factory._interactions[interactionType] = interaction;\n };\n\n static createInteraction(interactionType: string, view: IView, options?: any) {\n const Ctor = Factory._interactions[interactionType];\n if (!Ctor) {\n return null;\n }\n\n return new Ctor(view, options);\n }\n}\n"]}
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  }), exports.moveOut = exports.moveIn = void 0;
6
6
 
7
7
  const vutils_1 = require("@visactor/vutils"), moveIn = (element, options, animationParameters) => {
8
- var _a, _b, _c, _d, _e;
9
- const offset = null !== (_a = null == options ? void 0 : options.offset) && void 0 !== _a ? _a : 0, groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null, groupWidth = null !== (_b = null == groupBounds ? void 0 : groupBounds.width()) && void 0 !== _b ? _b : animationParameters.width, groupHeight = null !== (_c = null == groupBounds ? void 0 : groupBounds.height()) && void 0 !== _c ? _c : animationParameters.height, changedX = ("negative" === (null == options ? void 0 : options.orient) ? groupWidth : 0) + offset, changedY = ("negative" === (null == options ? void 0 : options.orient) ? groupHeight : 0) + offset, fromX = (0,
10
- vutils_1.isValidNumber)(null === (_d = null == options ? void 0 : options.point) || void 0 === _d ? void 0 : _d.x) ? options.point.x : changedX, fromY = (0,
11
- vutils_1.isValidNumber)(null === (_e = null == options ? void 0 : options.point) || void 0 === _e ? void 0 : _e.y) ? options.point.y : changedY;
8
+ var _a, _b, _c;
9
+ const offset = null !== (_a = null == options ? void 0 : options.offset) && void 0 !== _a ? _a : 0, groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null, groupWidth = null !== (_b = null == groupBounds ? void 0 : groupBounds.width()) && void 0 !== _b ? _b : animationParameters.width, groupHeight = null !== (_c = null == groupBounds ? void 0 : groupBounds.height()) && void 0 !== _c ? _c : animationParameters.height, changedX = ("negative" === (null == options ? void 0 : options.orient) ? groupWidth : 0) + offset, changedY = ("negative" === (null == options ? void 0 : options.orient) ? groupHeight : 0) + offset, point = (0,
10
+ vutils_1.isFunction)(null == options ? void 0 : options.point) ? options.point.call(null, element.getDatum(), element, animationParameters) : null == options ? void 0 : options.point, fromX = (0,
11
+ vutils_1.isValidNumber)(null == point ? void 0 : point.x) ? point.x : changedX, fromY = (0,
12
+ vutils_1.isValidNumber)(null == point ? void 0 : point.y) ? point.y : changedY;
12
13
  switch (null == options ? void 0 : options.direction) {
13
14
  case "x":
14
15
  return {
@@ -47,10 +48,11 @@ const vutils_1 = require("@visactor/vutils"), moveIn = (element, options, animat
47
48
  exports.moveIn = moveIn;
48
49
 
49
50
  const moveOut = (element, options, animationParameters) => {
50
- var _a, _b, _c, _d, _e;
51
- const offset = null !== (_a = null == options ? void 0 : options.offset) && void 0 !== _a ? _a : 0, groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null, groupWidth = null !== (_b = null == groupBounds ? void 0 : groupBounds.width()) && void 0 !== _b ? _b : animationParameters.width, groupHeight = null !== (_c = null == groupBounds ? void 0 : groupBounds.height()) && void 0 !== _c ? _c : animationParameters.height, changedX = ("negative" === (null == options ? void 0 : options.orient) ? groupWidth : 0) + offset, changedY = ("negative" === (null == options ? void 0 : options.orient) ? groupHeight : 0) + offset, fromX = (0,
52
- vutils_1.isValidNumber)(null === (_d = null == options ? void 0 : options.point) || void 0 === _d ? void 0 : _d.x) ? options.point.x : changedX, fromY = (0,
53
- vutils_1.isValidNumber)(null === (_e = null == options ? void 0 : options.point) || void 0 === _e ? void 0 : _e.y) ? options.point.y : changedY;
51
+ var _a, _b, _c;
52
+ const offset = null !== (_a = null == options ? void 0 : options.offset) && void 0 !== _a ? _a : 0, groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null, groupWidth = null !== (_b = null == groupBounds ? void 0 : groupBounds.width()) && void 0 !== _b ? _b : animationParameters.width, groupHeight = null !== (_c = null == groupBounds ? void 0 : groupBounds.height()) && void 0 !== _c ? _c : animationParameters.height, changedX = ("negative" === (null == options ? void 0 : options.orient) ? groupWidth : 0) + offset, changedY = ("negative" === (null == options ? void 0 : options.orient) ? groupHeight : 0) + offset, point = (0,
53
+ vutils_1.isFunction)(null == options ? void 0 : options.point) ? options.point.call(null, element.getDatum(), element, animationParameters) : null == options ? void 0 : options.point, fromX = (0,
54
+ vutils_1.isValidNumber)(null == point ? void 0 : point.x) ? point.x : changedX, fromY = (0,
55
+ vutils_1.isValidNumber)(null == point ? void 0 : point.y) ? point.y : changedY;
54
56
  switch (null == options ? void 0 : options.direction) {
55
57
  case "x":
56
58
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graph/animation/animation/move.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AAM1C,MAAM,MAAM,GAA4B,CAC7C,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,MAAM,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,CAAC,CAAC;IAEpC,MAAM,WAAW,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7F,MAAM,UAAU,GAAG,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,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} from '@visactor/vutils';\nimport type { IElement, IMoveAnimationOptions, IAnimationParameters, TypeAnimation } from '../../../types';\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const offset = options?.offset ?? 0;\n // consider the offset of group\n const groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null;\n const groupWidth = groupBounds?.width() ?? animationParameters.width;\n const groupHeight = groupBounds?.height() ?? animationParameters.height;\n const changedX = (options?.orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (options?.orient === 'negative' ? groupHeight : 0) + offset;\n const fromX = isValidNumber(options?.point?.x) ? options.point.x : changedX;\n const fromY = isValidNumber(options?.point?.y) ? options.point.y : changedY;\n\n switch (options?.direction) {\n case 'x':\n return {\n from: { x: fromX },\n to: { x: element.getGraphicAttribute('x', false) }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: element.getGraphicAttribute('y', false) }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: element.getGraphicAttribute('x', false),\n y: element.getGraphicAttribute('y', false)\n }\n };\n }\n};\n\nexport const moveOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const offset = options?.offset ?? 0;\n // consider the offset of group\n const groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null;\n const groupWidth = groupBounds?.width() ?? animationParameters.width;\n const groupHeight = groupBounds?.height() ?? animationParameters.height;\n const changedX = (options?.orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (options?.orient === 'negative' ? groupHeight : 0) + offset;\n const fromX = isValidNumber(options?.point?.x) ? options.point.x : changedX;\n const fromY = isValidNumber(options?.point?.y) ? options.point.y : changedY;\n\n switch (options?.direction) {\n case 'x':\n return {\n from: { x: element.getGraphicAttribute('x', true) },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: element.getGraphicAttribute('y', true) },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: element.getGraphicAttribute('x', true),\n y: element.getGraphicAttribute('y', true)\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n"]}
1
+ {"version":3,"sources":["../src/graph/animation/animation/move.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAMtD,MAAM,MAAM,GAA4B,CAC7C,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,MAAM,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,CAAC,CAAC;IAEpC,MAAM,WAAW,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7F,MAAM,UAAU,GAAG,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,EAAE,mCAAI,mBAAmB,CAAC,KAAK,CAAC;IACrE,MAAM,WAAW,GAAG,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAE,mCAAI,mBAAmB,CAAC,MAAM,CAAC;IACxE,MAAM,QAAQ,GAAG,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,MAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC5E,MAAM,QAAQ,GAAG,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,MAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC7E,MAAM,KAAK,GAAG,IAAA,mBAAU,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;QACtC,CAAC,CAAC,OAAO,CAAC,KAAK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AAL,KAAK,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC3D,MAAM,KAAK,GAAG,IAAA,sBAAa,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAE3D,QAAQ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE;QAC1B,KAAK,GAAG;YACN,OAAO;gBACL,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;gBACnD,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE;aACjB,CAAC;QACJ,KAAK,GAAG;YACN,OAAO;gBACL,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;gBACnD,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE;aACjB,CAAC;QACJ,KAAK,IAAI,CAAC;QACV;YACE,OAAO;gBACL,IAAI,EAAE;oBACJ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC;oBACzC,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC;iBAC1C;gBACD,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE;aAC3B,CAAC;KACL;AACH,CAAC,CAAC;AAvCW,QAAA,OAAO,WAuClB","file":"move.js","sourcesContent":["import { isFunction, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IMoveAnimationOptions, IAnimationParameters, TypeAnimation } from '../../../types';\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const offset = options?.offset ?? 0;\n // consider the offset of group\n const groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null;\n const groupWidth = groupBounds?.width() ?? animationParameters.width;\n const groupHeight = groupBounds?.height() ?? animationParameters.height;\n const changedX = (options?.orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (options?.orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(options?.point)\n ? options.point.call(null, element.getDatum(), element, animationParameters)\n : options?.point;\n const fromX = isValidNumber(point?.x) ? point.x : changedX;\n const fromY = isValidNumber(point?.y) ? point.y : changedY;\n switch (options?.direction) {\n case 'x':\n return {\n from: { x: fromX },\n to: { x: element.getGraphicAttribute('x', false) }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: element.getGraphicAttribute('y', false) }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: element.getGraphicAttribute('x', false),\n y: element.getGraphicAttribute('y', false)\n }\n };\n }\n};\n\nexport const moveOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const offset = options?.offset ?? 0;\n // consider the offset of group\n const groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null;\n const groupWidth = groupBounds?.width() ?? animationParameters.width;\n const groupHeight = groupBounds?.height() ?? animationParameters.height;\n const changedX = (options?.orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (options?.orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(options?.point)\n ? options.point.call(null, element.getDatum(), element, animationParameters)\n : options?.point;\n const fromX = isValidNumber(point?.x) ? point.x : changedX;\n const fromY = isValidNumber(point?.y) ? point.y : changedY;\n\n switch (options?.direction) {\n case 'x':\n return {\n from: { x: element.getGraphicAttribute('x', true) },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: element.getGraphicAttribute('y', true) },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: element.getGraphicAttribute('x', true),\n y: element.getGraphicAttribute('y', true)\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n"]}