• echarts 水球示例


    使用echarts水球要先安装水球的依赖。

    npm i echarts-liquidfill

    代码:

    1. // import Common from "./common";
    2. import * as echarts from "echarts";
    3. import "echarts-liquidfill/src/liquidFill.js";// ecahrts的水球
    4. export default class Water{
    5. constructor(el, option) {
    6. // super(el, option); // 调用父类的构造函数中的值
    7. this.$el = el;
    8. this.$e = echarts;//将echrts的相关属性赋值给$e
    9. this.option = option;
    10. this.init();
    11. }
    12. init() {
    13. this.myChart = this.$e.init(this.$el);// this.$el是要展示echarts的容器, this.$e.init表示调用echarts下面的init方法
    14. this.setCharts(); // 调用init方法
    15. this.myChart.setOption(this.chartOption, true);
    16. window.addEventListener("resize", () => { // 监听resize方法,如果触发这个事件,则调用父类中定义的这个方法
    17. this.myChart.resize();
    18. });
    19. }
    20. setCharts() {
    21. this.chartOption = {
    22. backgroundColor:"transparent",
    23. series: [
    24. {
    25. type: "liquidFill",
    26. radius: "90%",
    27. data: [
    28. this.option.data / 100,
    29. {
    30. value: (this.option.data - 10) / 100,
    31. direction: "left"
    32. }
    33. ],
    34. backgroundStyle: {
    35. borderWidth: 0.5,
    36. color:{
    37. type: 'radial',
    38. x: 0.5,
    39. y: 0.5,
    40. r: 0.5,
    41. colorStops: [{
    42. offset: 0,
    43. color: 'rgba(0,24,55, 0)'
    44. },
    45. {
    46. offset: 0.25,
    47. color: 'rgba(0,24,55, 0)'
    48. },
    49. {
    50. offset: 1,
    51. color: this.option.color
    52. }],
    53. globalCoord: false
    54. }
    55. },
    56. label: {
    57. textAlign: "center",
    58. textStyle: {
    59. fontSize: 18,
    60. fontWeight: "600",
    61. color: "#fff",
    62. textAlign: "center",
    63. textBorderColor: "red",
    64. textShadowColor: "red",
    65. textShadowBlur: "0",
    66. textShadowOffsetX: 0,
    67. textShadowOffsetY: 1
    68. }
    69. },
    70. color: [{
    71. type: "linear",
    72. x: 0,
    73. y: 0,
    74. x2: 1,
    75. y2: 1,
    76. colorStops: [{
    77. offset: 0,
    78. color: [this.option.color] // 0% 处的颜色
    79. }, {
    80. offset: 1,
    81. color: [this.option.color] // 100% 处的颜色
    82. }],
    83. global: false // 缺省为 false
    84. }],
    85. outline: { // 水球的外轮廓边框
    86. show: false,
    87. borderDistance: 2,
    88. itemStyle: {
    89. borderColor: this.option.color ,
    90. borderWidth: 1,
    91. }
    92. },
    93. // backgroundStyle: {
    94. // color: "rgba(67,209,100,.3)"
    95. // }
    96. // outline: {
    97. // show: true,
    98. // borderDistance: 5,
    99. // color:"red",
    100. // itemStyle: {
    101. // borderWidth: 0,
    102. // color: {
    103. // type: "linear",
    104. // x: 0,
    105. // y: 0,
    106. // x2: 1,
    107. // y2: 0,
    108. // colorStops: [{
    109. // offset: 0, color: "#fff" // 0% 处的颜色
    110. // }, {
    111. // offset: 1, color: "#fff" // 100% 处的颜色
    112. // }],
    113. // global: false // 缺省为 false
    114. // }
    115. // }
    116. // }
    117. }
    118. ]
    119. };
    120. }
    121. }

    实现的效果:

     

  • 相关阅读:
    【2023最新B站评论爬虫】用python爬取上千条哔哩哔哩评论
    河南大学数据分析可视化实验-数据分析基础
    【echarts】13、echarts+vue2 - 折线图
    神经网络层次分析模型,神经网络层次分析方法
    C++ 队列!还是要从 STL 中的说起……
    腾讯WeTest:为用户开新篇,七周年全球惠享巨献
    Fish Shell 的使用特性和优势
    python代码服务汇总
    Mac怎么删除文件和软件?苹果电脑删除第三方软件方法
    1067 试密码
  • 原文地址:https://blog.csdn.net/qq_44603011/article/details/126700860