index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view>
  3. <uv-navbar title="IBMS楼宇集成系统" :placeholder="true" :titleStyle="{color:'#ffffff'}" bgColor="#1d345e"
  4. leftIcon=""></uv-navbar>
  5. <view class="stat_echart_box">
  6. <x-Echarts :options="statOption"></x-Echarts>
  7. </view>
  8. <view class="stat_echart_box">
  9. <x-Echarts :options="chartOption"></x-Echarts>
  10. </view>
  11. <view class="stat_box_line">
  12. <view class="stat_line">
  13. <view class="space_between">
  14. <view style="width: 32%;">
  15. <view class="stat_title_circle">PM3.4</view>
  16. <view class="stat_title_gray">HWSEFSASF</view>
  17. </view>
  18. <view style="flex: 1;">
  19. <uv-line-progress :percentage="50" activeColor="#035bfa" inactiveColor="#2d3240" height="8"
  20. :showText="false"></uv-line-progress>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="stat_line">
  25. <view class="space_between">
  26. <view style="width: 32%;">
  27. <view class="stat_title_circle">SO2</view>
  28. <view class="stat_title_gray">HWSEFSASF</view>
  29. </view>
  30. <view style="flex: 1;">
  31. <uv-line-progress :percentage="60" activeColor="#8bfa03" inactiveColor="#2d3240" height="8"
  32. :showText="false"></uv-line-progress>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="stat_line">
  37. <view class="space_between">
  38. <view style="width: 32%;">
  39. <view class="stat_title_circle">SO5</view>
  40. <view class="stat_title_gray">HWSEFSASF</view>
  41. </view>
  42. <view style="flex: 1;">
  43. <uv-line-progress :percentage="30" activeColor="#fbfb03" inactiveColor="#2d3240" height="8"
  44. :showText="false"></uv-line-progress>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script setup lang="ts">
  52. import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
  53. import { ref } from 'vue'
  54. const title = ref('Hello')
  55. const map : any = {
  56. '区域名称1': 1048,
  57. '区域名称2': 735,
  58. '区域名称3': 580,
  59. '区域名称4': 484,
  60. '区域名称5': 300,
  61. '区域名称6': 890,
  62. }
  63. let total = 0
  64. for (const mapKey in map) {
  65. total += map[mapKey]
  66. }
  67. const statOption = ref({
  68. title: {
  69. text: '增长分布',
  70. x: '3%',
  71. y: '4%',
  72. textStyle: {
  73. color: "#ffffff",
  74. fontSize: 14,
  75. },
  76. },
  77. tooltip: {
  78. trigger: 'item',
  79. },
  80. legend: [{
  81. data: ['区域名称1', '区域名称2', '区域名称3'],
  82. top: 'center',
  83. left: '37%',
  84. orient: 'vertical',
  85. icon: 'circle',
  86. itemGap: 20,
  87. itemHeight: 10,
  88. formatter: (name : any) => {
  89. return [
  90. `{a|${(map[name] / total * 100).toFixed(2)}%}`,
  91. `{b|${name}}`,
  92. ].join('\n')
  93. },
  94. textStyle: {
  95. rich: {
  96. a: {
  97. color: '#fff',
  98. fontSize: '12px',
  99. lineHeight: 20,
  100. },
  101. b: {
  102. color: '#fff',
  103. fontSize: '12px',
  104. },
  105. },
  106. },
  107. },
  108. {
  109. data: ['区域名称4', '区域名称5', '区域名称6'],
  110. top: 'center',
  111. left: '68%',
  112. orient: 'vertical',
  113. icon: 'circle',
  114. itemGap: 20,
  115. itemHeight: 10,
  116. formatter: (name : any) => {
  117. return [
  118. `{a|${(map[name] / total * 100).toFixed(2)}%}`,
  119. `{b|${name}}`,
  120. ].join('\n')
  121. },
  122. textStyle: {
  123. rich: {
  124. a: {
  125. color: '#fff',
  126. fontSize: '12px',
  127. lineHeight: 20,
  128. },
  129. b: {
  130. color: '#fff',
  131. fontSize: '12px',
  132. },
  133. },
  134. },
  135. },
  136. ],
  137. series: [
  138. {
  139. name: '区域',
  140. type: 'pie',
  141. radius: ['35%', '46%'],
  142. center: ['20%', '50%'],
  143. left: 0,
  144. avoidLabelOverlap: false,
  145. label: {
  146. show: false,
  147. position: 'center',
  148. },
  149. labelLine: {
  150. show: false,
  151. },
  152. data: [
  153. { value: 1048, name: '区域名称1' },
  154. { value: 735, name: '区域名称2' },
  155. { value: 580, name: '区域名称3' },
  156. { value: 484, name: '区域名称4' },
  157. { value: 300, name: '区域名称5' },
  158. { value: 890, name: '区域名称6' },
  159. ],
  160. },
  161. ],
  162. })
  163. let yAxisData = ['08-03', '08-04', '08-05', '08-06', '08-07', '08-08', '08-09', '08-10', '08-11', '08-12', '08-13', '08-14']
  164. let data = [100, 90, 200, 250, 240, 220, 120, 390, 480, 270, 290, 200]
  165. const chartOption = ref({
  166. title: {
  167. text: '增长趋势',
  168. x: '3%',
  169. y: '4%',
  170. textStyle: {
  171. color: "#ffffff",
  172. fontSize: 14,
  173. },
  174. },
  175. grid: {
  176. bottom: '15%',
  177. left: '12%',
  178. top: '20%',
  179. right: '5%',
  180. },
  181. xAxis: {
  182. type: 'category',
  183. boundaryGap: true,
  184. axisTick: {
  185. show: false
  186. },
  187. axisLine: {
  188. lineStyle: {
  189. color: '#94A7BD'//轴线和单位颜色
  190. }
  191. },
  192. data: yAxisData
  193. },
  194. yAxis: {
  195. type: 'value',
  196. name: '',
  197. nameTextStyle: {
  198. fontSize: 14,
  199. color: '#94A7BD',
  200. padding: [0, 0, 0, -45],
  201. },
  202. axisLine: {
  203. lineStyle: {
  204. color: '#94A7BD'//轴线和单位颜色
  205. }
  206. },
  207. splitLine: {
  208. show: true,
  209. lineStyle: {
  210. color: '#182D46',
  211. type: [2, 3],
  212. dashOffset: 2
  213. }
  214. }
  215. },
  216. series: [{
  217. name: '数据',
  218. type: 'line',
  219. symbol: 'none',
  220. smooth: true,
  221. areaStyle: {
  222. color: {
  223. type: 'linear', x: 0, y: 0, x2: 0, y2: 1,
  224. colorStops: [{
  225. offset: 0, color: 'rgba(54,161,255,0.6)' // 0% 处的颜色
  226. }, {
  227. offset: 1, color: 'rgba(25,104,255,0)' // 100% 处的颜色
  228. }],
  229. global: false // 缺省为 false
  230. },
  231. },
  232. lineStyle: {
  233. color: '#2695FE',
  234. width: 2,
  235. type: 'solid'
  236. },
  237. // 最高点标点
  238. data: data.map(item => {
  239. const maxValue = Math.max(...data)
  240. if (item === maxValue) {
  241. return {
  242. value: item,
  243. symbol: 'circle',
  244. symbolSize: 8,
  245. itemStyle: { color: '#fff', shadowColor: 'rgba(255,255,255,0.6)', shadowBlur: 10 }
  246. }
  247. }
  248. return item
  249. })
  250. }]
  251. });
  252. onShow(() => {
  253. })
  254. </script>
  255. <style lang="scss" scoped>
  256. .stat_echart_box {
  257. width: calc(100% - 60rpx);
  258. margin: 30rpx 30rpx 0rpx 30rpx;
  259. height: 400rpx;
  260. border-radius: 30rpx;
  261. background-color: rgba(85, 110, 143, .3);
  262. }
  263. .stat_box_line {
  264. width: calc(100% - 60rpx);
  265. margin: 30rpx 30rpx 0rpx 30rpx;
  266. padding: 10rpx 0rpx;
  267. border-radius: 30rpx;
  268. background-color: rgba(85, 110, 143, .3);
  269. }
  270. .stat_line {
  271. padding: 20rpx 30rpx;
  272. }
  273. .stat_title_circle {
  274. color: #fff;
  275. font-size: 30rpx;
  276. font-weight: bold;
  277. padding-left: 35rpx;
  278. position: relative;
  279. }
  280. .stat_title_circle::before {
  281. content: '';
  282. position: absolute;
  283. top: 15rpx;
  284. left: 0rpx;
  285. width: 15rpx;
  286. height: 15rpx;
  287. background-color: #fff;
  288. border-radius: 50%;
  289. }
  290. .stat_title_gray {
  291. color: #909399;
  292. font-size: 26rpx;
  293. margin-top: 4rpx;
  294. padding-left: 35rpx;
  295. }
  296. </style>