Merge branch 'main' of http://47.109.205.240:3000/Web/digital-agriculture-screen
This commit is contained in:
commit
cb914e8582
@ -33,7 +33,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance, resize } = useEcharts(chartRef);
|
const { setOptions, getInstance, resize, startAutoPlay } = useEcharts(chartRef);
|
||||||
const optionVal = reactive({});
|
const optionVal = reactive({});
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
@ -55,6 +55,11 @@ export default {
|
|||||||
Object.assign(optionVal, cloneDeep(props.option));
|
Object.assign(optionVal, cloneDeep(props.option));
|
||||||
}
|
}
|
||||||
setOptions(props.option);
|
setOptions(props.option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
resize();
|
resize();
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
|
@ -34,7 +34,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance } = useEcharts(chartRef);
|
const { setOptions, getInstance, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
@ -138,6 +138,11 @@ export default {
|
|||||||
option.series = seriesData;
|
option.series = seriesData;
|
||||||
option.xAxis.data = xAxisData;
|
option.xAxis.data = xAxisData;
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance, resize, registerMap } = useEcharts(chartRef);
|
const { setOptions, getInstance, resize, registerMap, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
// series: [],
|
// series: [],
|
||||||
});
|
});
|
||||||
@ -68,6 +68,11 @@ export default {
|
|||||||
}
|
}
|
||||||
// option.series = props.chartData;
|
// option.series = props.chartData;
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
registerMap(props.name, props.geo);
|
registerMap(props.name, props.geo);
|
||||||
resize();
|
resize();
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
|
@ -29,7 +29,7 @@ export default {
|
|||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions } = useEcharts(chartRef);
|
const { setOptions, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
@ -84,6 +84,11 @@ export default {
|
|||||||
option.series = seriesData;
|
option.series = seriesData;
|
||||||
option.xAxis.data = xAxisData;
|
option.xAxis.data = xAxisData;
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return { chartRef };
|
return { chartRef };
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance, resize } = useEcharts(chartRef);
|
const { setOptions, getInstance, resize, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
grid: {
|
grid: {
|
||||||
left: '3%',
|
left: '3%',
|
||||||
@ -104,6 +104,11 @@ export default {
|
|||||||
Object.assign(option, cloneDeep(props.option));
|
Object.assign(option, cloneDeep(props.option));
|
||||||
}
|
}
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
resize();
|
resize();
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance, resize } = useEcharts(chartRef);
|
const { setOptions, getInstance, resize, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
series: [],
|
series: [],
|
||||||
});
|
});
|
||||||
@ -58,6 +58,11 @@ export default {
|
|||||||
}
|
}
|
||||||
option.series = props.chartData;
|
option.series = props.chartData;
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
resize();
|
resize();
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance, resize } = useEcharts(chartRef);
|
const { setOptions, getInstance, resize, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
tooltip: {
|
tooltip: {
|
||||||
formatter: '{b} ({c})',
|
formatter: '{b} ({c})',
|
||||||
@ -74,6 +74,11 @@ export default {
|
|||||||
}
|
}
|
||||||
option.series[0].data = props.chartData;
|
option.series[0].data = props.chartData;
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
resize();
|
resize();
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
|
@ -34,7 +34,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance } = useEcharts(chartRef);
|
const { setOptions, getInstance, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
title: {
|
title: {
|
||||||
text: '',
|
text: '',
|
||||||
@ -78,6 +78,11 @@ export default {
|
|||||||
option.radar.indicator = indicator;
|
option.radar.indicator = indicator;
|
||||||
option.series[0]['data'] = data;
|
option.series[0]['data'] = data;
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance, resize } = useEcharts(chartRef);
|
const { setOptions, getInstance, resize, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
series: [],
|
series: [],
|
||||||
});
|
});
|
||||||
@ -58,6 +58,11 @@ export default {
|
|||||||
}
|
}
|
||||||
option.series = props.chartData;
|
option.series = props.chartData;
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
resize();
|
resize();
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance, resize } = useEcharts(chartRef);
|
const { setOptions, getInstance, resize, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
tooltip: {
|
tooltip: {
|
||||||
formatter: '{b} ({c})',
|
formatter: '{b} ({c})',
|
||||||
@ -73,6 +73,11 @@ export default {
|
|||||||
Object.assign(option, cloneDeep(props.option));
|
Object.assign(option, cloneDeep(props.option));
|
||||||
}
|
}
|
||||||
setOptions(props.option);
|
setOptions(props.option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
resize();
|
resize();
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
|||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
const { setOptions, getInstance, resize } = useEcharts(chartRef);
|
const { setOptions, getInstance, resize, startAutoPlay } = useEcharts(chartRef);
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
series: [],
|
series: [],
|
||||||
});
|
});
|
||||||
@ -58,6 +58,11 @@ export default {
|
|||||||
}
|
}
|
||||||
option.series = props.chartData;
|
option.series = props.chartData;
|
||||||
setOptions(option);
|
setOptions(option);
|
||||||
|
startAutoPlay({
|
||||||
|
interval: 2000,
|
||||||
|
seriesIndex: 0,
|
||||||
|
showTooltip: true,
|
||||||
|
});
|
||||||
resize();
|
resize();
|
||||||
getInstance()?.off('click', onClick);
|
getInstance()?.off('click', onClick);
|
||||||
getInstance()?.on('click', onClick);
|
getInstance()?.on('click', onClick);
|
||||||
|
@ -6,6 +6,57 @@ import { useBreakpoint } from './useBreakpoint';
|
|||||||
import echarts from '../utils/echarts';
|
import echarts from '../utils/echarts';
|
||||||
|
|
||||||
export const useEcharts = (elRef, theme = 'default') => {
|
export const useEcharts = (elRef, theme = 'default') => {
|
||||||
|
// 新增轮播相关状态
|
||||||
|
const autoPlayTimer = ref(null);
|
||||||
|
const currentIndex = ref(-1);
|
||||||
|
const dataLength = ref(0);
|
||||||
|
|
||||||
|
// 新增方法 - 启动轮播
|
||||||
|
const startAutoPlay = (options = {}) => {
|
||||||
|
const {
|
||||||
|
interval = 2000, // 轮播间隔(ms)
|
||||||
|
seriesIndex = 0, // 默认操作第一个系列
|
||||||
|
showTooltip = true, // 是否显示提示框
|
||||||
|
} = options;
|
||||||
|
|
||||||
|
stopAutoPlay(); // 先停止已有轮播
|
||||||
|
|
||||||
|
// 获取数据长度
|
||||||
|
const seriesData = unref(getOptions).series?.[seriesIndex]?.data;
|
||||||
|
dataLength.value = seriesData?.length || 0;
|
||||||
|
if (dataLength.value === 0) return;
|
||||||
|
|
||||||
|
autoPlayTimer.value = setInterval(() => {
|
||||||
|
currentIndex.value = (currentIndex.value + 1) % dataLength.value;
|
||||||
|
|
||||||
|
// 执行轮播动作
|
||||||
|
chartInstance?.dispatchAction({
|
||||||
|
type: 'downplay',
|
||||||
|
seriesIndex: seriesIndex,
|
||||||
|
});
|
||||||
|
chartInstance?.dispatchAction({
|
||||||
|
type: 'highlight',
|
||||||
|
seriesIndex: seriesIndex,
|
||||||
|
dataIndex: currentIndex.value,
|
||||||
|
});
|
||||||
|
if (showTooltip) {
|
||||||
|
chartInstance?.dispatchAction({
|
||||||
|
type: 'showTip',
|
||||||
|
seriesIndex: seriesIndex,
|
||||||
|
dataIndex: currentIndex.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, interval);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 新增方法 - 停止轮播
|
||||||
|
const stopAutoPlay = () => {
|
||||||
|
if (autoPlayTimer.value) {
|
||||||
|
clearInterval(autoPlayTimer.value);
|
||||||
|
autoPlayTimer.value = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const getDarkMode = computed(() => {
|
const getDarkMode = computed(() => {
|
||||||
return theme === 'default' ? 'dark' : theme;
|
return theme === 'default' ? 'dark' : theme;
|
||||||
});
|
});
|
||||||
@ -31,23 +82,39 @@ export const useEcharts = (elRef, theme = 'default') => {
|
|||||||
if (!el || !unref(el)) {
|
if (!el || !unref(el)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
nextTick(() => {
|
||||||
|
if (el.offsetWidth === 0 || el.offsetHeight === 0) {
|
||||||
|
// console.warn('图表容器不可见,延迟初始化');
|
||||||
|
useTimeoutFn(() => initCharts(t), 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
chartInstance = echarts.init(el, t);
|
chartInstance = echarts.init(el, t);
|
||||||
const { removeEvent } = useEventListener({
|
const { removeEvent } = useEventListener({
|
||||||
el: window,
|
el: window,
|
||||||
name: 'resize',
|
name: 'resize',
|
||||||
listener: resizeFn,
|
listener: resizeFn,
|
||||||
|
});
|
||||||
|
removeResizeFn = removeEvent;
|
||||||
|
const { widthRef } = useBreakpoint();
|
||||||
|
if (unref(widthRef) <= 768 || el.offsetHeight === 0) {
|
||||||
|
useTimeoutFn(() => {
|
||||||
|
resizeFn();
|
||||||
|
}, 30);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
removeResizeFn = removeEvent;
|
|
||||||
const { widthRef } = useBreakpoint();
|
|
||||||
if (unref(widthRef) <= 768 || el.offsetHeight === 0) {
|
|
||||||
useTimeoutFn(() => {
|
|
||||||
resizeFn();
|
|
||||||
}, 30);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOptions(options = {}, clear = true) {
|
function setOptions(options = {}, clear = true) {
|
||||||
|
const mergedOptions = {
|
||||||
|
animation: true,
|
||||||
|
animationDuration: 3000,
|
||||||
|
animationEasing: 'cubicOut',
|
||||||
|
...unref(options),
|
||||||
|
animationThreshold: 2000, // 数据量超过2000自动关闭动画
|
||||||
|
animationDelayUpdate: (idx) => idx * 50, // 数据项延迟
|
||||||
|
};
|
||||||
|
cacheOptions.value = mergedOptions;
|
||||||
cacheOptions.value = options;
|
cacheOptions.value = options;
|
||||||
if (unref(elRef)?.offsetHeight === 0) {
|
if (unref(elRef)?.offsetHeight === 0) {
|
||||||
useTimeoutFn(() => {
|
useTimeoutFn(() => {
|
||||||
@ -98,6 +165,7 @@ export const useEcharts = (elRef, theme = 'default') => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
tryOnUnmounted(() => {
|
tryOnUnmounted(() => {
|
||||||
|
stopAutoPlay(); // 清理定时器
|
||||||
if (!chartInstance) return;
|
if (!chartInstance) return;
|
||||||
removeResizeFn();
|
removeResizeFn();
|
||||||
chartInstance.dispose();
|
chartInstance.dispose();
|
||||||
@ -115,7 +183,9 @@ export const useEcharts = (elRef, theme = 'default') => {
|
|||||||
setOptions,
|
setOptions,
|
||||||
resize,
|
resize,
|
||||||
echarts,
|
echarts,
|
||||||
getInstance,
|
getInstance: () => chartInstance,
|
||||||
registerMap,
|
registerMap,
|
||||||
|
startAutoPlay, // 暴露轮播方法
|
||||||
|
stopAutoPlay,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -5,21 +5,21 @@
|
|||||||
<el-row style="width: 100%; height: 100%">
|
<el-row style="width: 100%; height: 100%">
|
||||||
<el-col :span="6" class="left-charts">
|
<el-col :span="6" class="left-charts">
|
||||||
<div class="left-charts-item">
|
<div class="left-charts-item">
|
||||||
<customBack top-title="土地资源分布" :top-postion="'left'">
|
<customBack top-title="耕地面积统计" :top-postion="'left'">
|
||||||
<template #back>
|
<template #back>
|
||||||
<distributionCharts></distributionCharts>
|
<distributionCharts></distributionCharts>
|
||||||
</template>
|
</template>
|
||||||
</customBack>
|
</customBack>
|
||||||
</div>
|
</div>
|
||||||
<div class="left-charts-item">
|
<div class="left-charts-item">
|
||||||
<customBack top-title="土地流转信息" :top-postion="'left'">
|
<customBack top-title="农村土地资源" :top-postion="'left'">
|
||||||
<template #back>
|
<template #back>
|
||||||
<landCirculation></landCirculation>
|
<landCirculation></landCirculation>
|
||||||
</template>
|
</template>
|
||||||
</customBack>
|
</customBack>
|
||||||
</div>
|
</div>
|
||||||
<div class="left-charts-item">
|
<div class="left-charts-item">
|
||||||
<customBack top-title="土地使用巡查案件" :top-postion="'left'">
|
<customBack top-title="项目效益分析" :top-postion="'left'">
|
||||||
<template #back>
|
<template #back>
|
||||||
<landPatrol></landPatrol>
|
<landPatrol></landPatrol>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user