xm-response-times.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div>
  3. <div :class="$style.box">
  4. <div :class="$style.opt">
  5. <a-radio-group
  6. v-model="radioVal"
  7. button-style="solid"
  8. :class="$style.radio"
  9. @change="changeval(radioVal)"
  10. >
  11. <a-radio-button value="1">当天</a-radio-button>
  12. <a-radio-button value="3">近三天</a-radio-button>
  13. <a-radio-button value="5">近五天</a-radio-button>
  14. <a-radio-button value="7">近一周</a-radio-button>
  15. </a-radio-group>
  16. </div>
  17. <sd-echart :options="pie" autoresize :class="$style.echart" />
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import TrackService from './track-service'
  23. import components from './_import-components/xm-response-times-import'
  24. import 'echarts/lib/chart/pie'
  25. import 'echarts/lib/component/legend'
  26. import 'echarts/lib/component/tooltip'
  27. 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'`
  28. let _this
  29. export default {
  30. name: 'XmResponseTimes',
  31. metaInfo: {
  32. title: 'ResponseTimes',
  33. },
  34. components,
  35. data() {
  36. return {
  37. radioVal: '1',
  38. full: false,
  39. pie: {
  40. tooltip: {
  41. trigger: 'item',
  42. // formatter后tooltip不能直接显示数据项的圆形色块,所以用回调函数拼接
  43. formatter(params) {
  44. const color = params.color
  45. const circle = `<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:`
  46. const data = `${circle}${color}"></span> ${params.data.name}s: ${params.data.value}`
  47. return `${params.seriesName}<br/>${data}<br/>`
  48. },
  49. backgroundColor: 'rgba(255,255,255,0.9)',
  50. textStyle: {
  51. color: 'black',
  52. },
  53. axisPointer: {
  54. type: 'shadow',
  55. },
  56. padding: [10, 10, 10, 10],
  57. },
  58. legend: {
  59. top: 'bottom',
  60. bottom: '1',
  61. itemGap: 40,
  62. textStyle: {
  63. color: 'rgba(255,255,255,0.9)',
  64. },
  65. formatter: function(name) {
  66. return name + 's'
  67. },
  68. },
  69. title: {
  70. text: '响应时间',
  71. textStyle: {
  72. color: 'white',
  73. fontSize: '20',
  74. fontFamily: fontFamily,
  75. fontWeight: 200,
  76. },
  77. left: 'left',
  78. padding: [10, 0, 0, 15],
  79. show: true,
  80. textAlign: 'left',
  81. textVerticalAlign: 'left',
  82. },
  83. grid: {
  84. top: '3%',
  85. left: '1%',
  86. right: '1%',
  87. bottom: '1%',
  88. containLabel: true,
  89. },
  90. color: ['#B903EE', '#DC9F69', '#25B3E1', '#30BE62', '#CC5A63'],
  91. toolbox: {
  92. show: true,
  93. top: '40',
  94. iconStyle: {
  95. borderColor: '#fff',
  96. },
  97. emphasis: {
  98. iconStyle: {
  99. borderColor: '#fff',
  100. },
  101. },
  102. itemSize: 18,
  103. feature: {
  104. myReload: {
  105. show: true,
  106. title: ' ',
  107. icon:
  108. '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',
  109. onclick: function() {
  110. _this.initData()
  111. },
  112. },
  113. saveAsImage: { show: true, title: ' ', backgroundColor: '#0B3787' },
  114. myFull: {
  115. show: true,
  116. title: ' ',
  117. icon:
  118. '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',
  119. onclick: function() {
  120. if (_this.full === false) {
  121. _this.full = true
  122. _this.$emit('fullresponse', true)
  123. } else {
  124. _this.full = false
  125. _this.$emit('fullresponse', false)
  126. }
  127. },
  128. },
  129. },
  130. },
  131. series: [
  132. {
  133. name: '响应时间',
  134. type: 'pie',
  135. label: {
  136. formatter: '{c} ({d}%)',
  137. fontSize: 15,
  138. textStyle: {
  139. color: 'rgba(255,255,255,0.8)',
  140. },
  141. },
  142. labelLine: {
  143. length: 5,
  144. length2: 20,
  145. lineStyle: {
  146. color: 'rgba(255,255,255,0.4)',
  147. },
  148. },
  149. radius: [30, 90],
  150. center: ['50%', '60%'],
  151. roseType: 'radius',
  152. itemStyle: {
  153. borderRadius: 0,
  154. },
  155. data: this.resdata,
  156. },
  157. ],
  158. },
  159. }
  160. },
  161. created() {
  162. this.initData()
  163. _this = this
  164. },
  165. methods: {
  166. initData() {
  167. this.getdata(this.radioVal)
  168. },
  169. changeval(val) {
  170. this.getdata(val)
  171. },
  172. getdata(days) {
  173. const costTime = [2, 3, 5, 8]
  174. const params = {
  175. days: days,
  176. totalCostTimeLimit: costTime + '',
  177. }
  178. TrackService.getResponseTime(params)
  179. .then((res) => {
  180. if (res.data.length > 0) {
  181. this.pie.series[0].data = []
  182. this.pie.series[0].data = res.data
  183. }
  184. })
  185. .catch((e) => {})
  186. },
  187. },
  188. }
  189. </script>
  190. <style module lang="scss">
  191. @use '@/common/design' as *;
  192. .box {
  193. position: absolute;
  194. width: 100%;
  195. height: 100%;
  196. color: $card-background;
  197. background: #0b3787;
  198. .opt {
  199. position: relative;
  200. flex-wrap: wrap;
  201. height: 100%;
  202. p {
  203. flex-basis: 100%;
  204. padding: 10px 0 5px 15px;
  205. margin-bottom: 0;
  206. font-size: $switch-height;
  207. }
  208. }
  209. .radio {
  210. position: absolute;
  211. z-index: 99;
  212. padding-top: 4px;
  213. margin: 40px 0 0 15px;
  214. }
  215. .picker {
  216. min-width: 170px;
  217. max-width: 170px;
  218. margin-left: 20px;
  219. :global(.ant-select) {
  220. width: 100%;
  221. }
  222. }
  223. }
  224. .echart {
  225. position: absolute;
  226. bottom: 0;
  227. left: 50%;
  228. z-index: 0;
  229. width: 100%;
  230. height: 100%;
  231. padding-top: 5px;
  232. padding-right: 20px;
  233. overflow: hidden;
  234. transform: translate(-50%, 0%);
  235. }
  236. </style>