bjxm.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div class="bjxm">
  3. <div class="title">
  4. <div class="icon"></div>
  5. <span>报建项目</span>
  6. </div>
  7. <div class="content">
  8. <div class="item">
  9. <div class="icon">
  10. <div class="icon_zxkg"></div>
  11. </div>
  12. <div class="text">
  13. <p>报建数量</p>
  14. <span>66</span>个
  15. </div>
  16. </div>
  17. <div class="item">
  18. <div class="icon">
  19. <div class="icon_zxkg"></div>
  20. </div>
  21. <div class="text">
  22. <p>用地面积</p>
  23. <span>6666</span>平方千米
  24. </div>
  25. </div>
  26. <div id="bjxm_echart"></div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  32. export default {
  33. components: {},
  34. data() {
  35. return {};
  36. },
  37. //监听属性 类似于data概念
  38. computed: {},
  39. //监控data中的数据变化
  40. watch: {},
  41. //方法集合
  42. methods: {
  43. init_bjxm_echart() {
  44. var myChart = echarts.init(document.getElementById("bjxm_echart"));
  45. // 柱状图的宽度,y是x的一半
  46. const offsetX = 10
  47. const offsetY = 5
  48. // 绘制左侧面
  49. const CubeLeft = echarts.graphic.extendShape({
  50. shape: {
  51. x: 0,
  52. y: 0
  53. },
  54. buildPath: function (ctx, shape) {
  55. const xAxisPoint = shape.xAxisPoint
  56. const c0 = [shape.x, shape.y]
  57. const c1 = [shape.x - offsetX, shape.y - offsetY]
  58. const c2 = [xAxisPoint[0] - offsetX, xAxisPoint[1] - offsetY]
  59. const c3 = [xAxisPoint[0], xAxisPoint[1]]
  60. ctx.moveTo(c0[0], c0[1]).lineTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).closePath()
  61. }
  62. })
  63. // 绘制右侧面
  64. const CubeRight = echarts.graphic.extendShape({
  65. shape: {
  66. x: 0,
  67. y: 0
  68. },
  69. buildPath: function (ctx, shape) {
  70. const xAxisPoint = shape.xAxisPoint
  71. const c1 = [shape.x, shape.y]
  72. const c2 = [xAxisPoint[0], xAxisPoint[1]]
  73. const c3 = [xAxisPoint[0] + offsetX, xAxisPoint[1] - offsetY]
  74. const c4 = [shape.x + offsetX, shape.y - offsetY]
  75. ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath()
  76. }
  77. })
  78. // 绘制顶面
  79. const CubeTop = echarts.graphic.extendShape({
  80. shape: {
  81. x: 0,
  82. y: 0,
  83. },
  84. buildPath: function (ctx, shape) {
  85. const c1 = [shape.x, shape.y]
  86. const c2 = [shape.x + offsetX, shape.y - offsetY]
  87. const c3 = [shape.x, shape.y - offsetX]
  88. const c4 = [shape.x - offsetX, shape.y - offsetY]
  89. ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath()
  90. }
  91. })
  92. // 注册三个面图形
  93. echarts.graphic.registerShape('CubeLeft', CubeLeft)
  94. echarts.graphic.registerShape('CubeRight', CubeRight)
  95. echarts.graphic.registerShape('CubeTop', CubeTop)
  96. // 数据
  97. const VALUE = [210.9, 260.8, 204.2, 504.9, 740.5]
  98. let option = {
  99. //你的代码
  100. backgroundColor: 'rgba(17, 42, 62, 0)',//"#012366",
  101. tooltip: {
  102. trigger: 'axis',
  103. axisPointer: {
  104. type: 'shadow'
  105. },
  106. formatter: function (params) {
  107. const item = params[1]
  108. return item.name + "\n" + item.value;
  109. }
  110. },
  111. grid: {
  112. left: 0,
  113. right: 0,
  114. bottom: 20,
  115. top: 30,
  116. containLabel: true
  117. },
  118. xAxis: {
  119. type: 'category',
  120. data: ['崖州区', '天崖区', '吉阳区', '海棠区', '育才区'],
  121. axisLine: {
  122. lineStyle: {
  123. color: '#BCD3E5'
  124. }
  125. },
  126. // offset: 25,
  127. axisTick: {
  128. show: false,
  129. length: 9,
  130. alignWithLabel: true,
  131. lineStyle: {
  132. color: '#BCD3E5'
  133. }
  134. },
  135. axisLabel: {
  136. show: true,
  137. fontSize: 12,
  138. },
  139. },
  140. yAxis: [
  141. {
  142. min: 0,
  143. max: 1200,
  144. interval: 200,
  145. type: 'value',
  146. name: '用地面积(km2)',
  147. axisLine: {
  148. show: false,
  149. lineStyle: {
  150. color: '#BCD3E5'
  151. }
  152. },
  153. splitLine: {
  154. show: false,
  155. lineStyle: {
  156. type: "dashed",
  157. color: "rgba(255,255,255,0.1)"
  158. },
  159. },
  160. axisTick: {
  161. show: false
  162. },
  163. axisLabel: {
  164. show: true,
  165. fontSize: 12,
  166. },
  167. boundaryGap: ['20%', '20%']
  168. },
  169. {
  170. min: 0,
  171. max: 1200,
  172. interval: 200,
  173. name: '项目数(个)',
  174. type: 'value',
  175. axisLine: {
  176. show: false,
  177. lineStyle: {
  178. color: '#BCD3E5'
  179. }
  180. },
  181. splitLine: {
  182. show: true,
  183. lineStyle: {
  184. type: "dashed",
  185. color: "rgba(255,255,255,0.1)"
  186. },
  187. },
  188. axisTick: {
  189. show: false
  190. },
  191. axisLabel: {
  192. show: true,
  193. fontSize: 12,
  194. },
  195. boundaryGap: ['20%', '20%']
  196. },],
  197. series: [
  198. {
  199. type: 'custom',
  200. renderItem: (params, api) => {
  201. const location = api.coord([api.value(0), api.value(1)])
  202. var color = api.value(1) > 10000 ? 'red' : new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  203. offset: 0,
  204. color: 'rgba(33,101,140,0.5)'
  205. },
  206. {
  207. offset: 0.8,
  208. color: 'rgba(33,101,140,0.5)'
  209. }
  210. ])
  211. return {
  212. type: 'group',
  213. children: [
  214. {
  215. type: 'CubeLeft',
  216. shape: {
  217. api,
  218. xValue: api.value(0),
  219. yValue: api.value(1),
  220. x: location[0],
  221. y: location[1],
  222. xAxisPoint: api.coord([api.value(0), 0])
  223. },
  224. style: {
  225. fill: color = api.value(1) > 10000 ? 'red' : new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  226. offset: 0,
  227. color: 'rgba(34, 129, 209, 0.8)'
  228. },
  229. {
  230. offset: 0.8,
  231. color: 'rgba(34, 129, 209, 0.8)'
  232. }
  233. ])
  234. }
  235. },
  236. {
  237. type: 'CubeRight',
  238. shape: {
  239. api,
  240. xValue: api.value(0),
  241. yValue: api.value(1),
  242. x: location[0],
  243. y: location[1],
  244. xAxisPoint: api.coord([api.value(0), 0])
  245. },
  246. style: {
  247. fill: color = api.value(1) > 10000 ? 'red' : new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  248. offset: 0,
  249. color: 'rgba(97, 173, 237, 0.8)'
  250. },
  251. {
  252. offset: 0.8,
  253. color: 'rgba(97, 173, 237, 0.8)'
  254. }
  255. ])
  256. }
  257. }, {
  258. type: 'CubeTop',
  259. shape: {
  260. api,
  261. xValue: api.value(0),
  262. yValue: api.value(1),
  263. x: location[0],
  264. y: location[1],
  265. xAxisPoint: api.coord([api.value(0), 0])
  266. },
  267. style: {
  268. fill: color = api.value(1) > 10000 ? 'red' : new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  269. offset: 0,
  270. color: 'rgba(60, 167, 255, 1)'
  271. },
  272. {
  273. offset: 1,
  274. color: 'rgba(135, 200, 255, 1)'
  275. }
  276. ])
  277. }
  278. }]
  279. }
  280. },
  281. data: VALUE
  282. },
  283. {
  284. type: 'line',
  285. smooth: true,
  286. itemStyle: {
  287. normal: {
  288. color: '#FFCC64' // 折线的颜色
  289. }
  290. },
  291. data: VALUE,
  292. },
  293. ]
  294. };
  295. myChart.setOption(option);
  296. },
  297. },
  298. beforeCreate() { }, //生命周期 - 创建之前
  299. created() { }, //生命周期 - 创建完成(可以访问当前this实例)
  300. beforeMount() { }, //生命周期 - 挂载之前
  301. mounted() {
  302. this.init_bjxm_echart();
  303. }, //生命周期 - 挂在完成
  304. beforeUpdate() { }, //生命周期 - 更新之前
  305. updated() { }, //生命周期 - 更新之后
  306. beforeDestroy() { }, //生命周期 - 销毁之前
  307. destroy() { }, //生命周期 - 销毁完成
  308. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  309. deactivated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  310. };
  311. </script>
  312. <style lang="scss" scoped>
  313. .bjxm {
  314. border-width: 0px;
  315. position: absolute;
  316. width: 385px;
  317. height: 310px;
  318. top: 67%;
  319. left: 30rem;
  320. background: inherit;
  321. border: none;
  322. border-radius: 0px;
  323. -webkit-box-shadow: none;
  324. box-shadow: none;
  325. z-index: 100;
  326. }
  327. .title {
  328. border-width: 0px;
  329. width: 100%;
  330. height: 40px;
  331. // font-family: 'Arial Negreta', 'Arial Normal', 'Arial';
  332. // font-weight: 700;
  333. // font-style: normal;
  334. // color: #fff;
  335. // padding: 2%;
  336. background: no-repeat;
  337. background-image: url("/static/images/overview/标题框.png");
  338. .icon {
  339. background: no-repeat;
  340. background-image: url("/static/images/overview/icon_标题框装饰.png");
  341. display: inline-block;
  342. width: 30px;
  343. height: 30px;
  344. background-position: 14px 7px;
  345. }
  346. span {
  347. color: #fff;
  348. font-size: 14px;
  349. font-weight: bold;
  350. position: relative;
  351. bottom: 0.5rem;
  352. }
  353. }
  354. .content {
  355. position: absolute;
  356. left: 5%;
  357. width: 400px;
  358. height: 220px;
  359. top: 13%;
  360. }
  361. .item {
  362. width: 45%;
  363. height: 30%;
  364. display: inline-block;
  365. }
  366. .icon {
  367. width: 50px;
  368. padding: 1.5%;
  369. border-radius: 8px;
  370. display: inline-block;
  371. height: 50px;
  372. }
  373. .icon_zxkg {
  374. background: no-repeat 50%;
  375. background-image: url("/static/images/overview/icongdbh0.png");
  376. /* border: #00FFFF 1px solid; */
  377. width: 45px;
  378. height: 45px;
  379. display: inline-block;
  380. }
  381. .text {
  382. display: inline-block;
  383. // border: #00FFFF 1px solid;
  384. width: 100px;
  385. p {
  386. font-kerning: normal;
  387. font-family: "Arial Negreta", "Arial Normal", "Arial";
  388. font-weight: 700;
  389. font-style: normal;
  390. font-size: 14px;
  391. color: #ffffff;
  392. }
  393. span {
  394. font-family: "Arial Negreta", "Arial Normal", "Arial";
  395. font-weight: 700;
  396. font-style: normal;
  397. color: #68f4fb;
  398. }
  399. }
  400. .value {
  401. display: inline-block;
  402. // border: #00FFFF 1px solid;
  403. width: 50px;
  404. }
  405. #bjxm_echart {
  406. position: relative;
  407. top: 0;
  408. width: 23.5rem;
  409. height: 11rem;
  410. }
  411. </style>