personTrendChart.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. }
  6. },
  7. props: {
  8. height: Number,
  9. },
  10. mounted() {
  11. let app = this;
  12. this.$nextTick(()=>{
  13. setTimeout(()=>{
  14. app.initChart()
  15. },50)
  16. })
  17. },
  18. methods: {
  19. initChart() {
  20. let chart = this.$echarts.init(this.$refs.myChart)
  21. let defaultOption = {
  22. legend: {
  23. data: [
  24. '自有员工',
  25. '外协员工',
  26. '访客人员',
  27. ]
  28. },
  29. grid: {
  30. left: '0%', //默认10%
  31. right: '0%', //默认10%
  32. bottom: '15%', //默认60
  33. top: '15%',
  34. containLabel: true
  35. //grid区域是否包含坐标轴的刻度标签
  36. },
  37. xAxis: {
  38. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  39. },
  40. yAxis: [
  41. {
  42. name: '人数(人)',
  43. type: 'value',
  44. nameTextStyle: {
  45. padding: [10, 0, 10, -12]
  46. },
  47. },
  48. ],
  49. dataZoom: [
  50. {
  51. start: 0,
  52. end: 100,
  53. height: 16,
  54. }
  55. ],
  56. tooltip: {
  57. trigger: 'axis',
  58. axisPointer: {
  59. type: 'shadow'
  60. },
  61. textStyle: {
  62. color: '#fff',
  63. align: 'left',
  64. fontSize: 14
  65. },
  66. axisLine: {//x坐标轴轴线
  67. show: true,
  68. lineStyle: {//x坐标轴轴线样式
  69. color: '#000',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
  70. }
  71. },
  72. backgroundColor: 'rgba(0,0,0,0.8)',
  73. },
  74. series: [
  75. {
  76. name: '自有员工',
  77. data: [302, 395, 227, 375, 349, 396, 304, 226, 207, 383, 287, 243],
  78. type: 'line',
  79. stack: 'x',
  80. smooth: true,
  81. areaStyle: {
  82. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  83. offset: 0,
  84. color: '#A6C9FF' // 0% 处的颜色
  85. }, {
  86. offset: 0.8,
  87. color: '#ffffff' // 100% 处的颜色
  88. }], false),
  89. },
  90. lineStyle: {
  91. color: "#5A9BFE",
  92. width: 1,
  93. },
  94. emphasis: {
  95. scale:1.5
  96. }
  97. },
  98. {
  99. name: '外协员工',
  100. data: [108, 104, 117, 152, 157, 121, 138, 146, 106, 143, 132, 177],
  101. type: 'line',
  102. stack: 'x',
  103. smooth: true,
  104. areaStyle: {
  105. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  106. offset: 0,
  107. color: '#B0E5CB' // 0% 处的颜色
  108. }, {
  109. offset: 0.8,
  110. color: '#ffffff' // 100% 处的颜色
  111. }], false),
  112. },
  113. lineStyle: {
  114. color: "#62CC97",
  115. width: 1,
  116. },
  117. emphasis: {
  118. scale:1.5
  119. },
  120. },
  121. {
  122. name: '访客人员',
  123. data: [40, 15, 59, 18, 33, 31, 31, 26, 34, 26, 28, 40],
  124. type: 'line',
  125. stack: 'x',
  126. smooth: true,
  127. areaStyle: {
  128. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  129. offset: 0,
  130. color: '#FFD7AC' // 0% 处的颜色
  131. }, {
  132. offset: 0.8,
  133. color: '#ffffff' // 100% 处的颜色
  134. }], false),
  135. },
  136. lineStyle: {
  137. color: "#FDB456",
  138. width: 1,
  139. },
  140. emphasis: {
  141. scale:1.5
  142. },
  143. }
  144. ]
  145. };
  146. //Object.assign(defaultOption, this.option)
  147. chart.setOption(defaultOption)
  148. }
  149. }
  150. }
  151. </script>
  152. <template>
  153. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  154. </template>
  155. <style lang="less" scoped>
  156. </style>