com-chart-3.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!-- 统计图 3 -->
  2. <template>
  3. <div class="echarts-div" id='line-chart' ref='line-chart'></div>
  4. </template>
  5. <script>
  6. module.exports = {
  7. data() {
  8. return {}
  9. },
  10. methods: {
  11. // 刷新折线图
  12. f5LineChart: function () {
  13. // =========================================== 定义数据
  14. var x_name = ''; // "活跃数据"; // x轴名称
  15. var y_name = "活跃数据"; // y轴名称
  16. var typeArray = ['总计登录', '新增注册'];
  17. var dataArray = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']; // 坐标X轴数据
  18. var valueArray0 = [84, 126, 262, 201, 148, 133, 86, 186, 232, 215, 326, 412]; //
  19. var valueArray1 = [284, 296, 382, 501, 348, 273, 266, 327, 412, 515, 526, 712]; //
  20. // =========================================== 开始渲染
  21. var myChart = echarts.init(this.$refs['line-chart']);
  22. var option = {
  23. tooltip: {
  24. trigger: 'axis',
  25. axisPointer: {
  26. type: 'cross',
  27. label: {
  28. backgroundColor: '#6a7985'
  29. }
  30. }
  31. },
  32. toolbox: {
  33. show: true,
  34. top: 0,
  35. feature: {
  36. saveAsImage: {
  37. show: true
  38. }
  39. }
  40. },
  41. grid: {x: 50, y: 30, x2: 25, y2: 25}, //设置canvas内部表格的内距
  42. legend: {
  43. data: typeArray
  44. },
  45. xAxis: {
  46. name: x_name,
  47. type: 'category',
  48. boundaryGap: false,
  49. // axisLabel: {
  50. // 'interval': 0
  51. // }, //强制不缩略x轴刻度,
  52. data: dataArray
  53. },
  54. yAxis: {
  55. name: y_name,
  56. type: 'value'
  57. },
  58. series: [
  59. {
  60. name: '总计登录',
  61. type: 'line',
  62. data: valueArray1,
  63. smooth: true, // 曲线形式
  64. areaStyle: {
  65. normal: {
  66. color: 'rgba(0, 128, 0, 0.3)' //改变区域颜色
  67. }
  68. },
  69. itemStyle: {
  70. normal: {
  71. color: 'rgba(0, 128, 0, 0.8)', //改变折线点的颜色
  72. }
  73. },
  74. },
  75. {
  76. name: '新增注册',
  77. type: 'line',
  78. data: valueArray0,
  79. smooth: true, // 曲线形式
  80. areaStyle: {
  81. normal: {
  82. color: 'rgba(70, 128, 255, 0.3)' //改变区域颜色
  83. }
  84. },
  85. itemStyle: {
  86. normal: {
  87. color: 'rgba(70, 128, 255, 0.8)', //改变折线点的颜色
  88. }
  89. },
  90. },
  91. ]
  92. };
  93. myChart.setOption(option);
  94. window.myChartList.push(myChart);
  95. },
  96. },
  97. created() {
  98. // 刷新所有图标数据
  99. this.$nextTick(function () {
  100. this.f5LineChart();
  101. });
  102. }
  103. }
  104. </script>
  105. <style scoped>
  106. </style>