KCFX.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="kcfx" @click="kucunfenxi">
  3. <div class="godetail"><img src="../../assets/bargound/shuangjiantou.png" alt="">&nbsp;库存分析</div>
  4. <div id="kcfxchart"></div>
  5. </div>
  6. </template>
  7. <script>
  8. import * as echarts from 'echarts';
  9. import { kcfxchartInfo } from "../../servuces/prove";
  10. export default {
  11. data () {
  12. return {
  13. kc_data: []
  14. }
  15. },
  16. mounted () {
  17. this.getData()
  18. },
  19. methods: {
  20. kcfxchart () {
  21. const kcfxchart = document.getElementById('kcfxchart')
  22. const myChartkcfx = echarts.init(kcfxchart)
  23. const kcfxoption = {
  24. legend: [{
  25. data: ['配件'],
  26. right: '25%',
  27. textStyle: {
  28. color: 'white' // 设置柱子1的图例文本颜色
  29. },
  30. itemStyle: {
  31. color: 'rgb(216,183,49)' // 设置柱子1的图例文本颜色
  32. }
  33. },
  34. {
  35. data: ['精品'],
  36. right: '6%',
  37. textStyle: {
  38. color: 'white' // 设置柱子2的图例文本颜色
  39. },
  40. itemStyle: {
  41. color: 'rgb(50,87,250)' // 设置柱子2的图例文本颜色
  42. }
  43. }
  44. ],
  45. tooltip: {
  46. backgroundColor: 'black',
  47. textStyle: {
  48. color: 'white'
  49. }
  50. },
  51. grid: {
  52. top: '20%',
  53. left: '1%',
  54. right: '6%',
  55. bottom: '6%',
  56. containLabel: true
  57. },
  58. dataset: {
  59. source: this.kc_data
  60. },
  61. xAxis: {
  62. type: 'category',
  63. axisLine: {
  64. lineStyle: {
  65. color: ' rgb(44,214,204)' // 设置x轴颜色为红色
  66. }
  67. },
  68. axisLabel: {
  69. color: 'white' // 设置x轴标签字体颜色为黑色
  70. },
  71. },
  72. yAxis: {
  73. show: true,
  74. splitLine: {
  75. //去除网格线
  76. lineStyle: {
  77. type: 'dashed',
  78. color: 'rgb(116, 116, 116,0.2)'
  79. },
  80. show: true
  81. },
  82. axisLine: {
  83. show: true,
  84. lineStyle: {
  85. color: ' rgb(44,214,204)' // 设置x轴颜色为红色
  86. }
  87. },
  88. axisLabel: {
  89. color: 'white' // 设置x轴标签字体颜色为黑色
  90. },
  91. axisTick: {
  92. //坐标刻度
  93. show: true
  94. },
  95. // boundaryGap: [0, '10%']
  96. },
  97. // Declare several bar series, each will be mapped
  98. // to a column of dataset.source by default.
  99. series: [
  100. {
  101. name: '配件', type: 'bar', barWidth: 20, barGap: '60%', itemStyle: {
  102. normal: {
  103. color: new echarts.graphic.LinearGradient(
  104. 0, 0, 0, 1, // 渐变方向从左上到右下
  105. [
  106. { offset: 1, color: '#00000000' }, // 渐变起始颜色
  107. { offset: 0, color: 'rgb(216,183,49)' } // 渐变结束颜色
  108. ]
  109. )
  110. }
  111. },
  112. },
  113. {
  114. name: '精品', type: 'bar', barWidth: 20, barGap: '60%', itemStyle: {
  115. normal: {
  116. color: new echarts.graphic.LinearGradient(
  117. 0, 0, 0, 1, // 渐变方向从左上到右下
  118. [
  119. { offset: 1, color: '#00000000' }, // 渐变起始颜色
  120. { offset: 0, color: 'rgb(50,87,250)' } // 渐变结束颜色
  121. ]
  122. )
  123. }
  124. },
  125. }]
  126. }
  127. kcfxoption && myChartkcfx.setOption(kcfxoption)
  128. window.addEventListener('resize', function () {
  129. myChartkcfx.resize();
  130. })
  131. },
  132. getData () {
  133. kcfxchartInfo().then(res => {
  134. this.kc_data = res.data;
  135. this.kcfxchart();
  136. })
  137. },
  138. kucunfenxi(){
  139. this.$router.push('/kucunfenxidetail')
  140. }
  141. }
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .kcfx {
  146. width: 100%;
  147. height: 100%;
  148. position: relative;
  149. .godetail {
  150. position: absolute;
  151. top: 0;
  152. }
  153. #kcfxchart {
  154. width: 100%;
  155. height: 100%;
  156. }
  157. }
  158. </style>