@anov/3d-ability 0.0.140 → 0.0.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/business/Animation/motion/index.js +35 -56
- package/dist/business/Animation/motion/index.js.map +1 -1
- package/dist/business/Animation/type.js +2 -2
- package/dist/business/Area/Fence/FenceBase.js +146 -187
- package/dist/business/Area/Fence/FenceBase.js.map +1 -1
- package/dist/business/Area/Fence/fence_base_01.js +120 -112
- package/dist/business/Area/Fence/fence_base_01.js.map +1 -1
- package/dist/business/Area/Fence/fence_feeting_01.js +218 -130
- package/dist/business/Area/Fence/fence_feeting_01.js.map +1 -1
- package/dist/business/Area/Fence/fence_roll_01.js +140 -130
- package/dist/business/Area/Fence/fence_roll_01.js.map +1 -1
- package/dist/business/Area/FillArea/FillAreaBase.js +87 -126
- package/dist/business/Area/FillArea/FillAreaBase.js.map +1 -1
- package/dist/business/Area/FillArea/fillArea_face_01.js +72 -98
- package/dist/business/Area/FillArea/fillArea_face_01.js.map +1 -1
- package/dist/business/Area/FillArea/fillArea_line_01.js +66 -94
- package/dist/business/Area/FillArea/fillArea_line_01.js.map +1 -1
- package/dist/business/Area/index.js +267 -483
- package/dist/business/Area/index.js.map +1 -1
- package/dist/business/Area/tool.js +14 -26
- package/dist/business/Area/tool.js.map +1 -1
- package/dist/business/Base/ObjectLayer.js +21 -46
- package/dist/business/Base/ObjectLayer.js.map +1 -1
- package/dist/business/Batch/index.js +189 -234
- package/dist/business/Batch/index.js.map +1 -1
- package/dist/business/Box/index.js +52 -81
- package/dist/business/Box/index.js.map +1 -1
- package/dist/business/Cylinder/index.js +51 -79
- package/dist/business/Cylinder/index.js.map +1 -1
- package/dist/business/Flyline/bubble/CircleBubble.js +1 -9
- package/dist/business/Flyline/bubble/CircleBubble.js.map +1 -1
- package/dist/business/Flyline/bubble/index.js +7 -21
- package/dist/business/Flyline/bubble/index.js.map +1 -1
- package/dist/business/Flyline/index.js +96 -162
- package/dist/business/Flyline/index.js.map +1 -1
- package/dist/business/Flyline/line/ArcLine.js +208 -291
- package/dist/business/Flyline/line/ArcLine.js.map +1 -1
- package/dist/business/Flyline/line/index.js +8 -22
- package/dist/business/Flyline/line/index.js.map +1 -1
- package/dist/business/HeatMap/HeatMap.js +380 -467
- package/dist/business/HeatMap/HeatMap.js.map +1 -1
- package/dist/business/HeatMap/core.js +405 -525
- package/dist/business/HeatMap/core.js.map +1 -1
- package/dist/business/HeatMap/shader.js +69 -3
- package/dist/business/HeatMap/shader.js.map +1 -1
- package/dist/business/InfoPanel/index.js +201 -242
- package/dist/business/InfoPanel/index.js.map +1 -1
- package/dist/business/Line/index.js +55 -88
- package/dist/business/Line/index.js.map +1 -1
- package/dist/business/Mark/KeyframeAnimation.js +145 -176
- package/dist/business/Mark/KeyframeAnimation.js.map +1 -1
- package/dist/business/Mark/index.js +196 -294
- package/dist/business/Mark/index.js.map +1 -1
- package/dist/business/Mark/shader/tanhao.js +36 -3
- package/dist/business/Mark/shader/tanhao.js.map +1 -1
- package/dist/business/Mark/type.js +1 -1
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.js +377 -551
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.js.map +1 -1
- package/dist/business/MaterialSwitch/inject.js +92 -58
- package/dist/business/MaterialSwitch/inject.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/finalFade.js +74 -2
- package/dist/business/MaterialSwitch/shader/finalFade.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/ground.js +95 -16
- package/dist/business/MaterialSwitch/shader/ground.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/groundBase64.js +9 -3
- package/dist/business/MaterialSwitch/shader/groundBase64.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/realFade.js +48 -9
- package/dist/business/MaterialSwitch/shader/realFade.js.map +1 -1
- package/dist/business/Plane/index.js +51 -78
- package/dist/business/Plane/index.js.map +1 -1
- package/dist/business/Poi/index.d.ts +5 -0
- package/dist/business/Poi/index.js +256 -295
- package/dist/business/Poi/index.js.map +1 -1
- package/dist/business/Poi/link/Cylinder.js +56 -89
- package/dist/business/Poi/link/Cylinder.js.map +1 -1
- package/dist/business/Poi/link/Pyramid.js +104 -165
- package/dist/business/Poi/link/Pyramid.js.map +1 -1
- package/dist/business/Poi/link/index.d.ts +1 -1
- package/dist/business/Poi/link/index.js +54 -114
- package/dist/business/Poi/link/index.js.map +1 -1
- package/dist/business/Poi/panel/index.d.ts +124 -0
- package/dist/business/Poi/panel/index.js +474 -0
- package/dist/business/Poi/panel/index.js.map +1 -0
- package/dist/business/Poi/panel/interfaces.d.ts +67 -0
- package/dist/business/Poi/panel/interfaces.js +2 -0
- package/dist/business/Poi/panel/interfaces.js.map +1 -0
- package/dist/business/Poi/panel/utils.d.ts +72 -0
- package/dist/business/Poi/panel/utils.js +126 -0
- package/dist/business/Poi/panel/utils.js.map +1 -0
- package/dist/business/Poi/particle/DoubleCircle.js +71 -107
- package/dist/business/Poi/particle/DoubleCircle.js.map +1 -1
- package/dist/business/Poi/particle/DynamicCircle.js +75 -111
- package/dist/business/Poi/particle/DynamicCircle.js.map +1 -1
- package/dist/business/Poi/particle/SingleCircle.js +62 -98
- package/dist/business/Poi/particle/SingleCircle.js.map +1 -1
- package/dist/business/Poi/particle/index.js +49 -117
- package/dist/business/Poi/particle/index.js.map +1 -1
- package/dist/business/Poi/shader/circle.js +31 -3
- package/dist/business/Poi/shader/circle.js.map +1 -1
- package/dist/business/Poi/shader/cylinder.js +37 -3
- package/dist/business/Poi/shader/cylinder.js.map +1 -1
- package/dist/business/Poi/shader/doubleCircle.js +55 -3
- package/dist/business/Poi/shader/doubleCircle.js.map +1 -1
- package/dist/business/Poi/shader/dynamicCircle.js +67 -3
- package/dist/business/Poi/shader/dynamicCircle.js.map +1 -1
- package/dist/business/Poi/title/Border.js +7 -27
- package/dist/business/Poi/title/Border.js.map +1 -1
- package/dist/business/Poi/title/Ellipse.js +7 -27
- package/dist/business/Poi/title/Ellipse.js.map +1 -1
- package/dist/business/Poi/title/index.js +208 -292
- package/dist/business/Poi/title/index.js.map +1 -1
- package/dist/business/Poi/tools.js +22 -19
- package/dist/business/Poi/tools.js.map +1 -1
- package/dist/business/Poi/types.d.ts +3 -0
- package/dist/business/Poi/types.js.map +1 -1
- package/dist/business/Sphere/index.js +47 -72
- package/dist/business/Sphere/index.js.map +1 -1
- package/dist/business/Spline/index.js +190 -245
- package/dist/business/Spline/index.js.map +1 -1
- package/dist/business/SplitBuilding/index.js +327 -536
- package/dist/business/SplitBuilding/index.js.map +1 -1
- package/dist/business/SplitBuilding/type.js +2 -2
- package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js +218 -275
- package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js +132 -177
- package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js +51 -1
- package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js +6 -1
- package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js.map +1 -1
- package/dist/business/TrafficComponents/base.js +32 -55
- package/dist/business/TrafficComponents/base.js.map +1 -1
- package/dist/business/TrafficComponents/utils.js +25 -24
- package/dist/business/TrafficComponents/utils.js.map +1 -1
- package/dist/business/Utils/Curve.js +40 -56
- package/dist/business/Utils/Curve.js.map +1 -1
- package/dist/business/Utils/constant.js +1 -1
- package/dist/business/Utils/constant.js.map +1 -1
- package/dist/business/Utils/defineProps.js +13 -14
- package/dist/business/Utils/defineProps.js.map +1 -1
- package/dist/business/Utils/round-curve.js +127 -153
- package/dist/business/Utils/round-curve.js.map +1 -1
- package/dist/business/VideoPanel/index.js +258 -319
- package/dist/business/VideoPanel/index.js.map +1 -1
- package/dist/business/Water/index.js +78 -108
- package/dist/business/Water/index.js.map +1 -1
- package/dist/business/Water/types.js +1 -1
- package/dist/business/Water/types.js.map +1 -1
- package/dist/core/Camera/PerspectiveCamera/CameraExpand.js +383 -449
- package/dist/core/Camera/PerspectiveCamera/CameraExpand.js.map +1 -1
- package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js +107 -142
- package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js.map +1 -1
- package/dist/core/Controls/FirstViewControl/index.js +84 -96
- package/dist/core/Controls/FirstViewControl/index.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/action/input.js +77 -98
- package/dist/core/Controls/ThirdViewControl/action/input.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/config/constants.js +1 -1
- package/dist/core/Controls/ThirdViewControl/config/constants.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/index.js +19 -28
- package/dist/core/Controls/ThirdViewControl/index.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/animation.js +126 -155
- package/dist/core/Controls/ThirdViewControl/player/animation.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/camera.js +47 -63
- package/dist/core/Controls/ThirdViewControl/player/camera.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/control.js +39 -49
- package/dist/core/Controls/ThirdViewControl/player/control.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player.js +66 -91
- package/dist/core/Controls/ThirdViewControl/player.js.map +1 -1
- package/dist/core/Controls/base.js +14 -30
- package/dist/core/Controls/base.js.map +1 -1
- package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js +92 -131
- package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js.map +1 -1
- package/dist/core/Debug/PerformanceInfo/Performance.js +22 -47
- package/dist/core/Debug/PerformanceInfo/Performance.js.map +1 -1
- package/dist/core/Light/PointLight/PointLightExt.js +4 -21
- package/dist/core/Light/PointLight/PointLightExt.js.map +1 -1
- package/dist/core/Material/FinirMaterial/FinirMaterial.js +37 -57
- package/dist/core/Material/FinirMaterial/FinirMaterial.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js +116 -153
- package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/shader/fragment.js +95 -1
- package/dist/core/Material/PristineGridMaterial/shader/fragment.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/shader/vertex.js +26 -1
- package/dist/core/Material/PristineGridMaterial/shader/vertex.js.map +1 -1
- package/dist/core/Material/SurfaceMaterial/index.js +76 -172
- package/dist/core/Material/SurfaceMaterial/index.js.map +1 -1
- package/dist/core/Material/decorators.js +6 -11
- package/dist/core/Material/decorators.js.map +1 -1
- package/dist/core/PostEffects/addACESFilmicToneMappingPass.js +16 -12
- package/dist/core/PostEffects/addACESFilmicToneMappingPass.js.map +1 -1
- package/dist/core/PostEffects/addBrightnessContrastPass.js +17 -13
- package/dist/core/PostEffects/addBrightnessContrastPass.js.map +1 -1
- package/dist/core/PostEffects/bloomPass.js +17 -10
- package/dist/core/PostEffects/bloomPass.js.map +1 -1
- package/dist/core/PostEffects/bloomSelect.js +60 -43
- package/dist/core/PostEffects/bloomSelect.js.map +1 -1
- package/dist/core/PostEffects/colorifyPass.js +17 -13
- package/dist/core/PostEffects/colorifyPass.js.map +1 -1
- package/dist/core/PostEffects/index.js +28 -22
- package/dist/core/PostEffects/index.js.map +1 -1
- package/dist/core/PostEffects/outlinePass.js +37 -50
- package/dist/core/PostEffects/outlinePass.js.map +1 -1
- package/dist/core/PostEffects/postprocessing.js +14 -12
- package/dist/core/PostEffects/postprocessing.js.map +1 -1
- package/dist/core/PostEffects/saoPass.js +15 -10
- package/dist/core/PostEffects/saoPass.js.map +1 -1
- package/dist/core/PostEffects/shader/colorify.js +22 -3
- package/dist/core/PostEffects/shader/colorify.js.map +1 -1
- package/dist/core/PostEffects/shader/gammaCorrectionShader.js +27 -3
- package/dist/core/PostEffects/shader/gammaCorrectionShader.js.map +1 -1
- package/dist/core/PostEffects/shader/mapping.js +66 -3
- package/dist/core/PostEffects/shader/mapping.js.map +1 -1
- package/dist/core/PostEffects/shader/thermalMaging.js +28 -3
- package/dist/core/PostEffects/shader/thermalMaging.js.map +1 -1
- package/dist/core/SceneEffect/grow/grow.js +85 -101
- package/dist/core/SceneEffect/grow/grow.js.map +1 -1
- package/dist/core/SceneEffect/grow/style_down.js +60 -77
- package/dist/core/SceneEffect/grow/style_down.js.map +1 -1
- package/dist/core/SceneEffect/grow/style_up.js +64 -81
- package/dist/core/SceneEffect/grow/style_up.js.map +1 -1
- package/dist/core/SceneEffect/grow/type.js +2 -2
- package/dist/core/SceneEffect/grow/type.js.map +1 -1
- package/dist/core/WeatherSystem/DynamicWeatherSystem.js +51 -76
- package/dist/core/WeatherSystem/DynamicWeatherSystem.js.map +1 -1
- package/dist/core/WeatherSystem/hdr/index.js +69 -105
- package/dist/core/WeatherSystem/hdr/index.js.map +1 -1
- package/dist/core/WeatherSystem/index.js +77 -124
- package/dist/core/WeatherSystem/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/fog/index.js +52 -80
- package/dist/core/WeatherSystem/objects/fog/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/index.js +72 -84
- package/dist/core/WeatherSystem/objects/rain/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/lineRain.js +88 -118
- package/dist/core/WeatherSystem/objects/rain/lineRain.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/plane.js +116 -146
- package/dist/core/WeatherSystem/objects/rain/plane.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/point.js +100 -148
- package/dist/core/WeatherSystem/objects/rain/point.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/cloud.js +71 -104
- package/dist/core/WeatherSystem/objects/sky/cloud.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/index.js +66 -84
- package/dist/core/WeatherSystem/objects/sky/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/outline.js +25 -45
- package/dist/core/WeatherSystem/objects/sky/outline.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/cloud.js +74 -3
- package/dist/core/WeatherSystem/shaders/cloud.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/fog.js +103 -3
- package/dist/core/WeatherSystem/shaders/fog.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/rain.js +206 -7
- package/dist/core/WeatherSystem/shaders/rain.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/sky.js +87 -3
- package/dist/core/WeatherSystem/shaders/sky.js.map +1 -1
- package/dist/core/WeatherSystem/sky/index.js +104 -135
- package/dist/core/WeatherSystem/sky/index.js.map +1 -1
- package/dist/core/WeatherSystem/utils/constant.js +44 -38
- package/dist/core/WeatherSystem/utils/constant.js.map +1 -1
- package/dist/core/WeatherSystem/utils/math.js +18 -25
- package/dist/core/WeatherSystem/utils/math.js.map +1 -1
- package/dist/core/WeatherSystem/utils/type.js +1 -1
- package/dist/core/WeatherSystem/utils/type.js.map +1 -1
- package/dist/core/WeatherSystem/weather/index.js +96 -141
- package/dist/core/WeatherSystem/weather/index.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,19 +1,9 @@
|
|
|
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; }
|
|
8
1
|
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; }
|
|
9
2
|
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; }
|
|
13
3
|
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; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
16
|
-
|
|
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 = {
|
|
17
7
|
defaultRadius: 40,
|
|
18
8
|
defaultRenderer: 'canvas2d',
|
|
19
9
|
defaultGradient: {
|
|
@@ -30,9 +20,8 @@ var HeatmapConfig = {
|
|
|
30
20
|
defaultValueField: 'value',
|
|
31
21
|
plugins: {}
|
|
32
22
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_classCallCheck(this, Store);
|
|
23
|
+
class Store {
|
|
24
|
+
constructor(config) {
|
|
36
25
|
_defineProperty(this, "_coordinator", {});
|
|
37
26
|
_defineProperty(this, "_data", []);
|
|
38
27
|
_defineProperty(this, "_radi", []);
|
|
@@ -47,177 +36,147 @@ var Store = /*#__PURE__*/function () {
|
|
|
47
36
|
this._valueField = config.valueField || config.defaultValueField;
|
|
48
37
|
if (config.radius) this._cfgRadius = config.radius;
|
|
49
38
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
}
|
|
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 {
|
|
105
66
|
return {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
67
|
+
x,
|
|
68
|
+
y,
|
|
69
|
+
value,
|
|
70
|
+
radius,
|
|
71
|
+
min,
|
|
72
|
+
max
|
|
109
73
|
};
|
|
110
74
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
+
});
|
|
124
88
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
89
|
+
}
|
|
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
|
+
});
|
|
141
118
|
}
|
|
142
|
-
return this;
|
|
143
119
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
setData(data) {
|
|
123
|
+
const dataPoints = data.data;
|
|
124
|
+
const pointsLen = dataPoints.length;
|
|
149
125
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
value
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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) {
|
|
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) {
|
|
219
179
|
var _width, _height;
|
|
220
|
-
_classCallCheck(this, Canvas2dRenderer);
|
|
221
180
|
_defineProperty(this, "shadowCanvas", void 0);
|
|
222
181
|
_defineProperty(this, "canvas", void 0);
|
|
223
182
|
_defineProperty(this, "_renderBoundaries", void 0);
|
|
@@ -234,11 +193,11 @@ var Canvas2dRenderer = /*#__PURE__*/function () {
|
|
|
234
193
|
_defineProperty(this, "_useGradientOpacity", void 0);
|
|
235
194
|
_defineProperty(this, "_min", void 0);
|
|
236
195
|
_defineProperty(this, "_max", void 0);
|
|
237
|
-
|
|
196
|
+
const container = config.container;
|
|
238
197
|
this.shadowCanvas = document.createElement('canvas');
|
|
239
198
|
this.canvas = config.canvas || document.createElement('canvas');
|
|
240
199
|
this._renderBoundaries = [10000, 10000, 0, 0];
|
|
241
|
-
|
|
200
|
+
const computed = getComputedStyle(config.container) || {};
|
|
242
201
|
this.canvas.className = 'heatmap-canvas';
|
|
243
202
|
this._width = this.canvas.width = this.shadowCanvas.width = config.width || +((_width = computed.width) === null || _width === void 0 ? void 0 : _width.replace(/px/, '')) || 0;
|
|
244
203
|
this._height = this.canvas.height = this.shadowCanvas.height = config.height || +((_height = computed.height) === null || _height === void 0 ? void 0 : _height.replace(/px/, '')) || 0;
|
|
@@ -251,264 +210,226 @@ var Canvas2dRenderer = /*#__PURE__*/function () {
|
|
|
251
210
|
this._templates = {};
|
|
252
211
|
this._setStyles(config);
|
|
253
212
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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);
|
|
288
|
-
}
|
|
289
|
-
return tplCanvas;
|
|
290
|
-
}
|
|
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
|
-
};
|
|
322
|
-
}
|
|
323
|
-
}, {
|
|
324
|
-
key: "renderPartial",
|
|
325
|
-
value: function renderPartial(data) {
|
|
326
|
-
if (data.data.length > 0) {
|
|
327
|
-
this._drawAlpha(data);
|
|
328
|
-
this._colorize();
|
|
329
|
-
}
|
|
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);
|
|
330
243
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
+
});
|
|
338
268
|
}
|
|
339
269
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
this.
|
|
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);
|
|
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();
|
|
364
280
|
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
this.
|
|
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;
|
|
281
|
+
}
|
|
282
|
+
renderAll(data) {
|
|
283
|
+
this._clear();
|
|
284
|
+
if (data.data.length > 0) {
|
|
285
|
+
this._drawAlpha(this._prepareData(data));
|
|
286
|
+
this._colorize();
|
|
376
287
|
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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];
|
|
399
336
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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);
|
|
406
343
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
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;
|
|
413
349
|
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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;
|
|
442
380
|
} else {
|
|
443
|
-
|
|
444
|
-
if (alpha < minOpacity) finalAlpha = minOpacity;else finalAlpha = alpha;
|
|
445
|
-
} else {
|
|
446
|
-
finalAlpha = maxOpacity;
|
|
447
|
-
}
|
|
381
|
+
finalAlpha = maxOpacity;
|
|
448
382
|
}
|
|
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;
|
|
453
383
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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();
|
|
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;
|
|
475
388
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
389
|
+
|
|
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() {
|
|
482
410
|
_defineProperty(this, "cStore", void 0);
|
|
483
411
|
this.cStore = {};
|
|
484
412
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
var len = cStore[evtName].length;
|
|
500
|
-
for (var i = 0; i < len; i++) {
|
|
501
|
-
var callback = cStore[evtName][i];
|
|
502
|
-
callback(data);
|
|
503
|
-
}
|
|
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);
|
|
504
427
|
}
|
|
505
428
|
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
function Heatmap(config) {
|
|
511
|
-
_classCallCheck(this, Heatmap);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
class Heatmap {
|
|
432
|
+
constructor(config) {
|
|
512
433
|
_defineProperty(this, "_config", void 0);
|
|
513
434
|
_defineProperty(this, "_coordinator", void 0);
|
|
514
435
|
_defineProperty(this, "_renderer", void 0);
|
|
@@ -516,16 +437,16 @@ var Heatmap = /*#__PURE__*/function () {
|
|
|
516
437
|
this._config = _objectSpread(_objectSpread({}, HeatmapConfig), config);
|
|
517
438
|
this._coordinator = new Coordinator();
|
|
518
439
|
if (config.plugin) {
|
|
519
|
-
|
|
440
|
+
const pluginToLoad = config.plugin;
|
|
520
441
|
if (!HeatmapConfig.plugins[pluginToLoad]) {
|
|
521
|
-
throw new Error(
|
|
442
|
+
throw new Error(`Plugin '${pluginToLoad}' not found. Maybe it was not registered.`);
|
|
522
443
|
} else {
|
|
523
|
-
|
|
444
|
+
const plugin = HeatmapConfig.plugins[pluginToLoad];
|
|
524
445
|
// set plugin renderer and store
|
|
525
|
-
|
|
526
|
-
|
|
446
|
+
const Renderer = plugin.renderer;
|
|
447
|
+
const Store = plugin.store;
|
|
527
448
|
this._renderer = new Renderer(config);
|
|
528
|
-
this._store = new
|
|
449
|
+
this._store = new Store(config);
|
|
529
450
|
}
|
|
530
451
|
} else {
|
|
531
452
|
this._renderer = new Canvas2dRenderer(config);
|
|
@@ -533,107 +454,66 @@ var Heatmap = /*#__PURE__*/function () {
|
|
|
533
454
|
}
|
|
534
455
|
this._connect();
|
|
535
456
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
min: data.min,
|
|
548
|
-
max: data.max,
|
|
549
|
-
gradient: _this._config.gradient || _this._config.defaultGradient
|
|
550
|
-
});
|
|
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
|
|
551
468
|
});
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
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
|
-
}();
|
|
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
|
+
}
|
|
632
512
|
export default {
|
|
633
|
-
create
|
|
513
|
+
create(config) {
|
|
634
514
|
return new Heatmap(config);
|
|
635
515
|
},
|
|
636
|
-
register
|
|
516
|
+
register(pluginKey, plugin) {
|
|
637
517
|
HeatmapConfig.plugins[pluginKey] = plugin;
|
|
638
518
|
}
|
|
639
519
|
};
|