weatherChart.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639
  1. /**
  2. * 天气图表
  3. * Created by Administrator on 2017/11/2.
  4. */
  5. define(['meteoDir/other/echarts'], function (ec) {
  6. meteo.c.chart = {
  7. chart1: null,
  8. count: 0,
  9. hourDay: null,
  10. color_TT: '#af381e',
  11. color_PR: '#1b37ff',
  12. color_RH: '#49a12d',
  13. color_WS: '#ffc937',
  14. color_VIS: '#1687ff',
  15. color_RN: '#006F00',
  16. color_TT_D: '#af381e',
  17. color_TT_N: '#2d51ff',
  18. color_RN_D: '#49a12d',
  19. color_RN_N: '#1d6f37',
  20. getChart: function (id) {
  21. return ec.init(document.getElementById(id));
  22. },
  23. getChartOption: function (json, title) {
  24. // meteo.c.chart.count = json.length;
  25. // 整理数据
  26. var wth = [];
  27. var tt = [];
  28. var pr = [];
  29. var rh = [];
  30. var ws = [];
  31. var wd = [];
  32. var vis = [];
  33. var rn = [];
  34. var time = [];
  35. var ot = null;
  36. var prMax = 0;
  37. var prMin = 9999;
  38. var rnMin = 9999;
  39. for (var i = 0; i < json.length; i++) {
  40. // wth.push([json[i].wth, i]);
  41. wth.push([0, i]);
  42. tt.push(json[i].tt);
  43. pr.push(json[i].pr);
  44. prMax = prMax > json[i].pr ? prMax : json[i].pr;
  45. prMin = prMin < json[i].pr ? prMin : json[i].pr;
  46. rh.push(json[i].rh);
  47. ws.push(json[i].ws);
  48. wd.push(json[i].wd);
  49. if (json[i].vis > 100) {
  50. vis.push(((json[i].vis / 1000) >> 0));
  51. } else {
  52. vis.push(json[i].vis);
  53. }
  54. rnMin = rnMin < json[i].rn ? rnMin : json[i].rn;
  55. rn.push(json[i].rn);
  56. if (!ot || ot > json[i].ldate.split("/")[1]) {
  57. time.push(json[i].ldate.split("/")[0] + "日" + json[i].ldate.split("/")[1] + "时");
  58. } else {
  59. time.push(json[i].ldate.split("/")[1] + "时");
  60. }
  61. ot = json[i].ldate.split("/")[1];
  62. }
  63. if (rnMin == 0 || rnMin == 9999 || rnMin == 0.1) rnMin = 10;
  64. prMax = 10 - prMax % 10 + prMax;
  65. prMin = prMin - prMin % 10;
  66. // var ipr = prMax - prMin;
  67. // if (ipr < 12) prMin = prMin - (12 - ipr);
  68. //echart数据
  69. var option = {
  70. // title: {
  71. // text: title
  72. // },
  73. tooltip: {
  74. show: false
  75. },
  76. grid: {
  77. // left: '20%',
  78. left: '10',
  79. right: '10',
  80. top: '100',
  81. bottom: '40'
  82. },
  83. // toolbox: { //右上角功能
  84. // feature: {
  85. // dataView: {show: true, readOnly: false},
  86. // restore: {show: true},
  87. // saveAsImage: {show: true}
  88. // }
  89. // },
  90. legend: {
  91. data: ['气温(℃)', '海平面气压(hPa)', '湿度(%)', '风速(m/s)', '能见度(km)', '降水(mm)']
  92. // data: ['气温', '海平面气压', '湿度', '风速(m/s)', '能见度', '降水']
  93. },
  94. xAxis: {
  95. data: time,
  96. axisLabel: {
  97. interval: 0
  98. },
  99. axisTick: {
  100. alignWithLabel: true
  101. },
  102. splitLine: {
  103. show: true
  104. }
  105. },
  106. yAxis: [{
  107. // name: "",
  108. axisLine: {
  109. lineStyle: {
  110. color: meteo.c.chart.color_TT
  111. }
  112. },
  113. // nameTextStyle: {
  114. // color: meteo.c.chart.color_TT
  115. // },
  116. axisLabel: {
  117. formatter: '',
  118. color: meteo.c.chart.color_TT
  119. },
  120. splitLine: {
  121. show: false
  122. }
  123. }, {
  124. // name: "",
  125. max: prMax,
  126. min: prMin,
  127. axisLine: {
  128. lineStyle: {
  129. color: meteo.c.chart.color_TT
  130. }
  131. },
  132. // nameTextStyle: {
  133. // color: meteo.c.chart.color_TT
  134. // },
  135. axisLabel: {
  136. formatter: '',
  137. color: meteo.c.chart.color_TT
  138. },
  139. splitLine: {
  140. show: false
  141. }
  142. }, {
  143. // name: "",
  144. axisLine: {
  145. lineStyle: {
  146. color: meteo.c.chart.color_TT
  147. }
  148. },
  149. // nameTextStyle: {
  150. // color: meteo.c.chart.color_TT
  151. // },
  152. axisLabel: {
  153. formatter: '',
  154. color: meteo.c.chart.color_TT
  155. },
  156. splitLine: {
  157. show: false
  158. }
  159. }, {
  160. // name: "",
  161. axisLine: {
  162. lineStyle: {
  163. color: meteo.c.chart.color_TT
  164. }
  165. },
  166. // nameTextStyle: {
  167. // color: meteo.c.chart.color_TT
  168. // },
  169. axisLabel: {
  170. formatter: '',
  171. color: meteo.c.chart.color_TT
  172. },
  173. splitLine: {
  174. show: false
  175. }
  176. }, {
  177. // name: "",
  178. axisLine: {
  179. lineStyle: {
  180. color: meteo.c.chart.color_TT
  181. }
  182. },
  183. // nameTextStyle: {
  184. // color: meteo.c.chart.color_TT
  185. // },
  186. axisLabel: {
  187. formatter: '',
  188. color: meteo.c.chart.color_TT
  189. },
  190. splitLine: {
  191. show: false
  192. }
  193. }, {
  194. // name: "",
  195. axisLine: {
  196. lineStyle: {
  197. color: meteo.c.chart.color_TT
  198. }
  199. },
  200. // nameTextStyle: {
  201. // color: meteo.c.chart.color_TT
  202. // },
  203. axisLabel: {
  204. formatter: '',
  205. color: meteo.c.chart.color_TT
  206. },
  207. splitLine: {
  208. show: false
  209. }
  210. }],
  211. series: [
  212. {
  213. name: '气温(℃)',
  214. type: 'line',
  215. label: {
  216. normal: { //普通文字标记
  217. show: true,
  218. position: 'top',
  219. color: meteo.c.chart.color_TT,
  220. fontStyle: 'normal',
  221. fontSize: 12,
  222. }
  223. },
  224. lineStyle: {
  225. normal: {
  226. color: meteo.c.chart.color_TT,
  227. width: 2,
  228. type: 'solid',
  229. }
  230. },
  231. itemStyle: {
  232. normal: {
  233. color: meteo.c.chart.color_TT
  234. }
  235. },
  236. data: tt,
  237. },
  238. {
  239. name: '海平面气压(hPa)',
  240. type: 'line',
  241. yAxisIndex: 1,
  242. label: {
  243. normal: { //普通文字标记
  244. show: true,
  245. position: 'top',
  246. color: meteo.c.chart.color_PR,
  247. fontStyle: 'normal',
  248. fontSize: 12,
  249. }
  250. },
  251. lineStyle: {
  252. normal: {
  253. color: meteo.c.chart.color_PR,
  254. width: 2,
  255. type: 'solid',
  256. }
  257. },
  258. itemStyle: {
  259. normal: {
  260. color: meteo.c.chart.color_PR
  261. }
  262. },
  263. data: pr,
  264. },
  265. {
  266. name: '湿度(%)',
  267. type: 'line',
  268. yAxisIndex: 2,
  269. label: {
  270. normal: { //普通文字标记
  271. show: true,
  272. position: 'top',
  273. color: meteo.c.chart.color_RH,
  274. fontStyle: 'normal',
  275. fontSize: 12,
  276. }
  277. },
  278. lineStyle: {
  279. normal: {
  280. color: meteo.c.chart.color_RH,
  281. width: 2,
  282. type: 'solid',
  283. }
  284. },
  285. itemStyle: {
  286. normal: {
  287. color: meteo.c.chart.color_RH
  288. }
  289. },
  290. data: rh,
  291. },
  292. {
  293. name: '风速(m/s)',
  294. type: 'line',
  295. yAxisIndex: 3,
  296. label: {
  297. normal: { //普通文字标记
  298. show: true,
  299. position: 'top',
  300. color: meteo.c.chart.color_WS,
  301. fontStyle: 'normal',
  302. fontSize: 12,
  303. }
  304. },
  305. lineStyle: {
  306. normal: {
  307. color: meteo.c.chart.color_WS,
  308. width: 2,
  309. type: 'solid',
  310. }
  311. },
  312. itemStyle: {
  313. normal: {
  314. color: meteo.c.chart.color_WS
  315. }
  316. },
  317. data: ws,
  318. },
  319. {
  320. name: '能见度(km)',
  321. type: 'line',
  322. yAxisIndex: 4,
  323. label: {
  324. normal: { //普通文字标记
  325. show: true,
  326. position: 'top',
  327. color: meteo.c.chart.color_VIS,
  328. fontStyle: 'normal',
  329. fontSize: 12,
  330. }
  331. },
  332. lineStyle: {
  333. normal: {
  334. color: meteo.c.chart.color_VIS,
  335. width: 2,
  336. type: 'solid',
  337. }
  338. },
  339. itemStyle: {
  340. normal: {
  341. color: meteo.c.chart.color_VIS
  342. }
  343. },
  344. data: vis,
  345. },
  346. {
  347. name: '降水(mm)',
  348. type: 'bar',
  349. yAxisIndex: 5,
  350. label: {
  351. normal: { //普通文字标记
  352. show: true,
  353. position: 'top',
  354. color: meteo.c.chart.color_RN,
  355. fontStyle: 'normal',
  356. fontSize: 12,
  357. }
  358. },
  359. lineStyle: {
  360. normal: {
  361. color: meteo.c.chart.color_RN,
  362. width: 2,
  363. type: 'solid',
  364. }
  365. },
  366. itemStyle: {
  367. normal: {
  368. color: meteo.c.chart.color_RN
  369. }
  370. },
  371. data: rn,
  372. },
  373. {
  374. name: '天气现象',
  375. type: 'custom',
  376. renderItem: function (parma, api) {
  377. // 对于 data 中的每个 dataItem,都会调用这个 renderItem 函数。
  378. // (但是注意,并不一定是按照 data 的顺序调用)
  379. // 这里进行一些处理,例如,坐标转换。
  380. // 这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
  381. var url = api.value(0);
  382. if (!url) return;
  383. var index = api.value(1);
  384. // 这里使用 api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
  385. // 这里使用 api.size(...) 获得 Y 轴上数值范围为 1 的一段所对应的像素长度。
  386. // 这里返回为这个 dataItem 构建的图形元素定义。
  387. var coordSys = parma.coordSys;
  388. var width = coordSys.x;
  389. var height = coordSys.y;
  390. var left = coordSys.x;
  391. var right = coordSys.width + coordSys.x;
  392. // var tr = (right - left) / meteo.c.chart.count;
  393. var tr = (right - left) / parma.dataInsideLength;
  394. // var tr = coordSys.width / 8;
  395. var positionx = width + (width + tr - width) / 2 + tr * index;
  396. // var ix = (width - height) / 2
  397. var wthp = meteo.c.wth.weatherId[url];
  398. if (url < 10) url = "0" + url;
  399. url = 'images/meteo/weatherImage/cww' + url + '.png';
  400. return {
  401. type: 'group',
  402. children: [{
  403. type: 'image',
  404. style: {
  405. image: url,
  406. x: -20,
  407. y: -20,
  408. width: 40,
  409. height: 40
  410. },
  411. position: [positionx, 60]
  412. }, {
  413. type: 'text',
  414. style: {
  415. text: wthp,
  416. textFont: api.font({fontSize: 14}),
  417. fill: 'black',
  418. textAlign: 'center',
  419. textVerticalAlign: 'bottom'
  420. },
  421. position: [positionx, 40]
  422. }]
  423. }
  424. },
  425. data: wth
  426. }
  427. ]
  428. }
  429. return option;
  430. },
  431. /*
  432. *地面站-逐时
  433. */
  434. getSurfHourChartOption: function (json, title) {
  435. meteo.c.chart.hourDay = null;
  436. // 整理数据
  437. var wth = [];//天气现象
  438. var tt = []; //温度
  439. var pr = []; //气压
  440. var rh = []; //湿度
  441. var ws = []; //风速
  442. var wd = []; //风向
  443. var vis = []; //能见度
  444. var rn = []; //降水量
  445. var time = []; //时间
  446. var ot = null; //
  447. var prMax = 0;
  448. var prMin = 9999;
  449. var rnMin = 9999;
  450. var count;
  451. for (var i = 0; i < json.length; i++) {
  452. count = json.length - 1;
  453. // wth.push([json[i].wth, i]);
  454. wth.push([json[i].wth, i, json[i].ldate, json[i].tt, json[i].ws, json[i].wd]);
  455. tt.push(json[i].tt);
  456. pr.push(json[i].pr);
  457. prMax = prMax > json[i].pr ? prMax : json[i].pr;
  458. prMin = prMin < json[i].pr ? prMin : json[i].pr;
  459. rh.push(json[i].rh);
  460. ws.push(json[i].ws);
  461. wd.push(json[i].wd);
  462. if (json[i].vis > 100) {
  463. vis.push(((json[i].vis / 1000) >> 0));
  464. } else {
  465. vis.push(json[i].vis);
  466. }
  467. rnMin = rnMin < json[i].rn ? rnMin : json[i].rn;
  468. rn.push(json[i].rn);
  469. if (!ot || ot > json[i].ldate.split("/")[1]) {
  470. time.push(json[i].ldate.split("/")[0] + "日" + json[i].ldate.split("/")[1] + "时");
  471. } else {
  472. time.push(json[i].ldate.split("/")[1] + "时");
  473. }
  474. ot = json[i].ldate.split("/")[1];
  475. }
  476. if (rnMin == 0 || rnMin == 9999 || rnMin == 0.1) rnMin = 10;
  477. //echart数据
  478. var option = {
  479. // title: {
  480. // text: title
  481. // },
  482. tooltip: {
  483. show: false
  484. },
  485. grid: {
  486. // left: '20%',
  487. left: '10',
  488. right: '10',
  489. top: '30',
  490. bottom: '160'
  491. },
  492. xAxis: {
  493. data: time,
  494. axisLabel: {
  495. interval: 0
  496. },
  497. splitLine: {
  498. show: true
  499. },
  500. show: false
  501. },
  502. yAxis: [
  503. {
  504. show: false,
  505. name: "气温",
  506. axisLabel: {
  507. formatter: '{value}\n',
  508. inseide: true,
  509. color: meteo.c.chart.color_TT
  510. },
  511. splitLine: {
  512. show: true
  513. }
  514. }],
  515. series: [
  516. {
  517. name: '气温(℃)',
  518. type: 'line',
  519. // showSymbol:false,
  520. label: {
  521. normal: {
  522. show: true,
  523. formatter: '{c}℃',
  524. color: 'rgba(88,160,253,1)'
  525. }
  526. },
  527. smooth: true,
  528. symbolSize: 8,
  529. hoverAnimation: true,
  530. /*areaStyle: {
  531. normal: {
  532. color: {
  533. type: 'linear',
  534. x: 0,
  535. y: 0,
  536. x2: 0,
  537. y2: 1,
  538. colorStops: [{
  539. offset: 0, color: 'rgba(88,160,253,1)'
  540. }, {
  541. offset: 1, color: 'rgba(88,160,253,0)'
  542. }]
  543. }
  544. }
  545. },*/
  546. lineStyle: {
  547. normal: {
  548. color: 'rgba(88,160,253,1)'
  549. }
  550. },
  551. itemStyle: {
  552. normal: {
  553. color: 'rgba(88,160,253,1)'
  554. }
  555. },
  556. data: tt,
  557. },
  558. {
  559. name: '天气现象',
  560. type: 'custom',
  561. data: wth,
  562. renderItem: function (parma, api) {
  563. // 对于 data 中的每个 dataItem,都会调用这个 renderItem 函数。
  564. // (但是注意,并不一定是按照 data 的顺序调用)
  565. // 这里进行一些处理,例如,坐标转换。
  566. // 这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
  567. var url = api.value(0);
  568. var index = api.value(1);
  569. var ldate = api.value(2);
  570. var tt = api.value(3) + "℃";
  571. var ws = getWsToSpeedLevel(api.value(4));
  572. var wd = getWdImageUrl(api.value(5));
  573. var date = "";
  574. var day = "";
  575. var hour;
  576. if (ldate != null) {
  577. date = ldate.split("/")[0] + "日" + ldate.split("/")[1] + "时";
  578. day = ldate.split("/")[0];
  579. hour = ldate.split("/")[1];
  580. } else {
  581. date = "缺测";
  582. }
  583. var rcolor = '#ffffff';
  584. if (day != meteo.c.chart.hourDay) {
  585. rcolor = "#f1f1f1"
  586. }
  587. meteo.c.chart.hourDay = ldate.split('/')[0];
  588. // 这里使用 api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
  589. // 这里使用 api.size(...) 获得 Y 轴上数值范围为 1 的一段所对应的像素长度。
  590. // 这里返回为这个 dataItem 构建的图形元素定义。
  591. var coordSys = parma.coordSys;
  592. var width = coordSys.x;
  593. var height = coordSys.y;
  594. var left = coordSys.x;
  595. var right = coordSys.width + coordSys.x;
  596. var tr = (right - left) / parma.dataInsideLength;
  597. var positionx = width + tr / 2 + tr * index;
  598. var wthp;
  599. var dayAndNightImageId = meteo.c.wth.dayAndNightImageId;
  600. if (url != null && url != "999999") {
  601. wthp = meteo.c.wth.weatherSurfId[url];
  602. // if (meteo.c.chart.arrayContains(dayAndNightImageId, url) && (hour == '20' || hour == '23' || hour == '02')) {
  603. // if (url < 10) url = "0" + url;
  604. // url = 'images/meteo/weatherIcon/cww' + url + 'n.png';
  605. // } else {
  606. if (url < 10) url = "0" + url;
  607. url = 'images/meteo/weather_surf/cww' + url + '.png';
  608. // }
  609. } else {
  610. url = "缺测";
  611. wthp = "缺测";
  612. }
  613. var wdUrl;
  614. if (wd != null) {
  615. wdUrl = 'images/meteo/windD/windd' + wd + '.png';
  616. }
  617. var x1 = positionx + tr / 2;
  618. var y1 = 130;
  619. var x2 = positionx + tr / 2;
  620. var y2 = 232;
  621. if (index == count) {
  622. x1 = positionx - tr / 2;
  623. x2 = positionx - tr / 2;
  624. }
  625. var rx = positionx - tr / 2;
  626. var ry = 5;
  627. return {
  628. type: 'group',
  629. children: [
  630. {
  631. type: 'rect',
  632. shape: {
  633. x: rx,
  634. y: ry,
  635. width: tr,
  636. height: 235
  637. },
  638. style: {
  639. fill: rcolor
  640. }
  641. },
  642. {
  643. type: 'text',
  644. style: {
  645. text: date,
  646. textFont: api.font({fontSize: 12}),
  647. fill: '#71B4F8',
  648. fontFamily: 'Arial',
  649. textAlign: 'center',
  650. textVerticalAlign: 'bottom'
  651. },
  652. position: [positionx, 140]
  653. }, {
  654. type: 'image',
  655. style: {
  656. image: url,
  657. x: -20 - 5,
  658. y: -20,
  659. width: 50,
  660. height: 50
  661. },
  662. position: [positionx, 170]
  663. }, {
  664. type: 'text',
  665. style: {
  666. text: wthp,
  667. textFont: api.font({fontSize: 14}),
  668. fill: '#71B4F8',
  669. fontFamily: 'Arial',
  670. textAlign: 'center',
  671. textVerticalAlign: 'bottom'
  672. },
  673. position: [positionx, 210]
  674. }, {
  675. type: 'image',
  676. style: {
  677. image: wdUrl,
  678. x: -20 - 2,
  679. y: -20 + 5,
  680. width: 16,
  681. height: 16
  682. },
  683. position: [positionx, 230]
  684. }, {
  685. type: 'text',
  686. style: {
  687. text: ws,
  688. textFont: api.font({fontSize: 10}),
  689. fill: '#71B4F8',
  690. fontSize: 10,
  691. fontFamily: 'Arial',
  692. textAlign: 'center',
  693. textVerticalAlign: 'bottom'
  694. },
  695. position: [positionx + 2, 230]
  696. }, {
  697. type: 'line',
  698. shape: {
  699. x1: x1,
  700. y1: y1,
  701. x2: x2,
  702. y2: y2
  703. },
  704. style: {
  705. stroke: '#E4EDF6'
  706. }
  707. }
  708. ]
  709. }
  710. }
  711. }
  712. ]
  713. }
  714. return option;
  715. },
  716. /*
  717. *地面站-七天
  718. */
  719. getSurfDaysChartOption: function (json, title) {
  720. // 整理数据
  721. var wth = [];//天气现象
  722. var time = []; //时间
  723. var ot = null; //
  724. var count;
  725. for (var i = 0; i < json.length; i++) {
  726. count = json.length - 1;
  727. wth.push([json[i].wth, i, json[i].ldate, json[i].tt, json[i].ws, json[i].wd]);
  728. if (!ot || ot > json[i].ldate.split("/")[1]) {
  729. time.push(json[i].ldate.split("/")[0] + "日" + json[i].ldate.split("/")[1] + "时");
  730. } else {
  731. time.push(json[i].ldate.split("/")[1] + "时");
  732. }
  733. }
  734. //echart数据
  735. var option = {
  736. tooltip: {
  737. show: false
  738. },
  739. grid: {
  740. // left: '20%',
  741. left: '10',
  742. right: '10',
  743. top: '100',
  744. bottom: '40'
  745. },
  746. xAxis: {
  747. data: time,
  748. axisLabel: {
  749. interval: 0
  750. },
  751. splitLine: {
  752. show: true
  753. },
  754. show: false
  755. },
  756. yAxis: [
  757. {
  758. show: false,
  759. name: "气温",
  760. axisLine: {
  761. lineStyle: {
  762. color: meteo.c.chart.color_TT
  763. }
  764. },
  765. axisLabel: {
  766. formatter: '',
  767. color: meteo.c.chart.color_TT
  768. },
  769. splitLine: {
  770. show: false
  771. }
  772. }],
  773. series: [
  774. {
  775. name: '天气现象',
  776. type: 'custom',
  777. data: wth,
  778. renderItem: function (parma, api) {
  779. // 对于 data 中的每个 dataItem,都会调用这个 renderItem 函数。
  780. // (但是注意,并不一定是按照 data 的顺序调用)
  781. // 这里进行一些处理,例如,坐标转换。
  782. // 这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
  783. var url = api.value(0);
  784. // if (!url) return;
  785. var index = api.value(1);
  786. var ldate = api.value(2);
  787. var tt = api.value(3) + "℃";
  788. var ws = getWsToSpeedLevel(api.value(4));
  789. var wd = getWdImageUrl(api.value(5));
  790. var date = "";
  791. var hour;
  792. if (ldate != null) {
  793. date = ldate.split("/")[0] + "日" + ldate.split("/")[1] + "时";
  794. hour = ldate.split("/")[1];
  795. } else {
  796. date = "缺测";
  797. }
  798. // 这里使用 api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
  799. // 这里使用 api.size(...) 获得 Y 轴上数值范围为 1 的一段所对应的像素长度。
  800. // 这里返回为这个 dataItem 构建的图形元素定义。
  801. var coordSys = parma.coordSys;
  802. var width = coordSys.x;
  803. var height = coordSys.y;
  804. var left = coordSys.x;
  805. var right = coordSys.width + coordSys.x;
  806. var tr = (right - left) / parma.dataInsideLength;
  807. var positionx = width + tr / 2 + tr * index;
  808. var wthp = meteo.c.wth.weatherId[url];
  809. var dayAndNightImageId = meteo.c.wth.dayAndNightImageId;
  810. if (meteo.c.chart.arrayContains(dayAndNightImageId, url) && hour == '20') {
  811. if (url < 10) url = "0" + url;
  812. url = 'images/meteo/weatherIcon/cww' + url + 'n.png';
  813. } else {
  814. if (url < 10) url = "0" + url;
  815. url = 'images/meteo/weatherIcon/cww' + url + '.png';
  816. }
  817. var wdUrl;
  818. if (wd != null) {
  819. wdUrl = 'images/meteo/windD/windd' + wd + '.png';
  820. } else {
  821. }
  822. var x1 = positionx + tr / 2;
  823. var y1 = 30;
  824. var x2 = positionx + tr / 2;
  825. var y2 = 202;
  826. if (index == count) {
  827. x1 = positionx - tr / 2;
  828. x2 = positionx - tr / 2;
  829. }
  830. var rx = positionx - tr / 2;
  831. var ry = 20;
  832. var rcolor = '#ffffff';
  833. if (ldate.split("/")[1] == "08") {
  834. rcolor = '#f1f1f1';
  835. }
  836. return {
  837. type: 'group',
  838. children: [
  839. {
  840. type: 'rect',
  841. shape: {
  842. x: rx,
  843. y: ry,
  844. width: tr,
  845. height: 220
  846. },
  847. style: {
  848. fill: rcolor
  849. }
  850. },
  851. {
  852. type: 'text',
  853. style: {
  854. text: date,
  855. textFont: api.font({fontSize: 12}),
  856. fill: '#71B4F8',
  857. fontFamily: 'Arial',
  858. textAlign: 'center',
  859. textVerticalAlign: 'bottom'
  860. },
  861. position: [positionx, 40]
  862. }, {
  863. type: 'image',
  864. style: {
  865. image: url,
  866. x: -20 - 5,
  867. y: -20,
  868. width: 50,
  869. height: 50
  870. },
  871. position: [positionx, 70]
  872. }, {
  873. type: 'text',
  874. style: {
  875. text: wthp,
  876. textFont: api.font({fontSize: 16}),
  877. fill: '#71B4F8',
  878. fontSize: 14,
  879. textWeight: 1,
  880. fontFamily: 'Arial',
  881. textAlign: 'center',
  882. textVerticalAlign: 'bottom'
  883. },
  884. position: [positionx, 120]
  885. }, {
  886. type: 'text',
  887. style: {
  888. text: tt,
  889. textFont: api.font({fontSize: 30}),
  890. textWeight: 2,
  891. fontSize: 18,
  892. fill: '#71B4F8',
  893. fontFamily: 'Arial',
  894. textAlign: 'center',
  895. textVerticalAlign: 'bottom'
  896. },
  897. position: [positionx, 160]
  898. }, {
  899. type: 'image',
  900. style: {
  901. image: wdUrl,
  902. x: -20 - 4,
  903. y: -20 + 5,
  904. width: 16,
  905. height: 16
  906. },
  907. position: [positionx, 200]
  908. }, {
  909. type: 'text',
  910. style: {
  911. text: ws,
  912. textFont: api.font({fontSize: 10}),
  913. fill: '#71B4F8',
  914. fontSize: 10,
  915. fontFamily: 'Arial',
  916. textAlign: 'center',
  917. textVerticalAlign: 'bottom'
  918. },
  919. position: [positionx + 4, 200]
  920. }, {
  921. type: 'line',
  922. shape: {
  923. x1: x1,
  924. y1: y1,
  925. x2: x2,
  926. y2: y2
  927. },
  928. style: {
  929. stroke: '#E4EDF6'
  930. }
  931. },
  932. ]
  933. }
  934. }
  935. }
  936. ]
  937. }
  938. return option;
  939. },
  940. /*
  941. *全球站-七天
  942. */
  943. getGlobalDaysChartOption: function (json, title) {
  944. var wth = [];//
  945. var time = []; //时间
  946. var count;
  947. for (var i = 0; i < json.length; i++) {
  948. count = json.length - 1;
  949. wth.push([i, json[i].ttDay, json[i].ttNight, json[i].wthDay, json[i].wthNight,
  950. json[i].wdDay, json[i].wdNight, json[i].wsDay, json[i].wsNight, json[i].ldate,]);
  951. }
  952. //echart数据
  953. var option = {
  954. // title: {
  955. // text: title
  956. // },
  957. tooltip: {
  958. show: false
  959. },
  960. grid: {
  961. left: '10',
  962. right: '10',
  963. top: '100',
  964. bottom: '40'
  965. },
  966. xAxis: {
  967. data: time,
  968. axisLabel: {
  969. interval: 0
  970. },
  971. splitLine: {
  972. show: true
  973. },
  974. show: false
  975. },
  976. yAxis: [
  977. {
  978. name: "气温",
  979. axisLine: {
  980. lineStyle: {
  981. color: meteo.c.chart.color_TT
  982. }
  983. },
  984. axisLabel: {
  985. formatter: '',
  986. color: meteo.c.chart.color_TT
  987. },
  988. splitLine: {
  989. show: false
  990. },
  991. show: false
  992. }],
  993. series: {
  994. name: '天气现象',
  995. type: 'custom',
  996. data: wth,
  997. renderItem: function (parma, api) {
  998. // 对于 data 中的每个 dataItem,都会调用这个 renderItem 函数。
  999. // (但是注意,并不一定是按照 data 的顺序调用)
  1000. // 这里进行一些处理,例如,坐标转换。
  1001. // 这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
  1002. // wth.push([i,json[i].ttDay, json[i].ttNight, json[i].wthDay, json[i].wthNight,
  1003. // json[i].wdDay,json[i].wdNight,json[i].wsDay,json[i].wsNight,json[i].ldate ]);
  1004. var index = api.value(0);
  1005. var ttDay = api.value(1);
  1006. var ttNight = api.value(2);
  1007. var wthDay = api.value(3);
  1008. var wthNight = api.value(4);
  1009. var wdDay = getWdImageUrl(api.value(5));
  1010. var wdNight = getWdImageUrl(api.value(6));
  1011. var wsDay = getWsToSpeedLevel(api.value(7));
  1012. var wsNight = getWsToSpeedLevel(api.value(8));
  1013. var ldate = api.value(9);
  1014. var tt = "";
  1015. if (ttDay != null || ttNight != null) {
  1016. tt = ttNight + "~" + ttDay + "℃";
  1017. } else {
  1018. tt = "缺测";
  1019. }
  1020. var date = "";
  1021. if (ldate != null) {
  1022. date = ldate.split("/")[0] + "日";
  1023. } else {
  1024. date = "缺测";
  1025. }
  1026. var dayAndNightImageId = meteo.c.wth.dayAndNightImageId;
  1027. var wthDayUrl;
  1028. var wthDayp;
  1029. if (wthDay != null && wthDay != "999999") {
  1030. wthDayp = meteo.c.wth.weatherId[wthDay];
  1031. if (wthDay < 10) wthDay = "0" + wthDay;
  1032. wthDayUrl = 'images/meteo/weatherIcon/cww' + wthDay + '.png';
  1033. } else {
  1034. wthDayp = "缺测";
  1035. wthDayUrl = "缺测";
  1036. }
  1037. var wthNightUrl;
  1038. var wthNightp;
  1039. if (wthNight != null && wthNight != "999999") {
  1040. wthNightp = meteo.c.wth.weatherId[wthNight];
  1041. if (meteo.c.chart.arrayContains(dayAndNightImageId, wthNight)) {
  1042. if (wthNight < 10) wthNight = "0" + wthNight;
  1043. wthNightUrl = 'images/meteo/weatherIcon/cww' + wthNight + 'n.png';
  1044. } else {
  1045. if (wthNight < 10) wthNight = "0" + wthNight;
  1046. wthNightUrl = 'images/meteo/weatherIcon/cww' + wthNight + '.png';
  1047. }
  1048. } else {
  1049. wthNightp = "缺测";
  1050. wthNightUrl = "缺测";
  1051. }
  1052. var wdDayUrl;
  1053. if (wdDay != null) {
  1054. wdDayUrl = 'images/meteo/windD/windd' + wdDay + '.png';
  1055. } else {
  1056. wdDayUrl = "缺测";
  1057. }
  1058. var wdNightUrl;
  1059. if (wdNight != null) {
  1060. wdNightUrl = 'images/meteo/windD/windd' + wdNight + '.png';
  1061. } else {
  1062. wdNightUrl = "缺测";
  1063. }
  1064. var coordSys = parma.coordSys;
  1065. var width = coordSys.x;
  1066. var height = coordSys.y;
  1067. var left = coordSys.x;
  1068. var right = coordSys.width + coordSys.x;
  1069. var tr = (right - left) / parma.dataInsideLength;
  1070. var positionx = width + tr / 2 + tr * index;
  1071. var x1 = positionx + tr / 2;
  1072. var y1 = 30;
  1073. var x2 = positionx + tr / 2;
  1074. var y2 = 232;
  1075. if (index == count) {
  1076. x1 = positionx - tr / 2;
  1077. x2 = positionx - tr / 2;
  1078. }
  1079. return {
  1080. type: 'group',
  1081. children: [
  1082. {
  1083. type: 'text',
  1084. style: {
  1085. text: date,
  1086. textFont: api.font({fontSize: 12}),
  1087. fill: '#71B4F8',
  1088. fontFamily: 'Arial',
  1089. textAlign: 'center',
  1090. textVerticalAlign: 'bottom'
  1091. },
  1092. position: [positionx, 40]
  1093. }, {
  1094. type: 'image',
  1095. style: {
  1096. image: wthDayUrl,
  1097. x: -20 - 5,
  1098. y: -20,
  1099. width: 50,
  1100. height: 50
  1101. },
  1102. position: [positionx, 60]
  1103. }, {
  1104. type: 'text',
  1105. style: {
  1106. text: wthDayp,
  1107. textFont: api.font({fontSize: 16}),
  1108. fill: '#71B4F8',
  1109. fontSize: 14,
  1110. textWeight: 1,
  1111. fontFamily: 'Arial',
  1112. textAlign: 'center',
  1113. textVerticalAlign: 'bottom'
  1114. },
  1115. position: [positionx, 105]
  1116. }, {
  1117. type: 'image',
  1118. style: {
  1119. image: wdDayUrl,
  1120. x: -20 - 4,
  1121. y: -20 + 5,
  1122. width: 16,
  1123. height: 16
  1124. },
  1125. position: [positionx, 130]
  1126. }, {
  1127. type: 'text',
  1128. style: {
  1129. text: wsDay,
  1130. textFont: api.font({fontSize: 10}),
  1131. fill: '#71B4F8',
  1132. fontSize: 10,
  1133. fontFamily: 'Arial',
  1134. textAlign: 'center',
  1135. textVerticalAlign: 'bottom'
  1136. },
  1137. position: [positionx + 4, 130]
  1138. }, {
  1139. type: 'text',
  1140. style: {
  1141. text: tt,
  1142. textFont: api.font({fontSize: 14}),
  1143. fill: '#71B4F8',
  1144. textWeight: 2,
  1145. fontSize: 18,
  1146. fontFamily: 'Arial',
  1147. textAlign: 'center',
  1148. textVerticalAlign: 'bottom'
  1149. },
  1150. position: [positionx, 160]
  1151. }, {
  1152. type: 'image',
  1153. style: {
  1154. image: wdNightUrl,
  1155. x: -20 - 4,
  1156. y: -20 + 5,
  1157. width: 16,
  1158. height: 16
  1159. },
  1160. position: [positionx, 180]
  1161. }, {
  1162. type: 'text',
  1163. style: {
  1164. text: wsNight,
  1165. textFont: api.font({fontSize: 10}),
  1166. fill: '#71B4F8',
  1167. fontSize: 10,
  1168. fontFamily: 'Arial',
  1169. textAlign: 'center',
  1170. textVerticalAlign: 'bottom'
  1171. },
  1172. position: [positionx + 4, 180]
  1173. }, {
  1174. type: 'text',
  1175. style: {
  1176. text: wthNightp,
  1177. textFont: api.font({fontSize: 14}),
  1178. fill: '#71B4F8',
  1179. fontFamily: 'Arial',
  1180. textAlign: 'center',
  1181. textVerticalAlign: 'bottom'
  1182. },
  1183. position: [positionx, 210]
  1184. }, {
  1185. type: 'image',
  1186. style: {
  1187. image: wthNightUrl,
  1188. x: -20 - 5,
  1189. y: -20,
  1190. width: 50,
  1191. height: 50
  1192. },
  1193. position: [positionx, 225]
  1194. }, {
  1195. type: 'line',
  1196. shape: {
  1197. x1: x1,
  1198. y1: y1,
  1199. x2: x2,
  1200. y2: y2
  1201. },
  1202. style: {
  1203. stroke: '#E4EDF6'
  1204. }
  1205. }
  1206. ]
  1207. };
  1208. }
  1209. }
  1210. }
  1211. return option;
  1212. },
  1213. getGlobalData: function (json, title) {
  1214. // meteo.c.chart.count = json.length;
  1215. // var chartWidth = meteo.c.chart.count * 60 + 310;
  1216. // chartWidth = chartWidth < 650 ? 650 : chartWidth;
  1217. // $("#" + id).css('width', chartWidth); //设置宽度
  1218. // var chart = ec.init(document.getElementById(id));
  1219. // var wth_D = [];
  1220. // var wth_N = [];
  1221. var tt_D = [];
  1222. var tt_N = [];
  1223. var rn_D = [];
  1224. var rn_N = [];
  1225. var time = [];
  1226. var rnMax = 0;
  1227. for (var i = 0; i < json.length; i++) {
  1228. // wth_D.push([json[i].wth, i]);
  1229. // wth_N.push([json[i].wth, i]);
  1230. tt_D.push(json[i].ttDay);
  1231. tt_N.push(json[i].ttNight);
  1232. rnMax = rnMax > json[i].rainDay ? rnMax : json[i].rainDay;
  1233. rnMax = rnMax > json[i].rainNight ? rnMax : json[i].rainNight;
  1234. rn_D.push(json[i].rainDay);
  1235. rn_N.push(json[i].rainNight);
  1236. time.push(json[i].ldate.split("/")[0] + "日" + json[i].ldate.split("/")[1] + "时");
  1237. }
  1238. if (rnMax == 0 || rnMax == 9999 || rnMax == 0.1) rnMax = 10;
  1239. var option = {
  1240. // title: {
  1241. // text: title
  1242. // },
  1243. tooltip: {
  1244. show: false
  1245. // show: true
  1246. },
  1247. grid: {
  1248. // left: '20%',
  1249. // left: '130',
  1250. // right: '160',
  1251. top: '100',
  1252. bottom: '40'
  1253. },
  1254. legend: {
  1255. data: ['白天气温', '夜间气温', '白天降水', '夜间降水']
  1256. },
  1257. xAxis: {
  1258. data: time,
  1259. axisLabel: {
  1260. interval: 0
  1261. },
  1262. axisTick: {
  1263. alignWithLabel: true
  1264. },
  1265. splitLine: {
  1266. show: true
  1267. }
  1268. },
  1269. yAxis: [{
  1270. name: "气温",
  1271. axisLine: {
  1272. lineStyle: {
  1273. color: meteo.c.chart.color_TT_D
  1274. }
  1275. },
  1276. nameTextStyle: {
  1277. color: meteo.c.chart.color_TT_D
  1278. },
  1279. axisLabel: {
  1280. formatter: '{value}℃',
  1281. color: meteo.c.chart.color_TT_D
  1282. },
  1283. splitLine: {
  1284. show: false
  1285. }
  1286. }, {
  1287. name: "降水",
  1288. position: 'right',
  1289. max: rnMax,
  1290. axisLine: {
  1291. lineStyle: {
  1292. color: meteo.c.chart.color_RN_D
  1293. }
  1294. },
  1295. nameTextStyle: {
  1296. color: meteo.c.chart.color_RN_D
  1297. },
  1298. axisLabel: {
  1299. formatter: '{value}mm',
  1300. color: meteo.c.chart.color_RN_D
  1301. },
  1302. splitLine: {
  1303. show: false
  1304. }
  1305. }],
  1306. series: [
  1307. {
  1308. name: '白天气温',
  1309. type: 'line',
  1310. label: {
  1311. normal: { //普通文字标记
  1312. show: true,
  1313. position: 'top',
  1314. color: meteo.c.chart.color_TT_D,
  1315. fontStyle: 'normal',
  1316. fontSize: 12,
  1317. }
  1318. },
  1319. lineStyle: {
  1320. normal: {
  1321. color: meteo.c.chart.color_TT_D,
  1322. width: 2,
  1323. type: 'solid',
  1324. }
  1325. },
  1326. itemStyle: {
  1327. normal: {
  1328. color: meteo.c.chart.color_TT_D
  1329. }
  1330. },
  1331. data: tt_D,
  1332. },
  1333. {
  1334. name: '夜间气温',
  1335. type: 'line',
  1336. label: {
  1337. normal: { //普通文字标记
  1338. show: true,
  1339. position: 'top',
  1340. color: meteo.c.chart.color_TT_N,
  1341. fontStyle: 'normal',
  1342. fontSize: 12,
  1343. }
  1344. },
  1345. lineStyle: {
  1346. normal: {
  1347. color: meteo.c.chart.color_TT_N,
  1348. width: 2,
  1349. type: 'solid',
  1350. }
  1351. },
  1352. itemStyle: {
  1353. normal: {
  1354. color: meteo.c.chart.color_TT_N
  1355. }
  1356. },
  1357. data: tt_N,
  1358. },
  1359. {
  1360. name: '白天降水',
  1361. type: 'bar',
  1362. yAxisIndex: 1,
  1363. label: {
  1364. normal: { //普通文字标记
  1365. show: true,
  1366. position: 'top',
  1367. color: meteo.c.chart.color_RN_D,
  1368. fontStyle: 'normal',
  1369. fontSize: 12,
  1370. }
  1371. },
  1372. lineStyle: {
  1373. normal: {
  1374. color: meteo.c.chart.color_RN_D,
  1375. width: 2,
  1376. type: 'solid',
  1377. }
  1378. },
  1379. itemStyle: {
  1380. normal: {
  1381. color: meteo.c.chart.color_RN_D
  1382. }
  1383. },
  1384. data: rn_D,
  1385. },
  1386. {
  1387. name: '夜间降水',
  1388. type: 'bar',
  1389. yAxisIndex: 1,
  1390. label: {
  1391. normal: { //普通文字标记
  1392. show: true,
  1393. position: 'top',
  1394. color: meteo.c.chart.color_RN_N,
  1395. fontStyle: 'normal',
  1396. fontSize: 12,
  1397. }
  1398. },
  1399. lineStyle: {
  1400. normal: {
  1401. color: meteo.c.chart.color_RN_N,
  1402. width: 2,
  1403. type: 'solid',
  1404. }
  1405. },
  1406. itemStyle: {
  1407. normal: {
  1408. color: meteo.c.chart.color_RN_N
  1409. }
  1410. },
  1411. data: rn_N,
  1412. },
  1413. // {
  1414. // name: '天气现象',
  1415. // type: 'custom',
  1416. // yAxisIndex: 2,
  1417. // renderItem: function (parma, api) {
  1418. // // 对于 data 中的每个 dataItem,都会调用这个 renderItem 函数。
  1419. // // (但是注意,并不一定是按照 data 的顺序调用)
  1420. //
  1421. // // 这里进行一些处理,例如,坐标转换。
  1422. // // 这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
  1423. // var url = api.value(0);
  1424. // var index = api.value(1);
  1425. // // 这里使用 api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
  1426. // // 这里使用 api.size(...) 获得 Y 轴上数值范围为 1 的一段所对应的像素长度。
  1427. // // 这里返回为这个 dataItem 构建的图形元素定义。
  1428. // var coordSys = parma.coordSys;
  1429. // var width = coordSys.x;
  1430. // var height = coordSys.y;
  1431. // var left = coordSys.x;
  1432. // var right = coordSys.width + coordSys.x;
  1433. //
  1434. // // var tr = (right - left) / meteo.c.chart.count;
  1435. // var tr = (right - left) / parma.dataInsideLength;
  1436. // // var tr = coordSys.width / 8;
  1437. // var positionx = width + (width + tr - width) / 2 + tr * index;
  1438. // // var ix = (width - height) / 2
  1439. // var wthp = url;
  1440. // if (url < 10) url = "0" + url;
  1441. // url = 'images/meteo/weatherImage/cww' + url + '.png';
  1442. //
  1443. // return {
  1444. // type: 'group',
  1445. // children: [{
  1446. // type: 'image',
  1447. // style: {
  1448. // image: url,
  1449. // x: -20,
  1450. // y: -20,
  1451. // width: 40,
  1452. // height: 40
  1453. // },
  1454. // position: [positionx, 60]
  1455. // }, {
  1456. // type: 'text',
  1457. // style: {
  1458. // text: wthp,
  1459. // textFont: api.font({fontSize: 14}),
  1460. // fill: '#f00',
  1461. // textAlign: 'center',
  1462. // textVerticalAlign: 'bottom'
  1463. // },
  1464. // position: [positionx, 40]
  1465. // }]
  1466. // }
  1467. // },
  1468. // data: wth
  1469. // }
  1470. ]
  1471. }
  1472. return option;
  1473. chart.resize();
  1474. chart.setOption(option);
  1475. $(".content_scrollx").mCustomScrollbar('update');
  1476. },
  1477. arrayContains: function (arr, obj) {
  1478. var i = arr.length;
  1479. while (i--) {
  1480. if (arr[i] == obj) {
  1481. return true;
  1482. }
  1483. }
  1484. return false;
  1485. },
  1486. }
  1487. return meteo.c.chart;
  1488. });
  1489. /*
  1490. * 通过风向wd获取风向的url
  1491. */
  1492. function getWdImageUrl(str) {
  1493. if (str == null) {
  1494. str = null;
  1495. return;
  1496. }
  1497. str = str > 360 ? str % 360 : str;
  1498. str = str < 0 ? (str + 360) : str;
  1499. str = (str - 22.5) / 45;
  1500. str = str < 0 ? '00' : //北
  1501. str < 1 ? '01' : //东北
  1502. str < 2 ? '02' : //东
  1503. str < 3 ? '03' : //东南
  1504. str < 4 ? '04' : //南
  1505. str < 5 ? '05' : //西南
  1506. str < 6 ? '06' : //西
  1507. str < 7 ? '07' : //西北
  1508. '00'; // 北
  1509. return str;
  1510. }
  1511. //通过风速ws求风级
  1512. function getWsToSpeedLevel(value) {
  1513. var str;
  1514. if (value == null) {
  1515. str = "缺测";
  1516. return str;
  1517. }
  1518. str = value <= 0.2 ? '无风' :
  1519. value <= 1.5 ? '1' :
  1520. value <= 3.3 ? '2' :
  1521. value <= 5.4 ? '3' :
  1522. value <= 7.9 ? '4' :
  1523. value <= 10.7 ? '5' :
  1524. value <= 13.8 ? '6' :
  1525. value <= 17.1 ? '7' :
  1526. value <= 20.7 ? '8' :
  1527. value <= 24.4 ? '9' :
  1528. value <= 28.4 ? '10' :
  1529. value <= 32.6 ? '11' :
  1530. value <= 36.9 ? '12' : '特';
  1531. str = str == "无风" ? str : str + '级';
  1532. return str;
  1533. }