浏览代码

fix: a2屏

mzr 2 周之前
父节点
当前提交
4f06643c0e
共有 3 个文件被更改,包括 103 次插入67 次删除
  1. 1 1
      package.json
  2. 101 65
      src/views/components/resident/index.vue
  3. 1 1
      yarn.lock

+ 1 - 1
package.json

@@ -23,7 +23,7 @@
     "vue-count-to": "^1.0.13",
     "vue-router": "^3.0.3",
     "vue-seamless-scroll": "^1.1.17",
-    "vue-tianditu": "2.7.6",
+    "vue-tianditu": "^2.7.6",
     "vuex": "^3.0.1"
   },
   "devDependencies": {

+ 101 - 65
src/views/components/resident/index.vue

@@ -84,13 +84,6 @@ export default {
     initChart () {
       const myChart = echarts.init(this.$refs.dom)
       const option = {
-        name: '仪表盘',
-        grid: {
-          top: '0px',
-          bottom: '5px',
-          left: '0px',
-          right: '0px'
-        },
         title: {
           show: true,
           text: [`{titleBg|关注率}`],
@@ -104,69 +97,112 @@ export default {
                 height: 26,
                 width: 70,
                 color: '#00CAFF',
-                fontSize: 16
+                fontSize: 14
               }
             }
           }
         },
-        series: [
-          {
-            type: 'gauge',
-            radius: '100%',
-            name: '绘服务',
-            axisLine: {
-              show: true,
-              lineStyle: {
-                width: 15,
-                color: [
-                  [
-                    0,
-                    new echarts.graphic.LinearGradient(0, 1, 0, 0, [
-                      {
-                        offset: 0,
-                        color: this.colorArr[1]
-                      },
-                      {
-                        offset: 1,
-                        color: this.colorArr[2]
-                      }
-                    ])
-                  ],
-                  [
-                    1, this.colorArr[0]
-                  ]
-                ]
-              }
-            },
-            splitLine: {
-              show: false
-            },
-            axisTick: {
-              show: false
-            },
-            axisLabel: {
-              show: false
-            },
-            pointer: {
-              show: false
-            },
-            title: {
-              offsetCenter: [0, '25%'],
-              fontSize: 14,
-              fontFamily: 'Microsoft YaHei',
-              fontWeight: '400',
-              color: '#5774A2'
-            },
-            detail: {
-              formatter: '{value}%',
-              offsetCenter: [0, '-10%'],
-              fontSize: 22,
-              fontFamily: 'DS-Digital',
-              fontWeight: 'bold',
-              color: '#00D2ED'
-            },
-            data: [{ value: 75, name: '绘服务' }]
+        angleAxis: {
+          show: false,
+          max: 100 * 360 / 270, // -45度到225度,二者偏移值是270度除360度
+          type: 'value',
+          startAngle: 225, // 极坐标初始角度
+          splitLine: {
+            show: false
           }
+        },
+        barMaxWidth: 16, // 圆环宽度
+        radiusAxis: {
+          show: false,
+          type: 'category'
+        },
+        // 圆环位置和大小
+        polar: {
+          center: ['50%', '50%'],
+          radius: '140'
+        },
+        series: [{
+          type: 'bar',
+          data: [{ // 上层圆环,显示数据
+            value: 75,
+            itemStyle: {
+              color: { // 图形渐变颜色方法,四个数字分别代表,右,下,左,上,offset表示0%到100%
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 1, // 从左到右 0-1
+                y2: 0,
+                colorStops: [{
+                  offset: 0,
+                  color: this.colorArr[1]
+                }, {
+                  offset: 1,
+                  color: this.colorArr[2]
+                }]
+              }
+            }
+          }],
+          // barGap: '-100%', // 柱间距离,上下两层圆环重合
+          coordinateSystem: 'polar',
+          roundCap: true // 顶端圆角从 v4.5.0 开始支持
+          // z: 2 // 圆环层级,同zindex
+        },
+        { // 下层圆环,显示最大值
+          type: 'bar',
+          data: [{
+            value: 100,
+            itemStyle: {
+              color: this.colorArr[0]
+            }
+          }],
+          barGap: '-100%',
+          coordinateSystem: 'polar',
+          roundCap: true,
+          z: 1
+        },
+        // 仪表盘
+        {
+          name: '关注率',
+          type: 'gauge',
+          axisLine: {
+            show: false
+          },
+          splitLine: {
+            show: false
+          },
+          axisTick: {
+            show: false
+          },
+          axisLabel: {
+            show: false
+          },
+          splitLabel: {
+            show: false
+          },
+          pointer: {
+            show: false
+          },
+          title: {
+            offsetCenter: [0, '45%'],
+            fontSize: 14,
+            fontFamily: 'Microsoft YaHei',
+            fontWeight: '400',
+            color: '#5774A2'
+          },
+          detail: {
+            formatter: '{value}%',
+            offsetCenter: [0, '-10%'],
+            fontSize: 22,
+            fontFamily: 'DS-Digital',
+            fontWeight: 'bold',
+            color: '#00D2ED'
+          },
+          data: [{
+            value: 75,
+            name: '绘服务'
+            // name: 75 + '\n' + '{a|' + '首要污染物:PM10' + '}'
+          }]
+        }
         ]
       }
       myChart.setOption(option)

+ 1 - 1
yarn.lock

@@ -9431,7 +9431,7 @@ vue-template-es2015-compiler@^1.9.0:
   resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
   integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==
 
-vue-tianditu@2.7.6:
+vue-tianditu@^2.7.6:
   version "2.7.6"
   resolved "https://registry.npmmirror.com/vue-tianditu/-/vue-tianditu-2.7.6.tgz#c48425c49306300cae9664182dd170c626a38371"
   integrity sha512-Yvcxg0IAgGB3ZY8zlC5ayjo9f85fa8PFTaifguTNpri76g67GO9toaRWMjBKi39yYHMBADaT3P6bEkJx87X8MQ==