@anov/3d-ability 0.0.142 → 0.0.144

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 (257) hide show
  1. package/dist/business/Animation/motion/index.js +56 -35
  2. package/dist/business/Animation/motion/index.js.map +1 -1
  3. package/dist/business/Animation/type.js +2 -2
  4. package/dist/business/Area/Fence/FenceBase.js +187 -146
  5. package/dist/business/Area/Fence/FenceBase.js.map +1 -1
  6. package/dist/business/Area/Fence/fence_base_01.js +112 -120
  7. package/dist/business/Area/Fence/fence_base_01.js.map +1 -1
  8. package/dist/business/Area/Fence/fence_feeting_01.js +130 -218
  9. package/dist/business/Area/Fence/fence_feeting_01.js.map +1 -1
  10. package/dist/business/Area/Fence/fence_roll_01.js +130 -140
  11. package/dist/business/Area/Fence/fence_roll_01.js.map +1 -1
  12. package/dist/business/Area/FillArea/FillAreaBase.js +126 -87
  13. package/dist/business/Area/FillArea/FillAreaBase.js.map +1 -1
  14. package/dist/business/Area/FillArea/fillArea_face_01.js +98 -72
  15. package/dist/business/Area/FillArea/fillArea_face_01.js.map +1 -1
  16. package/dist/business/Area/FillArea/fillArea_line_01.js +94 -66
  17. package/dist/business/Area/FillArea/fillArea_line_01.js.map +1 -1
  18. package/dist/business/Area/index.js +483 -267
  19. package/dist/business/Area/index.js.map +1 -1
  20. package/dist/business/Area/tool.js +26 -14
  21. package/dist/business/Area/tool.js.map +1 -1
  22. package/dist/business/Base/ObjectLayer.js +46 -21
  23. package/dist/business/Base/ObjectLayer.js.map +1 -1
  24. package/dist/business/Batch/index.js +234 -189
  25. package/dist/business/Batch/index.js.map +1 -1
  26. package/dist/business/Box/index.js +81 -52
  27. package/dist/business/Box/index.js.map +1 -1
  28. package/dist/business/Cylinder/index.js +79 -51
  29. package/dist/business/Cylinder/index.js.map +1 -1
  30. package/dist/business/Flyline/bubble/CircleBubble.js +9 -1
  31. package/dist/business/Flyline/bubble/CircleBubble.js.map +1 -1
  32. package/dist/business/Flyline/bubble/index.js +21 -7
  33. package/dist/business/Flyline/bubble/index.js.map +1 -1
  34. package/dist/business/Flyline/index.js +162 -96
  35. package/dist/business/Flyline/index.js.map +1 -1
  36. package/dist/business/Flyline/line/ArcLine.js +291 -208
  37. package/dist/business/Flyline/line/ArcLine.js.map +1 -1
  38. package/dist/business/Flyline/line/index.js +22 -8
  39. package/dist/business/Flyline/line/index.js.map +1 -1
  40. package/dist/business/HeatMap/HeatMap.js +467 -380
  41. package/dist/business/HeatMap/HeatMap.js.map +1 -1
  42. package/dist/business/HeatMap/core.js +525 -405
  43. package/dist/business/HeatMap/core.js.map +1 -1
  44. package/dist/business/HeatMap/shader.js +3 -69
  45. package/dist/business/HeatMap/shader.js.map +1 -1
  46. package/dist/business/InfoPanel/index.js +242 -201
  47. package/dist/business/InfoPanel/index.js.map +1 -1
  48. package/dist/business/Line/index.js +88 -55
  49. package/dist/business/Line/index.js.map +1 -1
  50. package/dist/business/Mark/KeyframeAnimation.js +176 -145
  51. package/dist/business/Mark/KeyframeAnimation.js.map +1 -1
  52. package/dist/business/Mark/index.js +294 -196
  53. package/dist/business/Mark/index.js.map +1 -1
  54. package/dist/business/Mark/shader/tanhao.js +3 -36
  55. package/dist/business/Mark/shader/tanhao.js.map +1 -1
  56. package/dist/business/Mark/type.js +1 -1
  57. package/dist/business/MaterialSwitch/MaterialSwitchSystem.js +551 -377
  58. package/dist/business/MaterialSwitch/MaterialSwitchSystem.js.map +1 -1
  59. package/dist/business/MaterialSwitch/inject.js +58 -92
  60. package/dist/business/MaterialSwitch/inject.js.map +1 -1
  61. package/dist/business/MaterialSwitch/shader/finalFade.js +2 -74
  62. package/dist/business/MaterialSwitch/shader/finalFade.js.map +1 -1
  63. package/dist/business/MaterialSwitch/shader/ground.js +16 -95
  64. package/dist/business/MaterialSwitch/shader/ground.js.map +1 -1
  65. package/dist/business/MaterialSwitch/shader/groundBase64.js +3 -9
  66. package/dist/business/MaterialSwitch/shader/groundBase64.js.map +1 -1
  67. package/dist/business/MaterialSwitch/shader/realFade.js +9 -48
  68. package/dist/business/MaterialSwitch/shader/realFade.js.map +1 -1
  69. package/dist/business/Plane/index.js +78 -51
  70. package/dist/business/Plane/index.js.map +1 -1
  71. package/dist/business/Poi/index.js +336 -248
  72. package/dist/business/Poi/index.js.map +1 -1
  73. package/dist/business/Poi/link/Cylinder.js +89 -56
  74. package/dist/business/Poi/link/Cylinder.js.map +1 -1
  75. package/dist/business/Poi/link/Pyramid.js +165 -104
  76. package/dist/business/Poi/link/Pyramid.js.map +1 -1
  77. package/dist/business/Poi/link/index.d.ts +1 -1
  78. package/dist/business/Poi/link/index.js +114 -54
  79. package/dist/business/Poi/link/index.js.map +1 -1
  80. package/dist/business/Poi/panel/index.js +373 -315
  81. package/dist/business/Poi/panel/index.js.map +1 -1
  82. package/dist/business/Poi/panel/utils.js +10 -5
  83. package/dist/business/Poi/panel/utils.js.map +1 -1
  84. package/dist/business/Poi/particle/DoubleCircle.js +107 -71
  85. package/dist/business/Poi/particle/DoubleCircle.js.map +1 -1
  86. package/dist/business/Poi/particle/DynamicCircle.js +111 -75
  87. package/dist/business/Poi/particle/DynamicCircle.js.map +1 -1
  88. package/dist/business/Poi/particle/SingleCircle.js +98 -62
  89. package/dist/business/Poi/particle/SingleCircle.js.map +1 -1
  90. package/dist/business/Poi/particle/index.js +117 -49
  91. package/dist/business/Poi/particle/index.js.map +1 -1
  92. package/dist/business/Poi/shader/circle.js +3 -31
  93. package/dist/business/Poi/shader/circle.js.map +1 -1
  94. package/dist/business/Poi/shader/cylinder.js +3 -37
  95. package/dist/business/Poi/shader/cylinder.js.map +1 -1
  96. package/dist/business/Poi/shader/doubleCircle.js +3 -55
  97. package/dist/business/Poi/shader/doubleCircle.js.map +1 -1
  98. package/dist/business/Poi/shader/dynamicCircle.js +3 -67
  99. package/dist/business/Poi/shader/dynamicCircle.js.map +1 -1
  100. package/dist/business/Poi/title/Border.js +27 -7
  101. package/dist/business/Poi/title/Border.js.map +1 -1
  102. package/dist/business/Poi/title/Ellipse.js +27 -7
  103. package/dist/business/Poi/title/Ellipse.js.map +1 -1
  104. package/dist/business/Poi/title/index.js +292 -208
  105. package/dist/business/Poi/title/index.js.map +1 -1
  106. package/dist/business/Poi/tools.js +17 -18
  107. package/dist/business/Poi/tools.js.map +1 -1
  108. package/dist/business/Sphere/index.js +72 -47
  109. package/dist/business/Sphere/index.js.map +1 -1
  110. package/dist/business/Spline/index.js +245 -190
  111. package/dist/business/Spline/index.js.map +1 -1
  112. package/dist/business/SplitBuilding/index.js +536 -327
  113. package/dist/business/SplitBuilding/index.js.map +1 -1
  114. package/dist/business/SplitBuilding/type.js +2 -2
  115. package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js +275 -218
  116. package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js.map +1 -1
  117. package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js +177 -132
  118. package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js.map +1 -1
  119. package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js +1 -51
  120. package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js.map +1 -1
  121. package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js +1 -6
  122. package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js.map +1 -1
  123. package/dist/business/TrafficComponents/base.js +55 -32
  124. package/dist/business/TrafficComponents/base.js.map +1 -1
  125. package/dist/business/TrafficComponents/utils.js +24 -25
  126. package/dist/business/TrafficComponents/utils.js.map +1 -1
  127. package/dist/business/Utils/Curve.js +56 -40
  128. package/dist/business/Utils/Curve.js.map +1 -1
  129. package/dist/business/Utils/constant.js +1 -1
  130. package/dist/business/Utils/constant.js.map +1 -1
  131. package/dist/business/Utils/defineProps.js +14 -13
  132. package/dist/business/Utils/defineProps.js.map +1 -1
  133. package/dist/business/Utils/round-curve.js +153 -127
  134. package/dist/business/Utils/round-curve.js.map +1 -1
  135. package/dist/business/VideoPanel/index.js +319 -258
  136. package/dist/business/VideoPanel/index.js.map +1 -1
  137. package/dist/business/Water/index.js +108 -78
  138. package/dist/business/Water/index.js.map +1 -1
  139. package/dist/business/Water/types.js +1 -1
  140. package/dist/business/Water/types.js.map +1 -1
  141. package/dist/core/Camera/PerspectiveCamera/CameraExpand.js +449 -383
  142. package/dist/core/Camera/PerspectiveCamera/CameraExpand.js.map +1 -1
  143. package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js +142 -107
  144. package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js.map +1 -1
  145. package/dist/core/Controls/FirstViewControl/index.js +96 -84
  146. package/dist/core/Controls/FirstViewControl/index.js.map +1 -1
  147. package/dist/core/Controls/ThirdViewControl/action/input.js +98 -77
  148. package/dist/core/Controls/ThirdViewControl/action/input.js.map +1 -1
  149. package/dist/core/Controls/ThirdViewControl/config/constants.js +1 -1
  150. package/dist/core/Controls/ThirdViewControl/config/constants.js.map +1 -1
  151. package/dist/core/Controls/ThirdViewControl/index.js +28 -19
  152. package/dist/core/Controls/ThirdViewControl/index.js.map +1 -1
  153. package/dist/core/Controls/ThirdViewControl/player/animation.js +155 -126
  154. package/dist/core/Controls/ThirdViewControl/player/animation.js.map +1 -1
  155. package/dist/core/Controls/ThirdViewControl/player/camera.js +63 -47
  156. package/dist/core/Controls/ThirdViewControl/player/camera.js.map +1 -1
  157. package/dist/core/Controls/ThirdViewControl/player/control.js +49 -39
  158. package/dist/core/Controls/ThirdViewControl/player/control.js.map +1 -1
  159. package/dist/core/Controls/ThirdViewControl/player.js +91 -66
  160. package/dist/core/Controls/ThirdViewControl/player.js.map +1 -1
  161. package/dist/core/Controls/base.js +30 -14
  162. package/dist/core/Controls/base.js.map +1 -1
  163. package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js +131 -92
  164. package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js.map +1 -1
  165. package/dist/core/Debug/PerformanceInfo/Performance.js +47 -22
  166. package/dist/core/Debug/PerformanceInfo/Performance.js.map +1 -1
  167. package/dist/core/Light/PointLight/PointLightExt.js +21 -4
  168. package/dist/core/Light/PointLight/PointLightExt.js.map +1 -1
  169. package/dist/core/Material/FinirMaterial/FinirMaterial.js +57 -37
  170. package/dist/core/Material/FinirMaterial/FinirMaterial.js.map +1 -1
  171. package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js +153 -116
  172. package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js.map +1 -1
  173. package/dist/core/Material/PristineGridMaterial/shader/fragment.js +1 -95
  174. package/dist/core/Material/PristineGridMaterial/shader/fragment.js.map +1 -1
  175. package/dist/core/Material/PristineGridMaterial/shader/vertex.js +1 -26
  176. package/dist/core/Material/PristineGridMaterial/shader/vertex.js.map +1 -1
  177. package/dist/core/Material/SurfaceMaterial/index.js +172 -76
  178. package/dist/core/Material/SurfaceMaterial/index.js.map +1 -1
  179. package/dist/core/Material/decorators.js +11 -6
  180. package/dist/core/Material/decorators.js.map +1 -1
  181. package/dist/core/PostEffects/addACESFilmicToneMappingPass.js +12 -16
  182. package/dist/core/PostEffects/addACESFilmicToneMappingPass.js.map +1 -1
  183. package/dist/core/PostEffects/addBrightnessContrastPass.js +13 -17
  184. package/dist/core/PostEffects/addBrightnessContrastPass.js.map +1 -1
  185. package/dist/core/PostEffects/bloomPass.js +10 -17
  186. package/dist/core/PostEffects/bloomPass.js.map +1 -1
  187. package/dist/core/PostEffects/bloomSelect.js +43 -60
  188. package/dist/core/PostEffects/bloomSelect.js.map +1 -1
  189. package/dist/core/PostEffects/colorifyPass.js +13 -17
  190. package/dist/core/PostEffects/colorifyPass.js.map +1 -1
  191. package/dist/core/PostEffects/index.js +22 -28
  192. package/dist/core/PostEffects/index.js.map +1 -1
  193. package/dist/core/PostEffects/outlinePass.js +50 -37
  194. package/dist/core/PostEffects/outlinePass.js.map +1 -1
  195. package/dist/core/PostEffects/postprocessing.js +12 -14
  196. package/dist/core/PostEffects/postprocessing.js.map +1 -1
  197. package/dist/core/PostEffects/saoPass.js +10 -15
  198. package/dist/core/PostEffects/saoPass.js.map +1 -1
  199. package/dist/core/PostEffects/shader/colorify.js +3 -22
  200. package/dist/core/PostEffects/shader/colorify.js.map +1 -1
  201. package/dist/core/PostEffects/shader/gammaCorrectionShader.js +3 -27
  202. package/dist/core/PostEffects/shader/gammaCorrectionShader.js.map +1 -1
  203. package/dist/core/PostEffects/shader/mapping.js +3 -66
  204. package/dist/core/PostEffects/shader/mapping.js.map +1 -1
  205. package/dist/core/PostEffects/shader/thermalMaging.js +3 -28
  206. package/dist/core/PostEffects/shader/thermalMaging.js.map +1 -1
  207. package/dist/core/SceneEffect/grow/grow.js +101 -85
  208. package/dist/core/SceneEffect/grow/grow.js.map +1 -1
  209. package/dist/core/SceneEffect/grow/style_down.js +77 -60
  210. package/dist/core/SceneEffect/grow/style_down.js.map +1 -1
  211. package/dist/core/SceneEffect/grow/style_up.js +81 -64
  212. package/dist/core/SceneEffect/grow/style_up.js.map +1 -1
  213. package/dist/core/SceneEffect/grow/type.js +2 -2
  214. package/dist/core/SceneEffect/grow/type.js.map +1 -1
  215. package/dist/core/WeatherSystem/DynamicWeatherSystem.js +76 -51
  216. package/dist/core/WeatherSystem/DynamicWeatherSystem.js.map +1 -1
  217. package/dist/core/WeatherSystem/hdr/index.js +105 -69
  218. package/dist/core/WeatherSystem/hdr/index.js.map +1 -1
  219. package/dist/core/WeatherSystem/index.js +124 -77
  220. package/dist/core/WeatherSystem/index.js.map +1 -1
  221. package/dist/core/WeatherSystem/objects/fog/index.js +80 -52
  222. package/dist/core/WeatherSystem/objects/fog/index.js.map +1 -1
  223. package/dist/core/WeatherSystem/objects/rain/index.js +84 -72
  224. package/dist/core/WeatherSystem/objects/rain/index.js.map +1 -1
  225. package/dist/core/WeatherSystem/objects/rain/lineRain.js +118 -88
  226. package/dist/core/WeatherSystem/objects/rain/lineRain.js.map +1 -1
  227. package/dist/core/WeatherSystem/objects/rain/plane.js +146 -116
  228. package/dist/core/WeatherSystem/objects/rain/plane.js.map +1 -1
  229. package/dist/core/WeatherSystem/objects/rain/point.js +148 -100
  230. package/dist/core/WeatherSystem/objects/rain/point.js.map +1 -1
  231. package/dist/core/WeatherSystem/objects/sky/cloud.js +104 -71
  232. package/dist/core/WeatherSystem/objects/sky/cloud.js.map +1 -1
  233. package/dist/core/WeatherSystem/objects/sky/index.js +84 -66
  234. package/dist/core/WeatherSystem/objects/sky/index.js.map +1 -1
  235. package/dist/core/WeatherSystem/objects/sky/outline.js +45 -25
  236. package/dist/core/WeatherSystem/objects/sky/outline.js.map +1 -1
  237. package/dist/core/WeatherSystem/shaders/cloud.js +3 -74
  238. package/dist/core/WeatherSystem/shaders/cloud.js.map +1 -1
  239. package/dist/core/WeatherSystem/shaders/fog.js +3 -103
  240. package/dist/core/WeatherSystem/shaders/fog.js.map +1 -1
  241. package/dist/core/WeatherSystem/shaders/rain.js +7 -206
  242. package/dist/core/WeatherSystem/shaders/rain.js.map +1 -1
  243. package/dist/core/WeatherSystem/shaders/sky.js +3 -87
  244. package/dist/core/WeatherSystem/shaders/sky.js.map +1 -1
  245. package/dist/core/WeatherSystem/sky/index.js +135 -104
  246. package/dist/core/WeatherSystem/sky/index.js.map +1 -1
  247. package/dist/core/WeatherSystem/utils/constant.js +38 -44
  248. package/dist/core/WeatherSystem/utils/constant.js.map +1 -1
  249. package/dist/core/WeatherSystem/utils/math.js +25 -18
  250. package/dist/core/WeatherSystem/utils/math.js.map +1 -1
  251. package/dist/core/WeatherSystem/utils/type.js +1 -1
  252. package/dist/core/WeatherSystem/utils/type.js.map +1 -1
  253. package/dist/core/WeatherSystem/weather/index.js +141 -96
  254. package/dist/core/WeatherSystem/weather/index.js.map +1 -1
  255. package/dist/utils/index.js +1 -1
  256. package/dist/utils/index.js.map +1 -1
  257. package/package.json +3 -3
@@ -1,9 +1,19 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
5
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- const HeatmapConfig = {
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
+ var HeatmapConfig = {
7
17
  defaultRadius: 40,
8
18
  defaultRenderer: 'canvas2d',
9
19
  defaultGradient: {
@@ -20,8 +30,9 @@ const HeatmapConfig = {
20
30
  defaultValueField: 'value',
21
31
  plugins: {}
22
32
  };
23
- class Store {
24
- constructor(config) {
33
+ var Store = /*#__PURE__*/function () {
34
+ function Store(config) {
35
+ _classCallCheck(this, Store);
25
36
  _defineProperty(this, "_coordinator", {});
26
37
  _defineProperty(this, "_data", []);
27
38
  _defineProperty(this, "_radi", []);
@@ -36,147 +47,177 @@ class Store {
36
47
  this._valueField = config.valueField || config.defaultValueField;
37
48
  if (config.radius) this._cfgRadius = config.radius;
38
49
  }
39
- _organiseData(dataPoint, forceRender) {
40
- const x = dataPoint[this._xField];
41
- const y = dataPoint[this._yField];
42
- const radi = this._radi;
43
- const store = this._data;
44
- const max = this._max;
45
- const min = this._min;
46
- const value = dataPoint[this._valueField] || 1;
47
- const radius = dataPoint.radius || this._cfgRadius || HeatmapConfig.defaultRadius;
48
- if (!store[x]) {
49
- store[x] = [];
50
- radi[x] = [];
51
- }
52
- if (!store[x][y]) {
53
- store[x][y] = value;
54
- radi[x][y] = radius;
55
- } else {
56
- store[x][y] += value;
57
- }
58
- const storedVal = store[x][y];
59
- if (storedVal > max) {
60
- if (!forceRender) this._max = storedVal;else this.setDataMax(storedVal);
61
- return false;
62
- } else if (storedVal < min) {
63
- if (!forceRender) this._min = storedVal;else this.setDataMin(storedVal);
64
- return false;
65
- } else {
50
+ _createClass(Store, [{
51
+ key: "_organiseData",
52
+ value: function _organiseData(dataPoint, forceRender) {
53
+ var x = dataPoint[this._xField];
54
+ var y = dataPoint[this._yField];
55
+ var radi = this._radi;
56
+ var store = this._data;
57
+ var max = this._max;
58
+ var min = this._min;
59
+ var value = dataPoint[this._valueField] || 1;
60
+ var radius = dataPoint.radius || this._cfgRadius || HeatmapConfig.defaultRadius;
61
+ if (!store[x]) {
62
+ store[x] = [];
63
+ radi[x] = [];
64
+ }
65
+ if (!store[x][y]) {
66
+ store[x][y] = value;
67
+ radi[x][y] = radius;
68
+ } else {
69
+ store[x][y] += value;
70
+ }
71
+ var storedVal = store[x][y];
72
+ if (storedVal > max) {
73
+ if (!forceRender) this._max = storedVal;else this.setDataMax(storedVal);
74
+ return false;
75
+ } else if (storedVal < min) {
76
+ if (!forceRender) this._min = storedVal;else this.setDataMin(storedVal);
77
+ return false;
78
+ } else {
79
+ return {
80
+ x: x,
81
+ y: y,
82
+ value: value,
83
+ radius: radius,
84
+ min: min,
85
+ max: max
86
+ };
87
+ }
88
+ }
89
+ }, {
90
+ key: "_unOrganizeData",
91
+ value: function _unOrganizeData() {
92
+ var unorganizedData = [];
93
+ var data = this._data;
94
+ var radi = this._radi;
95
+ for (var x in data) {
96
+ for (var y in data[x]) {
97
+ unorganizedData.push({
98
+ x: x,
99
+ y: y,
100
+ radius: radi[x][y],
101
+ value: data[x][y]
102
+ });
103
+ }
104
+ }
66
105
  return {
67
- x,
68
- y,
69
- value,
70
- radius,
71
- min,
72
- max
106
+ min: this._min,
107
+ max: this._max,
108
+ data: unorganizedData
73
109
  };
74
110
  }
75
- }
76
- _unOrganizeData() {
77
- const unorganizedData = [];
78
- const data = this._data;
79
- const radi = this._radi;
80
- for (const x in data) {
81
- for (const y in data[x]) {
82
- unorganizedData.push({
83
- x,
84
- y,
85
- radius: radi[x][y],
86
- value: data[x][y]
87
- });
88
- }
111
+ }, {
112
+ key: "_onExtremaChange",
113
+ value: function _onExtremaChange() {
114
+ this._coordinator.emit('extremachange', {
115
+ min: this._min,
116
+ max: this._max
117
+ });
89
118
  }
90
- return {
91
- min: this._min,
92
- max: this._max,
93
- data: unorganizedData
94
- };
95
- }
96
- _onExtremaChange() {
97
- this._coordinator.emit('extremachange', {
98
- min: this._min,
99
- max: this._max
100
- });
101
- }
102
- addData(...args) {
103
- if (args[0].length > 0) {
104
- const dataArr = args[0];
105
- let dataLen = dataArr.length;
106
- while (dataLen--) this.addData(dataArr[dataLen]);
107
- } else {
108
- // add to store
109
- const organisedEntry = this._organiseData(args[0], true);
110
- if (organisedEntry) {
111
- // if it's the first datapoint initialize the extremas with it
112
- if (this._data.length === 0) this._min = this._max = organisedEntry.value;
113
- this._coordinator.emit('renderpartial', {
114
- min: this._min,
115
- max: this._max,
116
- data: [organisedEntry]
117
- });
119
+ }, {
120
+ key: "addData",
121
+ value: function addData() {
122
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
123
+ args[_key] = arguments[_key];
124
+ }
125
+ if (args[0].length > 0) {
126
+ var dataArr = args[0];
127
+ var dataLen = dataArr.length;
128
+ while (dataLen--) this.addData(dataArr[dataLen]);
129
+ } else {
130
+ // add to store
131
+ var organisedEntry = this._organiseData(args[0], true);
132
+ if (organisedEntry) {
133
+ // if it's the first datapoint initialize the extremas with it
134
+ if (this._data.length === 0) this._min = this._max = organisedEntry.value;
135
+ this._coordinator.emit('renderpartial', {
136
+ min: this._min,
137
+ max: this._max,
138
+ data: [organisedEntry]
139
+ });
140
+ }
118
141
  }
142
+ return this;
119
143
  }
120
- return this;
121
- }
122
- setData(data) {
123
- const dataPoints = data.data;
124
- const pointsLen = dataPoints.length;
144
+ }, {
145
+ key: "setData",
146
+ value: function setData(data) {
147
+ var dataPoints = data.data;
148
+ var pointsLen = dataPoints.length;
125
149
 
126
- // reset data arrays
127
- this._data = [];
128
- this._radi = [];
129
- for (let i = 0; i < pointsLen; i++) this._organiseData(dataPoints[i], false);
130
- this._max = data.max;
131
- this._min = data.min || 0;
132
- this._onExtremaChange();
133
- this._coordinator.emit('renderall', this.getInternalData());
134
- return this;
135
- }
136
- removeData() {
137
- // TODO: implement
138
- }
139
- setDataMax(max) {
140
- this._max = max;
141
- this._onExtremaChange();
142
- this._coordinator.emit('renderall', this.getInternalData());
143
- return this;
144
- }
145
- setDataMin(min) {
146
- this._min = min;
147
- this._onExtremaChange();
148
- this._coordinator.emit('renderall', this.getInternalData());
149
- return this;
150
- }
151
- setCoordinator(coordinator) {
152
- this._coordinator = coordinator;
153
- }
154
- getInternalData() {
155
- return {
156
- max: this._max,
157
- min: this._min,
158
- data: this._data,
159
- radi: this._radi
160
- };
161
- }
162
- getData() {
163
- return this._unOrganizeData();
164
- }
165
- getValueAt(point) {
166
- var _renderer;
167
- const shadowCtx = (_renderer = this._renderer) === null || _renderer === void 0 ? void 0 : _renderer.shadowCtx;
168
- if (!shadowCtx) return null;
169
- const img = shadowCtx.getImageData(point.x, point.y, 1, 1);
170
- const data = img.data[3];
171
- const max = this._max;
172
- const min = this._min;
173
- const value = Math.abs(max - min) * (data / 255) >> 0;
174
- return value;
175
- }
176
- }
177
- class Canvas2dRenderer {
178
- constructor(config) {
150
+ // reset data arrays
151
+ this._data = [];
152
+ this._radi = [];
153
+ for (var i = 0; i < pointsLen; i++) this._organiseData(dataPoints[i], false);
154
+ this._max = data.max;
155
+ this._min = data.min || 0;
156
+ this._onExtremaChange();
157
+ this._coordinator.emit('renderall', this.getInternalData());
158
+ return this;
159
+ }
160
+ }, {
161
+ key: "removeData",
162
+ value: function removeData() {
163
+ // TODO: implement
164
+ }
165
+ }, {
166
+ key: "setDataMax",
167
+ value: function setDataMax(max) {
168
+ this._max = max;
169
+ this._onExtremaChange();
170
+ this._coordinator.emit('renderall', this.getInternalData());
171
+ return this;
172
+ }
173
+ }, {
174
+ key: "setDataMin",
175
+ value: function setDataMin(min) {
176
+ this._min = min;
177
+ this._onExtremaChange();
178
+ this._coordinator.emit('renderall', this.getInternalData());
179
+ return this;
180
+ }
181
+ }, {
182
+ key: "setCoordinator",
183
+ value: function setCoordinator(coordinator) {
184
+ this._coordinator = coordinator;
185
+ }
186
+ }, {
187
+ key: "getInternalData",
188
+ value: function getInternalData() {
189
+ return {
190
+ max: this._max,
191
+ min: this._min,
192
+ data: this._data,
193
+ radi: this._radi
194
+ };
195
+ }
196
+ }, {
197
+ key: "getData",
198
+ value: function getData() {
199
+ return this._unOrganizeData();
200
+ }
201
+ }, {
202
+ key: "getValueAt",
203
+ value: function getValueAt(point) {
204
+ var _renderer;
205
+ var shadowCtx = (_renderer = this._renderer) === null || _renderer === void 0 ? void 0 : _renderer.shadowCtx;
206
+ if (!shadowCtx) return null;
207
+ var img = shadowCtx.getImageData(point.x, point.y, 1, 1);
208
+ var data = img.data[3];
209
+ var max = this._max;
210
+ var min = this._min;
211
+ var value = Math.abs(max - min) * (data / 255) >> 0;
212
+ return value;
213
+ }
214
+ }]);
215
+ return Store;
216
+ }();
217
+ var Canvas2dRenderer = /*#__PURE__*/function () {
218
+ function Canvas2dRenderer(config) {
179
219
  var _width, _height;
220
+ _classCallCheck(this, Canvas2dRenderer);
180
221
  _defineProperty(this, "shadowCanvas", void 0);
181
222
  _defineProperty(this, "canvas", void 0);
182
223
  _defineProperty(this, "_renderBoundaries", void 0);
@@ -193,11 +234,11 @@ class Canvas2dRenderer {
193
234
  _defineProperty(this, "_useGradientOpacity", void 0);
194
235
  _defineProperty(this, "_min", void 0);
195
236
  _defineProperty(this, "_max", void 0);
196
- const container = config.container;
237
+ var container = config.container;
197
238
  this.shadowCanvas = document.createElement('canvas');
198
239
  this.canvas = config.canvas || document.createElement('canvas');
199
240
  this._renderBoundaries = [10000, 10000, 0, 0];
200
- const computed = getComputedStyle(config.container) || {};
241
+ var computed = getComputedStyle(config.container) || {};
201
242
  this.canvas.className = 'heatmap-canvas';
202
243
  this._width = this.canvas.width = this.shadowCanvas.width = config.width || +((_width = computed.width) === null || _width === void 0 ? void 0 : _width.replace(/px/, '')) || 0;
203
244
  this._height = this.canvas.height = this.shadowCanvas.height = config.height || +((_height = computed.height) === null || _height === void 0 ? void 0 : _height.replace(/px/, '')) || 0;
@@ -210,226 +251,264 @@ class Canvas2dRenderer {
210
251
  this._templates = {};
211
252
  this._setStyles(config);
212
253
  }
213
- _getColorPalette(config) {
214
- var _config$gradient;
215
- const gradientConfig = (_config$gradient = config.gradient) !== null && _config$gradient !== void 0 ? _config$gradient : config.defaultGradient;
216
- const paletteCanvas = document.createElement('canvas');
217
- const paletteCtx = paletteCanvas.getContext('2d');
218
- paletteCanvas.width = 256;
219
- paletteCanvas.height = 1;
220
- const gradient = paletteCtx.createLinearGradient(0, 0, 256, 1);
221
- for (const key in gradientConfig) gradient.addColorStop(+key, gradientConfig[key]);
222
- paletteCtx.fillStyle = gradient;
223
- paletteCtx.fillRect(0, 0, 256, 1);
224
- return paletteCtx.getImageData(0, 0, 256, 1).data;
225
- }
226
- _getPointTemplate(radius, blurFactor) {
227
- const tplCanvas = document.createElement('canvas');
228
- const tplCtx = tplCanvas.getContext('2d');
229
- const x = radius;
230
- const y = radius;
231
- tplCanvas.width = tplCanvas.height = radius * 2;
232
- if (blurFactor === 1) {
233
- tplCtx.beginPath();
234
- tplCtx.arc(x, y, radius, 0, 2 * Math.PI, false);
235
- tplCtx.fillStyle = 'rgba(0,0,0,1)';
236
- tplCtx.fill();
237
- } else {
238
- const gradient = tplCtx.createRadialGradient(x, y, radius * blurFactor, x, y, radius);
239
- gradient.addColorStop(0, 'rgba(0,0,0,1)');
240
- gradient.addColorStop(1, 'rgba(0,0,0,0)');
241
- tplCtx.fillStyle = gradient;
242
- tplCtx.fillRect(0, 0, 2 * radius, 2 * radius);
254
+ _createClass(Canvas2dRenderer, [{
255
+ key: "_getColorPalette",
256
+ value: function _getColorPalette(config) {
257
+ var _config$gradient;
258
+ var gradientConfig = (_config$gradient = config.gradient) !== null && _config$gradient !== void 0 ? _config$gradient : config.defaultGradient;
259
+ var paletteCanvas = document.createElement('canvas');
260
+ var paletteCtx = paletteCanvas.getContext('2d');
261
+ paletteCanvas.width = 256;
262
+ paletteCanvas.height = 1;
263
+ var gradient = paletteCtx.createLinearGradient(0, 0, 256, 1);
264
+ for (var _key2 in gradientConfig) gradient.addColorStop(+_key2, gradientConfig[_key2]);
265
+ paletteCtx.fillStyle = gradient;
266
+ paletteCtx.fillRect(0, 0, 256, 1);
267
+ return paletteCtx.getImageData(0, 0, 256, 1).data;
243
268
  }
244
- return tplCanvas;
245
- }
246
- _prepareData(data) {
247
- const renderData = [];
248
- const min = data.min;
249
- const max = data.max;
250
- const radi = data.radi;
251
- const data2 = data.data;
252
- const xValues = Object.keys(data2);
253
- let xValuesLen = xValues.length;
254
- while (xValuesLen--) {
255
- const xValue = xValues[xValuesLen];
256
- const yValues = Object.keys(data2[xValue]);
257
- let yValuesLen = yValues.length;
258
- while (yValuesLen--) {
259
- const yValue = yValues[yValuesLen];
260
- const value = data2[xValue][yValue];
261
- const radius = radi[xValue][yValue];
262
- renderData.push({
263
- x: xValue,
264
- y: yValue,
265
- value,
266
- radius
267
- });
269
+ }, {
270
+ key: "_getPointTemplate",
271
+ value: function _getPointTemplate(radius, blurFactor) {
272
+ var tplCanvas = document.createElement('canvas');
273
+ var tplCtx = tplCanvas.getContext('2d');
274
+ var x = radius;
275
+ var y = radius;
276
+ tplCanvas.width = tplCanvas.height = radius * 2;
277
+ if (blurFactor === 1) {
278
+ tplCtx.beginPath();
279
+ tplCtx.arc(x, y, radius, 0, 2 * Math.PI, false);
280
+ tplCtx.fillStyle = 'rgba(0,0,0,1)';
281
+ tplCtx.fill();
282
+ } else {
283
+ var gradient = tplCtx.createRadialGradient(x, y, radius * blurFactor, x, y, radius);
284
+ gradient.addColorStop(0, 'rgba(0,0,0,1)');
285
+ gradient.addColorStop(1, 'rgba(0,0,0,0)');
286
+ tplCtx.fillStyle = gradient;
287
+ tplCtx.fillRect(0, 0, 2 * radius, 2 * radius);
268
288
  }
289
+ return tplCanvas;
269
290
  }
270
- return {
271
- min,
272
- max,
273
- data: renderData
274
- };
275
- }
276
- renderPartial(data) {
277
- if (data.data.length > 0) {
278
- this._drawAlpha(data);
279
- this._colorize();
291
+ }, {
292
+ key: "_prepareData",
293
+ value: function _prepareData(data) {
294
+ var renderData = [];
295
+ var min = data.min;
296
+ var max = data.max;
297
+ var radi = data.radi;
298
+ var data2 = data.data;
299
+ var xValues = Object.keys(data2);
300
+ var xValuesLen = xValues.length;
301
+ while (xValuesLen--) {
302
+ var xValue = xValues[xValuesLen];
303
+ var yValues = Object.keys(data2[xValue]);
304
+ var yValuesLen = yValues.length;
305
+ while (yValuesLen--) {
306
+ var yValue = yValues[yValuesLen];
307
+ var value = data2[xValue][yValue];
308
+ var radius = radi[xValue][yValue];
309
+ renderData.push({
310
+ x: xValue,
311
+ y: yValue,
312
+ value: value,
313
+ radius: radius
314
+ });
315
+ }
316
+ }
317
+ return {
318
+ min: min,
319
+ max: max,
320
+ data: renderData
321
+ };
280
322
  }
281
- }
282
- renderAll(data) {
283
- this._clear();
284
- if (data.data.length > 0) {
285
- this._drawAlpha(this._prepareData(data));
286
- this._colorize();
323
+ }, {
324
+ key: "renderPartial",
325
+ value: function renderPartial(data) {
326
+ if (data.data.length > 0) {
327
+ this._drawAlpha(data);
328
+ this._colorize();
329
+ }
287
330
  }
288
- }
289
- _updateGradient(config) {
290
- this._palette = this._getColorPalette(config);
291
- }
292
- updateConfig(config) {
293
- if (config.gradient) this._updateGradient(config);
294
- this._setStyles(config);
295
- }
296
- setDimensions(width, height) {
297
- this._width = width;
298
- this._height = height;
299
- this.canvas.width = this.shadowCanvas.width = width;
300
- this.canvas.height = this.shadowCanvas.height = height;
301
- }
302
- _clear() {
303
- this.shadowCtx.clearRect(0, 0, this._width, this._height);
304
- this.ctx.clearRect(0, 0, this._width, this._height);
305
- }
306
- _setStyles(config) {
307
- this._blur = config.blur === 0 ? 0 : config.blur || config.defaultBlur;
308
- if (config.backgroundColor) this.canvas.style.backgroundColor = config.backgroundColor;
309
- this._width = this.canvas.width = this.shadowCanvas.width = config.width || this._width;
310
- this._height = this.canvas.height = this.shadowCanvas.height = config.height || this._height;
311
- this._opacity = (config.opacity || 0) * 255;
312
- this._maxOpacity = (config.maxOpacity || config.defaultMaxOpacity) * 255;
313
- this._minOpacity = (config.minOpacity || config.defaultMinOpacity) * 255;
314
- this._useGradientOpacity = !!config.useGradientOpacity;
315
- }
316
- _drawAlpha(data) {
317
- this._min = data.min;
318
- this._max = data.max;
319
- const data2 = data.data || [];
320
- let dataLen = data2.length;
321
- // on a point basis?
322
- const blur = 1 - this._blur;
323
- while (dataLen--) {
324
- const point = data2[dataLen];
325
- const x = point.x;
326
- const y = point.y;
327
- const radius = point.radius;
328
- // if value is bigger than max
329
- // use max as value
330
- const value = Math.min(point.value, this._max);
331
- const rectX = x - radius;
332
- const rectY = y - radius;
333
- const shadowCtx = this.shadowCtx;
334
- let tpl;
335
- if (!this._templates[radius]) this._templates[radius] = tpl = this._getPointTemplate(radius, blur);else tpl = this._templates[radius];
331
+ }, {
332
+ key: "renderAll",
333
+ value: function renderAll(data) {
334
+ this._clear();
335
+ if (data.data.length > 0) {
336
+ this._drawAlpha(this._prepareData(data));
337
+ this._colorize();
338
+ }
339
+ }
340
+ }, {
341
+ key: "_updateGradient",
342
+ value: function _updateGradient(config) {
343
+ this._palette = this._getColorPalette(config);
344
+ }
345
+ }, {
346
+ key: "updateConfig",
347
+ value: function updateConfig(config) {
348
+ if (config.gradient) this._updateGradient(config);
349
+ this._setStyles(config);
350
+ }
351
+ }, {
352
+ key: "setDimensions",
353
+ value: function setDimensions(width, height) {
354
+ this._width = width;
355
+ this._height = height;
356
+ this.canvas.width = this.shadowCanvas.width = width;
357
+ this.canvas.height = this.shadowCanvas.height = height;
358
+ }
359
+ }, {
360
+ key: "_clear",
361
+ value: function _clear() {
362
+ this.shadowCtx.clearRect(0, 0, this._width, this._height);
363
+ this.ctx.clearRect(0, 0, this._width, this._height);
364
+ }
365
+ }, {
366
+ key: "_setStyles",
367
+ value: function _setStyles(config) {
368
+ this._blur = config.blur === 0 ? 0 : config.blur || config.defaultBlur;
369
+ if (config.backgroundColor) this.canvas.style.backgroundColor = config.backgroundColor;
370
+ this._width = this.canvas.width = this.shadowCanvas.width = config.width || this._width;
371
+ this._height = this.canvas.height = this.shadowCanvas.height = config.height || this._height;
372
+ this._opacity = (config.opacity || 0) * 255;
373
+ this._maxOpacity = (config.maxOpacity || config.defaultMaxOpacity) * 255;
374
+ this._minOpacity = (config.minOpacity || config.defaultMinOpacity) * 255;
375
+ this._useGradientOpacity = !!config.useGradientOpacity;
376
+ }
377
+ }, {
378
+ key: "_drawAlpha",
379
+ value: function _drawAlpha(data) {
380
+ this._min = data.min;
381
+ this._max = data.max;
382
+ var data2 = data.data || [];
383
+ var dataLen = data2.length;
384
+ // on a point basis?
385
+ var blur = 1 - this._blur;
386
+ while (dataLen--) {
387
+ var point = data2[dataLen];
388
+ var x = point.x;
389
+ var y = point.y;
390
+ var radius = point.radius;
391
+ // if value is bigger than max
392
+ // use max as value
393
+ var value = Math.min(point.value, this._max);
394
+ var rectX = x - radius;
395
+ var rectY = y - radius;
396
+ var shadowCtx = this.shadowCtx;
397
+ var tpl = void 0;
398
+ if (!this._templates[radius]) this._templates[radius] = tpl = this._getPointTemplate(radius, blur);else tpl = this._templates[radius];
336
399
 
337
- // value from minimum / value range
338
- // => [0, 1]
339
- const templateAlpha = (value - this._min) / (this._max - this._min);
340
- // this fixes #176: small values are not visible because globalAlpha < .01 cannot be read from imageData
341
- shadowCtx.globalAlpha = templateAlpha < 0.01 ? 0.01 : templateAlpha;
342
- shadowCtx.drawImage(tpl, rectX, rectY);
400
+ // value from minimum / value range
401
+ // => [0, 1]
402
+ var templateAlpha = (value - this._min) / (this._max - this._min);
403
+ // this fixes #176: small values are not visible because globalAlpha < .01 cannot be read from imageData
404
+ shadowCtx.globalAlpha = templateAlpha < 0.01 ? 0.01 : templateAlpha;
405
+ shadowCtx.drawImage(tpl, rectX, rectY);
343
406
 
344
- // update renderBoundaries
345
- if (rectX < this._renderBoundaries[0]) this._renderBoundaries[0] = rectX;
346
- if (rectY < this._renderBoundaries[1]) this._renderBoundaries[1] = rectY;
347
- if (rectX + 2 * radius > this._renderBoundaries[2]) this._renderBoundaries[2] = rectX + 2 * radius;
348
- if (rectY + 2 * radius > this._renderBoundaries[3]) this._renderBoundaries[3] = rectY + 2 * radius;
407
+ // update renderBoundaries
408
+ if (rectX < this._renderBoundaries[0]) this._renderBoundaries[0] = rectX;
409
+ if (rectY < this._renderBoundaries[1]) this._renderBoundaries[1] = rectY;
410
+ if (rectX + 2 * radius > this._renderBoundaries[2]) this._renderBoundaries[2] = rectX + 2 * radius;
411
+ if (rectY + 2 * radius > this._renderBoundaries[3]) this._renderBoundaries[3] = rectY + 2 * radius;
412
+ }
349
413
  }
350
- }
351
- _colorize() {
352
- let x = this._renderBoundaries[0];
353
- let y = this._renderBoundaries[1];
354
- let width = this._renderBoundaries[2] - x;
355
- let height = this._renderBoundaries[3] - y;
356
- const maxWidth = this._width;
357
- const maxHeight = this._height;
358
- const opacity = this._opacity;
359
- const maxOpacity = this._maxOpacity;
360
- const minOpacity = this._minOpacity;
361
- const useGradientOpacity = this._useGradientOpacity;
362
- if (x < 0) x = 0;
363
- if (y < 0) y = 0;
364
- if (x + width > maxWidth) width = maxWidth - x;
365
- if (y + height > maxHeight) height = maxHeight - y;
366
- const img = this.shadowCtx.getImageData(x, y, width, height);
367
- const imgData = img.data;
368
- const len = imgData.length;
369
- const palette = this._palette;
370
- for (let i = 3; i < len; i += 4) {
371
- const alpha = imgData[i];
372
- const offset = alpha * 4;
373
- if (!offset) continue;
374
- let finalAlpha;
375
- if (opacity > 0) {
376
- finalAlpha = opacity;
377
- } else {
378
- if (alpha < maxOpacity) {
379
- if (alpha < minOpacity) finalAlpha = minOpacity;else finalAlpha = alpha;
414
+ }, {
415
+ key: "_colorize",
416
+ value: function _colorize() {
417
+ var x = this._renderBoundaries[0];
418
+ var y = this._renderBoundaries[1];
419
+ var width = this._renderBoundaries[2] - x;
420
+ var height = this._renderBoundaries[3] - y;
421
+ var maxWidth = this._width;
422
+ var maxHeight = this._height;
423
+ var opacity = this._opacity;
424
+ var maxOpacity = this._maxOpacity;
425
+ var minOpacity = this._minOpacity;
426
+ var useGradientOpacity = this._useGradientOpacity;
427
+ if (x < 0) x = 0;
428
+ if (y < 0) y = 0;
429
+ if (x + width > maxWidth) width = maxWidth - x;
430
+ if (y + height > maxHeight) height = maxHeight - y;
431
+ var img = this.shadowCtx.getImageData(x, y, width, height);
432
+ var imgData = img.data;
433
+ var len = imgData.length;
434
+ var palette = this._palette;
435
+ for (var i = 3; i < len; i += 4) {
436
+ var alpha = imgData[i];
437
+ var offset = alpha * 4;
438
+ if (!offset) continue;
439
+ var finalAlpha = void 0;
440
+ if (opacity > 0) {
441
+ finalAlpha = opacity;
380
442
  } else {
381
- finalAlpha = maxOpacity;
443
+ if (alpha < maxOpacity) {
444
+ if (alpha < minOpacity) finalAlpha = minOpacity;else finalAlpha = alpha;
445
+ } else {
446
+ finalAlpha = maxOpacity;
447
+ }
382
448
  }
449
+ imgData[i - 3] = palette[offset];
450
+ imgData[i - 2] = palette[offset + 1];
451
+ imgData[i - 1] = palette[offset + 2];
452
+ imgData[i] = useGradientOpacity ? palette[offset + 3] : finalAlpha;
383
453
  }
384
- imgData[i - 3] = palette[offset];
385
- imgData[i - 2] = palette[offset + 1];
386
- imgData[i - 1] = palette[offset + 2];
387
- imgData[i] = useGradientOpacity ? palette[offset + 3] : finalAlpha;
388
- }
389
454
 
390
- // 创建新的ImageData对象
391
- const newImg = new ImageData(imgData, width, height);
392
- this.ctx.putImageData(newImg, x, y);
393
- this._renderBoundaries = [1000, 1000, 0, 0];
394
- }
395
- getValueAt(point) {
396
- const shadowCtx = this.shadowCtx;
397
- const img = shadowCtx.getImageData(point.x, point.y, 1, 1);
398
- const data = img.data[3];
399
- const max = this._max;
400
- const min = this._min;
401
- const value = Math.abs(max - min) * (data / 255) >> 0;
402
- return value;
403
- }
404
- getDataURL() {
405
- return this.canvas.toDataURL();
406
- }
407
- }
408
- class Coordinator {
409
- constructor() {
455
+ // 创建新的ImageData对象
456
+ var newImg = new ImageData(imgData, width, height);
457
+ this.ctx.putImageData(newImg, x, y);
458
+ this._renderBoundaries = [1000, 1000, 0, 0];
459
+ }
460
+ }, {
461
+ key: "getValueAt",
462
+ value: function getValueAt(point) {
463
+ var shadowCtx = this.shadowCtx;
464
+ var img = shadowCtx.getImageData(point.x, point.y, 1, 1);
465
+ var data = img.data[3];
466
+ var max = this._max;
467
+ var min = this._min;
468
+ var value = Math.abs(max - min) * (data / 255) >> 0;
469
+ return value;
470
+ }
471
+ }, {
472
+ key: "getDataURL",
473
+ value: function getDataURL() {
474
+ return this.canvas.toDataURL();
475
+ }
476
+ }]);
477
+ return Canvas2dRenderer;
478
+ }();
479
+ var Coordinator = /*#__PURE__*/function () {
480
+ function Coordinator() {
481
+ _classCallCheck(this, Coordinator);
410
482
  _defineProperty(this, "cStore", void 0);
411
483
  this.cStore = {};
412
484
  }
413
- on(evtName, callback, scope) {
414
- const cStore = this.cStore;
415
- if (!cStore[evtName]) cStore[evtName] = [];
416
- cStore[evtName].push(data => {
417
- return callback.call(scope, data);
418
- });
419
- }
420
- emit(evtName, data) {
421
- const cStore = this.cStore;
422
- if (cStore[evtName]) {
423
- const len = cStore[evtName].length;
424
- for (let i = 0; i < len; i++) {
425
- const callback = cStore[evtName][i];
426
- callback(data);
485
+ _createClass(Coordinator, [{
486
+ key: "on",
487
+ value: function on(evtName, callback, scope) {
488
+ var cStore = this.cStore;
489
+ if (!cStore[evtName]) cStore[evtName] = [];
490
+ cStore[evtName].push(function (data) {
491
+ return callback.call(scope, data);
492
+ });
493
+ }
494
+ }, {
495
+ key: "emit",
496
+ value: function emit(evtName, data) {
497
+ var cStore = this.cStore;
498
+ if (cStore[evtName]) {
499
+ var len = cStore[evtName].length;
500
+ for (var i = 0; i < len; i++) {
501
+ var callback = cStore[evtName][i];
502
+ callback(data);
503
+ }
427
504
  }
428
505
  }
429
- }
430
- }
431
- class Heatmap {
432
- constructor(config) {
506
+ }]);
507
+ return Coordinator;
508
+ }();
509
+ var Heatmap = /*#__PURE__*/function () {
510
+ function Heatmap(config) {
511
+ _classCallCheck(this, Heatmap);
433
512
  _defineProperty(this, "_config", void 0);
434
513
  _defineProperty(this, "_coordinator", void 0);
435
514
  _defineProperty(this, "_renderer", void 0);
@@ -437,16 +516,16 @@ class Heatmap {
437
516
  this._config = _objectSpread(_objectSpread({}, HeatmapConfig), config);
438
517
  this._coordinator = new Coordinator();
439
518
  if (config.plugin) {
440
- const pluginToLoad = config.plugin;
519
+ var pluginToLoad = config.plugin;
441
520
  if (!HeatmapConfig.plugins[pluginToLoad]) {
442
- throw new Error(`Plugin '${pluginToLoad}' not found. Maybe it was not registered.`);
521
+ throw new Error("Plugin '".concat(pluginToLoad, "' not found. Maybe it was not registered."));
443
522
  } else {
444
- const plugin = HeatmapConfig.plugins[pluginToLoad];
523
+ var plugin = HeatmapConfig.plugins[pluginToLoad];
445
524
  // set plugin renderer and store
446
- const Renderer = plugin.renderer;
447
- const Store = plugin.store;
525
+ var Renderer = plugin.renderer;
526
+ var _Store = plugin.store;
448
527
  this._renderer = new Renderer(config);
449
- this._store = new Store(config);
528
+ this._store = new _Store(config);
450
529
  }
451
530
  } else {
452
531
  this._renderer = new Canvas2dRenderer(config);
@@ -454,66 +533,107 @@ class Heatmap {
454
533
  }
455
534
  this._connect();
456
535
  }
457
- _connect() {
458
- const renderer = this._renderer;
459
- const coordinator = this._coordinator;
460
- const store = this._store;
461
- coordinator.on('renderpartial', renderer.renderPartial, renderer);
462
- coordinator.on('renderall', renderer.renderAll, renderer);
463
- coordinator.on('extremachange', data => {
464
- this._config.onExtremaChange && this._config.onExtremaChange({
465
- min: data.min,
466
- max: data.max,
467
- gradient: this._config.gradient || this._config.defaultGradient
536
+ _createClass(Heatmap, [{
537
+ key: "_connect",
538
+ value: function _connect() {
539
+ var _this = this;
540
+ var renderer = this._renderer;
541
+ var coordinator = this._coordinator;
542
+ var store = this._store;
543
+ coordinator.on('renderpartial', renderer.renderPartial, renderer);
544
+ coordinator.on('renderall', renderer.renderAll, renderer);
545
+ coordinator.on('extremachange', function (data) {
546
+ _this._config.onExtremaChange && _this._config.onExtremaChange({
547
+ min: data.min,
548
+ max: data.max,
549
+ gradient: _this._config.gradient || _this._config.defaultGradient
550
+ });
468
551
  });
469
- });
470
- store.setCoordinator(coordinator);
471
- }
472
- addData(...args) {
473
- if (args.length === 1) this._store.addData(args[0]);else this._store.addData(...args);
474
- return this;
475
- }
476
- removeData(...args) {
477
- if (this._store.removeData) this._store.removeData();
478
- return this;
479
- }
480
- setData(...args) {
481
- if (args.length === 1) this._store.setData(args[0]);else this._store.setData(...args);
482
- return this;
483
- }
484
- setDataMax(...args) {
485
- if (args.length === 1) this._store.setDataMax(args[0]);else this._store.setDataMax(...args);
486
- return this;
487
- }
488
- setDataMin(...args) {
489
- if (args.length === 1) this._store.setDataMin(args[0]);else this._store.setDataMin(...args);
490
- return this;
491
- }
492
- configure(config) {
493
- this._config = _objectSpread(_objectSpread({}, this._config), config);
494
- this._renderer.updateConfig(this._config);
495
- this._coordinator.emit('renderall', this._store.getInternalData());
496
- return this;
497
- }
498
- repaint() {
499
- this._coordinator.emit('renderall', this._store.getInternalData());
500
- return this;
501
- }
502
- getData() {
503
- return this._store.getData();
504
- }
505
- getDataURL() {
506
- return this._renderer.getDataURL();
507
- }
508
- getValueAt(point) {
509
- if (this._store.getValueAt) return this._store.getValueAt(point);else if (this._renderer.getValueAt) return this._renderer.getValueAt(point);else return null;
510
- }
511
- }
552
+ store.setCoordinator(coordinator);
553
+ }
554
+ }, {
555
+ key: "addData",
556
+ value: function addData() {
557
+ var _this$_store;
558
+ for (var _len2 = arguments.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {
559
+ args[_key3] = arguments[_key3];
560
+ }
561
+ if (args.length === 1) this._store.addData(args[0]);else (_this$_store = this._store).addData.apply(_this$_store, _toConsumableArray(args));
562
+ return this;
563
+ }
564
+ }, {
565
+ key: "removeData",
566
+ value: function removeData() {
567
+ if (this._store.removeData) this._store.removeData();
568
+ return this;
569
+ }
570
+ }, {
571
+ key: "setData",
572
+ value: function setData() {
573
+ var _this$_store2;
574
+ for (var _len3 = arguments.length, args = new Array(_len3), _key4 = 0; _key4 < _len3; _key4++) {
575
+ args[_key4] = arguments[_key4];
576
+ }
577
+ if (args.length === 1) this._store.setData(args[0]);else (_this$_store2 = this._store).setData.apply(_this$_store2, _toConsumableArray(args));
578
+ return this;
579
+ }
580
+ }, {
581
+ key: "setDataMax",
582
+ value: function setDataMax() {
583
+ var _this$_store3;
584
+ for (var _len4 = arguments.length, args = new Array(_len4), _key5 = 0; _key5 < _len4; _key5++) {
585
+ args[_key5] = arguments[_key5];
586
+ }
587
+ if (args.length === 1) this._store.setDataMax(args[0]);else (_this$_store3 = this._store).setDataMax.apply(_this$_store3, _toConsumableArray(args));
588
+ return this;
589
+ }
590
+ }, {
591
+ key: "setDataMin",
592
+ value: function setDataMin() {
593
+ var _this$_store4;
594
+ for (var _len5 = arguments.length, args = new Array(_len5), _key6 = 0; _key6 < _len5; _key6++) {
595
+ args[_key6] = arguments[_key6];
596
+ }
597
+ if (args.length === 1) this._store.setDataMin(args[0]);else (_this$_store4 = this._store).setDataMin.apply(_this$_store4, _toConsumableArray(args));
598
+ return this;
599
+ }
600
+ }, {
601
+ key: "configure",
602
+ value: function configure(config) {
603
+ this._config = _objectSpread(_objectSpread({}, this._config), config);
604
+ this._renderer.updateConfig(this._config);
605
+ this._coordinator.emit('renderall', this._store.getInternalData());
606
+ return this;
607
+ }
608
+ }, {
609
+ key: "repaint",
610
+ value: function repaint() {
611
+ this._coordinator.emit('renderall', this._store.getInternalData());
612
+ return this;
613
+ }
614
+ }, {
615
+ key: "getData",
616
+ value: function getData() {
617
+ return this._store.getData();
618
+ }
619
+ }, {
620
+ key: "getDataURL",
621
+ value: function getDataURL() {
622
+ return this._renderer.getDataURL();
623
+ }
624
+ }, {
625
+ key: "getValueAt",
626
+ value: function getValueAt(point) {
627
+ if (this._store.getValueAt) return this._store.getValueAt(point);else if (this._renderer.getValueAt) return this._renderer.getValueAt(point);else return null;
628
+ }
629
+ }]);
630
+ return Heatmap;
631
+ }();
512
632
  export default {
513
- create(config) {
633
+ create: function create(config) {
514
634
  return new Heatmap(config);
515
635
  },
516
- register(pluginKey, plugin) {
636
+ register: function register(pluginKey, plugin) {
517
637
  HeatmapConfig.plugins[pluginKey] = plugin;
518
638
  }
519
639
  };