index1.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <el-row>
  3. <div id="index1" ref="echartD" style="width:100%;height:300px;"></div>
  4. </el-row>
  5. </template>
  6. <script>
  7. import * as echarts from "echarts";
  8. export default {
  9. // props: ["resData"],
  10. props: {
  11. dataMap: { type: Number, default: () => 0 },
  12. dataNumber: { type: Number, default: () => 0 },
  13. color: { type: String, default: () => "#468EFD" },
  14. size: { type: Number, default: () => 20 },
  15. tick: { type: Boolean, default: () => true },
  16. with: { type: Number, default: () => 200 },
  17. },
  18. data() {
  19. return {};
  20. },
  21. watch: {
  22. dataMap(val) {
  23. this.getData(val);
  24. },
  25. dataNumber(val) {
  26. this.getData(val);
  27. },
  28. },
  29. mounted() {
  30. this.getData();
  31. },
  32. methods: {
  33. getData() {
  34. echarts.init(this.$refs.echartD).setOption({
  35. grid: {
  36. // top: 0,
  37. // bottom: 0,
  38. // left: 0,
  39. // right: 0,
  40. // margi
  41. },
  42. series: [
  43. // 进度条
  44. {
  45. name: "仪表盘",
  46. type: "gauge",
  47. radius: "55%", // 半径
  48. startAngle: 270, //开始角度 左侧角度
  49. endAngle: -89.999, //结束角度 右侧
  50. splitNumber: 20,
  51. axisLine: {
  52. lineStyle: {
  53. color: [
  54. [this.dataMap, this.color],
  55. [1, "#FF0087"],
  56. ],
  57. width: this.with,
  58. },
  59. },
  60. axisLabel: {
  61. show: false,
  62. },
  63. axisTick: {
  64. show: false,
  65. },
  66. splitLine: {
  67. show: false,
  68. },
  69. itemStyle: {
  70. show: false,
  71. },
  72. detail: {
  73. formatter: (value) => {
  74. return this.dataNumber ? this.dataNumber :`${(value * 100).toFixed(0)}%`;
  75. },
  76. offsetCenter: [0, "0%"],
  77. textStyle: {
  78. //fontSize: this.size,
  79. fontSize: this.size,
  80. fontWeight: "700",
  81. color:this.color,
  82. // color: "#FFF",
  83. fontFamily: '"DS", "DS-B", "DS-BB", "DS-BS"',
  84. },
  85. },
  86. title: {
  87. offsetCenter: [0, "10%"],
  88. },
  89. pointer: {
  90. show: false,
  91. },
  92. data: [
  93. (this.dataNumber || this.dataMap),
  94. ],
  95. },
  96. ],
  97. });
  98. // window.addEventListener("resize", function() {
  99. // myChart.resize();
  100. // });
  101. },
  102. }
  103. };
  104. </script>
  105. <style lang="scss" scoped></style>