barOption.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import * as echarts from "echarts";
  2. const commonStyle = {
  3. xAxis: {
  4. type: "category",
  5. axisTick: {
  6. show: false,
  7. },
  8. axisLine: {
  9. lineStyle: {
  10. color: "rgba(185,185,185,0.3)",
  11. },
  12. },
  13. axisLabel: {
  14. show: true,
  15. color: "rgba(255,255,255,0.6)",
  16. margin: 5,
  17. },
  18. data: ["正常", "较大", "异常"],
  19. },
  20. yAxis: {
  21. type: "value",
  22. show: false,
  23. axisLine: {
  24. show: false,
  25. },
  26. },
  27. grid: {
  28. top: "0%",
  29. left: "-10%",
  30. right: "0%",
  31. bottom: "0%",
  32. containLabel: true,
  33. },
  34. };
  35. const styleName1 = {
  36. ...commonStyle,
  37. series: [
  38. {
  39. data: [32, 40, 42],
  40. type: "bar",
  41. barWidth: 26,
  42. label: {
  43. show: true,
  44. color: "#fff",
  45. position: "insideTop",
  46. },
  47. itemStyle: {
  48. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  49. {
  50. offset: 0,
  51. color: "#BBA269",
  52. },
  53. {
  54. offset: 1,
  55. color: "#3D3523",
  56. },
  57. ]),
  58. borderRadius: [2, 2, 0, 0],
  59. },
  60. },
  61. ],
  62. };
  63. const styleName2 = {
  64. ...commonStyle,
  65. series: [
  66. {
  67. data: [32, 40, 42],
  68. type: "bar",
  69. barWidth: 26,
  70. stack: "total",
  71. label: {
  72. show: true,
  73. color: "#fff",
  74. position: "insideTop",
  75. formatter: ({ value }) => {
  76. return value ? value : "";
  77. },
  78. },
  79. itemStyle: {
  80. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  81. {
  82. offset: 0,
  83. color: "#BBA269",
  84. },
  85. {
  86. offset: 1,
  87. color: "#3D3523",
  88. },
  89. ]),
  90. // borderRadius: [2, 2, 0, 0],
  91. },
  92. emphasis: {
  93. color: '#B81500' // 高亮时的颜色
  94. },
  95. },
  96. {
  97. data: [0, 1, 0,13],
  98. type: "bar",
  99. barWidth: 26,
  100. stack: "total",
  101. label: {
  102. show: true,
  103. color: "#fff",
  104. // position: "top",
  105. formatter: ({ value }) => {
  106. return value ? value : "";
  107. },
  108. },
  109. itemStyle: {
  110. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  111. {
  112. offset: 0,
  113. color: "#ff0000",
  114. },
  115. {
  116. offset: 1,
  117. color: "#B81500",
  118. },
  119. ]),
  120. borderRadius: [2, 2, 0, 0],
  121. },
  122. emphasis: {
  123. color: '#B81500' // 高亮时的颜色
  124. },
  125. },
  126. {
  127. data: [16,15,16, 3],
  128. type: "bar",
  129. barWidth: 26,
  130. stack: "total",
  131. itemStyle: {
  132. color: "rgba(56,56,56,0.94)",
  133. borderRadius: [2, 2, 0, 0],
  134. },
  135. emphasis: {
  136. color: '#B81500' // 高亮时的颜色
  137. },
  138. label: {
  139. show: true,
  140. position: "insideTop",
  141. color: "#fff",
  142. formatter: ({ value }) => {
  143. return value ? value : "";
  144. },
  145. },
  146. },
  147. ],
  148. };
  149. const styleName3 = {
  150. ...commonStyle,
  151. series: [
  152. {
  153. data: [32, 40, 42],
  154. type: "bar",
  155. barWidth: 26,
  156. stack: "total",
  157. label: {
  158. show: true,
  159. color: "#fff",
  160. position: "insideTop",
  161. formatter: ({ value }) => {
  162. return value ? value : "";
  163. },
  164. },
  165. itemStyle: {
  166. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  167. {
  168. offset: 0,
  169. color: "#BBA269",
  170. },
  171. {
  172. offset: 1,
  173. color: "#3D3523",
  174. },
  175. ]),
  176. // borderRadius: [2, 2, 0, 0],
  177. },
  178. emphasis: {
  179. color: '#006F0B' // 高亮时的颜色
  180. },
  181. },
  182. {
  183. data: [16, 16, 16, 0],
  184. type: "bar",
  185. barWidth: 26,
  186. stack: "total",
  187. label: {
  188. show: true,
  189. color: "#fff",
  190. position: "insideTop",
  191. formatter: ({ value }) => {
  192. return value ? value : "";
  193. },
  194. },
  195. itemStyle: {
  196. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  197. {
  198. offset: 0,
  199. color: "#bb7d4c",
  200. },
  201. {
  202. offset: 1,
  203. color: "#90603a",
  204. },
  205. ]),
  206. borderRadius: [2, 2, 0, 0],
  207. },
  208. emphasis: {
  209. color: '#006F0B' // 高亮时的颜色
  210. },
  211. },
  212. {
  213. data: [0,0, 0, 0],
  214. type: "bar",
  215. barWidth: 26,
  216. stack: "total",
  217. itemStyle: {
  218. color: "rgba(56,56,56,0.94)",
  219. borderRadius: [2, 2, 0, 0],
  220. },
  221. emphasis: {
  222. color: '#006F0B' // 高亮时的颜色
  223. },
  224. label: {
  225. show: true,
  226. position: "insideTop",
  227. color: "#fff",
  228. formatter: ({ value }) => {
  229. return value ? value : "";
  230. },
  231. },
  232. },
  233. ],
  234. };
  235. export const barOption = { styleName1, styleName2,styleName3 };