widgetBarMap.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. <template>
  2. <div :style="styleObj">
  3. <v-chart ref="myVChart" :options="options" autoresize/>
  4. </div>
  5. </template>
  6. <script>
  7. import {targetWidgetLinkageLogic} from "@/views/bigscreenDesigner/designer/linkageLogic";
  8. import "../../../../../../node_modules/echarts/map/js/china.js";
  9. import "../../../../../../node_modules/echarts/map/js/world.js";
  10. import "../../../../../../node_modules/echarts/map/js/province/anhui";
  11. import "../../../../../../node_modules/echarts/map/js/province/aomen";
  12. import "../../../../../../node_modules/echarts/map/js/province/beijing";
  13. import "../../../../../../node_modules/echarts/map/js/province/chongqing";
  14. import "../../../../../../node_modules/echarts/map/js/province/fujian";
  15. import "../../../../../../node_modules/echarts/map/js/province/gansu";
  16. import "../../../../../../node_modules/echarts/map/js/province/guangxi";
  17. import "../../../../../../node_modules/echarts/map/js/province/guizhou";
  18. import "../../../../../../node_modules/echarts/map/js/province/hainan";
  19. import "../../../../../../node_modules/echarts/map/js/province/hebei";
  20. import "../../../../../../node_modules/echarts/map/js/province/heilongjiang";
  21. import "../../../../../../node_modules/echarts/map/js/province/henan";
  22. import "../../../../../../node_modules/echarts/map/js/province/hubei";
  23. import "../../../../../../node_modules/echarts/map/js/province/hunan";
  24. import "../../../../../../node_modules/echarts/map/js/province/jiangsu";
  25. import "../../../../../../node_modules/echarts/map/js/province/jiangxi";
  26. import "../../../../../../node_modules/echarts/map/js/province/jilin";
  27. import "../../../../../../node_modules/echarts/map/js/province/liaoning";
  28. import "../../../../../../node_modules/echarts/map/js/province/neimenggu";
  29. import "../../../../../../node_modules/echarts/map/js/province/ningxia";
  30. import "../../../../../../node_modules/echarts/map/js/province/qinghai";
  31. import "../../../../../../node_modules/echarts/map/js/province/shandong";
  32. import "../../../../../../node_modules/echarts/map/js/province/shanghai";
  33. import "../../../../../../node_modules/echarts/map/js/province/shanxi";
  34. import "../../../../../../node_modules/echarts/map/js/province/shanxi1";
  35. import "../../../../../../node_modules/echarts/map/js/province/sichuan";
  36. import "../../../../../../node_modules/echarts/map/js/province/taiwan";
  37. import "../../../../../../node_modules/echarts/map/js/province/tianjin";
  38. import "../../../../../../node_modules/echarts/map/js/province/xianggang";
  39. import "../../../../../../node_modules/echarts/map/js/province/xinjiang";
  40. import "../../../../../../node_modules/echarts/map/js/province/xizang";
  41. import "../../../../../../node_modules/echarts/map/js/province/yunnan";
  42. import "../../../../../../node_modules/echarts/map/js/province/zhejiang";
  43. import {conversionProvince} from "@/utils/china";
  44. import echarts from "echarts";
  45. let geoCoordMap = conversionProvince;
  46. export default {
  47. name: "widgetBarMap",
  48. props: {
  49. value: Object,
  50. ispreview: Boolean,
  51. },
  52. data() {
  53. return {
  54. options: {
  55. title: {
  56. show: true,
  57. },
  58. //backgroundColor: '#131C38',
  59. tooltip: {
  60. trigger: 'item',
  61. show: true,
  62. enterable: true,
  63. textStyle: {
  64. fontSize: 20,
  65. color: '#fff'
  66. },
  67. backgroundColor: 'rgba(0,2,89,0.8)',
  68. formatter: function (params, ticket, callback) {
  69. if (params.seriesType == "scatter") {
  70. return params.data.name + "" + params.data.value[2];
  71. } else {
  72. return params.name;
  73. }
  74. },
  75. },
  76. geo: {
  77. map: "china",
  78. show: true,
  79. roam: false,
  80. layoutSize: "80%",
  81. label: {
  82. emphasis: {
  83. show: false,
  84. color: "white",
  85. },
  86. },
  87. itemStyle: {
  88. normal: {
  89. borderColor: new echarts.graphic.LinearGradient(
  90. 0,
  91. 0,
  92. 0,
  93. 1,
  94. [
  95. {
  96. offset: 0,
  97. color: "#00F6FF",
  98. },
  99. {
  100. offset: 1,
  101. color: "#53D9FF",
  102. },
  103. ],
  104. false
  105. ),
  106. borderWidth: 1,
  107. shadowColor: "rgba(10,76,139,1)",
  108. shadowOffsetY: 0,
  109. shadowBlur: 60,
  110. },
  111. },
  112. },
  113. series: [
  114. {
  115. aspectScale: 0.75,
  116. type: 'map',
  117. map: 'china',
  118. //roam: true,
  119. effect: {
  120. show: false,
  121. period: 6,
  122. trailLength: 0.7,
  123. color: "#fff",
  124. symbolSize: 3,
  125. },
  126. label: {
  127. normal: {
  128. //调整数值
  129. position: "right",
  130. // 地图省市区显隐
  131. show: false,
  132. color: "#53D9FF",
  133. fontSize: 20,
  134. },
  135. emphasis: {
  136. show: true,
  137. },
  138. },
  139. itemStyle: {
  140. normal: {
  141. //地图块颜色
  142. areaColor: {
  143. x: 0,
  144. y: 0,
  145. x2: 0,
  146. y2: 1,
  147. colorStops: [
  148. {
  149. offset: 0,
  150. color: "#073684", // 0% 处的颜色
  151. },
  152. {
  153. offset: 1,
  154. color: "#061E3D", // 100% 处的颜色
  155. },
  156. ],
  157. },
  158. borderColor: "#215495",
  159. borderWidth: 1,
  160. },
  161. //鼠标放置颜色加深
  162. emphasis: {
  163. areaColor: {
  164. x: 0,
  165. y: 0,
  166. x2: 0,
  167. y2: 1,
  168. colorStops: [
  169. {
  170. offset: 0,
  171. color: "#073684", // 0% 处的颜色
  172. },
  173. {
  174. offset: 1,
  175. color: "#2B91B7", // 100% 处的颜色
  176. },
  177. ],
  178. },
  179. },
  180. },
  181. data: []
  182. },
  183. // 柱状体的主干
  184. {
  185. type: 'lines',
  186. zlevel: 1,
  187. effect: {
  188. show: false,
  189. symbolSize: 5 // 图标大小
  190. },
  191. lineStyle: {
  192. width: 20, // 尾迹线条宽度
  193. color: 'rgb(22,255,255, .6)',
  194. opacity: 1, // 尾迹线条透明度
  195. curveness: 0 // 尾迹线条曲直度
  196. },
  197. silent: true,
  198. data: []
  199. },
  200. // 柱状体的顶部
  201. {
  202. type: 'scatter',
  203. coordinateSystem: 'geo',
  204. //geoIndex: 0,
  205. zlevel: 1,
  206. rippleEffect: {
  207. brushType: "stroke",
  208. },
  209. label: {
  210. show: true,
  211. formatter: function (params) {
  212. return "{cnNum|" + params.data[2] + "}";
  213. },
  214. rich: {
  215. cnNum: {
  216. // 数值字号
  217. fontSize: 13,
  218. color: "#D4EEFF",
  219. },
  220. },
  221. position: "top"
  222. },
  223. symbol: 'circle',
  224. symbolSize: [20, 10],
  225. itemStyle: {
  226. color: 'rgb(22,255,255, 1)',
  227. opacity: 1
  228. },
  229. silent: true,
  230. data: []
  231. },
  232. // 柱状体的底部
  233. {
  234. type: 'scatter',
  235. coordinateSystem: 'geo',
  236. rippleEffect: {
  237. brushType: "stroke",
  238. },
  239. //geoIndex: 0,
  240. zlevel: 1,
  241. label: {
  242. // 这儿是处理的
  243. formatter: '{b}',
  244. position: 'bottom',
  245. color: '#fff',
  246. fontSize: 12,
  247. distance: 10,
  248. show: true
  249. },
  250. symbol: 'circle',
  251. symbolSize: [20, 10],
  252. itemStyle: {
  253. // color: '#F7AF21',
  254. color: 'rgb(22,255,255, 1)',
  255. opacity: 1
  256. },
  257. silent: true,
  258. data: []
  259. },
  260. // 底部外框
  261. {
  262. type: 'scatter',
  263. coordinateSystem: 'geo',
  264. //geoIndex: 0,
  265. rippleEffect: {
  266. brushType: "stroke",
  267. },
  268. zlevel: 1,
  269. label: {
  270. show: false
  271. },
  272. symbol: 'circle',
  273. symbolSize: [40, 20],
  274. itemStyle: {
  275. color: {
  276. type: 'radial',
  277. x: 0.5,
  278. y: 0.5,
  279. r: 0.5,
  280. colorStops: [
  281. {
  282. offset: 0, color: 'rgb(22,255,255, 0)' // 0% 处的颜色
  283. },
  284. {
  285. offset: .75, color: 'rgb(22,255,255, 0)' // 100% 处的颜色
  286. },
  287. {
  288. offset: .751, color: 'rgb(22,255,255, 1)' // 100% 处的颜色
  289. },
  290. {
  291. offset: 1, color: 'rgb(22,255,255, 1)' // 100% 处的颜色
  292. }
  293. ],
  294. global: false // 缺省为 false
  295. },
  296. opacity: 1
  297. },
  298. silent: true,
  299. data: []
  300. }
  301. ]
  302. },
  303. optionsStyle: {}, // 样式
  304. optionsData: {}, // 数据
  305. optionsCollapse: {}, // 图标属性
  306. optionsSetup: {},
  307. flagInter: null,
  308. };
  309. },
  310. computed: {
  311. styleObj() {
  312. return {
  313. position: this.ispreview ? "absolute" : "static",
  314. width: this.optionsStyle.width + "px",
  315. height: this.optionsStyle.height + "px",
  316. left: this.optionsStyle.left + "px",
  317. top: this.optionsStyle.top + "px",
  318. background: this.optionsSetup.background,
  319. };
  320. },
  321. allComponentLinkage() {
  322. return this.$store.state.designer.allComponentLinkage;
  323. },
  324. },
  325. watch: {
  326. value: {
  327. handler(val) {
  328. this.optionsStyle = val.position;
  329. this.optionsData = val.data;
  330. this.optionsCollapse = val.setup;
  331. this.optionsSetup = val.setup;
  332. this.editorOptions();
  333. },
  334. deep: true,
  335. },
  336. },
  337. mounted() {
  338. this.optionsStyle = this.value.position;
  339. this.optionsData = this.value.data;
  340. this.optionsCollapse = this.value.setup;
  341. this.optionsSetup = this.value.setup;
  342. this.editorOptions();
  343. targetWidgetLinkageLogic(this); // 联动-目标组件逻辑
  344. },
  345. methods: {
  346. // 修改图标options属性
  347. editorOptions() {
  348. this.setOptionsTitle();
  349. this.setOptionsGeo();
  350. this.setOptionsTooltip();
  351. this.setOptionsMap();
  352. this.setOptionsData();
  353. },
  354. // 标题设置
  355. setOptionsTitle() {
  356. const optionsSetup = this.optionsSetup;
  357. const title = {
  358. text: optionsSetup.text,
  359. show: optionsSetup.isShowTitle,
  360. left: optionsSetup.titleLeft,
  361. top: optionsSetup.titleTop + "%",
  362. itemGap: optionsSetup.titleItemGap,
  363. textStyle: {
  364. color: optionsSetup.textColor,
  365. fontSize: optionsSetup.textFontSize,
  366. fontWeight: optionsSetup.textFontWeight,
  367. fontStyle: optionsSetup.textFontStyle,
  368. fontFamily: optionsSetup.textFontFamily,
  369. },
  370. subtext: optionsSetup.subtext,
  371. subtextStyle: {
  372. color: optionsSetup.subtextColor,
  373. fontWeight: optionsSetup.subtextFontWeight,
  374. fontSize: optionsSetup.subtextFontSize,
  375. fontStyle: optionsSetup.subtextFontStyle,
  376. fontFamily: optionsSetup.subtextFontFamily
  377. },
  378. };
  379. this.options.title = title;
  380. },
  381. // tooltip 设置
  382. setOptionsTooltip() {
  383. const optionsSetup = this.optionsSetup;
  384. const tooltip = {
  385. trigger: "item",
  386. show: optionsSetup.isShowTooltip,
  387. textStyle: {
  388. color: optionsSetup.tooltipColor,
  389. fontSize: optionsSetup.tooltipFontSize,
  390. fontWeight: optionsSetup.tooltipFontWeight,
  391. fontStyle: optionsSetup.tooltipFontStyle,
  392. fontFamily: optionsSetup.tooltipFontFamily,
  393. },
  394. formatter: function (params) {
  395. if (params.seriesType == 'scatter') {
  396. return params.data.name + "" + params.data.value[2];
  397. } else {
  398. return params.name;
  399. }
  400. },
  401. };
  402. this.options.tooltip = tooltip;
  403. },
  404. setOptionsGeo() {
  405. this.options.geo['map'] = this.optionsSetup.mapName == '' ? "china" : this.optionsSetup.mapName;
  406. this.options.series[0]['map'] = this.optionsSetup.mapName == '' ? "china" : this.optionsSetup.mapName;
  407. },
  408. // 地图设置
  409. setOptionsMap() {
  410. const optionsSetup = this.optionsSetup;
  411. const label = {
  412. normal: {
  413. //调整数值
  414. position: "right",
  415. // 地图省市区显隐
  416. show: optionsSetup.isShowMap,
  417. color: optionsSetup.fontColor,
  418. fontSize: optionsSetup.fontSize,
  419. fontWeight: optionsSetup.fontWeight,
  420. fontStyle: optionsSetup.fontStyle,
  421. fontFamily: optionsSetup.fontFamily,
  422. },
  423. emphasis: {
  424. show: false,
  425. },
  426. }
  427. const itemStyle = {
  428. normal: {
  429. //地图块颜色
  430. areaColor: {
  431. x: 0,
  432. y: 0,
  433. x2: 0,
  434. y2: 1,
  435. colorStops: [
  436. {
  437. offset: 0,
  438. color: optionsSetup.font0PreColor, // 0% 处的颜色
  439. },
  440. {
  441. offset: 1,
  442. color: optionsSetup.font100PreColor, // 100% 处的颜色
  443. },
  444. ],
  445. },
  446. borderColor: optionsSetup.borderColor,
  447. borderWidth: optionsSetup.borderWidth,
  448. },
  449. //鼠标放置颜色加深
  450. emphasis: {
  451. areaColor: {
  452. x: 0,
  453. y: 0,
  454. x2: 0,
  455. y2: 1,
  456. colorStops: [
  457. {
  458. offset: 0,
  459. color: "#073684", // 0% 处的颜色
  460. },
  461. {
  462. offset: 1,
  463. color: optionsSetup.fontHighlightColor, // 100% 处的颜色
  464. },
  465. ],
  466. },
  467. },
  468. }
  469. this.options.series[0]['label'] = label;
  470. this.options.series[0]['itemStyle'] = itemStyle;
  471. },
  472. // 计算柱图的高度比例
  473. calMaxHeight(val, heightRate) {
  474. const maxValue = Math.max.apply(null, val.map(item => item.value))
  475. return heightRate / maxValue;
  476. },
  477. // 计算柱体的主干
  478. calScatterTrunk(val, heightRate) {
  479. return val.map((item) => {
  480. return {
  481. coords: [geoCoordMap[item.name], [geoCoordMap[item.name][0], geoCoordMap[item.name][1] + item.value * this.calMaxHeight(val, heightRate)]]
  482. }
  483. })
  484. },
  485. // 计算柱体顶部
  486. calScatterTop(val, heightRate) {
  487. return val.map((item) => {
  488. return [geoCoordMap[item.name][0], geoCoordMap[item.name][1] + item.value * this.calMaxHeight(val, heightRate), item.value]
  489. })
  490. },
  491. // 计算柱体的底部
  492. calScatterBottom(val) {
  493. return val.map((item) => {
  494. return {
  495. name: item.name,
  496. value: geoCoordMap[item.name]
  497. }
  498. })
  499. },
  500. // 柱体主干
  501. getOptionsBarTrunk(optionsSetup, arrColor, allData, heightRate) {
  502. const barTrunk = {
  503. type: 'lines',
  504. zlevel: 1,
  505. effect: {
  506. show: false,
  507. symbolSize: 5 // 图标大小
  508. },
  509. lineStyle: {
  510. width: optionsSetup.barWidth, // 尾迹线条宽度
  511. color: (params) => {
  512. return arrColor[params.dataIndex];
  513. },
  514. opacity: 1, // 尾迹线条透明度
  515. curveness: 0 // 尾迹线条曲直度
  516. },
  517. silent: true,
  518. data: this.calScatterTrunk(allData, heightRate),
  519. };
  520. return barTrunk;
  521. },
  522. // 柱体顶
  523. getOptionsBarTop(optionsSetup, arrColor, allData, heightRate) {
  524. const barTop = {
  525. type: 'scatter',
  526. coordinateSystem: 'geo',
  527. //geoIndex: 0,
  528. zlevel: 1,
  529. rippleEffect: {
  530. brushType: "stroke",
  531. },
  532. label: {
  533. show: optionsSetup.isShowFontData,
  534. formatter: function (params) {
  535. return "{cnNum|" + params.data[2] + "}";
  536. },
  537. rich: {
  538. cnNum: {
  539. // 数值字号
  540. fontSize: optionsSetup.fontDataSize,
  541. color: (params) => {
  542. return arrColor[params.dataIndex];
  543. },
  544. fontWeight: optionsSetup.fontDataWeight,
  545. fontStyle: optionsSetup.fontDataStyle,
  546. fontFamily: optionsSetup.fontDataFamily,
  547. },
  548. },
  549. position: "top"
  550. },
  551. symbol: 'circle',
  552. symbolSize: [optionsSetup.barWidth, 10],
  553. itemStyle: {
  554. color: (params) => {
  555. return arrColor[params.dataIndex];
  556. },
  557. opacity: 1
  558. },
  559. silent: true,
  560. data: this.calScatterTop(allData, heightRate)
  561. }
  562. return barTop;
  563. },
  564. // 柱底
  565. getOptionsBarBottom(optionsSetup, arrColor, allData) {
  566. const batBottom = {
  567. type: 'scatter',
  568. coordinateSystem: 'geo',
  569. rippleEffect: {
  570. brushType: "stroke",
  571. },
  572. //geoIndex: 0,
  573. zlevel: 1,
  574. label: {
  575. // 这儿是处理的
  576. show: optionsSetup.isShowFontText,
  577. formatter: '{b}',
  578. position: 'bottom',
  579. fontSize: optionsSetup.fontTextSize,
  580. color: (params) => {
  581. return arrColor[params.dataIndex];
  582. },
  583. fontWeight: optionsSetup.fontTextWeight,
  584. fontStyle: optionsSetup.fontTextStyle,
  585. fontFamily: optionsSetup.fontTextFamily,
  586. distance: 10,
  587. },
  588. symbol: 'circle',
  589. symbolSize: [optionsSetup.barWidth, 10],
  590. itemStyle: {
  591. color: (params) => {
  592. return arrColor[params.dataIndex];
  593. },
  594. opacity: 1,
  595. },
  596. silent: true,
  597. data: this.calScatterBottom(allData),
  598. }
  599. return batBottom;
  600. },
  601. // 柱底外圆
  602. getOptionsBarBottomOut(optionsSetup, arrColor, allData) {
  603. const barBottomOut = {
  604. type: 'scatter',
  605. coordinateSystem: 'geo',
  606. //geoIndex: 0,
  607. rippleEffect: {
  608. brushType: "stroke",
  609. },
  610. zlevel: 1,
  611. label: {
  612. show: false
  613. },
  614. symbol: 'circle',
  615. symbolSize: [optionsSetup.barBottomOutSymbolSize, 10],
  616. // 渐变色
  617. itemStyle: {
  618. color: (params) => {
  619. return {
  620. type: 'radial',
  621. x: 0.5,
  622. y: 0.5,
  623. r: 0.5,
  624. colorStops: [
  625. {
  626. offset: 0, color: 'rgba(22,255,255, 0)' // 0% 处的颜色
  627. },
  628. {
  629. offset: .75, color: 'rgba(22,255,255, 0)' // 100% 处的颜色
  630. },
  631. {
  632. offset: .751, color: arrColor[params.dataIndex] // 100% 处的颜色
  633. },
  634. {
  635. offset: 1, color: arrColor[params.dataIndex] // 100% 处的颜色
  636. }
  637. ],
  638. global: false // 缺省为 false
  639. }
  640. },
  641. opacity: 1,
  642. },
  643. silent: true,
  644. data: this.calScatterBottom(allData),
  645. }
  646. return barBottomOut;
  647. },
  648. //数据解析
  649. setOptionsData(e, paramsConfig) {
  650. const optionsData = this.optionsData; // 数据类型 静态 or 动态
  651. // 联动接收者逻辑开始
  652. optionsData.dynamicData = optionsData.dynamicData || {}; // 兼容 dynamicData undefined
  653. const myDynamicData = optionsData.dynamicData;
  654. clearInterval(this.flagInter); // 不管咋,先干掉上一次的定时任务,避免多跑
  655. if (
  656. e &&
  657. optionsData.dataType !== "staticData" &&
  658. Object.keys(myDynamicData.contextData).length
  659. ) {
  660. const keyArr = Object.keys(myDynamicData.contextData);
  661. paramsConfig.forEach((conf) => {
  662. if (keyArr.includes(conf.targetKey)) {
  663. myDynamicData.contextData[conf.targetKey] = e[conf.originKey];
  664. }
  665. });
  666. }
  667. // 联动接收者逻辑结束
  668. optionsData.dataType == "staticData"
  669. ? this.staticDataFn(optionsData.staticData)
  670. : this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
  671. },
  672. staticDataFn(val) {
  673. let name = [];
  674. let latitude = [];
  675. let longitude = [];
  676. let value = [];
  677. for (const i in val) {
  678. name[i] = val[i].name;
  679. latitude[i] = val[i].latitude;
  680. longitude[i] = val[i].longitude;
  681. value[i] = val[i].value;
  682. }
  683. let allData = [];
  684. for (const i in name) {
  685. geoCoordMap[name[i]] = [latitude[i], longitude[i]]
  686. const obj = {
  687. name: name[i],
  688. value: value[i]
  689. }
  690. allData.push(obj)
  691. }
  692. const optionsSetup = this.optionsSetup;
  693. const heightRate = optionsSetup.heightRate;
  694. // 颜色设置
  695. const customColor = optionsSetup.customColor;
  696. if (!customColor) return;
  697. const arrColor = [];
  698. for (const i in val) {
  699. arrColor.push(customColor[i % customColor.length].color)
  700. }
  701. this.options.series[1] = this.getOptionsBarTrunk(optionsSetup, arrColor, allData, heightRate);
  702. this.options.series[2] = this.getOptionsBarTop(optionsSetup, arrColor, allData, heightRate);
  703. this.options.series[3] = this.getOptionsBarBottom(optionsSetup, arrColor, allData);
  704. this.options.series[4] = this.getOptionsBarBottomOut(optionsSetup, arrColor, allData);
  705. },
  706. dynamicDataFn(val, refreshTime) {
  707. if (!val) return;
  708. if (this.ispreview) {
  709. this.getEchartData(val);
  710. this.flagInter = setInterval(() => {
  711. this.getEchartData(val);
  712. }, refreshTime);
  713. } else {
  714. this.getEchartData(val);
  715. }
  716. },
  717. getEchartData(val) {
  718. const data = this.queryEchartsData(val);
  719. data.then((res) => {
  720. this.renderingFn(res);
  721. });
  722. },
  723. renderingFn(val) {
  724. let name = [];
  725. let latitude = [];
  726. let longitude = [];
  727. let value = [];
  728. for (const i in val) {
  729. name[i] = val[i].name;
  730. latitude[i] = val[i].latitude;
  731. longitude[i] = val[i].longitude;
  732. value[i] = val[i].value;
  733. }
  734. for (const i in val) {
  735. name[i] = val[i].name;
  736. latitude[i] = val[i].latitude;
  737. longitude[i] = val[i].longitude;
  738. value[i] = val[i].value;
  739. }
  740. let allData = [];
  741. for (const i in name) {
  742. geoCoordMap[name[i]] = [latitude[i], longitude[i]]
  743. const obj = {
  744. name: name[i],
  745. value: value[i]
  746. }
  747. allData.push(obj)
  748. }
  749. const optionsSetup = this.optionsSetup;
  750. const heightRate = optionsSetup.heightRate;
  751. // 颜色设置
  752. const customColor = optionsSetup.customColor;
  753. if (!customColor) return;
  754. const arrColor = [];
  755. for (const i in val) {
  756. arrColor.push(customColor[i % customColor.length].color)
  757. }
  758. this.$set(this.options.series, 1, this.getOptionsBarTrunk(optionsSetup, arrColor, allData, heightRate))
  759. this.$set(this.options.series, 2, this.getOptionsBarTop(optionsSetup, arrColor, allData, heightRate))
  760. this.$set(this.options.series, 3, this.getOptionsBarBottom(optionsSetup, arrColor, allData))
  761. this.$set(this.options.series, 4, this.getOptionsBarBottomOut(optionsSetup, arrColor, allData))
  762. },
  763. },
  764. };
  765. </script>
  766. <style lang="scss" scoped>
  767. .echartMap {
  768. width: 100%;
  769. height: 100%;
  770. }
  771. .echarts {
  772. width: 100%;
  773. height: 100%;
  774. overflow: hidden;
  775. }
  776. </style>