From 9703b689b37296e6086eae4650613a8a070716d1 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Wed, 20 Dec 2023 11:49:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BC=AA3D=E6=9F=B1=E7=8A=B6?= =?UTF-8?q?=E5=9B=BE=E3=80=813D=E9=A5=BC=E5=9B=BE=E6=89=87=E5=BD=A2?= =?UTF-8?q?=E4=B8=8A=E5=A2=9E=E5=8A=A0=E6=A0=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/echarts/BarFake3d1.vue | 250 ++++++++++++++++++++++++++ src/components/echarts/Pie3d.vue | 55 +++++- src/components/scroll/ScrollPanel.vue | 2 +- src/module/ModuleBottom.vue | 6 +- src/module/ModuleLeft1.vue | 5 +- 5 files changed, 305 insertions(+), 13 deletions(-) create mode 100644 src/components/echarts/BarFake3d1.vue diff --git a/src/components/echarts/BarFake3d1.vue b/src/components/echarts/BarFake3d1.vue new file mode 100644 index 0000000..ddd6ca9 --- /dev/null +++ b/src/components/echarts/BarFake3d1.vue @@ -0,0 +1,250 @@ + + + + + \ No newline at end of file diff --git a/src/components/echarts/Pie3d.vue b/src/components/echarts/Pie3d.vue index 7c05b2c..54fb736 100644 --- a/src/components/echarts/Pie3d.vue +++ b/src/components/echarts/Pie3d.vue @@ -157,6 +157,7 @@ const getPie3D = (pieData) => { for (let i = 0; i < pieData.length; i++) { sumValue += pieData[i].value; let seriesItem = { + id: i, name: !pieData[i].name ? `series${i}` : pieData[i].name, type: "surface", parametric: true, @@ -182,14 +183,53 @@ const getPie3D = (pieData) => { } series.push(seriesItem); } + let barData = []; for (let i = 0; i < series.length; i++) { - endValue = startValue + series[i].pieData.value; - series[i].pieData.startRatio = startValue / sumValue; - series[i].pieData.endRatio = endValue / sumValue; - series[i].parametricEquation = getParametricEquation(series[i].pieData.startRatio, series[i].pieData.endRatio); + let pieData = series[i].pieData; + endValue = startValue + pieData.value; + pieData.startRatio = startValue / sumValue; + pieData.endRatio = endValue / sumValue; + series[i].parametricEquation = getParametricEquation(pieData.startRatio, pieData.endRatio); startValue = endValue; legendData.push(series[i].name); + // 柱子,为了在饼状图上显示数字 + let midRatio = (pieData.startRatio + pieData.endRatio) / 2; + barData.push({ + name: `${pieData.name}: ${pieData.value}`, + // 柱子透明 + itemStyle: { + color: [1, 1, 1, 0] + }, + label: { + show: true, + formatter: `{b}`, + textStyle: { + color: '#FFF', + fontSize: 12 + } + }, + value: [Math.sin(midRatio * Math.PI * 2) * 0.6, Math.cos(midRatio * Math.PI * 2) * 0.6, 0.1] + }) } + // 添加柱子,为了在饼状图上显示数字 + series.push({ + type: 'bar3D', + data: barData, + shading: 'lambert', + label: { + fontSize: 16, + borderWidth: 1 + }, + emphasis: { + label: { + fontSize: 20, + color: '#FFFFFF' + }, + itemStyle: { + color: '#FFFFFF' + } + } + }) let option = { legend: { show: true, @@ -229,12 +269,12 @@ const getPie3D = (pieData) => { left: -80, viewControl: { //3d效果可以放大、旋转等,请自己去查看官方配置 - alpha: 40, // 角度 - beta: 180, // 饼块开始位置角度 + alpha: 45, // 角度 + beta: 0, // 饼块开始位置角度 rotateSensitivity: 0, zoomSensitivity: 0, panSensitivity: 0, - autoRotate: false, + autoRotate: true, }, light: { main: { @@ -283,6 +323,7 @@ const init = () => { let option = getPie3D(paramsList); var chart = echarts.init(document.getElementById(domId.value)); chart.setOption(option); + chart.on('click', (params) => { emits('click', { index: params.seriesIndex, diff --git a/src/components/scroll/ScrollPanel.vue b/src/components/scroll/ScrollPanel.vue index e065e35..7db9807 100644 --- a/src/components/scroll/ScrollPanel.vue +++ b/src/components/scroll/ScrollPanel.vue @@ -2,7 +2,7 @@
序号 - 民族 + 宗教 人数(人) 占有率(%)
diff --git a/src/module/ModuleBottom.vue b/src/module/ModuleBottom.vue index e317958..6b02d12 100644 --- a/src/module/ModuleBottom.vue +++ b/src/module/ModuleBottom.vue @@ -5,14 +5,14 @@
- - + +
- +
diff --git a/src/module/ModuleLeft1.vue b/src/module/ModuleLeft1.vue index 2feec45..d5e2286 100644 --- a/src/module/ModuleLeft1.vue +++ b/src/module/ModuleLeft1.vue @@ -1,8 +1,8 @@