centerl.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. const myChartp = echarts.init(document.getElementById('centerl'), 'vintage');
  2. var myColors = ['#81E7ED'];
  3. var dataLine = [40, 56, 23];
  4. var positionLeft = 10,
  5. max = 100 + positionLeft;
  6. var g_cellBar0_y = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAoCAYAAAAhf6DEAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAA6SURBVEhLY2x8/vY/A4mg3zwcTDOBSTLBqGYSwahmEsGoZhLBqGYSwahmEsGoZhLBqGYSwZDUzMAAAJldBMF2UASmAAAAAElFTkSuQmCC';
  7. var g_cellBarImg0_y = new Image();
  8. g_cellBarImg0_y.src = g_cellBar0_y;
  9. var option9 = {
  10. grid: [{
  11. left: '8%',
  12. top: '12%',
  13. right: '5%',
  14. bottom: '8%',
  15. containLabel: true
  16. },
  17. {
  18. left: '10%',
  19. top: '12%',
  20. right: '5%',
  21. bottom: '8%',
  22. containLabel: true
  23. }
  24. ],
  25. xAxis: [{
  26. // max:max,
  27. show: false
  28. }],
  29. yAxis: [{
  30. axisTick: 'none',
  31. axisLine: 'none',
  32. axisLabel: {
  33. inside: true,
  34. align: 'left',
  35. textStyle: {
  36. color: '#81E7ED',
  37. fontSize: '16'
  38. }
  39. },
  40. z: 10,
  41. data: ['电脑', '手机', 'U盘']
  42. }, {
  43. axisTick: 'none',
  44. axisLine: 'none',
  45. show: true,
  46. axisLabel: {
  47. inside: true,
  48. align: 'right',
  49. textStyle: {
  50. color: '#ffffff',
  51. fontSize: '16'
  52. }
  53. },
  54. z: 10,
  55. data: [40, 56, 23,]
  56. }, {
  57. axisLine: {
  58. lineStyle: {
  59. color: 'rgba(0,0,0,0)'
  60. }
  61. },
  62. data: []
  63. }],
  64. series: [
  65. { //间距
  66. type: 'bar',
  67. barWidth: 0,
  68. stack: 'b',
  69. legendHoverLink: false,
  70. itemStyle: {
  71. normal: {
  72. color: 'rgba(0,0,0,0)'
  73. }
  74. },
  75. z: 3,
  76. data: [positionLeft, positionLeft, positionLeft]
  77. }, {
  78. name: '条',
  79. type: 'bar',
  80. stack: 'b',
  81. yAxisIndex: 0,
  82. data: dataLine,
  83. label: {
  84. normal: {
  85. show: false,
  86. position: 'right',
  87. distance: 10,
  88. formatter: function(param) {
  89. return param.value + '%'
  90. },
  91. textStyle: {
  92. color: '#ffffff',
  93. fontSize: '16'
  94. }
  95. }
  96. },
  97. itemStyle: {
  98. color: {
  99. image: g_cellBarImg0_y,
  100. repeat: 'repeat'
  101. }
  102. },
  103. z: 2
  104. }, {
  105. name: '白框',
  106. type: 'bar',
  107. yAxisIndex: 1,
  108. barGap: '-100%',
  109. data: [99.8, 99.9, 99.9],
  110. borderColor:'#0e2147',
  111. itemStyle: {
  112. normal: {
  113. color: '#0e2147',
  114. barBorderRadius: 2
  115. }
  116. },
  117. z: 1
  118. },
  119. {
  120. name: '外框',
  121. type: 'bar',
  122. yAxisIndex: 2,
  123. barGap: '-100%',
  124. data: [100, 100, 100],
  125. label: {
  126. normal: {
  127. show: false,
  128. position: 'right',
  129. distance: 10,
  130. formatter: function(data) {
  131. return dataLine[data.dataIndex] + "%";
  132. },
  133. textStyle: {
  134. color: '#ffffff',
  135. fontSize: '16'
  136. }
  137. }
  138. },
  139. itemStyle: {
  140. normal: {
  141. color: function(params) {
  142. var num = myColors.length
  143. return myColors[params.dataIndex % num]
  144. },
  145. barBorderRadius: [0, 7, 0, 7]
  146. }
  147. },
  148. z: 0
  149. },
  150. ]
  151. }
  152. myChartp.setOption(option9);