当前位置:   article > 正文

echarts水波球特效(附带外边框进度条)_水波球插件

水波球插件

这里用到了echarts的liquidFill图表,需要加载liquidFill插件 

npm i echarts-liquidFill --save

1. 在main.js入口文件中引入

也可通过script标签形式引入 

<script src="http://echarts.baidu.com/resource/echarts-liquidfill-1.0.4/dist/echarts-liquidfill.js" type="text/javascript" charset="utf-8"></script>

 2.option配置如下(可根据需要自行配置,大概的配置点已经注释出来了)

    

  1. chart.setOption({
  2. // backgroundColor: "#050038",
  3. title: {
  4. text: `总完成`,
  5. left: "center",
  6. top: "100",
  7. textStyle: {
  8. fontWeight: "normal",
  9. fontSize: 20,
  10. color: "rgb(0,0,0)"
  11. },
  12. subtext: `${this.progress.num}%`, //副标题
  13. subtextStyle: {
  14. fontWeight: "bold",
  15. fontSize: 40,
  16. color: "rgb(0,0,0)"
  17. }
  18. },
  19. series: [
  20. {
  21. type: "liquidFill", // 图表类型
  22. radius: "80%",
  23. center: ["50%", "50%"],
  24. data: [
  25. this.progress.num / 100,
  26. this.progress.num / 100,
  27. this.progress.num / 100
  28. ], // data个数代表波浪数
  29. backgroundStyle: {
  30. borderWidth: 1,
  31. color: "#F4F9FF"
  32. },
  33. label: {
  34. normal: {
  35. show: false, //不显示label 用副标题代替了
  36. formatter: (0.5 * 100).toFixed(0) + "%",
  37. textStyle: {
  38. fontSize: 38,
  39. color: "black"
  40. }
  41. }
  42. },
  43. color: [ //color一定要是个数组 ,每一项对应一个波浪,可以给每个波浪单独配置颜色
  44. {
  45. type: "linear",
  46. x: 0,
  47. y: 0,
  48. x2: 0,
  49. y2: 1,
  50. colorStops: [
  51. {
  52. offset: 1,
  53. color: "rgba(255,255,255,1)"
  54. },
  55. {
  56. offset: 0,
  57. color: "rgba(103,205,251,1)"
  58. }
  59. ],
  60. globalCoord: false
  61. },
  62. {
  63. type: "linear",
  64. x: 0,
  65. y: 0,
  66. x2: 0,
  67. y2: 1,
  68. colorStops: [
  69. {
  70. offset: 1,
  71. color: "rgba(187,248,252,0.5)"
  72. },
  73. {
  74. offset: 0,
  75. color: "rgba(30,134,245,1)"
  76. }
  77. ],
  78. globalCoord: false
  79. },
  80. {
  81. type: "linear",
  82. x: 0,
  83. y: 0,
  84. x2: 0,
  85. y2: 1,
  86. colorStops: [
  87. {
  88. offset: 1,
  89. color: "rgba(180,251,255,0.66)"
  90. },
  91. {
  92. offset: 0,
  93. color: "rgba(128,122,254,0.66)"
  94. }
  95. ],
  96. globalCoord: false
  97. }
  98. ],
  99. outline: {
  100. show: false
  101. }
  102. },
  103. //外层线
  104. {
  105. type: "pie",
  106. center: ["50%", "50%"],
  107. radius: ["92%", "93%"], //外层线粗细
  108. hoverAnimation: false,
  109. data: [
  110. {
  111. name: "",
  112. value: 100,
  113. labelLine: {
  114. show: false
  115. },
  116. itemStyle: {
  117. color: "#67CDFB"
  118. },
  119. emphasis: {
  120. labelLine: {
  121. show: false
  122. },
  123. itemStyle: {
  124. // color: "#5886f0"
  125. }
  126. }
  127. }
  128. ]
  129. },
  130. //进度线
  131. {
  132. type: "pie",
  133. center: ["50%", "50%"],
  134. radius: ["90%", "95%"], //进度线粗细
  135. hoverAnimation: false,
  136. data: [
  137. {
  138. name: "",
  139. value: this.progress.num, //进度
  140. labelLine: {
  141. show: false
  142. },
  143. itemStyle: {
  144. color: {
  145. type: "linear",
  146. x: 0,
  147. y: 0,
  148. x2: 1,
  149. y2: 2,
  150. colorStops: [
  151. // !! 在此添加渐变过程色 !!
  152. { offset: 0, color: "#33E2ED" },
  153. { offset: 1, color: "#807AFE" }
  154. ]
  155. }
  156. },
  157. emphasis: {
  158. labelLine: {
  159. show: false
  160. },
  161. itemStyle: {
  162. // color: "#5886f0"
  163. }
  164. }
  165. },
  166. {
  167. //画剩余的刻度圆环
  168. name: "",
  169. value: 100 - this.progress.num,
  170. itemStyle: {
  171. color: "rgba(0,0,0,0)"
  172. },
  173. label: {
  174. show: false
  175. },
  176. labelLine: {
  177. show: false
  178. },
  179. emphasis: {
  180. labelLine: {
  181. show: false
  182. },
  183. itemStyle: {
  184. color: "#050038"
  185. }
  186. }
  187. }
  188. ]
  189. }
  190. ]
  191. });
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/127836
推荐阅读
相关标签
  

闽ICP备14008679号