PlatformSourceChart.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <!-- 平台来源 -->
  3. <div class="echarts">
  4. <ECharts :option="option" :resize="false" />
  5. </div>
  6. </template>
  7. <script setup lang="ts">
  8. import ECharts from "@/components/ECharts/index.vue";
  9. import { ECOption } from "@/components/ECharts/config";
  10. interface ChartProp {
  11. name: string;
  12. value: number;
  13. percentage: string;
  14. }
  15. const data = [
  16. { value: 40, name: "智慧文旅平台", percentage: "40%" },
  17. { value: 10, name: "携程", percentage: "10%" },
  18. { value: 20, name: "飞猪", percentage: "20%" },
  19. { value: 30, name: "其他渠道", percentage: "30%" }
  20. ];
  21. const option: ECOption = {
  22. grid: {
  23. top: "0%",
  24. left: "2%",
  25. right: "2%",
  26. bottom: "0%"
  27. },
  28. tooltip: {
  29. trigger: "item",
  30. formatter: "{b} : {c}人"
  31. },
  32. legend: {
  33. show: true,
  34. top: "middle",
  35. left: "20px",
  36. icon: "circle",
  37. orient: "vertical",
  38. align: "auto",
  39. itemWidth: 10,
  40. textStyle: {
  41. color: "#fff"
  42. },
  43. itemGap: 20,
  44. formatter: function (name: string) {
  45. let text = "";
  46. data.forEach((val: ChartProp) => {
  47. if (val.name === name) {
  48. text = name + " --- " + val.percentage;
  49. }
  50. });
  51. return text;
  52. },
  53. data: data.map((val: ChartProp) => val.name)
  54. },
  55. series: [
  56. {
  57. type: "pie",
  58. radius: ["60%", "85%"],
  59. center: ["68%", "45%"],
  60. color: ["#0E7CE2", "#FF8352", "#E271DE", "#F8456B", "#00FFFF", "#4AEAB0"],
  61. itemStyle: {
  62. borderColor: "#031845",
  63. borderWidth: 10
  64. },
  65. data: data,
  66. labelLine: {
  67. show: false
  68. },
  69. label: {
  70. show: false
  71. }
  72. },
  73. {
  74. type: "pie",
  75. radius: ["20%", "28%"],
  76. center: ["68%", "45%"],
  77. color: ["#ffffff", "red"],
  78. startAngle: 105,
  79. data: [
  80. {
  81. value: 30,
  82. name: "",
  83. itemStyle: {
  84. color: "transparent"
  85. }
  86. },
  87. {
  88. value: 5,
  89. name: "",
  90. itemStyle: {
  91. color: "transparent"
  92. }
  93. },
  94. {
  95. value: 65,
  96. name: "ddd",
  97. itemStyle: {
  98. color: "#ffffff"
  99. }
  100. }
  101. ],
  102. silent: true,
  103. labelLine: {
  104. show: false
  105. },
  106. label: {
  107. show: false
  108. }
  109. },
  110. {
  111. type: "pie",
  112. radius: [0, "30%"],
  113. center: ["68%", "45%"],
  114. startAngle: 90,
  115. data: [
  116. {
  117. value: 25,
  118. name: "1",
  119. itemStyle: {
  120. color: "transparent",
  121. borderWidth: 4,
  122. borderColor: "#ffffff"
  123. }
  124. },
  125. {
  126. value: 75,
  127. name: "2",
  128. itemStyle: {
  129. color: "transparent"
  130. }
  131. }
  132. ],
  133. selectedOffset: 10,
  134. silent: true,
  135. labelLine: {
  136. show: false
  137. },
  138. label: {
  139. show: false
  140. }
  141. },
  142. {
  143. type: "pie",
  144. radius: ["96%", "97%"],
  145. center: ["68%", "45%"],
  146. color: ["#007afe", "transparent", "#007afe", "transparent", "#007afe", "transparent"],
  147. data: [
  148. { value: 17, name: "11" },
  149. { value: 17, name: "22" },
  150. { value: 17, name: "33" },
  151. { value: 17, name: "44" },
  152. { value: 17, name: "55" },
  153. { value: 17, name: "66" }
  154. ],
  155. silent: true,
  156. labelLine: { show: false },
  157. label: { show: false }
  158. },
  159. {
  160. type: "pie",
  161. zlevel: 0,
  162. silent: true,
  163. radius: ["45%", "46%"],
  164. center: ["68%", "45%"],
  165. z: 10,
  166. label: { show: false },
  167. labelLine: { show: false },
  168. data: new Array(150).fill("").map((_val: string, index: number) => {
  169. if (index % 3 === 0) {
  170. return {
  171. name: (index + 1).toString(),
  172. value: 10,
  173. itemStyle: {
  174. color: "#fff",
  175. borderWidth: 0,
  176. borderColor: "rgba(0,0,0,0)"
  177. }
  178. };
  179. } else {
  180. return {
  181. name: (index + 1).toString(),
  182. value: 25,
  183. itemStyle: {
  184. color: "rgba(0,0,0,0)",
  185. borderWidth: 0,
  186. borderColor: "rgba(0,0,0,0)"
  187. }
  188. };
  189. }
  190. })
  191. },
  192. {
  193. type: "pie",
  194. zlevel: 0,
  195. silent: true,
  196. radius: ["58%", "60%"],
  197. center: ["68%", "45%"],
  198. z: 10,
  199. startAngle: 90,
  200. label: { show: false },
  201. color: ["red", "blue", "red", "blue"],
  202. labelLine: { show: false },
  203. data: [
  204. {
  205. name: "r1",
  206. value: 25,
  207. itemStyle: {
  208. color: {
  209. type: "linear",
  210. x: 0,
  211. y: 0,
  212. x2: 0,
  213. y2: 1,
  214. colorStops: [
  215. { offset: 0, color: "rgba(51,149,191,0.5)" },
  216. { offset: 1, color: "rgba(51,149,191,0)" }
  217. ],
  218. global: false
  219. }
  220. }
  221. },
  222. {
  223. name: "r2",
  224. value: 25,
  225. itemStyle: {
  226. color: {
  227. type: "linear",
  228. x: 0,
  229. y: 0,
  230. x2: 0,
  231. y2: 1,
  232. colorStops: [
  233. { offset: 0, color: "rgba(0,0,0,0)" },
  234. { offset: 1, color: "rgba(51,149,191,0.5)" }
  235. ],
  236. global: false
  237. }
  238. }
  239. },
  240. {
  241. name: "r3",
  242. value: 25,
  243. itemStyle: {
  244. color: {
  245. type: "linear",
  246. x: 0,
  247. y: 0,
  248. x2: 0,
  249. y2: 1,
  250. colorStops: [
  251. { offset: 0, color: "rgba(51,149,191,0)" },
  252. { offset: 1, color: "rgba(51,149,191,0.5)" }
  253. ],
  254. global: false
  255. }
  256. }
  257. },
  258. {
  259. name: "r4",
  260. value: 25,
  261. itemStyle: {
  262. color: {
  263. type: "linear",
  264. x: 0,
  265. y: 0,
  266. x2: 0,
  267. y2: 1,
  268. colorStops: [
  269. { offset: 0, color: "rgba(51,149,191,0.5)" },
  270. { offset: 1, color: "rgba(0,0,0,0)" }
  271. ],
  272. global: false
  273. }
  274. }
  275. }
  276. ]
  277. }
  278. ]
  279. };
  280. </script>
  281. <style lang="scss" scoped>
  282. .echarts {
  283. width: 100%;
  284. height: 100%;
  285. }
  286. </style>