column1.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. layui.use(['echarts'], function() {
  2. let echarts = layui.echarts;
  3. var column1 = echarts.init(document.getElementById('column1'),null, {
  4. width: 600,
  5. height: 400
  6. });
  7. option = {
  8. tooltip: {
  9. trigger: 'axis',
  10. axisPointer: {
  11. type: 'shadow' ,
  12. color: '#fff',
  13. fontSize: '26'
  14. }
  15. },
  16. legend: {
  17. top:'5%',
  18. right:'10%',
  19. data: ['猕猴桃', '香蕉'],
  20. fontSize:12,
  21. color:'#808080',
  22. icon:'rect'
  23. },
  24. grid: {
  25. top:60,
  26. left:50,
  27. bottom:60,
  28. right:60
  29. },
  30. xAxis: [{
  31. type: 'category',
  32. axisTick:{
  33. show:false
  34. },
  35. axisLine:{
  36. show:false
  37. },
  38. axisLabel:{
  39. color:'#4D4D4D',
  40. fontSize:14,
  41. margin:21,
  42. fontWeight:'bold'
  43. },
  44. data: ['第一周', '第二周', '第三周', '第四周'],
  45. }],
  46. yAxis: [{
  47. name:'单位:万',
  48. nameTextStyle:{
  49. color:'#808080',
  50. fontSize:12,
  51. padding:[0, 0, 0, -5]
  52. },
  53. max: function(value) {
  54. if(value.max<5){
  55. return 5
  56. }else{
  57. return value.max
  58. }
  59. },
  60. type: 'value',
  61. axisLine:{
  62. show:false
  63. },
  64. axisLabel:{
  65. color:'#808080',
  66. fontSize:12,
  67. margin:5
  68. },
  69. splitLine:{
  70. show:false
  71. },
  72. axisTick:{
  73. show:false
  74. }
  75. }],
  76. series: [
  77. {
  78. name: '猕猴桃',
  79. type: 'bar',
  80. label:{
  81. show:true,
  82. position:'top',
  83. fontSize:14,
  84. color:'#3DC3F0',
  85. fontWeight:'bold'
  86. },
  87. barMaxWidth:60,
  88. color: {
  89. type: 'linear',
  90. x: 0,
  91. y: 0,
  92. x2: 0,
  93. y2: 1,
  94. colorStops: [{
  95. offset: 0, color: '#3DC3F0' // 0% 处的颜色
  96. }, {
  97. offset: 1, color: '#CCF2FF' // 100% 处的颜色
  98. }]
  99. },
  100. data: [60, 110, 180, 100]
  101. },
  102. {
  103. name: '香蕉',
  104. type: 'bar',
  105. label:{
  106. show:true,
  107. position:'top',
  108. fontSize:14,
  109. color:'#3D8BF0',
  110. fontWeight:'bold'
  111. },
  112. barMaxWidth:60,
  113. color: {
  114. type: 'linear',
  115. x: 0,
  116. y: 0,
  117. x2: 0,
  118. y2: 1,
  119. colorStops: [{
  120. offset: 0, color: '#3D8BF0' // 0% 处的颜色
  121. }, {
  122. offset: 1, color: '#CCE2FF' // 100% 处的颜色
  123. }]
  124. },
  125. data: [90, 130, 170, 130]
  126. }
  127. ]
  128. };
  129. column1.setOption(option);
  130. window.onresize = function() {
  131. column1.resize();
  132. }
  133. })