scene-report.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import * as echarts from '../ec-canvas/echarts'
  2. import { mergeOptions } from '../ec-canvas/defaultOption'
  3. import CensusApi from '../../../apis/census'
  4. Component({
  5. /**
  6. * 组件的初始数据
  7. */
  8. data: {
  9. activeType: 0,
  10. ec: {
  11. onInit: initChart
  12. },
  13. ec2: {
  14. onInit: init2Chart
  15. },
  16. barEc: {
  17. onInit: initBarChart
  18. },
  19. dataNumList: [
  20. {
  21. value: 20,
  22. label: '展位浏览量',
  23. key: 'goods_num',
  24. bgColor: 'rgba(115,142,254,0.1)',
  25. color: '#738EFE'
  26. },
  27. {
  28. value: 20,
  29. label: '客户访问量',
  30. key: 'video_num',
  31. bgColor: 'rgba(77,174,255,0.1)',
  32. color: '#4DAEFF'
  33. },
  34. {
  35. value: 20,
  36. label: '商务询盘量',
  37. bgColor: 'rgba(23,210,210,0.1)',
  38. color: '#17D2D2'
  39. },
  40. {
  41. value: 20,
  42. label: '展位商品数',
  43. bgColor: 'rgba(246,151,88,0.1)',
  44. color: '#F69758'
  45. }
  46. ],
  47. chartTypes: [
  48. {
  49. icon: 'data_booth',
  50. name: '展位数据',
  51. value: 0
  52. },
  53. {
  54. icon: 'data_visitor',
  55. name: '访客数据',
  56. value: 1
  57. },
  58. {
  59. icon: 'data_wares',
  60. name: '商品数据',
  61. value: 2
  62. },
  63. ]
  64. },
  65. lifetimes: {
  66. },
  67. ready () {
  68. },
  69. methods: {
  70. changeActiveType (e) {
  71. const { value } = e.currentTarget.dataset
  72. this.setData({
  73. activeType: value
  74. })
  75. }
  76. }
  77. })
  78. function initChart(canvas, width, height, dpr) {
  79. const chart = echarts.init(canvas, null, {
  80. width: width,
  81. height: height,
  82. devicePixelRatio: dpr // new
  83. });
  84. canvas.setChart(chart);
  85. var option = {
  86. title: {
  87. text: ''
  88. },
  89. tooltip: {
  90. formatter: `{a}: {c} \n ${new Date().getFullYear()}-{b}`
  91. },
  92. series: [
  93. {
  94. data: [500,500,500,500,500],
  95. type: 'line',
  96. smooth: true,
  97. symbolSize: 0,
  98. name: '浏览量'
  99. },
  100. ]
  101. };
  102. chart.setOption(mergeOptions(option));
  103. return chart;
  104. }
  105. function initBarChart(canvas, width, height, dpr) {
  106. const chart = echarts.init(canvas, null, {
  107. width: width,
  108. height: height,
  109. devicePixelRatio: dpr // new
  110. });
  111. canvas.setChart(chart);
  112. var option = {
  113. title: {
  114. text: ''
  115. },
  116. xAxis: {
  117. type: 'category',
  118. data: ['aaa', 'aaa', 'aaa', 'asdsad'],
  119. axisLabel: {
  120. align: 'center'
  121. }
  122. },
  123. series: [
  124. {
  125. name: '浏览量',
  126. type: 'bar',
  127. data: [2.0, 4.9, 7.0, 11],
  128. barGap: 0,
  129. barWidth: 10,
  130. itemStyle: {
  131. barBorderRadius:[10, 10, 0, 0],
  132. }
  133. }
  134. ]
  135. };
  136. chart.setOption(mergeOptions(option));
  137. return chart;
  138. }
  139. function init2Chart(canvas, width, height, dpr) {
  140. const chart = echarts.init(canvas, null, {
  141. width: width,
  142. height: height,
  143. devicePixelRatio: dpr // new
  144. });
  145. canvas.setChart(chart);
  146. var option = {
  147. series: [
  148. {
  149. data: [1000,1000,1000,1000],
  150. type: 'line',
  151. smooth: true,
  152. name: '客户访问量',
  153. areaStyle: {
  154. opacity: 0.1
  155. },
  156. symbolSize: 0
  157. },
  158. {
  159. data: [1201, 1201, 1201, 1201, 1201, 1201],
  160. type: 'line',
  161. smooth: true,
  162. name: '商务询盘量',
  163. areaStyle: {
  164. opacity: 0.1
  165. },
  166. symbolSize: 0
  167. },
  168. ]
  169. };
  170. chart.setOption(mergeOptions(option));
  171. return chart;
  172. }