From f62526a22b6b081bb3f2e08e7ac1e16ab3078aba Mon Sep 17 00:00:00 2001 From: "2090205686@qq.com" Date: Thu, 22 May 2025 15:40:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E5=87=BA=E5=93=81=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/custom-echart-bar/index.vue | 13 +- .../src/styles/common/define.scss | 2 - .../views/entities/components/valueCharts.vue | 119 +++++++++++++++--- .../src/views/land/components/landOne.vue | 1 + 4 files changed, 111 insertions(+), 24 deletions(-) diff --git a/new-digital-agriculture-screen/src/components/custom-echart-bar/index.vue b/new-digital-agriculture-screen/src/components/custom-echart-bar/index.vue index d1b5e37..1e34cdf 100644 --- a/new-digital-agriculture-screen/src/components/custom-echart-bar/index.vue +++ b/new-digital-agriculture-screen/src/components/custom-echart-bar/index.vue @@ -33,10 +33,16 @@ export default { type: Boolean, default: false, }, + // 是否展示高亮圈圈 showMarkPoint: { type: Boolean, default: false, }, + // 是否堆叠展示 + isHorizontal: { + type: Boolean, + default: false, + }, }, emits: ['click'], setup(props, { emit }) { @@ -67,10 +73,6 @@ export default { type: 'value', }, series: [], - isHorizontal: { - type: Boolean, - default: false, - }, }); watchEffect(() => { @@ -108,8 +110,9 @@ export default { option.series = props.isSeries && option.series.length > 0 ? option.series : seriesData; if (props.isHorizontal) { option.yAxis.data = xAxisData; - } else { option.xAxis.data = []; + } else { + option.xAxis.data = xAxisData; } console.log(option); setOptions(option); diff --git a/new-digital-agriculture-screen/src/styles/common/define.scss b/new-digital-agriculture-screen/src/styles/common/define.scss index c08d1cc..dffc95c 100644 --- a/new-digital-agriculture-screen/src/styles/common/define.scss +++ b/new-digital-agriculture-screen/src/styles/common/define.scss @@ -11,8 +11,6 @@ .custom-tooltip-container{ border-radius: 8px !important; - padding: 6px 16px 6px 8px !important; - background-color: rgba(0,0,0,0.7) !important; backdrop-filter: blur(8px) !important; & span{ width: 8px !important; diff --git a/new-digital-agriculture-screen/src/views/entities/components/valueCharts.vue b/new-digital-agriculture-screen/src/views/entities/components/valueCharts.vue index 397fe75..8f990d7 100644 --- a/new-digital-agriculture-screen/src/views/entities/components/valueCharts.vue +++ b/new-digital-agriculture-screen/src/views/entities/components/valueCharts.vue @@ -16,6 +16,15 @@ const props = defineProps({ }, }); +let values = reactive([]); +const getValue = (dataList) => { + let arr = []; + for (let i = 0; i < dataList.length; i++) { + arr.push(dataList[i].value); + } + return arr; +}; + const state = reactive({ data: [], option: { @@ -45,10 +54,10 @@ const state = reactive({ extraCssText: 'backdrop-filter: blur(8px);', }, barStyle: { - barWidth: 10, + barWidth: 14, itemStyle: { - borderWidth: 10, - borderRadius: [8, 8, 8, 8], // 设置柱子的圆角半径 + borderWidth: 14, + borderRadius: [10, 10, 10, 10], // 设置柱子的圆角半径 }, color: { type: 'linear', @@ -86,25 +95,100 @@ const state = reactive({ show: false, }, }, - yAxis: { - type: 'category', - data: ['耿马镇', '勐撒镇', '勐永镇', '孟定镇', '大兴乡'], - axisTick: { - show: false, + yAxis: [ + { + type: 'category', + data: ['耿马镇', '勐撒镇', '勐永镇', '孟定镇', '大兴乡'], + axisTick: { + show: false, + }, + splitLine: { + show: false, + }, + axisLine: { + show: false, + }, }, - splitLine: { - show: false, + { + // 右侧数量 + type: 'category', + inverse: true, + offset: 10, + axisTick: 'none', + axisLine: 'none', + show: true, + axisLabel: { + textStyle: { + color: '#ffffff', + fontSize: '16', + }, + formatter: function (value) { + let str = '{title|' + value + '吨}'; + return str; + }, + rich: { + title: { + color: '#fff', + fontSize: 16, + }, + }, + }, + data: [12000, 8000, 6000, 4000, 3500], }, - axisLine: { - show: false, - }, - }, + ], series: [ { + name: '值', type: 'bar', - // barWidth: '40%', // 设置柱的宽度 - // barMinHeight: 2, // 设置柱的最小高度 - // barGap: '20%', // 设置柱之间的间隙 + zlevel: 1, + barBorderRadius: 10, + itemStyle: { + borderRadius: [10, 10, 10, 10], + color: 'rgba(100, 200, 255, 0.3)', + }, + backgroundStyle: { + color: 'rgba(100, 200, 255, 0.3)', + borderRadius: [10, 10, 10, 10], // 必须与barBorderRadius保持一致 + }, + barWidth: 20, + data: values, + label: { + position: [0, -16], + align: 'left', + show: true, + formatter: (params) => { + return params.name; + }, + }, + barMaxWidth: 40, + markLine: { + label: { + color: '#26a69a', + }, + }, + }, + { + name: '背景', + type: 'bar', + barWidth: 20, + barGap: '-100%', + data: [], + barBorderRadius: 30, + itemStyle: { + normal: { + color: 'rgba(105,131,242,.3)', + borderRadius: 10, + }, + }, + label: { + show: false, + }, + barMaxWidth: 40, + markLine: { + label: { + color: '#26a69a', + }, + }, }, ], }, @@ -148,6 +232,7 @@ const loadData = (val) => { } } } + values = getValue(state.data); console.log(val); }; diff --git a/new-digital-agriculture-screen/src/views/land/components/landOne.vue b/new-digital-agriculture-screen/src/views/land/components/landOne.vue index 8c7cf27..b510852 100644 --- a/new-digital-agriculture-screen/src/views/land/components/landOne.vue +++ b/new-digital-agriculture-screen/src/views/land/components/landOne.vue @@ -23,6 +23,7 @@ const state = reactive({ containLabel: true, }, tooltip: { + show: true, trigger: 'axis', axisPointer: { type: 'shadow',