e20_geojson_buildings.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. function fontSize(res) {
  2. let font_size = window.getComputedStyle(document.documentElement).fontSize.replace("px", "") * 1;
  3. return res * font_size;
  4. }
  5. function initEcharts() {
  6. //饼形图
  7. var myChart = echarts.init(document.getElementById("ring"));
  8. var option = {
  9. backgroundColor: "transparent",
  10. legend: {
  11. show: false,
  12. top: "0%",
  13. left: "center",
  14. icon: "roundRect",
  15. itemWidth: 8,
  16. textStyle: {
  17. fontSize: fontSize(0.68),
  18. },
  19. },
  20. series: [
  21. {
  22. type: "pie",
  23. radius: "80%",
  24. center: ["50%", "50%"],
  25. avoidLabelOverlap: false,
  26. itemStyle: {
  27. borderType: "solid",
  28. borderColor: "#ffffff",
  29. },
  30. emphasis: {
  31. scale: false,
  32. scaleSize: 2,
  33. },
  34. label: {
  35. show: true,
  36. position: "center",
  37. lineHeight: 28,
  38. formatter: function (params) {
  39. if (params.dataIndex === self.left_index) {
  40. return "{p|" + params.data.value + "}" + "\n{nm|" + params.data.name + "}";
  41. } else {
  42. return "";
  43. }
  44. },
  45. emphasis: {
  46. formatter: function (params) {
  47. if (params.dataIndex != self.left_index) {
  48. return "{p|" + params.data.name + "}" + "\n{nm|" + params.data.value + "}";
  49. }
  50. },
  51. },
  52. rich: {
  53. p: {
  54. width: 130,
  55. itemWidth: 100,
  56. color: "#fff",
  57. fontSize: fontSize(1),
  58. lineHeight: fontSize(1),
  59. fontWeight: "bold",
  60. // backgroundColor: "rgba(15, 21, 70, 1)", // 覆盖index=0时的数据
  61. },
  62. nm: {
  63. width: 130,
  64. itemWidth: 100,
  65. color: "#fff",
  66. fontSize: fontSize(1.5),
  67. lineHeight: fontSize(1.625),
  68. fontWeight: "bold",
  69. // backgroundColor: "rgba(15, 21, 70, 1)", // 覆盖index=0时的数据
  70. },
  71. },
  72. },
  73. labelLine: {
  74. show: false,
  75. },
  76. data: [
  77. {
  78. value: 64,
  79. name: "办公建筑",
  80. itemStyle: {
  81. color: "rgba(14,227,247, 0.58)",
  82. },
  83. },
  84. {
  85. value: 1,
  86. name: "综合建筑",
  87. itemStyle: {
  88. color: "rgba(255,113,94, 0.58)",
  89. },
  90. },
  91. {
  92. value: 4,
  93. name: "商场建筑",
  94. itemStyle: {
  95. color: "rgba(254, 217, 118, 0.64)",
  96. },
  97. },
  98. {
  99. value: 10,
  100. name: "宾馆饭店",
  101. itemStyle: {
  102. color: "rgba(234,94,230, 0.64)",
  103. },
  104. },
  105. {
  106. value: 1,
  107. name: "医疗卫生",
  108. itemStyle: {
  109. color: "rgba(94, 225, 186, 0.58)",
  110. },
  111. },
  112. {
  113. value: 1,
  114. name: "文化教育",
  115. itemStyle: {
  116. color: "rgba(113, 204, 78, 0.58)",
  117. },
  118. },
  119. ],
  120. },
  121. ],
  122. };
  123. myChart.setOption(option);
  124. //柱状图
  125. var myChart2 = echarts.init(document.getElementById("bar"), "dark");
  126. var option2 = {
  127. backgroundColor: "transparent",
  128. tooltip: {
  129. trigger: "axis",
  130. show: true,
  131. confine: true,
  132. textStyle: {
  133. align: "left",
  134. },
  135. formatter: function (item) {
  136. let html = `${item[0].name}:${item[0].data}`;
  137. item.slice(1).forEach((s) => {
  138. if (s.seriesName.indexOf("series") == -1) {
  139. html += `<br/> ${s.seriesName}:${s.data}`;
  140. }
  141. });
  142. return html;
  143. },
  144. axisPointer: {
  145. // 坐标轴指示器,坐标轴触发有效
  146. type: "none", // cross 默认为直线,可选为:'line' | 'shadow'
  147. },
  148. },
  149. legend: {
  150. show: false,
  151. top: "5%",
  152. left: "center",
  153. icon: "roundRect",
  154. itemWidth: 8,
  155. textStyle: {
  156. fontSize: fontSize(0.6875),
  157. },
  158. },
  159. grid: {
  160. left: "0%",
  161. right: "0%",
  162. top: "20%",
  163. bottom: "5%",
  164. containLabel: true,
  165. },
  166. xAxis: {
  167. type: "category",
  168. data: ["办公建筑", "综合建筑", "商场建筑", "宾馆饭店", "医疗卫生", "文化教育"],
  169. axisTick: {
  170. alignWithLabel: false,
  171. show: true,
  172. lineStyle: {
  173. color: "#ccc",
  174. },
  175. },
  176. axisLabel: {
  177. fontSize: fontSize(0.6875),
  178. interval: 0,
  179. padding: [10, 0, 0, 0],
  180. },
  181. axisLine: {
  182. lineStyle: {
  183. color: "#ccc",
  184. },
  185. },
  186. splitLine: {
  187. show: false,
  188. },
  189. show: true,
  190. },
  191. yAxis: {
  192. max: 70,
  193. name: "栋",
  194. nameTextStyle: {
  195. // color: "rgba(217, 35, 35, 1)",
  196. align: "right",
  197. verticalAlign: "middle",
  198. borderDashOffset: 0,
  199. padding: [6, 6, 6, 6],
  200. },
  201. axisLabel: {
  202. // color: '#ff0000',
  203. fontSize: fontSize(0.6875),
  204. interval: 0,
  205. padding: [0, 0, 0, 0],
  206. },
  207. splitLine: {
  208. show: false,
  209. },
  210. axisLine: {
  211. lineStyle: {
  212. color: "#ccc",
  213. },
  214. },
  215. axisTick: {
  216. alignWithLabel: false,
  217. show: true,
  218. lineStyle: {
  219. color: "#ccc",
  220. },
  221. },
  222. },
  223. series: [
  224. {
  225. name: "dotted",
  226. type: "pictorialBar",
  227. symbol: "rect",
  228. barGap: "-100%",
  229. showBackground: true,
  230. itemStyle: {
  231. color: "rgba(14,227,247, 1)",
  232. },
  233. symbolRepeat: true,
  234. symbolSize: [12, 4],
  235. symbolMargin: 1,
  236. data: [64, 1, 4, 10, 1, 1],
  237. z: -8,
  238. },
  239. {
  240. type: "bar",
  241. itemStyle: {
  242. color: "rgba(0,0,0,0.2)",
  243. },
  244. barGap: "-100%",
  245. barWidth: 12,
  246. z: -9,
  247. showBackground: true,
  248. data: [70, 70, 70, 70, 70, 70],
  249. },
  250. ],
  251. };
  252. myChart2.setOption(option2);
  253. // 折线图
  254. let myChart3 = echarts.init(document.getElementById("line"), "dark");
  255. var option3 = {
  256. backgroundColor: "transparent",
  257. tooltip: {
  258. trigger: "axis",
  259. show: true,
  260. confine: true,
  261. textStyle: {
  262. align: "left",
  263. },
  264. formatter: function (item) {
  265. let html = item[0].axisValue * 1 + "月";
  266. item.slice(0).forEach((s) => {
  267. if (s.seriesName.indexOf("series") == -1) {
  268. html += `<br/> ${s.seriesName}:${s.data}%`;
  269. }
  270. });
  271. return html;
  272. // return '{b0}<br/>{a1}: {c1}<br/>{a2}: {c2}'
  273. },
  274. // formatter: '{b0}<br/>{a1}: {c1}<br/>{a2}: {c2}',
  275. axisPointer: {
  276. // 坐标轴指示器,坐标轴触发有效
  277. type: "none", // 默认为直线,可选为:'line' | 'shadow'
  278. },
  279. },
  280. legend: {
  281. show: true,
  282. // data:[""]
  283. top: "0%",
  284. left: "center",
  285. icon: "circle",
  286. type: "scroll",
  287. itemHeight: fontSize(0.5),
  288. itemWidth: fontSize(0.5),
  289. textStyle: {
  290. fontSize: fontSize(0.6),
  291. },
  292. },
  293. grid: {
  294. left: "0%",
  295. right: "0%",
  296. top: "18%",
  297. bottom: "5%",
  298. containLabel: true,
  299. },
  300. xAxis: {
  301. type: "category",
  302. data: ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
  303. axisTick: {
  304. alignWithLabel: false,
  305. show: true,
  306. lineStyle: {
  307. color: "#ccc",
  308. },
  309. },
  310. axisLine: {
  311. lineStyle: {
  312. color: "#ccc",
  313. },
  314. },
  315. axisLabel: {
  316. //X轴文字样式
  317. fontSize: fontSize(0.6875),
  318. interval: 0,
  319. padding: [10, 0, 0, 0],
  320. },
  321. splitLine: {
  322. show: false,
  323. },
  324. show: true,
  325. },
  326. yAxis: {
  327. // max:100,
  328. type: "value",
  329. name: "kwh",
  330. axisLabel: {
  331. fontSize: fontSize(0.6875),
  332. interval: 0,
  333. padding: [0, 0, 0, 0],
  334. },
  335. nameLocation: "end",
  336. nameTextStyle: {
  337. align: "right",
  338. verticalAlign: "middle",
  339. borderDashOffset: 0,
  340. padding: [6, 6, 6, 6],
  341. },
  342. splitLine: { show: false },
  343. axisLine: {
  344. lineStyle: {
  345. color: "#ccc",
  346. },
  347. },
  348. axisTick: {
  349. alignWithLabel: false,
  350. show: true,
  351. lineStyle: {
  352. color: "#ccc",
  353. },
  354. },
  355. },
  356. series: [
  357. {
  358. name: "办公建筑",
  359. type: "line",
  360. symbol: "circle",
  361. symbolSize: 5,
  362. itemStyle: {
  363. color: "rgba(14,227,247,1)",
  364. },
  365. barGap: "-100%",
  366. barWidth: 12,
  367. z: -8,
  368. data: [4, 3, 5, 4, 0],
  369. },
  370. {
  371. name: "综合建筑",
  372. type: "line",
  373. symbol: "circle",
  374. symbolSize: 5,
  375. itemStyle: {
  376. color: "rgba(255,113,94, 1)",
  377. },
  378. barGap: "-100%",
  379. barWidth: 12,
  380. z: -8,
  381. data: [0.8, 0.6, 1, 0.6, 0],
  382. },
  383. {
  384. name: "商场建筑",
  385. type: "line",
  386. symbol: "circle",
  387. symbolSize: 5,
  388. itemStyle: {
  389. color: "rgba(254, 217, 118, 1)",
  390. },
  391. barGap: "-100%",
  392. barWidth: 12,
  393. z: -8,
  394. data: [0.6, 0.5, 0.8, 0.4, 0],
  395. },
  396. {
  397. name: "宾馆饭店",
  398. type: "line",
  399. symbol: "circle",
  400. symbolSize: 5,
  401. itemStyle: {
  402. color: "rgba(234,94,230, 1)",
  403. },
  404. barGap: "-100%",
  405. barWidth: 12,
  406. z: -8,
  407. data: [],
  408. },
  409. {
  410. name: "医疗卫生",
  411. type: "line",
  412. symbol: "circle",
  413. symbolSize: 5,
  414. itemStyle: {
  415. color: "rgba(94, 225, 186, 1)",
  416. },
  417. barGap: "-100%",
  418. barWidth: 12,
  419. z: -8,
  420. data: [1, 1, 1],
  421. },
  422. {
  423. name: "文化教育",
  424. type: "line",
  425. symbol: "circle",
  426. symbolSize: 5,
  427. itemStyle: {
  428. color: "rgba(113, 204, 78, 1)",
  429. },
  430. barGap: "-100%",
  431. barWidth: 12,
  432. z: -8,
  433. data: [1, 2, 1, 1, 2],
  434. },
  435. {
  436. type: "bar",
  437. itemStyle: {
  438. color: "rgba(0,0,0,0.2)",
  439. },
  440. barGap: "-100%",
  441. barWidth: 12,
  442. z: -9,
  443. showBackground: true,
  444. data: [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
  445. },
  446. ],
  447. };
  448. myChart3.setOption(option3);
  449. }