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

98 lines
1.8 KiB
Vue
Raw Normal View History

2021-11-16 14:49:02 +08:00
<template>
<v-chart :option="option" />
</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";
2021-11-23 07:44:22 +08:00
import { reactive } from "vue";
2021-11-16 14:49:02 +08:00
use([
CanvasRenderer,
TitleComponent,
GaugeChart
]);
2021-11-23 07:44:22 +08:00
const option = reactive({
2021-11-16 14:49:02 +08:00
title: {
text: '航向',
left: 'center'
},
series: [
{
type: 'gauge',
radius: '65%',
min : 0,
max : 360,
splitNumber: 12,
startAngle: 90,
endAngle:450,
axisLine: {
lineStyle: {
// color: '#ff0000'
width: 30
}
},
axisTick:{
lineStyle: {
color: '#eee'
},
},
axisLabel:{
distance: -20,
formatter: function(v: Number){
switch(v){
case 0 : return '北';
case 90 : return '东';
case 180: return '南';
case 270: return '西';
case 360: return '';
default : return v;
}
}
},
splitLine: {
length :15,
lineStyle: {
color: '#eee'
}
},
pointer:{
length :'40%',
width :8,
itemStyle: {
color: 'rgb(0,0,255)'
}
},
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>