xm-open-fenbu.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div>
  3. <div :class="$style.box" bordered>
  4. <div :class="$style.echartclass">
  5. <sd-echart :options="line" autoresize :class="$style.echart"
  6. /></div>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. import echarts from 'echarts'
  12. import moment from 'moment'
  13. import TrackService from './track-service'
  14. import components from './_import-components/xm-open-fenbu-import'
  15. import 'echarts/lib/chart/line'
  16. import 'echarts/lib/component/legend'
  17. import 'echarts/lib/component/tooltip'
  18. import 'echarts/lib/component/toolbox'
  19. import 'echarts/lib/component/dataZoom'
  20. let _this
  21. const fontFamily = `-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`
  22. export default {
  23. name: 'XmOpenFenbu',
  24. metaInfo: {
  25. title: 'OpenFenbu',
  26. },
  27. components,
  28. props: {
  29. isfull: {
  30. type: Boolean,
  31. },
  32. },
  33. data() {
  34. return {
  35. radioVal: '0',
  36. resdata: [],
  37. cval: [],
  38. full: false,
  39. line: {
  40. tooltip: {
  41. trigger: 'axis',
  42. backgroundColor: 'rgba(255,255,255,0.9)',
  43. padding: [5, 10, 10, 10],
  44. textStyle: {
  45. color: 'black',
  46. },
  47. formatter(params) {
  48. const color = '#0D9CC2'
  49. const newFormat = 'YYYY-MM-DD HH:mm'
  50. const timadata = moment(params[0].axisValue).format(newFormat)
  51. const circle = `<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:`
  52. const data = `${circle}${color}"></span>${params[0].value[1]}次`
  53. return `${timadata}<br/>${data}<br/>`
  54. },
  55. axisPointer: {
  56. animation: true,
  57. },
  58. },
  59. backgroundColor: '#01267B',
  60. grid: [{ show: false }],
  61. title: {
  62. text: '打开次数分布',
  63. textStyle: {
  64. color: 'white',
  65. fontSize: '20',
  66. fontFamily: fontFamily,
  67. fontWeight: 'normal',
  68. },
  69. left: 'left',
  70. top: '8',
  71. show: true,
  72. textAlign: 'left',
  73. textVerticalAlign: 'left',
  74. },
  75. toolbox: {
  76. show: true,
  77. top: 5,
  78. iconStyle: {
  79. borderColor: '#fff',
  80. },
  81. emphasis: {
  82. iconStyle: {
  83. borderColor: '#fff',
  84. },
  85. },
  86. itemSize: 18,
  87. feature: {
  88. myReload: {
  89. show: true,
  90. title: ' ',
  91. icon:
  92. 'path://M81.92 634.88h194.56c12.288 0 20.48 8.192 20.48 20.48s-8.192 20.48-20.48 20.48h-161.792c69.632 155.648 225.28 260.096 401.408 260.096 184.32 0 348.16-114.688 411.648-284.672 4.096-10.24 16.384-16.384 26.624-12.288 10.24 4.096 16.384 16.384 12.288 26.624-69.632 186.368-247.808 311.296-450.56 311.296-180.224 0-342.016-100.352-423.936-253.952v135.168c0 12.288-8.192 20.48-20.48 20.48s-20.48-8.192-20.48-20.48v-204.8c0-6.144 2.048-10.24 6.144-14.336s8.192-6.144 14.336-6.144h10.24z m860.16-245.76h-194.56c-12.288 0-20.48-8.192-20.48-20.48s8.192-20.48 20.48-20.48h161.792c-69.632-155.648-225.28-260.096-401.408-260.096-184.32 0-348.16 114.688-411.648 284.672-4.096 10.24-16.384 16.384-26.624 12.288-10.24-4.096-16.384-16.384-12.288-26.624 69.632-186.368 247.808-311.296 450.56-311.296 180.224 0 342.016 100.352 423.936 253.952v-135.168c0-12.288 8.192-20.48 20.48-20.48s20.48 8.192 20.48 20.48v204.8c0 6.144-2.048 10.24-6.144 14.336s-8.192 6.144-14.336 6.144h-10.24z',
  93. onclick: function() {
  94. _this.initData()
  95. },
  96. },
  97. saveAsImage: { show: true, title: ' ' },
  98. myTool: {
  99. show: true,
  100. title: ' ',
  101. icon:
  102. 'path://M119.579981 119.560026l185.746448 0c16.074094 0 29.283953-13.134135 29.283953-29.322839 0-16.303314-13.113669-29.321816-29.283953-29.321816l-215.107149 0c-8.037047 0-15.34857 3.282766-20.655436 8.590656-5.383614 5.307889-8.629541 12.619412-8.629541 20.694321L60.934303 305.306474c0 16.074094 13.134135 29.283953 29.321816 29.283953 16.303314 0 29.322839-13.114692 29.322839-29.283953L119.578957 119.560026zM901.51076 119.560026 715.764312 119.560026c-16.093537 0-29.283953-13.134135-29.283953-29.322839 0-16.303314 13.114692-29.321816 29.283953-29.321816l215.107149 0c8.037047 0 15.34857 3.282766 20.655436 8.590656 5.384637 5.307889 8.629541 12.619412 8.629541 20.694321L960.156438 305.306474c0 16.074094-13.134135 29.283953-29.321816 29.283953-16.303314 0-29.322839-13.114692-29.322839-29.283953L901.511783 119.560026zM119.579981 901.489782l185.746448 0c16.074094 0 29.283953 13.133112 29.283953 29.321816 0 16.303314-13.113669 29.321816-29.283953 29.321816l-215.107149 0c-8.037047 0-15.34857-3.28379-20.655436-8.590656-5.383614-5.306866-8.629541-12.619412-8.629541-20.694321L60.934303 715.744357c0-16.075117 13.134135-29.286 29.321816-29.286 16.303314 0 29.322839 13.114692 29.322839 29.286L119.578957 901.489782zM901.51076 901.489782 715.764312 901.489782c-16.093537 0-29.283953 13.133112-29.283953 29.321816 0 16.303314 13.114692 29.321816 29.283953 29.321816l215.107149 0c8.037047 0 15.34857-3.28379 20.655436-8.590656 5.384637-5.306866 8.629541-12.619412 8.629541-20.694321L960.156438 715.744357c0-16.075117-13.134135-29.286-29.321816-29.286-16.303314 0-29.322839 13.114692-29.322839 29.286L901.511783 901.489782z',
  103. onclick: function() {
  104. if (_this.full === false) {
  105. _this.full = true
  106. _this.$emit('fullfenbu', true)
  107. } else {
  108. _this.full = false
  109. _this.$emit('fullfenbu', false)
  110. }
  111. },
  112. },
  113. },
  114. },
  115. xAxis: {
  116. type: 'time',
  117. boundaryGap: false,
  118. axisLabel: {
  119. textStyle: {
  120. color: 'rgba(255,255,255,0.7)',
  121. },
  122. },
  123. axisTick: {
  124. // 隐藏刻度尺
  125. show: false,
  126. },
  127. splitLine: {
  128. show: false,
  129. },
  130. axisLine: {
  131. show: true,
  132. lineStyle: {
  133. color: 'rgba(255,255,255,0.3)',
  134. width: 0,
  135. type: 'solid',
  136. },
  137. },
  138. },
  139. yAxis: {
  140. type: 'value',
  141. boundaryGap: [0, '100%'],
  142. axisLabel: {
  143. textStyle: {
  144. color: 'rgba(255,255,255,0.7)',
  145. },
  146. },
  147. axisTick: {
  148. show: false,
  149. },
  150. axisLine: {
  151. show: false,
  152. lineStyle: {
  153. color: 'rgba(255,255,255,0.3)',
  154. width: 0,
  155. type: 'solid',
  156. },
  157. },
  158. splitLine: {
  159. show: true,
  160. lineStyle: {
  161. color: 'rgba(255,255,255,0.2)',
  162. },
  163. },
  164. data: '',
  165. },
  166. dataZoom: [
  167. {
  168. type: 'inside',
  169. start: 100,
  170. end: 95,
  171. fillerColor: '#1465BB',
  172. },
  173. {
  174. type: 'slider',
  175. start: 100,
  176. end: 95,
  177. borderColor: '#134690',
  178. backgroundColor: '#0B3787',
  179. fillerColor: '#1465BB',
  180. height: '4%',
  181. bottom: '2%',
  182. handleSize: 0,
  183. showDetail: false, // 不显示拖动条的文字
  184. },
  185. ],
  186. series: [
  187. {
  188. name: '打开次数',
  189. type: 'line',
  190. symbol: 'none',
  191. sampling: 'lttb',
  192. itemStyle: {
  193. color: 'rgba(255,255,255,0.1)',
  194. },
  195. areaStyle: {
  196. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  197. {
  198. offset: 1,
  199. color: '#01267B',
  200. },
  201. {
  202. offset: 0.5,
  203. color: '#12CEE1',
  204. },
  205. {
  206. offset: 0,
  207. color: '#12CEE1',
  208. },
  209. ]),
  210. },
  211. data: '',
  212. },
  213. ],
  214. },
  215. }
  216. },
  217. created() {
  218. _this = this
  219. this.initData()
  220. },
  221. mounted() {},
  222. methods: {
  223. initData() {
  224. const params = {
  225. days: 7,
  226. }
  227. TrackService.getOpenfenbu(params)
  228. .then((res) => {
  229. let data = []
  230. data = res.data.map((item) => {
  231. const obj = {}
  232. obj.name = item.time
  233. obj.value = [item.time, item.count]
  234. return obj
  235. })
  236. data.sort((a, b) => {
  237. return b.name - a.name
  238. })
  239. this.line.series[0].data = data
  240. this.cval = data.map((item) => {
  241. return item.value
  242. })
  243. })
  244. .catch((e) => {})
  245. },
  246. },
  247. }
  248. </script>
  249. <style module lang="scss">
  250. @use '@/common/design' as *;
  251. .box {
  252. position: absolute;
  253. width: 100%;
  254. height: 100%;
  255. padding-top: 10px;
  256. color: $card-background;
  257. p {
  258. margin-bottom: 0;
  259. font-size: $switch-height;
  260. }
  261. .opt {
  262. display: flex;
  263. justify-content: space-between;
  264. padding: 10px 10px 5px 15px;
  265. }
  266. .radio {
  267. padding-top: 4px;
  268. }
  269. }
  270. .echart {
  271. position: absolute;
  272. bottom: 0;
  273. left: 50%;
  274. width: 100%;
  275. height: 100%;
  276. padding: 0 0 0 10px;
  277. margin-top: 10px;
  278. transform: translate(-50%, 0%);
  279. }
  280. </style>