barOption.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. normal:{
  81. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  82. {
  83. offset: 0,
  84. color: "#BBA269",
  85. },
  86. {
  87. offset: 1,
  88. color: "#3D3523",
  89. },
  90. ]),
  91. },
  92. emphasis: {
  93. color: '#B81500' // 高亮时的颜色
  94. },
  95. // borderRadius: [2, 2, 0, 0],
  96. },
  97. },
  98. {
  99. data: [0, 0, 0,1],
  100. type: "bar",
  101. barWidth: 26,
  102. stack: "total",
  103. label: {
  104. show: true,
  105. color: "#fff",
  106. position: "top",
  107. formatter: ({ value }) => {
  108. return value ? value : "";
  109. },
  110. },
  111. itemStyle: {
  112. normal:{
  113. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  114. {
  115. offset: 0,
  116. color: "#bb7d4c",
  117. },
  118. {
  119. offset: 1,
  120. color: "#90603a",
  121. },
  122. ]),
  123. },
  124. emphasis: {
  125. color: '#B81500' // 高亮时的颜色
  126. },
  127. borderRadius: [2, 2, 0, 0],
  128. },
  129. },
  130. {
  131. data: [16,16,16, 15],
  132. type: "bar",
  133. barWidth: 26,
  134. stack: "total",
  135. itemStyle: {
  136. normal:{
  137. color: "rgba(56,56,56,0.94)",
  138. },
  139. emphasis: {
  140. color: '#B81500' // 高亮时的颜色
  141. },
  142. borderRadius: [2, 2, 0, 0],
  143. },
  144. label: {
  145. show: true,
  146. position: "insideTop",
  147. color: "#fff",
  148. formatter: ({ value }) => {
  149. return value ? value : "";
  150. },
  151. },
  152. },
  153. ],
  154. };
  155. const styleName3 = {
  156. ...commonStyle,
  157. series: [
  158. {
  159. data: [32, 40, 42],
  160. type: "bar",
  161. barWidth: 26,
  162. stack: "total",
  163. label: {
  164. show: true,
  165. color: "#fff",
  166. position: "insideTop",
  167. formatter: ({ value }) => {
  168. return value ? value : "";
  169. },
  170. },
  171. itemStyle: {
  172. normal:{
  173. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  174. {
  175. offset: 0,
  176. color: "#BBA269",
  177. },
  178. {
  179. offset: 1,
  180. color: "#3D3523",
  181. },
  182. ]),
  183. },
  184. emphasis: {
  185. color: '#006F0B' // 高亮时的颜色
  186. },
  187. // borderRadius: [2, 2, 0, 0],
  188. },
  189. },
  190. {
  191. data: [16, 8, 0, 0],
  192. type: "bar",
  193. barWidth: 26,
  194. stack: "total",
  195. label: {
  196. show: true,
  197. color: "#fff",
  198. position: "insideTop",
  199. formatter: ({ value }) => {
  200. return value ? value : "";
  201. },
  202. },
  203. itemStyle: {
  204. normal:{
  205. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  206. {
  207. offset: 0,
  208. color: "#bb7d4c",
  209. },
  210. {
  211. offset: 1,
  212. color: "#90603a",
  213. },
  214. ]),
  215. },
  216. emphasis: {
  217. color: '#006F0B' // 高亮时的颜色
  218. },
  219. borderRadius: [2, 2, 0, 0],
  220. },
  221. },
  222. {
  223. data: [0,0, 16, 16],
  224. type: "bar",
  225. barWidth: 26,
  226. stack: "total",
  227. itemStyle: {
  228. normal:{
  229. color: "rgba(56,56,56,0.94)",
  230. },
  231. emphasis: {
  232. color: '#006F0B' // 高亮时的颜色
  233. },
  234. borderRadius: [2, 2, 0, 0],
  235. },
  236. label: {
  237. show: true,
  238. position: "insideTop",
  239. color: "#fff",
  240. formatter: ({ value }) => {
  241. return value ? value : "";
  242. },
  243. },
  244. },
  245. ],
  246. };
  247. export const barOption = { styleName1, styleName2,styleName3 };