center3_d.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. function center3_d(data1,data){
  2. const myChartss = echarts.init(document.getElementById('center3_d'), 'vintage');
  3. // const data1 = [10, 20, 10, 30, 30];
  4. const data2 = [100, 100, 100, 100, 100];
  5. const path = 'path://M1390,595h79l-39,22Z';
  6. const myColor = ['#fff', '#fff', '#fff', '#fff', '#fff'];
  7. const option12 = {
  8. grid: {
  9. left: 100,
  10. bottom: 100
  11. },
  12. xAxis: {
  13. axisLabel: {
  14. padding:15,
  15. interval: 0,
  16. textStyle: {
  17. color: function (param, index) {
  18. return myColor[index]
  19. },
  20. fontSize: 16,
  21. fontWeight: 100,
  22. },
  23. margin: 20,
  24. },
  25. splitLine: {
  26. show: false
  27. },
  28. axisLine: {
  29. show: false,
  30. },
  31. splitArea: {
  32. show: false,
  33. },
  34. axisTick: {
  35. show: false
  36. },
  37. data: data
  38. },
  39. yAxis: {
  40. axisLine: {
  41. lineStyle: {
  42. color: '#6e6e6e',
  43. width: 1,
  44. }
  45. },
  46. axisLabel: {
  47. interval: 0,
  48. formatter: '{value}%',
  49. textStyle: {
  50. fontSize: 16,
  51. color: '#fff',
  52. },
  53. margin: 20,
  54. },
  55. splitLine: {
  56. show: true,
  57. },
  58. axisTick: {
  59. lineStyle: {
  60. color: '#fff',
  61. width: 1,
  62. height: 5,
  63. }
  64. },
  65. },
  66. series: [{
  67. type: 'bar',
  68. barWidth: 60,
  69. barGap: '-100%',
  70. stack: '广告',
  71. itemStyle: {
  72. color: function (params) {
  73. const colorList = [
  74. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  75. offset: 0,
  76. color: '#39b3ff'
  77. }, {
  78. offset: 0.5,
  79. color: '#39b3ff'
  80. }, {
  81. offset: 0.5,
  82. color: '#39b3ff'
  83. }, {
  84. offset: 1,
  85. color: '#39b3ff'
  86. }]),
  87. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  88. offset: 0,
  89. color: '#39b3ff'
  90. }, {
  91. offset: 0.5,
  92. color: '#39b3ff'
  93. }, {
  94. offset: 0.5,
  95. color: '#39b3ff'
  96. }, {
  97. offset: 1,
  98. color: '#39b3ff'
  99. }]),
  100. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  101. offset: 0,
  102. color: '#39b3ff'
  103. }, {
  104. offset: 0.5,
  105. color: '#39b3ff'
  106. }, {
  107. offset: 0.5,
  108. color: '#39b3ff'
  109. }, {
  110. offset: 1,
  111. color: '#39b3ff'
  112. }]),
  113. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  114. offset: 0,
  115. color: '#39b3ff'
  116. }, {
  117. offset: 0.5,
  118. color: '#39b3ff'
  119. }, {
  120. offset: 0.5,
  121. color: '#39b3ff'
  122. }, {
  123. offset: 1,
  124. color: '#39b3ff'
  125. }]),
  126. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  127. offset: 0,
  128. color: '#39b3ff'
  129. }, {
  130. offset: 0.5,
  131. color: '#39b3ff'
  132. }, {
  133. offset: 0.5,
  134. color: '#39b3ff'
  135. }, {
  136. offset: 1,
  137. color: '#39b3ff'
  138. }]),
  139. ];
  140. return colorList[params.dataIndex]
  141. },
  142. },
  143. data: data1
  144. },
  145. {
  146. "name": "",
  147. "type": "pictorialBar",
  148. symbol: path,
  149. "symbolSize": [60, 20],
  150. "symbolOffset": [0, 0],
  151. "z": 12,
  152. "symbolPosition": "end",
  153. itemStyle: {
  154. color: '#e2e2e2',
  155. opacity: 0,
  156. },
  157. "data": data2
  158. },
  159. {
  160. "name": "",
  161. "type": "pictorialBar",
  162. symbol: path,
  163. "symbolSize": [60, 20],
  164. "symbolOffset": [0, 20],
  165. "z": 12,
  166. itemStyle: {
  167. opacity: 1,
  168. color: function (params) {
  169. const colorList = [
  170. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  171. offset: 0,
  172. color: '#39b3ff'
  173. }, {
  174. offset: 0.5,
  175. color: '#39b3ff'
  176. }, {
  177. offset: 0.5,
  178. color: '#39b3ff'
  179. }, {
  180. offset: 1,
  181. color: '#39b3ff'
  182. }]),
  183. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  184. offset: 0,
  185. color: '#39b3ff'
  186. }, {
  187. offset: 0.5,
  188. color: '#39b3ff'
  189. }, {
  190. offset: 0.5,
  191. color: '#39b3ff'
  192. }, {
  193. offset: 1,
  194. color: '#39b3ff'
  195. }]),
  196. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  197. offset: 0,
  198. color: '#39b3ff'
  199. }, {
  200. offset: 0.5,
  201. color: '#39b3ff'
  202. }, {
  203. offset: 0.5,
  204. color: '#39b3ff'
  205. }, {
  206. offset: 1,
  207. color: '#39b3ff'
  208. }]),
  209. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  210. offset: 0,
  211. color: '#39b3ff'
  212. }, {
  213. offset: 0.5,
  214. color: '#39b3ff'
  215. }, {
  216. offset: 0.5,
  217. color: '#39b3ff'
  218. }, {
  219. offset: 1,
  220. color: '#39b3ff'
  221. }]),
  222. new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  223. offset: 0,
  224. color: '#39b3ff'
  225. }, {
  226. offset: 0.5,
  227. color: '#39b3ff'
  228. }, {
  229. offset: 0.5,
  230. color: '#39b3ff'
  231. }, {
  232. offset: 1,
  233. color: '#39b3ff'
  234. }]),
  235. ];
  236. return colorList[params.dataIndex]
  237. },
  238. },
  239. "data": [1, 1, 1, 1, 1]
  240. },
  241. {
  242. "name": "",
  243. "type": "pictorialBar",
  244. symbol: path,
  245. "symbolSize": [60, 20],
  246. "symbolOffset": [0, 0],
  247. "z": 12,
  248. label: {
  249. show: true,
  250. formatter: "{c}人",
  251. position: 'top',
  252. distance: 5,
  253. color: '#fff',
  254. fontWeight: 100,
  255. textShadowColor: 'rgba(255, 255, 255, .6)',
  256. fontSize: 16,
  257. textShadowBlur: '0',
  258. textShadowOffsetX: 1,
  259. textShadowOffsetY: 1,
  260. },
  261. itemStyle: {
  262. opacity: 1,
  263. color: function (params) {
  264. const colorList = ['#39b3ff', '#39b3ff', '#39b3ff', '#39b3ff', '#39b3ff'];
  265. return colorList[params.dataIndex]
  266. },
  267. },
  268. "symbolPosition": "end",
  269. "data": data1
  270. },
  271. {
  272. name: '',
  273. type: "effectScatter",
  274. rippleEffect: {
  275. period: 1,
  276. scale: 5,
  277. brushType: 'fill'
  278. },
  279. z: 20,
  280. symbolPosition: 'end',
  281. symbol: path,
  282. "symbolSize": [15, 5],
  283. "symbolOffset": [0, 9],
  284. itemStyle: {
  285. normal: {
  286. color: '#fff',
  287. }
  288. },
  289. data: data1
  290. },
  291. ]
  292. };
  293. const backImg = "/asset/get/s/data-1622796959507-HTopachtJ.png"
  294. myChartss._dom.style.backgroundImage = "url('" + backImg + "')";
  295. myChartss.setOption(option12);
  296. }