custRadarChart.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="content">
  3. <!-- #ifdef APP-PLUS || H5 -->
  4. <view @click="echarts.onClick" :prop="option" :change:prop="echarts.updateEcharts" ref="chartId" :id="chartId" class="echarts"></view>
  5. <view class="chengjiaoLab">
  6. <view class="name">
  7. {{dataInfo.dealRate}}
  8. </view>
  9. <view class="valueDes">成交几率</view>
  10. </view>
  11. <view class="yixiangLab" @click="desClickAction('left')">
  12. <view class="name" style="min-height: 70rpx;">
  13. {{dataInfo.yxLevel}}
  14. </view>
  15. <view class="valueDes">意向度</view>
  16. <view class="icon" v-if="isShowIcon">
  17. ?
  18. </view>
  19. </view>
  20. <view class="bakongLab" @click="desClickAction('right')">
  21. <view class="name" style="min-height: 70rpx;">
  22. {{bakongNum}}
  23. </view>
  24. <view class="valueDes">把控值</view>
  25. <view class="icon" v-if="isShowIcon">
  26. ?
  27. </view>
  28. </view>
  29. <!-- #endif -->
  30. </view>
  31. </template>
  32. <script>
  33. import echarts from '../../static/echarts.js'
  34. export default {
  35. props: {
  36. chartId: String,
  37. dataInfo: null,
  38. isShowIcon: {
  39. type: Boolean,
  40. default: () => {
  41. return false
  42. }
  43. }
  44. },
  45. data() {
  46. return {
  47. chengjiaoNum: 0,
  48. yixiangNum: 0,
  49. bakongNum: 0,
  50. option: {
  51. radar: [{
  52. indicator: [{
  53. name: '成交几率',
  54. max: 100,
  55. min: 0
  56. },
  57. {
  58. name: '意向度',
  59. max: 100,
  60. min: 0
  61. },
  62. {
  63. name: '把控值',
  64. max: 100,
  65. min: 0
  66. }
  67. ],
  68. center: ['50%', '55%'],
  69. radius: 110,
  70. startAngle: 90,
  71. splitNumber: 4,
  72. shape: 'circle',
  73. // name: {
  74. // formatter: '{value}',
  75. // textStyle: {
  76. // color: '#606060',
  77. // opacity: 0.7
  78. // }
  79. // },
  80. splitArea: {
  81. areaStyle: {
  82. // color: ['rgba(114, 172, 209, 0.2)',
  83. // 'rgba(114, 172, 209, 0.4)', 'rgba(114, 172, 209, 0.6)',
  84. // 'rgba(114, 172, 209, 0.8)', 'rgba(114, 172, 209, 1)'],
  85. color: [
  86. 'rgba(254,195,80,0.5)',
  87. 'rgba(254,195,80,0.4)',
  88. 'rgba(254,195,80,0.3)',
  89. 'rgba(254,195,80,0.2)',
  90. 'rgba(254,195,80,0.1)'
  91. ],
  92. shadowColor: 'rgba(0, 0, 0, 0)',
  93. // shadowBlur: 10
  94. }
  95. },
  96. axisLine: {
  97. lineStyle: {
  98. color: 'rgba(255, 255, 255, 0.5)'
  99. }
  100. },
  101. splitLine: {
  102. lineStyle: {
  103. color: 'rgba(255, 255, 255, 0.5)'
  104. }
  105. }
  106. }],
  107. series: [{
  108. name: '雷达图',
  109. type: 'radar',
  110. emphasis: {
  111. lineStyle: {
  112. width: 4
  113. }
  114. },
  115. data: [{
  116. value: [],
  117. name: '图一',
  118. symbol: 'circle',
  119. symbolSize: 6,
  120. itemStyle: {
  121. color: '#fff',
  122. borderWidth: 2,
  123. borderColor: '#202638'
  124. },
  125. lineStyle: {
  126. type: 'solid',
  127. color: '#202638'
  128. },
  129. areaStyle: {
  130. color: 'rgba(255, 255, 255, 0.7)'
  131. }
  132. }]
  133. }]
  134. }
  135. }
  136. },
  137. methods: {
  138. getDataAction() {
  139. this.chengjiaoNum = this.dataInfo.dealRateScore
  140. this.yixiangNum = this.dataInfo.yxScore
  141. this.bakongNum = this.dataInfo.bkScore
  142. // this.chengjiaoNum = Math.ceil(Math.random() * 100)
  143. // this.yixiangNum = Math.ceil(Math.random() * 100)
  144. // this.bakongNum = Math.ceil(Math.random() * 100)
  145. this.option.series[0].data[0].value = [this.chengjiaoNum, this.yixiangNum, this.bakongNum]
  146. // // console.log('数据刷新', this.option.series[0].data[0].value)
  147. },
  148. desClickAction(e) {
  149. this.$emit('desClickAction', e)
  150. },
  151. onViewClick(options) {
  152. // console.log(options)
  153. }
  154. },
  155. watch: {
  156. chartId: {
  157. handler(e) {
  158. // // console.log('走没走!!!!', e)
  159. this.getDataAction()
  160. },
  161. immediate: true
  162. },
  163. dataInfo: {
  164. handler(e) {
  165. this.getDataAction()
  166. },
  167. deep: true
  168. }
  169. }
  170. }
  171. </script>
  172. <script module="echarts" lang="renderjs">
  173. let myChart
  174. export default {
  175. mounted() {
  176. this.initAction()
  177. },
  178. methods: {
  179. initAction() {
  180. if (typeof window.echarts === 'function') {
  181. this.initEcharts()
  182. } else {
  183. // 动态引入较大类库避免影响页面展示
  184. const script = document.createElement('script')
  185. // view 层的页面运行在 www 根目录,其相对路径相对于 www 计算
  186. script.src = 'static/echarts.js'
  187. script.onload = this.initEcharts.bind(this)
  188. document.head.appendChild(script)
  189. }
  190. },
  191. initEcharts() {
  192. // console.log("initEcharts -> this.$refs", this.$refs.chartId.$el.id)
  193. myChart = echarts.init(document.getElementById(this.$refs.chartId.$el.id))
  194. // 观测更新的数据在 view 层可以直接访问到
  195. if (myChart) {
  196. myChart.setOption(this.option)
  197. }
  198. },
  199. updateEcharts(newValue, oldValue, ownerInstance, instance) {
  200. // 监听 service 层数据变更
  201. if (myChart) {
  202. myChart.setOption(newValue)
  203. }
  204. },
  205. onClick(event, ownerInstance) {
  206. // 调用 service 层的方法
  207. ownerInstance.callMethod('onViewClick', {
  208. test: 'test'
  209. })
  210. }
  211. }
  212. }
  213. </script>
  214. <style scoped lang="scss">
  215. .content {
  216. width: 100%;
  217. height: 100%;
  218. position: relative;
  219. font-size: 60rpx;
  220. font-family: DIN Alternate;
  221. font-weight: bold;
  222. .chengjiaoLab {
  223. position: absolute;
  224. top: 30rpx;
  225. left: 0;
  226. width: 100%;
  227. text-align: center;
  228. color: #FFA74E;
  229. }
  230. .yixiangLab {
  231. position: absolute;
  232. color: #546074;
  233. left: 60rpx;
  234. top: 435rpx;
  235. width: 80rpx;
  236. text-align: center;
  237. }
  238. .bakongLab {
  239. position: absolute;
  240. color: #546074;
  241. right: 60rpx;
  242. top: 435rpx;
  243. width: 80rpx;
  244. text-align: center;
  245. }
  246. .valueDes {
  247. color: rgba($color: #606060, $alpha: 0.7);
  248. font-size: 20rpx;
  249. text-align: center;
  250. }
  251. .icon {
  252. margin-left: 27rpx;
  253. margin-top: 35rpx;
  254. width: 26rpx;
  255. height: 26rpx;
  256. border-radius: 13rpx;
  257. font-size: 10rpx;
  258. text-align: center;
  259. line-height: 26rpx;
  260. background-color: #FEC350;
  261. color: #FFFFFF;
  262. }
  263. .echarts {
  264. width: 100%;
  265. margin-top: 0rpx;
  266. height: 100%;
  267. }
  268. }
  269. </style>