scene-report.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. properties: {
  9. sceneNum: {
  10. type: String,
  11. observer: function (val) {
  12. if (!this.properties.date || !this.properties.sceneNum) return;
  13. CensusApi.getSceneCensus({date: this.properties.date, sceneNum: val})
  14. }
  15. },
  16. date: {
  17. type: String,
  18. observer: function (val) {
  19. if (!this.properties.date || !this.properties.sceneNum) return;
  20. CensusApi.getSceneCensus({date: val, sceneNum: this.properties.sceneNum})
  21. }
  22. },
  23. },
  24. /**
  25. * 组件的初始数据
  26. */
  27. data: {
  28. ec: {
  29. onInit: initChart
  30. },
  31. dataNumList: [
  32. {
  33. value: 20,
  34. label: '展位浏览量',
  35. key: 'goods_num',
  36. bgColor: 'rgba(115,142,254,0.1)',
  37. color: '#738EFE'
  38. },
  39. {
  40. value: 20,
  41. label: '客户访问量',
  42. key: 'video_num',
  43. bgColor: 'rgba(77,174,255,0.1)',
  44. color: '#4DAEFF'
  45. },
  46. {
  47. value: 20,
  48. label: '商务询盘量',
  49. bgColor: 'rgba(23,210,210,0.1)',
  50. color: '#17D2D2'
  51. },
  52. {
  53. value: 20,
  54. label: '展位商品数',
  55. bgColor: 'rgba(246,151,88,0.1)',
  56. color: '#F69758'
  57. }
  58. ]
  59. },
  60. lifetimes: {
  61. },
  62. ready () {
  63. },
  64. methods: {
  65. }
  66. })
  67. function initChart(canvas, width, height, dpr) {
  68. const chart = echarts.init(canvas, null, {
  69. width: width,
  70. height: height,
  71. devicePixelRatio: dpr // new
  72. });
  73. canvas.setChart(chart);
  74. var option = {
  75. title: {
  76. text: '场景浏览数据'
  77. },
  78. series: [
  79. {
  80. data: [[0, 1000], [3, 500], [6, 750], [9, 1400], [12, 1250], [15, 1600], [18, 1800]],
  81. type: 'line',
  82. smooth: true,
  83. name: '主页访问量',
  84. symbolSize: 0
  85. },
  86. ]
  87. };
  88. chart.setOption(mergeOptions(option));
  89. return chart;
  90. }