column2.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. layui.use(['echarts'], function() {
  2. let echarts = layui.echarts;
  3. var column2 = echarts.init(document.getElementById('column2'),null, {
  4. width: 600,
  5. height: 400
  6. });
  7. var data = [1000, 600, 500, 300];
  8. option = {
  9. backgroundColor: '#ffffff',
  10. title: {
  11. text: 'ETC交易成功率',
  12. left: 'center',
  13. top: 2,
  14. fontSize: 20
  15. },
  16. color: ['#fed46b','#2194ff', ],
  17. tooltip: {
  18. trigger: 'axis',
  19. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  20. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  21. }
  22. },
  23. grid: {
  24. left: '3%',
  25. right: '4%',
  26. bottom: '10%',
  27. containLabel: true
  28. },
  29. legend: {
  30. left: 'center',
  31. bottom: '2%',
  32. data: ['去年', '今年', ]
  33. },
  34. xAxis: [{
  35. type: 'category',
  36. data: ['09-22', '09-22', '09-22', '09-22', '09-22', '09-22', '09-22'],
  37. axisTick: {
  38. alignWithLabel: true
  39. }
  40. }],
  41. yAxis: [{
  42. type: 'value'
  43. }],
  44. barMaxWidth: '30',
  45. label:{
  46. show:true,
  47. position:'top',
  48. formatter:function(params){
  49. return params.value+'%'
  50. }
  51. },
  52. series: [
  53. {
  54. name: '去年',
  55. type: 'bar',
  56. data: [90, 52, 90, 80, 90, 70, 90]
  57. },
  58. {
  59. name: '今年',
  60. type: 'bar',
  61. data: [10, 52, 90, 70, 90, 70, 90]
  62. },
  63. ]
  64. };
  65. column2.setOption(option);
  66. window.onresize = function() {
  67. column2.resize();
  68. }
  69. })