koishi-plugin-tmp-bot 1.20.0 → 1.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/evmOpenApi.js +136 -1
- package/lib/api/truckersMpApi.js +110 -1
- package/lib/api/truckersMpMapApi.js +25 -1
- package/lib/api/truckyAppApi.js +47 -1
- package/lib/command/tmpBind.js +19 -1
- package/lib/command/tmpDlcMap.js +33 -1
- package/lib/command/tmpFootprint.js +82 -1
- package/lib/command/tmpMileageRanking.js +55 -1
- package/lib/command/tmpPosition.d.ts +1 -1
- package/lib/command/tmpPosition.js +95 -1
- package/lib/command/tmpQuery.js +118 -0
- package/lib/command/tmpServer.js +34 -1
- package/lib/command/tmpTraffic/tmpTraffic.js +15 -1
- package/lib/command/tmpTraffic/tmpTrafficMap.js +119 -1
- package/lib/command/tmpTraffic/tmpTrafficText.js +58 -1
- package/lib/command/tmpVersion.js +14 -1
- package/lib/database/guildBind.js +41 -1
- package/lib/database/model.js +65 -1
- package/lib/database/translateCache.js +31 -1
- package/lib/index.js +53 -1
- package/lib/resource/dlc.html +30 -1
- package/lib/resource/footprint.html +125 -1
- package/lib/resource/mileage-leaderboard.html +174 -1
- package/lib/resource/package/ets-map.js +63 -1
- package/lib/resource/package/leaflet/heatmap.min.js +9 -1
- package/lib/resource/package/leaflet/leaflet-heatmap.js +246 -1
- package/lib/resource/package/leaflet/leaflet.min.js +1 -1
- package/lib/resource/position.html +105 -1
- package/lib/resource/traffic.html +121 -1
- package/lib/util/baiduTranslate.js +30 -1
- package/lib/util/common.js +5 -1
- package/lib/util/constant.js +36 -1
- package/package.json +3 -2
- package/readme.md +14 -13
- package/lib/command/tmpQuery/tmpQuery.d.ts +0 -2
- package/lib/command/tmpQuery/tmpQuery.js +0 -1
- package/lib/command/tmpQuery/tmpQueryImg.d.ts +0 -3
- package/lib/command/tmpQuery/tmpQueryImg.js +0 -1
- package/lib/command/tmpQuery/tmpQueryText.js +0 -1
- package/lib/resource/query.html +0 -227
- /package/lib/command/{tmpQuery/tmpQueryText.d.ts → tmpQuery.d.ts} +0 -0
|
@@ -1 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
let mapConfig = {
|
|
2
|
+
ets: {
|
|
3
|
+
tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/ets2/05102019/{z}/{x}/{y}.png',
|
|
4
|
+
multipliers: {
|
|
5
|
+
x: 70272,
|
|
6
|
+
y: 76157
|
|
7
|
+
},
|
|
8
|
+
breakpoints: {
|
|
9
|
+
uk: {
|
|
10
|
+
x: -31056.8,
|
|
11
|
+
y: -5832.867
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
bounds: {
|
|
15
|
+
y: 131072,
|
|
16
|
+
x: 131072
|
|
17
|
+
},
|
|
18
|
+
maxZoom: 8,
|
|
19
|
+
minZoom: 2,
|
|
20
|
+
// 游戏地转地图坐标
|
|
21
|
+
calculateMapCoordinate (x, y) {
|
|
22
|
+
return [
|
|
23
|
+
x / 1.609055 + mapConfig.ets.multipliers.x,
|
|
24
|
+
y / 1.609055 + mapConfig.ets.multipliers.y
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
promods: {
|
|
29
|
+
tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/promods/05102019/{z}/{x}/{y}.png',
|
|
30
|
+
multipliers: {
|
|
31
|
+
x: 51953,
|
|
32
|
+
y: 76024
|
|
33
|
+
},
|
|
34
|
+
breakpoints: {
|
|
35
|
+
uk: {
|
|
36
|
+
x: -31056.8,
|
|
37
|
+
y: -5832.867
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
bounds: {
|
|
41
|
+
y: 131072,
|
|
42
|
+
x: 131072
|
|
43
|
+
},
|
|
44
|
+
maxZoom: 8,
|
|
45
|
+
minZoom: 2,
|
|
46
|
+
// 游戏地转地图坐标
|
|
47
|
+
calculateMapCoordinate (x, y) {
|
|
48
|
+
return [
|
|
49
|
+
x / 2.598541 + mapConfig.promods.multipliers.x,
|
|
50
|
+
y / 2.598541 + mapConfig.promods.multipliers.y
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 定义地图
|
|
57
|
+
let map = L.map('map', {
|
|
58
|
+
attributionControl: false,
|
|
59
|
+
crs: L.CRS.Simple,
|
|
60
|
+
zoomControl: false,
|
|
61
|
+
zoomSnap: 0.2,
|
|
62
|
+
zoomDelta: 0.2
|
|
63
|
+
});
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
function a22_0x5814(_0x5245c6,_0x16299c){_0x5245c6=_0x5245c6-0x150;var _0x2699f5=a22_0x2699();var _0x5814f2=_0x2699f5[_0x5245c6];return _0x5814f2;}var a22_0x539753=a22_0x5814;function a22_0x2699(){var _0x15e633=['_yField','toDataURL','createRadialGradient','cStore','getDataURL','useGradientOpacity','value','style','3qwdKhu','defaultValueField','canvas','defaultXField','Plugin\x20\x27','_getInternalData','_config','16uwjsHL','_width','_renderer','defaultMinOpacity','drawImage','fillRect','clearRect','h337','maxOpacity','backgroundColor','amd','undefined','_data','_valueField','min','3467149bswfZG','6347010jstMhn','_clear','_drawAlpha','defaultRadius','minOpacity','opacity','removeData','merge','emit','17222220Hexomp','plugins','_onExtremaChange','_colorize','defaultBlur','renderPartial','_palette','660034pUwIVq','rgb(255,0,0)','defaultGradient','height','_maxOpacity','_cfgRadius','getContext','_templates','renderall','defaultRenderer','setDataMin','_height','call','exports','plugin','renderpartial','data','\x27\x20not\x20found.\x20Maybe\x20it\x20was\x20not\x20registered.','_coordinator','radius','getValueAt','_minOpacity','_max','_opacity','prototype','keys','valueField','ctx','rgba(0,0,0,1)','container','_radi','setCoordinator','defaultMaxOpacity','rgb(0,0,255)','yellow','1655138zwIcdg','function','relative','_xField','radi','createElement','fillStyle','putImageData','globalAlpha','_updateGradient','addData','_renderBoundaries','renderer','apply','push','blur','length','_unOrganizeData','extremachange','beginPath','cssText','onExtremaChange','defaultYField','setData','width','shadowCanvas','replace','store','canvas2d','gradient','getData','_min','setDataMax','_organiseData','max','_blur','appendChild','4315242xEpurR','getImageData','rgb(0,255,0)','1936644dUgttM','addColorStop','shadowCtx','position','_store','xField'];a22_0x2699=function(){return _0x15e633;};return a22_0x2699();}(function(_0x56f34e,_0x39e63a){var _0x194358=a22_0x5814,_0x2a92e4=_0x56f34e();while(!![]){try{var _0x585973=-parseInt(_0x194358(0x1ce))/0x1+-parseInt(_0x194358(0x171))/0x2+parseInt(_0x194358(0x1a7))/0x3*(-parseInt(_0x194358(0x199))/0x4)+parseInt(_0x194358(0x1be))/0x5+parseInt(_0x194358(0x196))/0x6+parseInt(_0x194358(0x1bd))/0x7*(-parseInt(_0x194358(0x1ae))/0x8)+parseInt(_0x194358(0x1c7))/0x9;if(_0x585973===_0x39e63a)break;else _0x2a92e4['push'](_0x2a92e4['shift']());}catch(_0xb139d7){_0x2a92e4['push'](_0x2a92e4['shift']());}}}(a22_0x2699,0xe5723),function(_0xabdee5,_0x137689,_0x989ab7){var _0x54b3d3=a22_0x5814;if(typeof module!==_0x54b3d3(0x1b9)&&module[_0x54b3d3(0x15b)])module[_0x54b3d3(0x15b)]=_0x989ab7();else typeof define===_0x54b3d3(0x172)&&define[_0x54b3d3(0x1b8)]?define(_0x989ab7):_0x137689[_0xabdee5]=_0x989ab7();}(a22_0x539753(0x1b5),this,function(){var _0x119273=a22_0x539753,_0x41aa2e={'defaultRadius':0x28,'defaultRenderer':_0x119273(0x18d),'defaultGradient':{0.25:_0x119273(0x16f),0.55:_0x119273(0x198),0.85:_0x119273(0x170),0x1:_0x119273(0x1cf)},'defaultMaxOpacity':0x1,'defaultMinOpacity':0x0,'defaultBlur':0.85,'defaultXField':'x','defaultYField':'y','defaultValueField':'value','plugins':{}},_0x46a8d3=function _0x4a6d1e(){var _0x1dd35f=_0x119273,_0x2f14fe=function _0x4c13ac(_0x9156a3){var _0x275b0=a22_0x5814;this[_0x275b0(0x160)]={},this[_0x275b0(0x1ba)]=[],this[_0x275b0(0x16c)]=[],this[_0x275b0(0x190)]=0x0,this[_0x275b0(0x164)]=0x1,this[_0x275b0(0x174)]=_0x9156a3[_0x275b0(0x19e)]||_0x9156a3[_0x275b0(0x1aa)],this[_0x275b0(0x19f)]=_0x9156a3['yField']||_0x9156a3[_0x275b0(0x187)],this[_0x275b0(0x1bb)]=_0x9156a3[_0x275b0(0x168)]||_0x9156a3[_0x275b0(0x1a8)],_0x9156a3['radius']&&(this[_0x275b0(0x153)]=_0x9156a3[_0x275b0(0x161)]);},_0x2668b6=_0x41aa2e[_0x1dd35f(0x1c1)];return _0x2f14fe[_0x1dd35f(0x166)]={'_organiseData':function(_0x8ad34d,_0x2263fd){var _0x3115e2=_0x1dd35f,_0x2110d7=_0x8ad34d[this['_xField']],_0x1434e2=_0x8ad34d[this[_0x3115e2(0x19f)]],_0xe7e47d=this[_0x3115e2(0x16c)],_0x2ada2f=this[_0x3115e2(0x1ba)],_0x209cfa=this[_0x3115e2(0x164)],_0x391c5f=this[_0x3115e2(0x190)],_0x39e654=_0x8ad34d[this[_0x3115e2(0x1bb)]]||0x1,_0x342d96=_0x8ad34d['radius']||this[_0x3115e2(0x153)]||_0x2668b6;return!_0x2ada2f[_0x2110d7]&&(_0x2ada2f[_0x2110d7]=[],_0xe7e47d[_0x2110d7]=[]),!_0x2ada2f[_0x2110d7][_0x1434e2]?(_0x2ada2f[_0x2110d7][_0x1434e2]=_0x39e654,_0xe7e47d[_0x2110d7][_0x1434e2]=_0x342d96):_0x2ada2f[_0x2110d7][_0x1434e2]+=_0x39e654,_0x2ada2f[_0x2110d7][_0x1434e2]>_0x209cfa?(!_0x2263fd?this[_0x3115e2(0x164)]=_0x2ada2f[_0x2110d7][_0x1434e2]:this['setDataMax'](_0x2ada2f[_0x2110d7][_0x1434e2]),![]):{'x':_0x2110d7,'y':_0x1434e2,'value':_0x39e654,'radius':_0x342d96,'min':_0x391c5f,'max':_0x209cfa};},'_unOrganizeData':function(){var _0x13267c=_0x1dd35f,_0x311d21=[],_0x586c96=this[_0x13267c(0x1ba)],_0x164d8b=this[_0x13267c(0x16c)];for(var _0xc7351c in _0x586c96){for(var _0x298992 in _0x586c96[_0xc7351c]){_0x311d21[_0x13267c(0x17f)]({'x':_0xc7351c,'y':_0x298992,'radius':_0x164d8b[_0xc7351c][_0x298992],'value':_0x586c96[_0xc7351c][_0x298992]});}}return{'min':this[_0x13267c(0x190)],'max':this['_max'],'data':_0x311d21};},'_onExtremaChange':function(){var _0x44a0f4=_0x1dd35f;this[_0x44a0f4(0x160)][_0x44a0f4(0x1c6)](_0x44a0f4(0x183),{'min':this[_0x44a0f4(0x190)],'max':this[_0x44a0f4(0x164)]});},'addData':function(){var _0x121e9e=_0x1dd35f;if(arguments[0x0][_0x121e9e(0x181)]>0x0){var _0x3db550=arguments[0x0],_0x258d9a=_0x3db550['length'];while(_0x258d9a--){this['addData'][_0x121e9e(0x15a)](this,_0x3db550[_0x258d9a]);}}else{var _0x3c9e39=this['_organiseData'](arguments[0x0],!![]);_0x3c9e39&&this[_0x121e9e(0x160)][_0x121e9e(0x1c6)](_0x121e9e(0x15d),{'min':this['_min'],'max':this[_0x121e9e(0x164)],'data':[_0x3c9e39]});}return this;},'setData':function(_0x3e77fd){var _0x16984e=_0x1dd35f,_0x25ab32=_0x3e77fd[_0x16984e(0x15e)],_0x8a71f4=_0x25ab32[_0x16984e(0x181)];this['_data']=[],this[_0x16984e(0x16c)]=[];for(var _0x27f33b=0x0;_0x27f33b<_0x8a71f4;_0x27f33b++){this[_0x16984e(0x192)](_0x25ab32[_0x27f33b],![]);}return this[_0x16984e(0x164)]=_0x3e77fd[_0x16984e(0x193)],this[_0x16984e(0x190)]=_0x3e77fd[_0x16984e(0x1bc)]||0x0,this[_0x16984e(0x1c9)](),this[_0x16984e(0x160)][_0x16984e(0x1c6)]('renderall',this['_getInternalData']()),this;},'removeData':function(){},'setDataMax':function(_0x10abcd){var _0x2cb9b3=_0x1dd35f;return this[_0x2cb9b3(0x164)]=_0x10abcd,this[_0x2cb9b3(0x1c9)](),this[_0x2cb9b3(0x160)][_0x2cb9b3(0x1c6)](_0x2cb9b3(0x156),this[_0x2cb9b3(0x1ac)]()),this;},'setDataMin':function(_0x331d17){var _0xe8efd5=_0x1dd35f;return this['_min']=_0x331d17,this[_0xe8efd5(0x1c9)](),this[_0xe8efd5(0x160)][_0xe8efd5(0x1c6)](_0xe8efd5(0x156),this[_0xe8efd5(0x1ac)]()),this;},'setCoordinator':function(_0x46ee72){var _0x7a1cff=_0x1dd35f;this[_0x7a1cff(0x160)]=_0x46ee72;},'_getInternalData':function(){var _0x10f1a5=_0x1dd35f;return{'max':this['_max'],'min':this['_min'],'data':this['_data'],'radi':this[_0x10f1a5(0x16c)]};},'getData':function(){var _0x1ea0a3=_0x1dd35f;return this[_0x1ea0a3(0x182)]();}},_0x2f14fe;}(),_0x2ae6ff=function _0x5554e0(){var _0x4fe34c=_0x119273,_0x5e24cb=function(_0xd58819){var _0x572178=a22_0x5814,_0x505e39=_0xd58819['gradient']||_0xd58819['defaultGradient'],_0x1de52e=document['createElement'](_0x572178(0x1a9)),_0x1c0aaf=_0x1de52e['getContext']('2d');_0x1de52e['width']=0x100,_0x1de52e[_0x572178(0x151)]=0x1;var _0x15546a=_0x1c0aaf['createLinearGradient'](0x0,0x0,0x100,0x1);for(var _0x923d8 in _0x505e39){_0x15546a[_0x572178(0x19a)](_0x923d8,_0x505e39[_0x923d8]);}return _0x1c0aaf[_0x572178(0x177)]=_0x15546a,_0x1c0aaf[_0x572178(0x1b3)](0x0,0x0,0x100,0x1),_0x1c0aaf[_0x572178(0x197)](0x0,0x0,0x100,0x1)[_0x572178(0x15e)];},_0x13668d=function(_0x18172e,_0x29e8fb){var _0x4d57e1=a22_0x5814,_0x38cf28=document[_0x4d57e1(0x176)]('canvas'),_0x15fd3b=_0x38cf28['getContext']('2d'),_0x586e97=_0x18172e,_0x34305d=_0x18172e;_0x38cf28[_0x4d57e1(0x189)]=_0x38cf28[_0x4d57e1(0x151)]=_0x18172e*0x2;if(_0x29e8fb==0x1)_0x15fd3b[_0x4d57e1(0x184)](),_0x15fd3b['arc'](_0x586e97,_0x34305d,_0x18172e,0x0,0x2*Math['PI'],![]),_0x15fd3b[_0x4d57e1(0x177)]=_0x4d57e1(0x16a),_0x15fd3b['fill']();else{var _0x11dcf6=_0x15fd3b[_0x4d57e1(0x1a1)](_0x586e97,_0x34305d,_0x18172e*_0x29e8fb,_0x586e97,_0x34305d,_0x18172e);_0x11dcf6[_0x4d57e1(0x19a)](0x0,'rgba(0,0,0,1)'),_0x11dcf6['addColorStop'](0x1,'rgba(0,0,0,0)'),_0x15fd3b[_0x4d57e1(0x177)]=_0x11dcf6,_0x15fd3b[_0x4d57e1(0x1b3)](0x0,0x0,0x2*_0x18172e,0x2*_0x18172e);}return _0x38cf28;},_0x59f82f=function(_0x1e571b){var _0x5b57cb=a22_0x5814,_0x5e0ea0=[],_0x5b45c8=_0x1e571b[_0x5b57cb(0x1bc)],_0x5ad467=_0x1e571b[_0x5b57cb(0x193)],_0xccaca8=_0x1e571b[_0x5b57cb(0x175)],_0x1e571b=_0x1e571b[_0x5b57cb(0x15e)],_0x1a70d8=Object[_0x5b57cb(0x167)](_0x1e571b),_0x3d2670=_0x1a70d8[_0x5b57cb(0x181)];while(_0x3d2670--){var _0x34bbe4=_0x1a70d8[_0x3d2670],_0x3ba9c=Object['keys'](_0x1e571b[_0x34bbe4]),_0x3e976b=_0x3ba9c[_0x5b57cb(0x181)];while(_0x3e976b--){var _0x4e70c3=_0x3ba9c[_0x3e976b],_0x329b6b=_0x1e571b[_0x34bbe4][_0x4e70c3],_0x47486e=_0xccaca8[_0x34bbe4][_0x4e70c3];_0x5e0ea0[_0x5b57cb(0x17f)]({'x':_0x34bbe4,'y':_0x4e70c3,'value':_0x329b6b,'radius':_0x47486e});}}return{'min':_0x5b45c8,'max':_0x5ad467,'data':_0x5e0ea0};};function _0x136995(_0x4fa7f6){var _0x3abe40=a22_0x5814,_0x59f6fe=_0x4fa7f6[_0x3abe40(0x16b)],_0xda6f40=this['shadowCanvas']=document[_0x3abe40(0x176)](_0x3abe40(0x1a9)),_0x18cb0a=this[_0x3abe40(0x1a9)]=_0x4fa7f6['canvas']||document[_0x3abe40(0x176)](_0x3abe40(0x1a9)),_0x42b099=this[_0x3abe40(0x17c)]=[0x2710,0x2710,0x0,0x0],_0x315561=getComputedStyle(_0x4fa7f6[_0x3abe40(0x16b)])||{};_0x18cb0a['className']='heatmap-canvas',this[_0x3abe40(0x1af)]=_0x18cb0a['width']=_0xda6f40[_0x3abe40(0x189)]=_0x4fa7f6[_0x3abe40(0x189)]||+_0x315561[_0x3abe40(0x189)]['replace'](/px/,''),this[_0x3abe40(0x159)]=_0x18cb0a[_0x3abe40(0x151)]=_0xda6f40[_0x3abe40(0x151)]=_0x4fa7f6[_0x3abe40(0x151)]||+_0x315561[_0x3abe40(0x151)][_0x3abe40(0x18b)](/px/,''),this[_0x3abe40(0x19b)]=_0xda6f40[_0x3abe40(0x154)]('2d'),this[_0x3abe40(0x169)]=_0x18cb0a[_0x3abe40(0x154)]('2d'),_0x18cb0a['style'][_0x3abe40(0x185)]=_0xda6f40['style']['cssText']='position:absolute;left:0;top:0;',_0x59f6fe['style'][_0x3abe40(0x19c)]=_0x3abe40(0x173),_0x59f6fe[_0x3abe40(0x195)](_0x18cb0a),this[_0x3abe40(0x1cd)]=_0x5e24cb(_0x4fa7f6),this[_0x3abe40(0x155)]={},this['_setStyles'](_0x4fa7f6);}return _0x136995[_0x4fe34c(0x166)]={'renderPartial':function(_0x8c4b0d){var _0xd5b1fa=_0x4fe34c;_0x8c4b0d[_0xd5b1fa(0x15e)]['length']>0x0&&(this['_drawAlpha'](_0x8c4b0d),this[_0xd5b1fa(0x1ca)]());},'renderAll':function(_0x20bee4){var _0x1fc8dc=_0x4fe34c;this[_0x1fc8dc(0x1bf)](),_0x20bee4[_0x1fc8dc(0x15e)]['length']>0x0&&(this[_0x1fc8dc(0x1c0)](_0x59f82f(_0x20bee4)),this[_0x1fc8dc(0x1ca)]());},'_updateGradient':function(_0x123672){this['_palette']=_0x5e24cb(_0x123672);},'updateConfig':function(_0x13cc40){var _0x8a548b=_0x4fe34c;_0x13cc40[_0x8a548b(0x18e)]&&this[_0x8a548b(0x17a)](_0x13cc40),this['_setStyles'](_0x13cc40);},'setDimensions':function(_0x5cebbe,_0x171db0){var _0x36ffd6=_0x4fe34c;this[_0x36ffd6(0x1af)]=_0x5cebbe,this['_height']=_0x171db0,this['canvas'][_0x36ffd6(0x189)]=this[_0x36ffd6(0x18a)][_0x36ffd6(0x189)]=_0x5cebbe,this[_0x36ffd6(0x1a9)][_0x36ffd6(0x151)]=this['shadowCanvas']['height']=_0x171db0;},'_clear':function(){var _0x4a0430=_0x4fe34c;this[_0x4a0430(0x19b)][_0x4a0430(0x1b4)](0x0,0x0,this[_0x4a0430(0x1af)],this[_0x4a0430(0x159)]),this[_0x4a0430(0x169)][_0x4a0430(0x1b4)](0x0,0x0,this[_0x4a0430(0x1af)],this[_0x4a0430(0x159)]);},'_setStyles':function(_0x4b13b3){var _0x2425e8=_0x4fe34c;this[_0x2425e8(0x194)]=_0x4b13b3[_0x2425e8(0x180)]==0x0?0x0:_0x4b13b3[_0x2425e8(0x180)]||_0x4b13b3[_0x2425e8(0x1cb)],_0x4b13b3['backgroundColor']&&(this['canvas'][_0x2425e8(0x1a6)][_0x2425e8(0x1b7)]=_0x4b13b3[_0x2425e8(0x1b7)]),this[_0x2425e8(0x1af)]=this[_0x2425e8(0x1a9)][_0x2425e8(0x189)]=this[_0x2425e8(0x18a)]['width']=_0x4b13b3[_0x2425e8(0x189)]||this[_0x2425e8(0x1af)],this[_0x2425e8(0x159)]=this[_0x2425e8(0x1a9)][_0x2425e8(0x151)]=this[_0x2425e8(0x18a)][_0x2425e8(0x151)]=_0x4b13b3['height']||this[_0x2425e8(0x159)],this[_0x2425e8(0x165)]=(_0x4b13b3[_0x2425e8(0x1c3)]||0x0)*0xff,this[_0x2425e8(0x152)]=(_0x4b13b3[_0x2425e8(0x1b6)]||_0x4b13b3[_0x2425e8(0x16e)])*0xff,this[_0x2425e8(0x163)]=(_0x4b13b3[_0x2425e8(0x1c2)]||_0x4b13b3[_0x2425e8(0x1b1)])*0xff,this['_useGradientOpacity']=!!_0x4b13b3[_0x2425e8(0x1a4)];},'_drawAlpha':function(_0x19f18f){var _0x3320e0=_0x4fe34c,_0x2f5587=this[_0x3320e0(0x190)]=_0x19f18f[_0x3320e0(0x1bc)],_0x176962=this[_0x3320e0(0x164)]=_0x19f18f['max'],_0x19f18f=_0x19f18f[_0x3320e0(0x15e)]||[],_0x3d0817=_0x19f18f[_0x3320e0(0x181)],_0x128c18=0x1-this['_blur'];while(_0x3d0817--){var _0x40f6de=_0x19f18f[_0x3d0817],_0x396a76=_0x40f6de['x'],_0x316086=_0x40f6de['y'],_0x1ecf18=_0x40f6de[_0x3320e0(0x161)],_0x39df77=Math[_0x3320e0(0x1bc)](_0x40f6de[_0x3320e0(0x1a5)],_0x176962),_0x43109f=_0x396a76-_0x1ecf18,_0x12b917=_0x316086-_0x1ecf18,_0x255562=this[_0x3320e0(0x19b)],_0x66f697;!this[_0x3320e0(0x155)][_0x1ecf18]?this[_0x3320e0(0x155)][_0x1ecf18]=_0x66f697=_0x13668d(_0x1ecf18,_0x128c18):_0x66f697=this[_0x3320e0(0x155)][_0x1ecf18];var _0x4ae07e=(_0x39df77-_0x2f5587)/(_0x176962-_0x2f5587);_0x255562[_0x3320e0(0x179)]=_0x4ae07e<0.01?0.01:_0x4ae07e,_0x255562[_0x3320e0(0x1b2)](_0x66f697,_0x43109f,_0x12b917),_0x43109f<this[_0x3320e0(0x17c)][0x0]&&(this['_renderBoundaries'][0x0]=_0x43109f),_0x12b917<this[_0x3320e0(0x17c)][0x1]&&(this['_renderBoundaries'][0x1]=_0x12b917),_0x43109f+0x2*_0x1ecf18>this['_renderBoundaries'][0x2]&&(this[_0x3320e0(0x17c)][0x2]=_0x43109f+0x2*_0x1ecf18),_0x12b917+0x2*_0x1ecf18>this['_renderBoundaries'][0x3]&&(this[_0x3320e0(0x17c)][0x3]=_0x12b917+0x2*_0x1ecf18);}},'_colorize':function(){var _0x1f1a7d=_0x4fe34c,_0x4ead3d=this[_0x1f1a7d(0x17c)][0x0],_0x1ee491=this[_0x1f1a7d(0x17c)][0x1],_0x19bf5b=this[_0x1f1a7d(0x17c)][0x2]-_0x4ead3d,_0x45f317=this[_0x1f1a7d(0x17c)][0x3]-_0x1ee491,_0x56008c=this[_0x1f1a7d(0x1af)],_0xab550d=this[_0x1f1a7d(0x159)],_0x57a381=this[_0x1f1a7d(0x165)],_0x68e269=this[_0x1f1a7d(0x152)],_0xc440a3=this[_0x1f1a7d(0x163)],_0x3b5260=this['_useGradientOpacity'];_0x4ead3d<0x0&&(_0x4ead3d=0x0);_0x1ee491<0x0&&(_0x1ee491=0x0);_0x4ead3d+_0x19bf5b>_0x56008c&&(_0x19bf5b=_0x56008c-_0x4ead3d);_0x1ee491+_0x45f317>_0xab550d&&(_0x45f317=_0xab550d-_0x1ee491);var _0x5e669e=this['shadowCtx'][_0x1f1a7d(0x197)](_0x4ead3d,_0x1ee491,_0x19bf5b,_0x45f317),_0x4caa18=_0x5e669e[_0x1f1a7d(0x15e)],_0x11fca5=_0x4caa18[_0x1f1a7d(0x181)],_0x5ac6c8=this[_0x1f1a7d(0x1cd)];for(var _0x26f429=0x3;_0x26f429<_0x11fca5;_0x26f429+=0x4){var _0x27981d=_0x4caa18[_0x26f429],_0x1c1931=_0x27981d*0x4;if(!_0x1c1931)continue;var _0x5050b4;_0x57a381>0x0?_0x5050b4=_0x57a381:_0x27981d<_0x68e269?_0x27981d<_0xc440a3?_0x5050b4=_0xc440a3:_0x5050b4=_0x27981d:_0x5050b4=_0x68e269,_0x4caa18[_0x26f429-0x3]=_0x5ac6c8[_0x1c1931],_0x4caa18[_0x26f429-0x2]=_0x5ac6c8[_0x1c1931+0x1],_0x4caa18[_0x26f429-0x1]=_0x5ac6c8[_0x1c1931+0x2],_0x4caa18[_0x26f429]=_0x3b5260?_0x5ac6c8[_0x1c1931+0x3]:_0x5050b4;}_0x5e669e[_0x1f1a7d(0x15e)]=_0x4caa18,this['ctx'][_0x1f1a7d(0x178)](_0x5e669e,_0x4ead3d,_0x1ee491),this[_0x1f1a7d(0x17c)]=[0x3e8,0x3e8,0x0,0x0];},'getValueAt':function(_0x1b1548){var _0x544174=_0x4fe34c,_0x4e85f9,_0x1b87e0=this['shadowCtx'],_0x22bbe7=_0x1b87e0['getImageData'](_0x1b1548['x'],_0x1b1548['y'],0x1,0x1),_0x425edd=_0x22bbe7[_0x544174(0x15e)][0x3],_0x525bc0=this[_0x544174(0x164)],_0x5f11ab=this['_min'];return _0x4e85f9=Math['abs'](_0x525bc0-_0x5f11ab)*(_0x425edd/0xff)>>0x0,_0x4e85f9;},'getDataURL':function(){var _0x48a3ab=_0x4fe34c;return this[_0x48a3ab(0x1a9)][_0x48a3ab(0x1a0)]();}},_0x136995;}(),_0x2aa11d=function _0x3a8965(){var _0xe3bca3=_0x119273,_0x3c8b8b=![];return _0x41aa2e[_0xe3bca3(0x157)]===_0xe3bca3(0x18d)&&(_0x3c8b8b=_0x2ae6ff),_0x3c8b8b;}(),_0x18794d={'merge':function(){var _0x3aa0ef=_0x119273,_0x5c8c3f={},_0x11f454=arguments[_0x3aa0ef(0x181)];for(var _0x725648=0x0;_0x725648<_0x11f454;_0x725648++){var _0x47be1c=arguments[_0x725648];for(var _0xf01e15 in _0x47be1c){_0x5c8c3f[_0xf01e15]=_0x47be1c[_0xf01e15];}}return _0x5c8c3f;}},_0x255461=function _0x222c78(){var _0x37fe14=_0x119273,_0x133f5c=function _0x1fddc9(){var _0x3f1381=a22_0x5814;function _0x1a17d9(){var _0x153997=a22_0x5814;this[_0x153997(0x1a2)]={};}return _0x1a17d9[_0x3f1381(0x166)]={'on':function(_0x4bfeee,_0x590d0f,_0x5a00df){var _0x507e64=_0x3f1381,_0x2ba25d=this[_0x507e64(0x1a2)];!_0x2ba25d[_0x4bfeee]&&(_0x2ba25d[_0x4bfeee]=[]),_0x2ba25d[_0x4bfeee][_0x507e64(0x17f)](function(_0x563664){var _0x5ca433=_0x507e64;return _0x590d0f[_0x5ca433(0x15a)](_0x5a00df,_0x563664);});},'emit':function(_0x46025b,_0x430259){var _0x402938=_0x3f1381,_0xd5a6b5=this[_0x402938(0x1a2)];if(_0xd5a6b5[_0x46025b]){var _0x12135a=_0xd5a6b5[_0x46025b][_0x402938(0x181)];for(var _0xe50bb6=0x0;_0xe50bb6<_0x12135a;_0xe50bb6++){var _0x483b3a=_0xd5a6b5[_0x46025b][_0xe50bb6];_0x483b3a(_0x430259);}}}},_0x1a17d9;}(),_0x1698e6=function(_0xad95){var _0x499c89=a22_0x5814,_0x2fd5bb=_0xad95[_0x499c89(0x1b0)],_0x4498e4=_0xad95[_0x499c89(0x160)],_0x1e447c=_0xad95['_store'];_0x4498e4['on'](_0x499c89(0x15d),_0x2fd5bb[_0x499c89(0x1cc)],_0x2fd5bb),_0x4498e4['on']('renderall',_0x2fd5bb['renderAll'],_0x2fd5bb),_0x4498e4['on'](_0x499c89(0x183),function(_0x130f78){var _0x48ef0c=_0x499c89;_0xad95[_0x48ef0c(0x1ad)][_0x48ef0c(0x186)]&&_0xad95[_0x48ef0c(0x1ad)][_0x48ef0c(0x186)]({'min':_0x130f78[_0x48ef0c(0x1bc)],'max':_0x130f78[_0x48ef0c(0x193)],'gradient':_0xad95[_0x48ef0c(0x1ad)][_0x48ef0c(0x18e)]||_0xad95[_0x48ef0c(0x1ad)][_0x48ef0c(0x150)]});}),_0x1e447c[_0x499c89(0x16d)](_0x4498e4);};function _0x3c37b3(){var _0x1d65c2=a22_0x5814,_0x53c266=this[_0x1d65c2(0x1ad)]=_0x18794d['merge'](_0x41aa2e,arguments[0x0]||{});this[_0x1d65c2(0x160)]=new _0x133f5c();if(_0x53c266['plugin']){var _0x6354f1=_0x53c266[_0x1d65c2(0x15c)];if(!_0x41aa2e[_0x1d65c2(0x1c8)][_0x6354f1])throw new Error(_0x1d65c2(0x1ab)+_0x6354f1+_0x1d65c2(0x15f));else{var _0x5990c7=_0x41aa2e[_0x1d65c2(0x1c8)][_0x6354f1];this[_0x1d65c2(0x1b0)]=new _0x5990c7[(_0x1d65c2(0x17d))](_0x53c266),this[_0x1d65c2(0x19d)]=new _0x5990c7[(_0x1d65c2(0x18c))](_0x53c266);}}else this[_0x1d65c2(0x1b0)]=new _0x2aa11d(_0x53c266),this[_0x1d65c2(0x19d)]=new _0x46a8d3(_0x53c266);_0x1698e6(this);}return _0x3c37b3[_0x37fe14(0x166)]={'addData':function(){var _0x15c162=_0x37fe14;return this[_0x15c162(0x19d)][_0x15c162(0x17b)][_0x15c162(0x17e)](this[_0x15c162(0x19d)],arguments),this;},'removeData':function(){var _0x4f3e60=_0x37fe14;return this[_0x4f3e60(0x19d)]['removeData']&&this[_0x4f3e60(0x19d)][_0x4f3e60(0x1c4)][_0x4f3e60(0x17e)](this['_store'],arguments),this;},'setData':function(){var _0x2ce9ac=_0x37fe14;return this[_0x2ce9ac(0x19d)][_0x2ce9ac(0x188)][_0x2ce9ac(0x17e)](this[_0x2ce9ac(0x19d)],arguments),this;},'setDataMax':function(){var _0x1081ea=_0x37fe14;return this[_0x1081ea(0x19d)][_0x1081ea(0x191)]['apply'](this[_0x1081ea(0x19d)],arguments),this;},'setDataMin':function(){var _0x53c80b=_0x37fe14;return this[_0x53c80b(0x19d)][_0x53c80b(0x158)]['apply'](this['_store'],arguments),this;},'configure':function(_0x430533){var _0x374753=_0x37fe14;return this['_config']=_0x18794d[_0x374753(0x1c5)](this['_config'],_0x430533),this[_0x374753(0x1b0)]['updateConfig'](this['_config']),this[_0x374753(0x160)]['emit']('renderall',this[_0x374753(0x19d)][_0x374753(0x1ac)]()),this;},'repaint':function(){var _0x1d1488=_0x37fe14;return this[_0x1d1488(0x160)]['emit'](_0x1d1488(0x156),this['_store'][_0x1d1488(0x1ac)]()),this;},'getData':function(){var _0x24d734=_0x37fe14;return this[_0x24d734(0x19d)][_0x24d734(0x18f)]();},'getDataURL':function(){var _0x46b603=_0x37fe14;return this[_0x46b603(0x1b0)][_0x46b603(0x1a3)]();},'getValueAt':function(_0x4b8c61){var _0x3258bc=_0x37fe14;if(this['_store'][_0x3258bc(0x162)])return this['_store'][_0x3258bc(0x162)](_0x4b8c61);else return this[_0x3258bc(0x1b0)][_0x3258bc(0x162)]?this['_renderer']['getValueAt'](_0x4b8c61):null;}},_0x3c37b3;}(),_0x366042={'create':function(_0x189ac0){return new _0x255461(_0x189ac0);},'register':function(_0x449256,_0x18e72f){_0x41aa2e['plugins'][_0x449256]=_0x18e72f;}};return _0x366042;}));
|
|
1
|
+
/*
|
|
2
|
+
* heatmap.js v2.0.2 | JavaScript Heatmap Library
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2008-2016 Patrick Wied <heatmapjs@patrick-wied.at> - All rights reserved.
|
|
5
|
+
* Dual licensed under MIT and Beerware license
|
|
6
|
+
*
|
|
7
|
+
* :: 2016-02-04 21:25
|
|
8
|
+
*/
|
|
9
|
+
(function (a, b, c) { if (typeof module !== "undefined" && module.exports) { module.exports = c() } else if (typeof define === "function" && define.amd) { define(c) } else { b[a] = c() } })("h337", this, function () { var a = { defaultRadius: 40, defaultRenderer: "canvas2d", defaultGradient: { .25: "rgb(0,0,255)", .55: "rgb(0,255,0)", .85: "yellow", 1: "rgb(255,0,0)" }, defaultMaxOpacity: 1, defaultMinOpacity: 0, defaultBlur: .85, defaultXField: "x", defaultYField: "y", defaultValueField: "value", plugins: {} }; var b = function h() { var b = function d(a) { this._coordinator = {}; this._data = []; this._radi = []; this._min = 0; this._max = 1; this._xField = a["xField"] || a.defaultXField; this._yField = a["yField"] || a.defaultYField; this._valueField = a["valueField"] || a.defaultValueField; if (a["radius"]) { this._cfgRadius = a["radius"] } }; var c = a.defaultRadius; b.prototype = { _organiseData: function (a, b) { var d = a[this._xField]; var e = a[this._yField]; var f = this._radi; var g = this._data; var h = this._max; var i = this._min; var j = a[this._valueField] || 1; var k = a.radius || this._cfgRadius || c; if (!g[d]) { g[d] = []; f[d] = [] } if (!g[d][e]) { g[d][e] = j; f[d][e] = k } else { g[d][e] += j } if (g[d][e] > h) { if (!b) { this._max = g[d][e] } else { this.setDataMax(g[d][e]) } return false } else { return { x: d, y: e, value: j, radius: k, min: i, max: h } } }, _unOrganizeData: function () { var a = []; var b = this._data; var c = this._radi; for (var d in b) { for (var e in b[d]) { a.push({ x: d, y: e, radius: c[d][e], value: b[d][e] }) } } return { min: this._min, max: this._max, data: a } }, _onExtremaChange: function () { this._coordinator.emit("extremachange", { min: this._min, max: this._max }) }, addData: function () { if (arguments[0].length > 0) { var a = arguments[0]; var b = a.length; while (b--) { this.addData.call(this, a[b]) } } else { var c = this._organiseData(arguments[0], true); if (c) { this._coordinator.emit("renderpartial", { min: this._min, max: this._max, data: [c] }) } } return this }, setData: function (a) { var b = a.data; var c = b.length; this._data = []; this._radi = []; for (var d = 0; d < c; d++) { this._organiseData(b[d], false) } this._max = a.max; this._min = a.min || 0; this._onExtremaChange(); this._coordinator.emit("renderall", this._getInternalData()); return this }, removeData: function () { }, setDataMax: function (a) { this._max = a; this._onExtremaChange(); this._coordinator.emit("renderall", this._getInternalData()); return this }, setDataMin: function (a) { this._min = a; this._onExtremaChange(); this._coordinator.emit("renderall", this._getInternalData()); return this }, setCoordinator: function (a) { this._coordinator = a }, _getInternalData: function () { return { max: this._max, min: this._min, data: this._data, radi: this._radi } }, getData: function () { return this._unOrganizeData() } }; return b }(); var c = function i() { var a = function (a) { var b = a.gradient || a.defaultGradient; var c = document.createElement("canvas"); var d = c.getContext("2d"); c.width = 256; c.height = 1; var e = d.createLinearGradient(0, 0, 256, 1); for (var f in b) { e.addColorStop(f, b[f]) } d.fillStyle = e; d.fillRect(0, 0, 256, 1); return d.getImageData(0, 0, 256, 1).data }; var b = function (a, b) { var c = document.createElement("canvas"); var d = c.getContext("2d"); var e = a; var f = a; c.width = c.height = a * 2; if (b == 1) { d.beginPath(); d.arc(e, f, a, 0, 2 * Math.PI, false); d.fillStyle = "rgba(0,0,0,1)"; d.fill() } else { var g = d.createRadialGradient(e, f, a * b, e, f, a); g.addColorStop(0, "rgba(0,0,0,1)"); g.addColorStop(1, "rgba(0,0,0,0)"); d.fillStyle = g; d.fillRect(0, 0, 2 * a, 2 * a) } return c }; var c = function (a) { var b = []; var c = a.min; var d = a.max; var e = a.radi; var a = a.data; var f = Object.keys(a); var g = f.length; while (g--) { var h = f[g]; var i = Object.keys(a[h]); var j = i.length; while (j--) { var k = i[j]; var l = a[h][k]; var m = e[h][k]; b.push({ x: h, y: k, value: l, radius: m }) } } return { min: c, max: d, data: b } }; function d(b) { var c = b.container; var d = this.shadowCanvas = document.createElement("canvas"); var e = this.canvas = b.canvas || document.createElement("canvas"); var f = this._renderBoundaries = [1e4, 1e4, 0, 0]; var g = getComputedStyle(b.container) || {}; e.className = "heatmap-canvas"; this._width = e.width = d.width = b.width || +g.width.replace(/px/, ""); this._height = e.height = d.height = b.height || +g.height.replace(/px/, ""); this.shadowCtx = d.getContext("2d"); this.ctx = e.getContext("2d"); e.style.cssText = d.style.cssText = "position:absolute;left:0;top:0;"; c.style.position = "relative"; c.appendChild(e); this._palette = a(b); this._templates = {}; this._setStyles(b) } d.prototype = { renderPartial: function (a) { if (a.data.length > 0) { this._drawAlpha(a); this._colorize() } }, renderAll: function (a) { this._clear(); if (a.data.length > 0) { this._drawAlpha(c(a)); this._colorize() } }, _updateGradient: function (b) { this._palette = a(b) }, updateConfig: function (a) { if (a["gradient"]) { this._updateGradient(a) } this._setStyles(a) }, setDimensions: function (a, b) { this._width = a; this._height = b; this.canvas.width = this.shadowCanvas.width = a; this.canvas.height = this.shadowCanvas.height = b }, _clear: function () { this.shadowCtx.clearRect(0, 0, this._width, this._height); this.ctx.clearRect(0, 0, this._width, this._height) }, _setStyles: function (a) { this._blur = a.blur == 0 ? 0 : a.blur || a.defaultBlur; if (a.backgroundColor) { this.canvas.style.backgroundColor = a.backgroundColor } this._width = this.canvas.width = this.shadowCanvas.width = a.width || this._width; this._height = this.canvas.height = this.shadowCanvas.height = a.height || this._height; this._opacity = (a.opacity || 0) * 255; this._maxOpacity = (a.maxOpacity || a.defaultMaxOpacity) * 255; this._minOpacity = (a.minOpacity || a.defaultMinOpacity) * 255; this._useGradientOpacity = !!a.useGradientOpacity }, _drawAlpha: function (a) { var c = this._min = a.min; var d = this._max = a.max; var a = a.data || []; var e = a.length; var f = 1 - this._blur; while (e--) { var g = a[e]; var h = g.x; var i = g.y; var j = g.radius; var k = Math.min(g.value, d); var l = h - j; var m = i - j; var n = this.shadowCtx; var o; if (!this._templates[j]) { this._templates[j] = o = b(j, f) } else { o = this._templates[j] } var p = (k - c) / (d - c); n.globalAlpha = p < .01 ? .01 : p; n.drawImage(o, l, m); if (l < this._renderBoundaries[0]) { this._renderBoundaries[0] = l } if (m < this._renderBoundaries[1]) { this._renderBoundaries[1] = m } if (l + 2 * j > this._renderBoundaries[2]) { this._renderBoundaries[2] = l + 2 * j } if (m + 2 * j > this._renderBoundaries[3]) { this._renderBoundaries[3] = m + 2 * j } } }, _colorize: function () { var a = this._renderBoundaries[0]; var b = this._renderBoundaries[1]; var c = this._renderBoundaries[2] - a; var d = this._renderBoundaries[3] - b; var e = this._width; var f = this._height; var g = this._opacity; var h = this._maxOpacity; var i = this._minOpacity; var j = this._useGradientOpacity; if (a < 0) { a = 0 } if (b < 0) { b = 0 } if (a + c > e) { c = e - a } if (b + d > f) { d = f - b } var k = this.shadowCtx.getImageData(a, b, c, d); var l = k.data; var m = l.length; var n = this._palette; for (var o = 3; o < m; o += 4) { var p = l[o]; var q = p * 4; if (!q) { continue } var r; if (g > 0) { r = g } else { if (p < h) { if (p < i) { r = i } else { r = p } } else { r = h } } l[o - 3] = n[q]; l[o - 2] = n[q + 1]; l[o - 1] = n[q + 2]; l[o] = j ? n[q + 3] : r } k.data = l; this.ctx.putImageData(k, a, b); this._renderBoundaries = [1e3, 1e3, 0, 0] }, getValueAt: function (a) { var b; var c = this.shadowCtx; var d = c.getImageData(a.x, a.y, 1, 1); var e = d.data[3]; var f = this._max; var g = this._min; b = Math.abs(f - g) * (e / 255) >> 0; return b }, getDataURL: function () { return this.canvas.toDataURL() } }; return d }(); var d = function j() { var b = false; if (a["defaultRenderer"] === "canvas2d") { b = c } return b }(); var e = { merge: function () { var a = {}; var b = arguments.length; for (var c = 0; c < b; c++) { var d = arguments[c]; for (var e in d) { a[e] = d[e] } } return a } }; var f = function k() { var c = function h() { function a() { this.cStore = {} } a.prototype = { on: function (a, b, c) { var d = this.cStore; if (!d[a]) { d[a] = [] } d[a].push(function (a) { return b.call(c, a) }) }, emit: function (a, b) { var c = this.cStore; if (c[a]) { var d = c[a].length; for (var e = 0; e < d; e++) { var f = c[a][e]; f(b) } } } }; return a }(); var f = function (a) { var b = a._renderer; var c = a._coordinator; var d = a._store; c.on("renderpartial", b.renderPartial, b); c.on("renderall", b.renderAll, b); c.on("extremachange", function (b) { a._config.onExtremaChange && a._config.onExtremaChange({ min: b.min, max: b.max, gradient: a._config["gradient"] || a._config["defaultGradient"] }) }); d.setCoordinator(c) }; function g() { var g = this._config = e.merge(a, arguments[0] || {}); this._coordinator = new c; if (g["plugin"]) { var h = g["plugin"]; if (!a.plugins[h]) { throw new Error("Plugin '" + h + "' not found. Maybe it was not registered.") } else { var i = a.plugins[h]; this._renderer = new i.renderer(g); this._store = new i.store(g) } } else { this._renderer = new d(g); this._store = new b(g) } f(this) } g.prototype = { addData: function () { this._store.addData.apply(this._store, arguments); return this }, removeData: function () { this._store.removeData && this._store.removeData.apply(this._store, arguments); return this }, setData: function () { this._store.setData.apply(this._store, arguments); return this }, setDataMax: function () { this._store.setDataMax.apply(this._store, arguments); return this }, setDataMin: function () { this._store.setDataMin.apply(this._store, arguments); return this }, configure: function (a) { this._config = e.merge(this._config, a); this._renderer.updateConfig(this._config); this._coordinator.emit("renderall", this._store._getInternalData()); return this }, repaint: function () { this._coordinator.emit("renderall", this._store._getInternalData()); return this }, getData: function () { return this._store.getData() }, getDataURL: function () { return this._renderer.getDataURL() }, getValueAt: function (a) { if (this._store.getValueAt) { return this._store.getValueAt(a) } else if (this._renderer.getValueAt) { return this._renderer.getValueAt(a) } else { return null } } }; return g }(); var g = { create: function (a) { return new f(a) }, register: function (b, c) { a.plugins[b] = c } }; return g });
|
|
@@ -1 +1,246 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Leaflet Heatmap Overlay
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2008-2016, Patrick Wied (https://www.patrick-wied.at)
|
|
5
|
+
* Dual-licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
|
6
|
+
* and the Beerware (http://en.wikipedia.org/wiki/Beerware) license.
|
|
7
|
+
*/
|
|
8
|
+
; (function (name, context, factory) {
|
|
9
|
+
// Supports UMD. AMD, CommonJS/Node.js and browser context
|
|
10
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
11
|
+
module.exports = factory(
|
|
12
|
+
require('heatmap.js'),
|
|
13
|
+
require('leaflet')
|
|
14
|
+
);
|
|
15
|
+
} else if (typeof define === "function" && define.amd) {
|
|
16
|
+
define(['heatmap.js', 'leaflet'], factory);
|
|
17
|
+
} else {
|
|
18
|
+
// browser globals
|
|
19
|
+
if (typeof window.h337 === 'undefined') {
|
|
20
|
+
throw new Error('heatmap.js must be loaded before the leaflet heatmap plugin');
|
|
21
|
+
}
|
|
22
|
+
if (typeof window.L === 'undefined') {
|
|
23
|
+
throw new Error('Leaflet must be loaded before the leaflet heatmap plugin');
|
|
24
|
+
}
|
|
25
|
+
context[name] = factory(window.h337, window.L);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
})("HeatmapOverlay", this, function (h337, L) {
|
|
29
|
+
'use strict';
|
|
30
|
+
|
|
31
|
+
// Leaflet < 0.8 compatibility
|
|
32
|
+
if (typeof L.Layer === 'undefined') {
|
|
33
|
+
L.Layer = L.Class;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var HeatmapOverlay = L.Layer.extend({
|
|
37
|
+
|
|
38
|
+
initialize: function (config) {
|
|
39
|
+
this.cfg = config;
|
|
40
|
+
this._el = L.DomUtil.create('div', 'leaflet-zoom-hide');
|
|
41
|
+
this._data = [];
|
|
42
|
+
this._max = 1;
|
|
43
|
+
this._min = 0;
|
|
44
|
+
this.cfg.container = this._el;
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
onAdd: function (map) {
|
|
48
|
+
var size = map.getSize();
|
|
49
|
+
|
|
50
|
+
this._map = map;
|
|
51
|
+
|
|
52
|
+
this._width = size.x;
|
|
53
|
+
this._height = size.y;
|
|
54
|
+
|
|
55
|
+
this._el.style.width = size.x + 'px';
|
|
56
|
+
this._el.style.height = size.y + 'px';
|
|
57
|
+
this._el.style.position = 'absolute';
|
|
58
|
+
|
|
59
|
+
this._origin = this._map.layerPointToLatLng(new L.Point(0, 0));
|
|
60
|
+
|
|
61
|
+
map.getPanes().overlayPane.appendChild(this._el);
|
|
62
|
+
|
|
63
|
+
if (!this._heatmap) {
|
|
64
|
+
this._heatmap = h337.create(this.cfg);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// this resets the origin and redraws whenever
|
|
68
|
+
// the zoom changed or the map has been moved
|
|
69
|
+
map.on('moveend', this._reset, this);
|
|
70
|
+
this._draw();
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
addTo: function (map) {
|
|
74
|
+
map.addLayer(this);
|
|
75
|
+
return this;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
onRemove: function (map) {
|
|
79
|
+
// remove layer's DOM elements and listeners
|
|
80
|
+
map.getPanes().overlayPane.removeChild(this._el);
|
|
81
|
+
|
|
82
|
+
map.off('moveend', this._reset, this);
|
|
83
|
+
},
|
|
84
|
+
_draw: function () {
|
|
85
|
+
if (!this._map) { return; }
|
|
86
|
+
|
|
87
|
+
var mapPane = this._map.getPanes().mapPane;
|
|
88
|
+
var point = mapPane._leaflet_pos;
|
|
89
|
+
|
|
90
|
+
// reposition the layer
|
|
91
|
+
this._el.style[HeatmapOverlay.CSS_TRANSFORM] = 'translate(' +
|
|
92
|
+
-Math.round(point.x) + 'px,' +
|
|
93
|
+
-Math.round(point.y) + 'px)';
|
|
94
|
+
|
|
95
|
+
this._update();
|
|
96
|
+
},
|
|
97
|
+
_update: function () {
|
|
98
|
+
var bounds, zoom, scale;
|
|
99
|
+
var generatedData = { max: this._max, min: this._min, data: [] };
|
|
100
|
+
|
|
101
|
+
bounds = this._map.getBounds();
|
|
102
|
+
zoom = this._map.getZoom();
|
|
103
|
+
scale = Math.pow(2, zoom);
|
|
104
|
+
|
|
105
|
+
if (this._data.length == 0) {
|
|
106
|
+
if (this._heatmap) {
|
|
107
|
+
this._heatmap.setData(generatedData);
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
var latLngPoints = [];
|
|
114
|
+
var radiusMultiplier = this.cfg.scaleRadius ? scale : 1;
|
|
115
|
+
var localMax = 0;
|
|
116
|
+
var localMin = 0;
|
|
117
|
+
var valueField = this.cfg.valueField;
|
|
118
|
+
var len = this._data.length;
|
|
119
|
+
|
|
120
|
+
while (len--) {
|
|
121
|
+
var entry = this._data[len];
|
|
122
|
+
var value = entry[valueField];
|
|
123
|
+
var latlng = entry.latlng;
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
// we don't wanna render points that are not even on the map ;-)
|
|
127
|
+
if (!bounds.contains(latlng)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
// local max is the maximum within current bounds
|
|
131
|
+
localMax = Math.max(value, localMax);
|
|
132
|
+
localMin = Math.min(value, localMin);
|
|
133
|
+
|
|
134
|
+
var point = this._map.latLngToContainerPoint(latlng);
|
|
135
|
+
var latlngPoint = { x: Math.round(point.x), y: Math.round(point.y) };
|
|
136
|
+
latlngPoint[valueField] = value;
|
|
137
|
+
|
|
138
|
+
var radius;
|
|
139
|
+
|
|
140
|
+
if (entry.radius) {
|
|
141
|
+
radius = entry.radius * radiusMultiplier;
|
|
142
|
+
} else {
|
|
143
|
+
radius = (this.cfg.radius || 2) * radiusMultiplier;
|
|
144
|
+
}
|
|
145
|
+
latlngPoint.radius = radius;
|
|
146
|
+
latLngPoints.push(latlngPoint);
|
|
147
|
+
}
|
|
148
|
+
if (this.cfg.useLocalExtrema) {
|
|
149
|
+
generatedData.max = localMax;
|
|
150
|
+
generatedData.min = localMin;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
generatedData.data = latLngPoints;
|
|
154
|
+
|
|
155
|
+
this._heatmap.setData(generatedData);
|
|
156
|
+
},
|
|
157
|
+
setData: function (data) {
|
|
158
|
+
this._max = data.max || this._max;
|
|
159
|
+
this._min = data.min || this._min;
|
|
160
|
+
var latField = this.cfg.latField || 'lat';
|
|
161
|
+
var lngField = this.cfg.lngField || 'lng';
|
|
162
|
+
var valueField = this.cfg.valueField || 'value';
|
|
163
|
+
|
|
164
|
+
// transform data to latlngs
|
|
165
|
+
var data = data.data;
|
|
166
|
+
var len = data.length;
|
|
167
|
+
var d = [];
|
|
168
|
+
|
|
169
|
+
while (len--) {
|
|
170
|
+
var entry = data[len];
|
|
171
|
+
var latlng = new L.LatLng(entry[latField], entry[lngField]);
|
|
172
|
+
var dataObj = { latlng: latlng };
|
|
173
|
+
dataObj[valueField] = entry[valueField];
|
|
174
|
+
if (entry.radius) {
|
|
175
|
+
dataObj.radius = entry.radius;
|
|
176
|
+
}
|
|
177
|
+
d.push(dataObj);
|
|
178
|
+
}
|
|
179
|
+
this._data = d;
|
|
180
|
+
|
|
181
|
+
this._draw();
|
|
182
|
+
},
|
|
183
|
+
// experimential... not ready.
|
|
184
|
+
addData: function (pointOrArray) {
|
|
185
|
+
if (pointOrArray.length > 0) {
|
|
186
|
+
var len = pointOrArray.length;
|
|
187
|
+
while (len--) {
|
|
188
|
+
this.addData(pointOrArray[len]);
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
var latField = this.cfg.latField || 'lat';
|
|
192
|
+
var lngField = this.cfg.lngField || 'lng';
|
|
193
|
+
var valueField = this.cfg.valueField || 'value';
|
|
194
|
+
var entry = pointOrArray;
|
|
195
|
+
var latlng = new L.LatLng(entry[latField], entry[lngField]);
|
|
196
|
+
var dataObj = { latlng: latlng };
|
|
197
|
+
|
|
198
|
+
dataObj[valueField] = entry[valueField];
|
|
199
|
+
this._max = Math.max(this._max, dataObj[valueField]);
|
|
200
|
+
this._min = Math.min(this._min, dataObj[valueField]);
|
|
201
|
+
|
|
202
|
+
if (entry.radius) {
|
|
203
|
+
dataObj.radius = entry.radius;
|
|
204
|
+
}
|
|
205
|
+
this._data.push(dataObj);
|
|
206
|
+
this._draw();
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
_reset: function () {
|
|
210
|
+
this._origin = this._map.layerPointToLatLng(new L.Point(0, 0));
|
|
211
|
+
|
|
212
|
+
var size = this._map.getSize();
|
|
213
|
+
if (this._width !== size.x || this._height !== size.y) {
|
|
214
|
+
this._width = size.x;
|
|
215
|
+
this._height = size.y;
|
|
216
|
+
|
|
217
|
+
this._el.style.width = this._width + 'px';
|
|
218
|
+
this._el.style.height = this._height + 'px';
|
|
219
|
+
|
|
220
|
+
this._heatmap._renderer.setDimensions(this._width, this._height);
|
|
221
|
+
}
|
|
222
|
+
this._draw();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
HeatmapOverlay.CSS_TRANSFORM = (function () {
|
|
227
|
+
var div = document.createElement('div');
|
|
228
|
+
var props = [
|
|
229
|
+
'transform',
|
|
230
|
+
'WebkitTransform',
|
|
231
|
+
'MozTransform',
|
|
232
|
+
'OTransform',
|
|
233
|
+
'msTransform'
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
for (var i = 0; i < props.length; i++) {
|
|
237
|
+
var prop = props[i];
|
|
238
|
+
if (div.style[prop] !== undefined) {
|
|
239
|
+
return prop;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return props[0];
|
|
243
|
+
})();
|
|
244
|
+
|
|
245
|
+
return HeatmapOverlay;
|
|
246
|
+
});
|