pieCamera.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div id="main2" style="width: 100%; height: 100%"></div>
  3. </template>
  4. <script>
  5. import echarts from "echarts";
  6. export default {
  7. name: "pieCamera",
  8. mounted() {
  9. this.showMain();
  10. },
  11. methods: {
  12. showMain() {
  13. // 基于准备好的dom,初始化echarts实例
  14. var myChart = echarts.init(document.getElementById("main2"));
  15. var data = {
  16. name: "摄像头",
  17. value: [39],
  18. // nAmount: 566557.14,
  19. };
  20. var color = ["#C8E4FF", "#0483FF", "#0483FF"];
  21. var title=data.value[0];
  22. var per="%"
  23. // 指定图表的配置项和数据
  24. var option = {
  25. title: {
  26. text: '{a|'+ title +'}{b|'+ per +'}',
  27. textStyle: {
  28. rich:{
  29. a: {
  30. fontSize: 25,
  31. color: color[2],
  32. fontFamily: "impact",
  33. },
  34. b: {
  35. fontSize: 16,
  36. fontFamily: "impact",
  37. color: color[2],
  38. },
  39. }
  40. },
  41. subtext: '异常率',
  42. subtextStyle: {
  43. color: '#fff',
  44. fontSize:'12',
  45. },
  46. itemGap: 3,
  47. left: "center",
  48. top: "37%", //aa圈内标题的位置
  49. },
  50. graphic: [
  51. {
  52. type: "text",
  53. z: 100,
  54. left: "center",
  55. top: "90%", // aa 底下标题w在容器里的位置
  56. style: {
  57. fill: "#fff",
  58. text: data.name,
  59. // text: [
  60. // '横轴表示温度,单位是°C',
  61. // '纵轴表示高度,单位是km',
  62. // '右上角有一个图片做的水印',
  63. // '这个文本块可以放在图中各',
  64. // '种位置'
  65. // ].join('\n'),
  66. font: "1.6rem Microsoft YaHei", // aa 底下标题字体大小
  67. },
  68. },
  69. ],
  70. tooltip: { //aa 手指移入
  71. formatter: function (params) {
  72. return (
  73. '<span style="color: #fff;">占比:' + params.value + "%</span>"
  74. );
  75. },
  76. },
  77. angleAxis: {
  78. max: 100,
  79. clockwise: false, // 逆时针
  80. // 隐藏刻度线
  81. show: false,
  82. startAngle: 90,
  83. },
  84. radiusAxis: {
  85. type: "category",
  86. show: true,
  87. axisLabel: {
  88. show: false,
  89. },
  90. axisLine: {
  91. show: false,
  92. },
  93. axisTick: {
  94. show: false,
  95. },
  96. },
  97. polar: [
  98. {
  99. center: ["50%", "50%"], //中心点位置 aa填充圈的中心位置
  100. radius: "100%", //图形大小 aa填充圈的图形大小
  101. },
  102. ],
  103. series: [
  104. {
  105. name: "小环",
  106. type: "gauge",
  107. splitNumber: 15,
  108. radius: "75%", //aa发散圈的大小
  109. center: ["50%", "50%"],
  110. startAngle: 0,
  111. endAngle: 359.9999,
  112. axisLine: {
  113. show: false,
  114. },
  115. axisTick: {
  116. show: true,
  117. lineStyle: {
  118. color: color[1],
  119. width: 1, // aa发散圈的粗细
  120. shadowBlur: 1,
  121. shadowColor: color[1],
  122. },
  123. length: 8, // aa发散圈的长度
  124. splitNumber: 5, //aa发散圈每一条间隔
  125. },
  126. splitLine: {
  127. show: false,
  128. },
  129. axisLabel: {
  130. show: false,
  131. },
  132. detail: {
  133. show: false,
  134. },
  135. },
  136. {
  137. type: "bar",
  138. z: 10,
  139. data: data.value,
  140. showBackground: false,
  141. backgroundStyle: {
  142. color: color[1],
  143. borderWidth: 10,
  144. width: 10,
  145. },
  146. coordinateSystem: "polar",
  147. // roundCap: true, //aa填充圈圆角
  148. barWidth: 7, //aa填充圈宽度
  149. itemStyle: {
  150. normal: {
  151. opacity: 1,
  152. color: new echarts.graphic.LinearGradient(0, 0, 1, 1, [
  153. {
  154. offset: 0,
  155. color: color[0],
  156. },
  157. {
  158. offset: 1,
  159. color: color[1],
  160. },
  161. ]),
  162. shadowBlur: 5,
  163. shadowColor: "#2A95F9",
  164. },
  165. },
  166. },
  167. {
  168. type: "pie",
  169. name: "内层细圆环",
  170. radius: ["50%", "52%"], //aa内层细圆环
  171. center: ["50%", "50%"],
  172. startAngle: 120,
  173. hoverAnimation: false,
  174. clockWise: true,
  175. barWidth: 1,
  176. itemStyle: {
  177. normal: {
  178. color: new echarts.graphic.LinearGradient(0, 0, 1, 1, [
  179. {
  180. offset: 0,
  181. color: color[0],
  182. },
  183. {
  184. offset: 1,
  185. color: color[1],
  186. },
  187. ]),
  188. },
  189. },
  190. tooltip: {
  191. show: false,
  192. },
  193. label: {
  194. show: false,
  195. },
  196. data: [100],
  197. },
  198. ],
  199. };
  200. // 使用刚指定的配置项和数据显示图表。
  201. myChart.setOption(option);
  202. window.addEventListener("resize", function() {
  203. myChart.resize();
  204. });
  205. },
  206. },
  207. };
  208. </script>