Files
gnss-tool-kit/src/render/components/Compass.vue

109 lines
2.2 KiB
Vue
Raw Normal View History

2021-11-16 14:49:02 +08:00
<template>
2024-03-25 14:52:39 +08:00
<v-chart id="myCompass" :option="option" />
2021-11-16 14:49:02 +08:00
</template>
<script lang="ts" setup>
import { use } from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
import { TitleComponent } from "echarts/components";
import { GaugeChart } from "echarts/charts";
import VChart from "vue-echarts";
2024-03-25 14:52:39 +08:00
import { reactive, onMounted } from "vue";
2021-11-16 14:49:02 +08:00
2026-03-18 16:39:48 +08:00
use([ CanvasRenderer, TitleComponent, GaugeChart ]);
const props = defineProps({
styleMode: String
});
2021-11-16 14:49:02 +08:00
2024-03-25 14:52:39 +08:00
onMounted(() => {
var mychart = document.getElementById("myCompass");
mychart.firstChild.style.margin = "auto";
});
2021-11-23 07:44:22 +08:00
const option = reactive({
2021-11-16 14:49:02 +08:00
title: {
text: '航向',
2021-11-27 16:11:30 +08:00
left: 'center',
textStyle: {
color: '#fff'
}
2021-11-16 14:49:02 +08:00
},
series: [
{
type: 'gauge',
2021-11-27 16:11:30 +08:00
radius: '60%',
2021-11-16 14:49:02 +08:00
min : 0,
max : 360,
2021-11-27 16:11:30 +08:00
splitNumber: 8,
2021-11-16 14:49:02 +08:00
startAngle: 90,
2021-11-27 16:11:30 +08:00
endAngle: 450,
// axisLine: {
// lineStyle: {
// color: '#fff',
// width: 5
// }
// },
2021-11-16 14:49:02 +08:00
axisTick:{
2021-11-27 16:11:30 +08:00
distance: 0,
2021-11-16 14:49:02 +08:00
lineStyle: {
2021-11-27 16:11:30 +08:00
color: 'white',
width: 2
}
2021-11-16 14:49:02 +08:00
},
axisLabel:{
2021-11-27 16:11:30 +08:00
color: 'white',
2026-03-18 16:39:48 +08:00
distance: props.styleMode == "small" ? -35 : -40,
fontSize: props.styleMode == "small" ? 12 : 18,
2021-11-16 14:49:02 +08:00
formatter: function(v: Number){
switch(v){
case 0 : return '北';
case 90 : return '东';
case 180: return '南';
case 270: return '西';
2021-11-27 16:11:30 +08:00
default : return '';
2021-11-16 14:49:02 +08:00
}
}
},
splitLine: {
length :15,
2021-11-27 16:11:30 +08:00
distance: 0,
2021-11-16 14:49:02 +08:00
lineStyle: {
2021-11-27 16:11:30 +08:00
color: 'white'
2021-11-16 14:49:02 +08:00
}
},
pointer:{
2021-11-27 16:11:30 +08:00
width: 5,
2021-11-16 14:49:02 +08:00
itemStyle: {
2021-11-27 16:11:30 +08:00
color: '#2AB8FF'
2021-11-16 14:49:02 +08:00
}
},
detail: {
show:false
},
2021-11-23 07:44:22 +08:00
data: [{ value: 0 }]
2021-11-16 14:49:02 +08:00
}
]
});
2021-11-23 07:44:22 +08:00
const update = (variation: number, variationPole: string) => {
switch (variationPole) {
case 'N':
break;
case 'E':
variation += 90
break;
case 'S':
variation += 180
break;
case 'W':
variation += 270
break;
}
option.series[0].data[0].value = variation
}
2021-11-16 14:49:02 +08:00
defineExpose({ update })
</script>