Ver Fonte

fix: 断面图修改

hum há 1 ano atrás
pai
commit
eaf1d52067

+ 4 - 10
ruoyi-ui/src/views/site/plain-time/chart-list.vue

@@ -4,7 +4,6 @@
 
 <script>
 import * as echarts from "echarts";
-require('echarts/theme/macarons') // echarts theme
 import resize from '@/utils/resize'
 
 export default {
@@ -39,15 +38,14 @@ export default {
         return;
       }
       const { sections, wlevelmax, wlevelmin, list } = plain;
-      const xAxisData = sections.map(({ x }) => x);
       const seriesData = sections.map(({ x, y }) => ([x, y]));
       const options = {
         xAxis: {
           name: '起点距',
           boundaryGap: false,
           type: 'value',
-          min: Math.min(...xAxisData),
-          max: Math.max(...xAxisData),
+          min: 'dataMin',
+          max: 'dataMax',
           axisLine: {
             lineStyle: {
               color: '#FF8500'
@@ -87,12 +85,8 @@ export default {
             nameTextStyle: {
               color: '#54606C'
             },
-            min: function (value) {
-              return Math.round(value.min - (value.max - value.min) * 0.1);
-            },
-            max: function (value) {
-              return Math.round(value.max + (value.max - value.min) * 0.1);
-            },
+            min: 'dataMin',
+            max: 'dataMax',
           },
           {
             axisLine: {

+ 6 - 11
ruoyi-ui/src/views/site/plain-time/chart.vue

@@ -4,7 +4,6 @@
 
 <script>
 import * as echarts from "echarts";
-require('echarts/theme/macarons') // echarts theme
 import resize from '@/utils/resize'
 
 export default {
@@ -39,14 +38,14 @@ export default {
         return;
       }
       const { sections, wlevelmax, wlevelmin, wlevel } = plain;
-      const xAxisData = sections.map(({ x }) => x);
-      const seriesData = sections.map(({ y }) => y);
+      const seriesData = sections.map(({ x, y }) => [x, y]);
       const options = {
         xAxis: {
           name: '起点距',
           boundaryGap: false,
-          data: xAxisData,
-          type: 'category',
+          type: 'value',
+          min: 'dataMin',
+          max: 'dataMax',
           axisLine: {
             lineStyle: {
               color: '#FF8500'
@@ -86,12 +85,8 @@ export default {
             nameTextStyle: {
               color: '#54606C'
             },
-            min: function (value) {
-              return Math.round(value.min - (value.max - value.min) * 0.1);
-            },
-            max: function (value) {
-              return Math.round(value.max + (value.max - value.min) * 0.1);
-            },
+            min: 'dataMin',
+            max: 'dataMax',
           },
           {
             axisLine: {

+ 4 - 10
ruoyi-ui/src/views/site/plain-water/chart-list.vue

@@ -4,7 +4,6 @@
 
 <script>
 import * as echarts from "echarts";
-require('echarts/theme/macarons') // echarts theme
 import resize from '@/utils/resize'
 
 export default {
@@ -39,15 +38,14 @@ export default {
         return;
       }
       const { sections, wlevelmax, wlevelmin, list } = plain;
-      const xAxisData = sections.map(({ x }) => x);
       const seriesData = sections.map(({ x, y }) => ([x, y]));
       const options = {
         xAxis: {
           name: '起点距',
           boundaryGap: false,
           type: 'value',
-          min: Math.min(...xAxisData),
-          max: Math.max(...xAxisData),
+          min: 'dataMin',
+          max: 'dataMax',
           axisLine: {
             lineStyle: {
               color: '#FF8500'
@@ -87,12 +85,8 @@ export default {
             nameTextStyle: {
               color: '#54606C'
             },
-            min: function (value) {
-              return Math.round(value.min - (value.max - value.min) * 0.1);
-            },
-            max: function (value) {
-              return Math.round(value.max + (value.max - value.min) * 0.1);
-            },
+            min: 'dataMin',
+            max: 'dataMax',
           },
           {
             axisLine: {

+ 6 - 10
ruoyi-ui/src/views/site/plain-water/chart.vue

@@ -4,7 +4,6 @@
 
 <script>
 import * as echarts from "echarts";
-require('echarts/theme/macarons') // echarts theme
 import resize from '@/utils/resize'
 
 export default {
@@ -46,8 +45,8 @@ export default {
           name: '起点距',
           boundaryGap: false,
           type: 'value',
-          min: Math.min(...xAxisData),
-          max: Math.max(...xAxisData),
+          min: 'dataMin',
+          max: 'dataMax',
           axisLine: {
             lineStyle: {
               color: '#FF8500'
@@ -87,12 +86,8 @@ export default {
             nameTextStyle: {
               color: '#54606C'
             },
-            min: function (value) {
-              return Math.round(value.min - (value.max - value.min) * 0.1);
-            },
-            max: function (value) {
-              return Math.round(value.max + (value.max - value.min) * 0.1);
-            },
+            min: 'dataMin',
+            max: 'dataMax',
           },
           {
             axisLine: {
@@ -172,7 +167,7 @@ export default {
           lineStyle: {
             width: 0,
           },
-          data: new Array(seriesData.length).fill(wlevel),
+          data: [[Math.min(...xAxisData), wlevel], [Math.max(...xAxisData), wlevel]],
           type: 'line',
           markLine: {
             symbol: 'none',
@@ -189,6 +184,7 @@ export default {
           },
         });
       }
+      this.chart.clear();
       this.chart.setOption(options);
     }
   }