index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <!--
  2. 描述: 环形饼图
  3. 作者: Jack Chen
  4. 日期: 2020-05-02
  5. -->
  6. <template>
  7. <div class="wrap-container sn-container">
  8. <div class="sn-content">
  9. <div class="sn-title">环形饼图</div>
  10. <div class="sn-body">
  11. <div class="wrap-container ring-pie">
  12. <div class="back-chart">
  13. <svg width="100%" height="100%" viewBox="0 0 150 150" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  14. <path id="svg_2" d="m3,75c0,-39.77901 32.22099,-72 72,-72c39.77901,0 72,32.22099 72,72c0,39.77901 -32.22099,72 -72,72c-39.77901,0 -72,-32.22099 -72,-72z" stroke="#2de6af" fill-opacity="null" fill="none"></path>
  15. </svg>
  16. </div>
  17. <div class="chartsdom" id="chart_rp"></div>
  18. <div class="arrow-cir arrow-cir1"></div>
  19. <div class="arrow-cir arrow-cir2"></div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. name: "ringPie",
  28. data() {
  29. return {
  30. option: null
  31. }
  32. },
  33. mounted() {
  34. this.getEchart();
  35. },
  36. methods: {
  37. getEchart() {
  38. let myChart = echarts.init(document.getElementById('chart_rp'));
  39. this.option = {
  40. series: [{
  41. name: '环形饼图',
  42. type: 'pie',
  43. radius: ['68%', '80%'],
  44. hoverAnimation: false,
  45. avoidLabelOverlap: false,
  46. label: {
  47. show: false,
  48. position: 'center'
  49. },
  50. emphasis: {
  51. label: {
  52. show: false
  53. }
  54. },
  55. labelLine: {
  56. show: false
  57. },
  58. data: [{
  59. value: 6,
  60. name: '区块链',
  61. itemStyle: {
  62. normal: {
  63. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  64. offset: 0,
  65. color: '#6984fe'
  66. },{
  67. offset: 1,
  68. color: '#24d1fd'
  69. }])
  70. }
  71. }
  72. },{
  73. value: 4,
  74. name: '大数据',
  75. itemStyle: {
  76. normal: {
  77. color: '#eee'
  78. }
  79. }
  80. }]
  81. }]
  82. }
  83. myChart.setOption(this.option, true);
  84. window.addEventListener('resize', () => {
  85. myChart.resize();
  86. });
  87. }
  88. },
  89. beforeDestroy() {
  90. }
  91. };
  92. </script>
  93. <style lang="scss" scoped>
  94. .sn-container {
  95. left: 974px;
  96. top: 1978px;
  97. width: 432px;
  98. height: 400px;
  99. .wrap-container {
  100. left: 125px;
  101. top: 94px;
  102. width: 150px;
  103. height: 150px;
  104. }
  105. .chartsdom {
  106. width: 100%;
  107. height: 100%;
  108. }
  109. .back-chart{
  110. width: 100%;
  111. height: 100%;
  112. position: absolute;
  113. left: 0;
  114. top: 0;
  115. background:url(../../assets/img/back_chart.png) no-repeat center;
  116. }
  117. .arrow-cir {
  118. width: 8px;
  119. height: 8px;
  120. offset-distance: 0%;
  121. position: absolute;
  122. top: 0;
  123. left: 0;
  124. opacity: 0;
  125. &.arrow-cir1 {
  126. background: url(../../assets/img/icon_04.png) no-repeat 50% 50%;
  127. -webkit-animation: arrow-cir1 5s linear infinite;
  128. animation: arrow-cir1 5s linear infinite;
  129. offset-path: path("m3,75c0,-39.77901 32.22099,-72 72,-72c39.77901,0 72,32.22099 72,72c0,39.77901 -32.22099,72 -72,72c-39.77901,0 -72,-32.22099 -72,-72z");
  130. }
  131. &.arrow-cir2 {
  132. background: url(../../assets/img/icon_05.png) no-repeat 50% 50%;
  133. -webkit-animation: arrow-cir2 5s linear infinite;
  134. animation: arrow-cir2 5s linear infinite;
  135. offset-path: path("m3,75c0,-39.77901 32.22099,-72 72,-72c39.77901,0 72,32.22099 72,72c0,39.77901 -32.22099,72 -72,72c-39.77901,0 -72,-32.22099 -72,-72z");
  136. }
  137. }
  138. }
  139. @-webkit-keyframes arrow-cir1 {
  140. 0% {
  141. offset-distance: 40%;
  142. opacity: 1;
  143. }
  144. 100% {
  145. offset-distance: 140%;
  146. opacity: 1;
  147. }
  148. }
  149. @keyframes arrow-cir1 {
  150. 0% {
  151. offset-distance: 40%;
  152. opacity: 1;
  153. }
  154. 100% {
  155. offset-distance: 140%;
  156. opacity: 1;
  157. }
  158. }
  159. @-webkit-keyframes arrow-cir2 {
  160. 0% {
  161. offset-distance: 0%;
  162. opacity: 1;
  163. }
  164. 100% {
  165. offset-distance: 100%;
  166. opacity: 1;
  167. }
  168. }
  169. @keyframes arrow-cir2 {
  170. 0% {
  171. offset-distance: 0%;
  172. opacity: 1;
  173. }
  174. 100% {
  175. offset-distance: 100%;
  176. opacity: 1;
  177. }
  178. }
  179. </style>