149 lines
3.5 KiB
Vue
149 lines
3.5 KiB
Vue
<template>
|
|
<Box title="稻虾产业">
|
|
<div class="h-full flex flex-col">
|
|
<div class="flex-1" ref="chartRef"> </div>
|
|
</div>
|
|
</Box>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent, reactive, ref, Ref, onBeforeMount, watch } from 'vue'
|
|
import Box from './Box.vue'
|
|
import { useECharts } from '/@/hooks/web/useECharts'
|
|
import { getRiceShrimpIndustry } from '/@/api/sys/other'
|
|
import { useVisualizationStore } from '/@/store/modules/visualization'
|
|
|
|
export default defineComponent({
|
|
components: {
|
|
Box,
|
|
},
|
|
setup() {
|
|
const Data = reactive({
|
|
x_axis: [],
|
|
series: [],
|
|
})
|
|
|
|
const chartRef = ref<HTMLDivElement | null>(null)
|
|
|
|
const visualizationStore = useVisualizationStore()
|
|
|
|
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
|
|
|
|
async function getData() {
|
|
const resData = await getRiceShrimpIndustry({
|
|
year: visualizationStore.getYear,
|
|
})
|
|
Data.x_axis = resData.x_axis
|
|
Data.series = resData.series
|
|
console.log(Data)
|
|
chartsInit()
|
|
}
|
|
|
|
const chartsInit = () => {
|
|
const legendData = []
|
|
const series = []
|
|
Data.series.forEach((e) => {
|
|
legendData.push(e.name)
|
|
})
|
|
return
|
|
setOptions({
|
|
grid: { left: '2%', right: '2%', top: '10%', bottom: '2%', containLabel: true },
|
|
legend: {
|
|
data: ['销售水量', '主营业务'],
|
|
top: '0%',
|
|
right: '0',
|
|
textStyle: {
|
|
color: '#ffffff',
|
|
},
|
|
},
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
lineStyle: {
|
|
width: 1,
|
|
color: '#019680',
|
|
},
|
|
},
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
data: Data.x_axis,
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
axisLine: {
|
|
show: false,
|
|
},
|
|
axisLabel: {
|
|
color: '#fff',
|
|
},
|
|
},
|
|
yAxis: [
|
|
{
|
|
type: 'value',
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
splitLine: {
|
|
lineStyle: {
|
|
type: 'solid',
|
|
color: '#8EEEFF',
|
|
opacity: 0.3,
|
|
},
|
|
},
|
|
axisLabel: {
|
|
color: '#fff',
|
|
},
|
|
},
|
|
],
|
|
series: [
|
|
{
|
|
name: '销售水量',
|
|
data: [11, 22, 40, 18, 3, 55, 66, 33, 14, 30],
|
|
type: 'line',
|
|
symbol: 'none',
|
|
itemStyle: {
|
|
color: '#00F4B9',
|
|
},
|
|
areaStyle: {
|
|
color: 'rgba(0, 244, 185, 0.4)',
|
|
},
|
|
},
|
|
{
|
|
name: '主营业务',
|
|
data: [11, 22, 40, 18, 3, 55, 66, 33, 14, 30].reverse(),
|
|
type: 'line',
|
|
symbol: 'none',
|
|
itemStyle: {
|
|
color: '#28F2E6',
|
|
},
|
|
areaStyle: {
|
|
color: 'rgba(40, 242, 230, 0.4)',
|
|
},
|
|
},
|
|
],
|
|
})
|
|
}
|
|
|
|
onBeforeMount(() => {
|
|
getData()
|
|
})
|
|
|
|
watch(
|
|
() => visualizationStore.getYear,
|
|
() => getData(),
|
|
)
|
|
|
|
return {
|
|
chartRef,
|
|
}
|
|
},
|
|
})
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.active {
|
|
@apply font-bold text-15px text-[#76E9F0];
|
|
}
|
|
</style>
|