水滴图表

This commit is contained in:
lzc 2025-03-21 17:33:11 +08:00
parent deb882fa58
commit 4bd8c7222f
7 changed files with 187 additions and 1 deletions

View File

@ -24,6 +24,7 @@
"dayjs": "^1.11.11", "dayjs": "^1.11.11",
"echarts": "^5.6.0", "echarts": "^5.6.0",
"echarts-gl": "^2.0.9", "echarts-gl": "^2.0.9",
"echarts-liquidfill": "^3.1.0",
"element-plus": "^2.7.3", "element-plus": "^2.7.3",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"js-base64": "^3.7.7", "js-base64": "^3.7.7",

View File

@ -0,0 +1,88 @@
<template>
<div ref="chartRef" :style="{ height, width }"></div>
</template>
<script>
import { ref, reactive, watch, watchEffect } from 'vue';
import { cloneDeep } from 'lodash';
import { useEcharts } from '../../hooks/useEcharts';
export default {
name: 'customEchartWaterDroplet',
props: {
chartData: {
type: Array,
default: () => [],
},
size: {
type: Object,
default: () => {},
},
option: {
type: Object,
default: () => ({}),
},
width: {
type: String,
default: '100%',
},
height: {
type: String,
default: 'calc(100vh - 78px)',
},
},
emits: ['click'],
setup(props, { emit }) {
const chartRef = ref(null);
const { setOptions, getInstance, resize } = useEcharts(chartRef);
const option = reactive({
tooltip: {
formatter: '{b} ({c})',
},
series: [
{
type: 'pie',
radius: '72%',
center: ['50%', '55%'],
data: [],
labelLine: { show: true },
label: {
show: true,
formatter: '{b} \n ({d}%)',
color: '#B1B9D3',
},
},
],
});
watchEffect(() => {
props.chartData && initCharts();
});
watch(
() => props.size,
() => {
resize();
},
{
immediate: true,
}
);
function initCharts() {
if (props.option) {
Object.assign(option, cloneDeep(props.option));
}
setOptions(props.option);
resize();
getInstance()?.off('click', onClick);
getInstance()?.on('click', onClick);
}
function onClick(params) {
emit('click', params);
}
return { chartRef };
},
};
</script>

View File

@ -13,6 +13,7 @@ import customEchartPictorialBar from './custom-echart-pictorial-bar';
import CustomEchartLineLine from './custom-echart-line-line'; import CustomEchartLineLine from './custom-echart-line-line';
import CustomEchartBubble from './custom-echart-bubble'; import CustomEchartBubble from './custom-echart-bubble';
import CustomEchartPie3d from './custom-echart-pie-3d'; import CustomEchartPie3d from './custom-echart-pie-3d';
import CustomEchartWaterDroplet from './custom-echart-water-droplet';
export { export {
SvgIcon, SvgIcon,
@ -30,4 +31,5 @@ export {
CustomEchartLineLine, CustomEchartLineLine,
CustomEchartBubble, CustomEchartBubble,
CustomEchartPie3d, CustomEchartPie3d,
CustomEchartWaterDroplet,
}; };

View File

@ -2,6 +2,8 @@ import * as echarts from 'echarts/core';
import { BarChart, LineChart, PieChart, MapChart, PictorialBarChart, RadarChart, GraphChart } from 'echarts/charts'; import { BarChart, LineChart, PieChart, MapChart, PictorialBarChart, RadarChart, GraphChart } from 'echarts/charts';
import 'echarts-gl'; import 'echarts-gl';
import 'echarts-liquidfill';
import { import {
TitleComponent, TitleComponent,
TooltipComponent, TooltipComponent,

View File

@ -2190,6 +2190,11 @@ echarts-gl@^2.0.9:
claygl "^1.2.1" claygl "^1.2.1"
zrender "^5.1.1" zrender "^5.1.1"
echarts-liquidfill@^3.1.0:
version "3.1.0"
resolved "https://registry.npmmirror.com/echarts-liquidfill/-/echarts-liquidfill-3.1.0.tgz#4ec70f3697382d0404c95fff9f3e8dd85c8377da"
integrity sha512-5Dlqs/jTsdTUAsd+K5LPLLTgrbbNORUSBQyk8PSy1Mg2zgHDWm83FmvA4s0ooNepCJojFYRITTQ4GU1UUSKYLw==
echarts@^5.6.0: echarts@^5.6.0:
version "5.6.0" version "5.6.0"
resolved "https://registry.npmmirror.com/echarts/-/echarts-5.6.0.tgz#2377874dca9fb50f104051c3553544752da3c9d6" resolved "https://registry.npmmirror.com/echarts/-/echarts-5.6.0.tgz#2377874dca9fb50f104051c3553544752da3c9d6"

View File

@ -0,0 +1,83 @@
<template>
<div class="irrigation-charts">
<custom-echart-water-droplet height="100%" :option="option" />
</div>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
let percent = ref(0.6);
const option = reactive({
backgroundColor: 'transparent', //
series: [
{
name: '预估量',
type: 'liquidFill',
radius: '42%',
center: ['50%', '50%'],
backgroundStyle: {
color: 'transparent',
},
data: [percent.value, percent.value],
amplitude: 12, //
label: {
//
position: ['50%', '45%'],
formatter: percent.value * 100 + '%', //,
textStyle: {
fontSize: '26px', //,
color: '#fff',
},
},
outline: {
borderDistance: 3,
itemStyle: {
borderWidth: 2,
borderColor: {
type: 'linear',
x: 1,
y: 0,
x2: 0,
y2: 0,
colorStops: [
{
offset: 0,
color: '#007DFF',
},
{
offset: 0.6,
color: 'rgba(45, 67, 114, 1)',
},
{
offset: 1,
color: 'rgba(45, 67, 114, 1)',
},
],
globalCoord: false,
},
},
},
itemStyle: {
color: {
type: 'linear', // 线
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: '#45bfe9' },
{ offset: 1, color: '#01589c' },
],
global: false, // false
},
},
},
],
});
onMounted(() => {});
</script>
<style lang="scss" scoped>
.irrigation-charts {
height: 100%;
}
</style>

View File

@ -39,7 +39,11 @@
</customBack> </customBack>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<customBack top-title="智慧水肥灌溉" :top-postion="'right'"> <template #back></template> </customBack> <customBack top-title="智慧水肥灌溉" :top-postion="'right'">
<template #back>
<irrigationCharts></irrigationCharts>
</template>
</customBack>
</el-col> </el-col>
</el-row> </el-row>
</el-col> </el-col>
@ -72,6 +76,7 @@ import plantTypeCharts from './components/plantTypeCharts.vue';
import insectPestsCharts from './components/insectPestsCharts'; import insectPestsCharts from './components/insectPestsCharts';
import pathologyCharts from './components/pathologyCharts.vue'; import pathologyCharts from './components/pathologyCharts.vue';
import waterfertilizerCharts from './components/waterfertilizerCharts.vue'; import waterfertilizerCharts from './components/waterfertilizerCharts.vue';
import irrigationCharts from './components/irrigationCharts.vue';
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.data-home-index { .data-home-index {