From 51ad59e2373cd307fef7918fbc52d9a61e308086 Mon Sep 17 00:00:00 2001 From: yuzongping <835949940@qq.com> Date: Tue, 10 Jun 2025 15:08:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=AA=E5=90=91=E6=9F=B1=E7=8A=B6=E5=9B=BE?= =?UTF-8?q?=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/charts/horizontal-bar/icon.png | Bin 0 -> 630 bytes .../charts/horizontal-bar/index.html | 1 + src/components/charts/horizontal-bar/index.js | 201 ++++++++++++++++++ .../charts/horizontal-bar/index.scss | 6 + .../charts/horizontal-bar/index.vue | 3 + src/views/resources/comps/buttom/1/data.js | 40 +--- src/views/resources/comps/left/top/1/1.png | Bin 2934 -> 0 bytes src/views/resources/comps/left/top/1/2.png | Bin 2890 -> 0 bytes src/views/resources/comps/left/top/1/3.png | Bin 2848 -> 0 bytes src/views/resources/comps/left/top/1/data.js | 26 --- .../resources/comps/left/top/1/index.html | 15 +- src/views/resources/comps/left/top/1/index.js | 6 +- .../resources/comps/left/top/1/index.scss | 16 +- .../resources/comps/right/bottom/1/index.html | 4 +- .../resources/comps/right/bottom/1/index.js | 1 + .../resources/comps/right/middle/1/index.html | 12 +- .../resources/comps/right/middle/1/index.js | 14 +- .../resources/comps/right/middle/1/index.scss | 17 ++ 18 files changed, 278 insertions(+), 84 deletions(-) create mode 100644 src/components/charts/horizontal-bar/icon.png create mode 100644 src/components/charts/horizontal-bar/index.html create mode 100644 src/components/charts/horizontal-bar/index.js create mode 100644 src/components/charts/horizontal-bar/index.scss create mode 100644 src/components/charts/horizontal-bar/index.vue delete mode 100644 src/views/resources/comps/left/top/1/1.png delete mode 100644 src/views/resources/comps/left/top/1/2.png delete mode 100644 src/views/resources/comps/left/top/1/3.png delete mode 100644 src/views/resources/comps/left/top/1/data.js diff --git a/src/components/charts/horizontal-bar/icon.png b/src/components/charts/horizontal-bar/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1e2736d31748412623e715a0005f3cde76253880 GIT binary patch literal 630 zcmV-+0*U>JP)Px%FiAu~R5(wilut;LaTv!x&sMovtu{*t49X-boOXyc=cR*?7}T*cvglyTOH#+K zU5n}<<{{9?>{w75bm-EiBcgnTBL4*rgW0xN%?)YqFWzmsz42;-@8LZ>&+qyCp6B^J z-$$_cJi&>RN>n>Y0My>X5t#!O5+#F)-ul=7hDo`hs&o91vdJTaCejO#n1XE5fPljd zo?6&i4T`Yn>Poz?;mdOT3TS6gJ7E)f&fr zHGWlH+F_*_B{}0l8-m=DHDuXp-vZuq1~estKi=d0oCkS=;~_HfCf@h`A5soG)(OsC z;Y6=DAVy;mHNwXMNY1QeqW0}UT|bX%ZY;F=-6!P15HdSo%GN0JXa^{1756o*U(&G- zB0VOE{^U07*k&#v61 z%hGN_i*J?EBG|j{Sd-qKWc4%&ZoPtpe+x@4jKYw8$wGf#f8ymd%6EzgZ$iR9>|3f=qlnUtgN0+(gZb_7pg)e(7-9 zB--VJ<~0&4Y=DfhMgXU0eQTur*5YEjfFb}C7aMa3A<^~0#KXpt42pq&0eZar^9W1J QGXMYp07*qoM6N<$g5xc~qF literal 0 HcmV?d00001 diff --git a/src/components/charts/horizontal-bar/index.html b/src/components/charts/horizontal-bar/index.html new file mode 100644 index 0000000..d60fced --- /dev/null +++ b/src/components/charts/horizontal-bar/index.html @@ -0,0 +1 @@ +
diff --git a/src/components/charts/horizontal-bar/index.js b/src/components/charts/horizontal-bar/index.js new file mode 100644 index 0000000..6b44938 --- /dev/null +++ b/src/components/charts/horizontal-bar/index.js @@ -0,0 +1,201 @@ +import * as echarts from 'echarts'; +import elementResizeDetectorMaker from 'element-resize-detector'; +export default { + props: { + id: { + type: String, + default: 'horizontal-bar' + }, + data: { + type: Array, + default: function () { + return [ + { + name: '闲置', + value: '10' + }, + { + name: '出租/出借', + value: '19' + } + ]; + } + }, + unit: { + type: String, + default: '单位:万元' + }, + color: { + type: Array, + default: function () { + return ['rgba(15, 252, 252, 1)', 'rgba(53, 197, 124, 1)'] + } + } + }, + data () { + return { + icon: require('./icon.png'), + chart: null + }; + }, + mounted () { + this.initChart(); + }, + computed: { + }, + methods: { + // 设置监听器 页面尺寸变化重新绘制图表 + initResizeCallBack () { + const erd = elementResizeDetectorMaker(); + erd.listenTo(document.getElementById(this.id), () => { + this.$nextTick(() => { + this.chart.resize(); + }); + }); + }, + initChart () { + this.chart = echarts.init(document.getElementById(this.id)); + this.chartSetOption(); + }, + chartSetOption () { + let yAxis1 = []; + let yAxis2 = []; + let data = []; + + let pictorialBarData = []; + this.data.forEach((item, index) => { + yAxis1.push(item.name) + yAxis2.push(item.value + '亩') + data.push( + { + value: item.value, + itemStyle: { + color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [ + { + offset: 0, + color: index === 0 ? 'rgba(134, 91, 252, 1)' : 'rgba(15, 252, 252, 1)', + }, + { + offset: 1, + color: index === 0 ? 'rgba(49, 129, 246, 1)' : 'rgba(194, 255, 255, 1)', + }, + ]), + }, + } + ) + + + pictorialBarData.push({ + value: item.value, + itemStyle: { + color: "rgba(255, 255, 255, 1)", + }, + }) + }); + const option = { + tooltip: { + trigger: "axis", + axisPointer: { + type: "shadow", + }, + formatter: function (objs, index) { + let obj = objs[0]; + return `${obj.name}
${obj.marker}${obj.seriesName} : ${obj.value}%`; + }, + }, + grid: { + top: "3%", + left: "3%", + right: "4%", + bottom: "3%", + containLabel: true, + }, + xAxis: { + show: false, + type: "value", + boundaryGap: [0, 0.01], + interval: 20, + min: 0, + max: 100, + splitLine: { + lineStyle: { + type: "dashed", + }, + }, + axisLine: { + show: false, + lineStyle: { + color: "#909396", + }, + }, + axisLabel: { + formatter: function (value, index) { + return value + "%"; + }, + color: "#303439", + }, + axisTick: { + show: false, + }, + }, + yAxis: [ + { + type: "category", + boundaryGap: true, + axisLabel: { + formatter: "{value}", + textStyle: { + color: "rgba(185, 211, 235, 1)", + }, + }, + axisLine: { + show: false + }, + axisTick: { + show: false, + }, + data: yAxis1, + }, + { + type: "category", + boundaryGap: true, + axisLabel: { + formatter: "{value}", + textStyle: { + color: "rgba(185, 211, 235, 1)", + }, + }, + axisLine: { + show: false + }, + axisTick: { + show: false, + }, + data: yAxis2, + } + ], + series: [ + { + name: "", + barMaxWidth: 6, + type: "bar", + data: data, + }, + { + name: "2", + barMaxWidth: 10, + type: "pictorialBar", + symbol: 'rect', + symbolSize: [4, 14], + symbolOffset: [4, 0], + symbolPosition: 'end', + data: pictorialBarData, + } + ], + }; + this.chart.setOption(option); + this.initResizeCallBack(); + + } + } +}; diff --git a/src/components/charts/horizontal-bar/index.scss b/src/components/charts/horizontal-bar/index.scss new file mode 100644 index 0000000..b89d9dc --- /dev/null +++ b/src/components/charts/horizontal-bar/index.scss @@ -0,0 +1,6 @@ +.chart { + overflow: visible; + width: 100%; + height: 100%; + z-index: 2; +} \ No newline at end of file diff --git a/src/components/charts/horizontal-bar/index.vue b/src/components/charts/horizontal-bar/index.vue new file mode 100644 index 0000000..5ca257a --- /dev/null +++ b/src/components/charts/horizontal-bar/index.vue @@ -0,0 +1,3 @@ +