• 弹窗里面画echarts图 el-popover


    1. <el-popover
    2. popper-class="punishmentPopover"
    3. placement="top"
    4. width="500"
    5. trigger="click"
    6. >
    7. <div id="punishment" ref="punishment1" />
    8. <div slot="reference" class="type_left" @click="handlePunishment('处分',1)">
    9. <p>处分</p>
    10. <span>{{punishList.dj}}人</span>
    11. </div>
    12. </el-popover>

    样式:

    1. <style>
    2. .punishmentPopover {
    3. background-color: rgba(13, 5, 30, 0.9);
    4. border: 1px solid rgba(255, 255, 255, 0.3);
    5. border-radius: 5px;
    6. z-index: 99999;
    7. }
    8. .punishmentPopover .popper__arrow::after {
    9. border-top-color: rgba(13, 5, 30, 0.9) !important;
    10. }
    11. .punishmentPopover .popper__arrow {
    12. border-top-color: rgba(255, 255, 255, 0.3) !important;
    13. }
    14. .punishmentPopover #punishment {
    15. width: 350px;
    16. height: 350px;
    17. }
    18. </style>

    方法:

    1. async handlePunishment(type, index) {
    2. let params = Object.assign({}, this.params);
    3. params.dataType = type;
    4. let res = await getAction("/casetrial/getSecondPunish", params);
    5. let arr = res.data.punishList;
    6. // console.log(arr, "情况统计下钻");
    7. let data = [];
    8. if (arr.length > 0) {
    9. arr.forEach(item => {
    10. data.push({
    11. value: item.count,
    12. name: item.level
    13. });
    14. });
    15. let str = "punishment" + index;
    16. // console.log(this.$refs[str], "this.$refs[str]");
    17. const myChart = this.$echarts.init(this.$refs[str]);
    18. // console.log(myChart, "myChart this.$refs[str]");
    19. this.drawPunishmentEcharts(myChart, type, data);
    20. }
    21. },
    22. // 情况统计下钻 图形
    23. drawPunishmentEcharts(myChart, title, echartData) {
    24. const colorList = [
    25. {
    26. x: 0,
    27. y: 0,
    28. x2: 0,
    29. y2: 1,
    30. colorStops: [
    31. {
    32. offset: 1,
    33. color: "#006AFF" // 0% 处的颜色
    34. },
    35. {
    36. offset: 0,
    37. color: "#8CE2FF" // 100% 处的颜色
    38. }
    39. ]
    40. },
    41. {
    42. x: 0,
    43. y: 0,
    44. x2: 0,
    45. y2: 1,
    46. colorStops: [
    47. {
    48. offset: 0,
    49. color: "#92F092" // 0% 处的颜色
    50. },
    51. {
    52. offset: 1,
    53. color: "#4BB84B" // 100% 处的颜色
    54. }
    55. ]
    56. },
    57. {
    58. x: 0,
    59. y: 0,
    60. x2: 0,
    61. y2: 1,
    62. colorStops: [
    63. {
    64. offset: 0,
    65. color: "#8BA7D8" // 0% 处的颜色
    66. },
    67. {
    68. offset: 1,
    69. color: "#8FABDA" // 100% 处的颜色
    70. }
    71. ]
    72. },
    73. {
    74. x: 0,
    75. y: 0,
    76. x2: 0,
    77. y2: 1,
    78. colorStops: [
    79. {
    80. offset: 0,
    81. color: "#22B3FF" // 0% 处的颜色
    82. },
    83. {
    84. offset: 1,
    85. color: "#62C6FA" // 100% 处的颜色
    86. }
    87. ]
    88. }
    89. ];
    90. let formatNumber = function(num) {
    91. let reg = /(?=(\B)(\d{3})+$)/g;
    92. return num.toString().replace(reg, ",");
    93. };
    94. let option = {
    95. color: colorList,
    96. title: {
    97. text: title,
    98. show: true, // 是否显示标题,默认 true
    99. padding: [10, 0, 5, 0],
    100. textStyle: {
    101. color: "white",
    102. fontSize: fontChart(18),
    103. fontFamily: "Alibaba PuHuiTi",
    104. fontWeight: 600
    105. },
    106. left: "center"
    107. },
    108. tooltip: {
    109. trigger: "item",
    110. borderColor: "rgba(255,255,255,.3)",
    111. backgroundColor: "rgba(13,5,30,.6)",
    112. borderWidth: 1,
    113. padding: 5,
    114. textStyle: {
    115. color: "#fff"
    116. }
    117. },
    118. legend: {
    119. // orient: "vertical",
    120. bottom: 10,
    121. // right: 5,
    122. itemWidth: 20,
    123. itemHeight: 10,
    124. itemGap: 15,
    125. borderRadius: 4,
    126. textStyle: {
    127. color: "white",
    128. fontFamily: "Alibaba PuHuiTi",
    129. fontSize: fontChart(16),
    130. fontWeight: 400
    131. }
    132. },
    133. series: [
    134. {
    135. type: "pie",
    136. roseType: "radius",
    137. radius: ["5%", "50%"],
    138. center: ["50%", "45%"],
    139. data: echartData,
    140. hoverAnimation: false,
    141. itemStyle: {
    142. normal: {
    143. borderColor: "#15213F",
    144. borderWidth: 4
    145. }
    146. },
    147. label: {
    148. normal: {
    149. formatter: e => {
    150. let newStr = " ";
    151. let start = 0; //开始截取位置
    152. let end = 0; //截取结束位置
    153. const name_len = e.name.length; //每个内容名称的长度
    154. const max_name = 5; //每行显示的最大长度
    155. const new_row = Math.ceil(name_len / max_name); //显示行数
    156. if (name_len > max_name) {
    157. //如果名称长度大于每行最大显示长度,则
    158. for (let i = 0; i < new_row; i++) {
    159. //循环行数
    160. let old = ""; //每次截取的字符
    161. start = i * max_name; //截取的起点
    162. end = start + max_name; //截取的终点
    163. if (i == new_row - 1) {
    164. //如果是最后一行
    165. old = e.name.substring(start);
    166. } else {
    167. old = e.name.substring(start, end) + "\n"; //截取内容加换行
    168. }
    169. newStr += old; //拼接字符串
    170. }
    171. } else {
    172. //否则不变显示
    173. newStr = e.name;
    174. }
    175. return (
    176. "{value|" +
    177. formatNumber(e.value) +
    178. "%" +
    179. "}\n{name|" +
    180. newStr +
    181. "}"
    182. );
    183. },
    184. rich: {
    185. name: {
    186. fontSize: fontChart(14),
    187. color: "#F0F0F0"
    188. },
    189. value: {
    190. fontSize: fontChart(18),
    191. fontWeight: "bolder",
    192. color: "#F0F0F0"
    193. }
    194. },
    195. overflow: "none"
    196. }
    197. },
    198. labelLine: {
    199. length: 1,
    200. length2: 5
    201. }
    202. }
    203. ]
    204. };
    205. option && myChart.setOption(option);
    206. window.addEventListener("resize", function() {
    207. myChart.resize();
    208. });
    209. },

  • 相关阅读:
    命令执行漏洞
    华为云云耀云服务器L实例评测 | 分分钟完成打地鼠小游戏部署
    linux 性能分析工具perf
    2024年腾讯云轻量16核32G28M服务器优惠价格3468元15个月
    罗马数字转整数------题解报告
    概率密度函数曲线及绘制
    应用案例 | 基于三维机器视觉的自动化码垛解决方案
    DotNetGuide荣登GitHub C#中文 Trending 月榜第一
    推荐几款火爆的Python在线编辑器
    maven报orace,jdbc错误,并出现大量红色波浪线Unresolved dependency
  • 原文地址:https://blog.csdn.net/weixin_50885665/article/details/133882062