workBusTrend.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. }
  6. },
  7. props: {
  8. height: Number,
  9. },
  10. mounted() {
  11. this.$nextTick(()=>{
  12. this.initChart()
  13. })
  14. },
  15. methods: {
  16. initChart() {
  17. let chart = this.$echarts.init(this.$refs.myChart)
  18. let defaultOption = {
  19. legend: {
  20. data: [
  21. '成本',
  22. ]
  23. },
  24. grid: {
  25. left: '0%', //默认10%
  26. right: '0%', //默认10%
  27. bottom: '15%', //默认60
  28. top: '15%',
  29. containLabel: true
  30. //grid区域是否包含坐标轴的刻度标签
  31. },
  32. xAxis: {
  33. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  34. },
  35. yAxis: [
  36. {
  37. name: '%',
  38. type: 'value',
  39. nameTextStyle: {
  40. padding: [10, 0, 10, -12]
  41. },
  42. },
  43. ],
  44. dataZoom: [
  45. {
  46. type: 'slider',
  47. start: 0,
  48. end: 30,
  49. height: 12,
  50. },
  51. {
  52. type: 'inside',
  53. start: 0,
  54. end: 100,
  55. }
  56. ],
  57. tooltip: {
  58. trigger: 'axis',
  59. axisPointer: {
  60. type: 'shadow'
  61. },
  62. textStyle: {
  63. color: '#fff',
  64. align: 'left',
  65. fontSize: 14
  66. },
  67. axisLine: {//x坐标轴轴线
  68. show: true,
  69. lineStyle: {//x坐标轴轴线样式
  70. color: '#000',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
  71. }
  72. },
  73. backgroundColor: 'rgba(0,0,0,0.8)',
  74. },
  75. series: [
  76. {
  77. name: '成本',
  78. data: [167, 156, 176, 156, 173, 127, 101, 165, 121, 193, 172, 149],
  79. type: 'line',
  80. stack: 'x',
  81. smooth: true,
  82. showSymbol:false,
  83. areaStyle: {
  84. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  85. offset: 0,
  86. color: '#B0E5CB' // 0% 处的颜色
  87. }, {
  88. offset: 0.8,
  89. color: '#ffffff' // 100% 处的颜色
  90. }], false),
  91. },
  92. lineStyle: {
  93. color: "#62CC97",
  94. width: 1,
  95. },
  96. itemStyle: {
  97. color: '#62CC97'
  98. },
  99. emphasis: {
  100. scale:1.5
  101. }
  102. },
  103. ]
  104. };
  105. //Object.assign(defaultOption, this.option)
  106. chart.setOption(defaultOption)
  107. }
  108. }
  109. }
  110. </script>
  111. <template>
  112. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  113. </template>
  114. <style lang="less" scoped>
  115. </style>