com-chart-3.vue 2.6 KB

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