|
@@ -9,6 +9,9 @@ import * as echarts from "echarts";
|
|
|
require('echarts/theme/macarons') // echarts theme
|
|
|
import resize from '@/utils/resize'
|
|
|
import { getSiteSection } from '@/api/site/berthing'
|
|
|
+import { getCarLocation } from '@/api/analysis/achievement'
|
|
|
+import CarSvg from '@/assets/images/car.svg'
|
|
|
+import BarSvg from '@/assets/images/bar.svg'
|
|
|
|
|
|
export default {
|
|
|
mixins: [resize],
|
|
@@ -17,16 +20,22 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- sections: []
|
|
|
+ sections: [],
|
|
|
+ location: 0,
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
this.loadSection();
|
|
|
+ this.loadCarLocation();
|
|
|
this.$nextTick(() => {
|
|
|
this.chart = echarts.init(this.$refs.chart, 'macarons');
|
|
|
})
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
+ if (this.timer1) {
|
|
|
+ clearTimeout(this.timer1);
|
|
|
+ }
|
|
|
+
|
|
|
if (!this.chart) {
|
|
|
return
|
|
|
}
|
|
@@ -34,6 +43,14 @@ export default {
|
|
|
this.chart = null
|
|
|
},
|
|
|
methods: {
|
|
|
+ loadCarLocation() {
|
|
|
+ getCarLocation(this.siteId).then((res) => {
|
|
|
+ this.location = res.data?.position || 0;
|
|
|
+ this.setOptions();
|
|
|
+ }).finally(() => {
|
|
|
+ this.timer1 = setTimeout(() => this.loadCarLocation(), 5e3)
|
|
|
+ })
|
|
|
+ },
|
|
|
loadSection() {
|
|
|
getSiteSection(this.siteId).then((res) => {
|
|
|
this.sections = JSON.parse(res.data.positions) || [];
|
|
@@ -47,13 +64,25 @@ export default {
|
|
|
const xAxisData = this.sections.map(({ x }) => x);
|
|
|
const seriesData = this.sections.map(({ y }) => y);
|
|
|
const waterData = this.sections.map(() => 405);
|
|
|
+ const locationData = this.sections.map(() => 420);
|
|
|
+ const topData = this.sections.map(() => 430);
|
|
|
+
|
|
|
+ console.log(Math.min(...xAxisData), Math.max(...xAxisData))
|
|
|
+
|
|
|
const options = {
|
|
|
- xAxis: {
|
|
|
- name: '起点距',
|
|
|
- data: xAxisData,
|
|
|
- boundaryGap: false,
|
|
|
- show: false,
|
|
|
- },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ data: xAxisData,
|
|
|
+ boundaryGap: false,
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ min: Math.min(...xAxisData),
|
|
|
+ max: Math.max(...xAxisData),
|
|
|
+ show: false,
|
|
|
+ }
|
|
|
+ ],
|
|
|
yAxis: [
|
|
|
{
|
|
|
name: '高程',
|
|
@@ -70,48 +99,96 @@ export default {
|
|
|
containLabel: true
|
|
|
},
|
|
|
tooltip: {
|
|
|
- trigger: 'axis',
|
|
|
- axisPointer: {
|
|
|
- type: 'line'
|
|
|
- },
|
|
|
- formatter: function(prams) {
|
|
|
- return `时间:${prams[0].name}<br/>水位:${prams[0].data}m`;
|
|
|
- },
|
|
|
- padding: [5, 10]
|
|
|
+ show: false,
|
|
|
},
|
|
|
- series: [{
|
|
|
- name: '水位',
|
|
|
- type: 'line',
|
|
|
- silent: true,
|
|
|
- data: waterData,
|
|
|
- symbolSize: 0,
|
|
|
- lineStyle: {
|
|
|
- normal: {
|
|
|
- width: 0
|
|
|
- }
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: '水位',
|
|
|
+ type: 'line',
|
|
|
+ silent: true,
|
|
|
+ data: waterData,
|
|
|
+ symbol: 'none',
|
|
|
+ lineStyle: {
|
|
|
+ normal: {
|
|
|
+ width: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ areaStyle: {
|
|
|
+ normal: {
|
|
|
+ color: '#adcef8',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ z: 1,
|
|
|
},
|
|
|
- areaStyle: {
|
|
|
- normal: {
|
|
|
- color: '#adcef8',
|
|
|
- }
|
|
|
+ {
|
|
|
+ name: '小车',
|
|
|
+ type: 'scatter',
|
|
|
+ data: [[this.location, 420]],
|
|
|
+ symbol: `image://${CarSvg}`,
|
|
|
+ symbolSize: [50, 30],
|
|
|
+ xAxisIndex: 1,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: '#ff5722',
|
|
|
+ shadowColor: '#ff5722',
|
|
|
+ shadowBlur: 100
|
|
|
+ }
|
|
|
+ },
|
|
|
+ silent: true,
|
|
|
+ z: 3
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '柱子',
|
|
|
+ type: 'scatter',
|
|
|
+ data: [[40, 420]],
|
|
|
+ symbol: `image://${BarSvg}`,
|
|
|
+ symbolSize: [20, 500],
|
|
|
+ symbolOffset: [0, '50%'],
|
|
|
+ xAxisIndex: 1,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: '#ff5722',
|
|
|
+ shadowColor: '#ff5722',
|
|
|
+ shadowBlur: 100
|
|
|
+ }
|
|
|
+ },
|
|
|
+ silent: true,
|
|
|
+ z: 3
|
|
|
},
|
|
|
- z: 1,
|
|
|
- }, {
|
|
|
- name: '高程',
|
|
|
- type: 'line',
|
|
|
- symbol: false,
|
|
|
- smooth: false,
|
|
|
- data: seriesData,
|
|
|
- lineStyle: {
|
|
|
- color: '#FF8500',
|
|
|
+ {
|
|
|
+ name: '小车',
|
|
|
+ type: 'line',
|
|
|
+ data: topData,
|
|
|
+ symbol: 'none',
|
|
|
+ lineStyle: {
|
|
|
+ normal: {
|
|
|
+ width: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ areaStyle: {
|
|
|
+ normal: {
|
|
|
+ color: 'transparent',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ z: 0,
|
|
|
},
|
|
|
- areaStyle: {
|
|
|
- normal: {
|
|
|
- color: '#f6c27d',
|
|
|
- }
|
|
|
+ {
|
|
|
+ name: '高程',
|
|
|
+ type: 'line',
|
|
|
+ symbol: false,
|
|
|
+ smooth: false,
|
|
|
+ data: seriesData,
|
|
|
+ lineStyle: {
|
|
|
+ color: '#FF8500',
|
|
|
+ },
|
|
|
+ areaStyle: {
|
|
|
+ normal: {
|
|
|
+ color: '#f6c27d',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ z: 10,
|
|
|
},
|
|
|
- z: 2,
|
|
|
- }]
|
|
|
+ ]
|
|
|
};
|
|
|
this.chart.setOption(options);
|
|
|
},
|