yipankeChart.vue 5.8 KB

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