summary.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import * as echarts from '../ec-canvas/echarts'
  2. import { mergeOptions } from '../ec-canvas/defaultOption'
  3. function initChart(canvas, width, height, dpr) {
  4. const chart = echarts.init(canvas, null, {
  5. width: width,
  6. height: height,
  7. devicePixelRatio: dpr // new
  8. });
  9. canvas.setChart(chart);
  10. var option = {
  11. series: [
  12. {
  13. data: [[0, 1000], [3, 500], [6, 750], [9, 1400], [12, 1250], [15, 1600], [18, 1800]],
  14. type: 'line',
  15. smooth: true,
  16. name: '主页访问量',
  17. areaStyle: {
  18. opacity: 0.1
  19. },
  20. symbolSize: 0
  21. },
  22. {
  23. data: [[0, 1250], [3, 600], [6, 800], [9, 1500], [12, 1400], [15, 1750], [18, 2000]],
  24. type: 'line',
  25. smooth: true,
  26. name: '场景浏览量',
  27. areaStyle: {
  28. opacity: 0.1
  29. },
  30. symbolSize: 0
  31. },
  32. ]
  33. };
  34. chart.setOption(mergeOptions(option));
  35. return chart;
  36. }
  37. function initBarChart(canvas, width, height, dpr) {
  38. const chart = echarts.init(canvas, null, {
  39. width: width,
  40. height: height,
  41. devicePixelRatio: dpr // new
  42. });
  43. canvas.setChart(chart);
  44. var option = {
  45. title: {
  46. text: '商品统计数据'
  47. },
  48. xAxis: {
  49. type: 'category',
  50. data: ['aaa', 'aaa', 'aaa', 'asdsad'],
  51. axisLabel: {
  52. align: 'center'
  53. }
  54. },
  55. series: [
  56. {
  57. name: '浏览量',
  58. type: 'bar',
  59. data: [2.0, 4.9, 7.0, 11],
  60. barGap: 0,
  61. barWidth: 10,
  62. itemStyle: {
  63. barBorderRadius:[10, 10, 0, 0],
  64. }
  65. },
  66. {
  67. name: '询盘数',
  68. type: 'bar',
  69. data: [2.0, 4.9, 7.0, 11],
  70. barGap: 0,
  71. barWidth: 10,
  72. itemStyle: {
  73. barBorderRadius:[10, 10, 0, 0],
  74. },
  75. },
  76. ]
  77. };
  78. chart.setOption(mergeOptions(option));
  79. return chart;
  80. }
  81. Component({
  82. /**
  83. * 组件的属性列表
  84. */
  85. properties: {
  86. },
  87. /**
  88. * 组件的初始数据
  89. */
  90. data: {
  91. ec: {
  92. onInit: initChart
  93. },
  94. barEc: {
  95. onInit: initBarChart
  96. }
  97. },
  98. /**
  99. * 组件的方法列表
  100. */
  101. methods: {
  102. }
  103. })