政务云大屏修改

This commit is contained in:
沈鸿 2025-05-19 13:45:13 +08:00
parent 1af489ab4b
commit 9e0ccac1e5
2 changed files with 50 additions and 39 deletions

View File

@ -9,16 +9,13 @@ import { useEcharts } from '@/hooks/useEcharts';
defineOptions({ name: 'NewHyalineCake' }); defineOptions({ name: 'NewHyalineCake' });
//
let selectedIndex = null; let selectedIndex = null;
let hoveredIndex = null; let hoveredIndex = null;
// props
const props = defineProps({ const props = defineProps({
chartData: { chartData: {
type: Array, type: Array,
default: () => [ default: () => [
//
{ name: '项目一', value: 60 }, { name: '项目一', value: 60 },
{ name: '项目二', value: 44 }, { name: '项目二', value: 44 },
{ name: '项目三', value: 32 }, { name: '项目三', value: 32 },
@ -27,8 +24,8 @@ const props = defineProps({
option: { option: {
type: Object, type: Object,
default: () => ({ default: () => ({
k: 1, // 1 k: 1, // 1
itemGap: 0.1, // , itemGap: 0.1, //
itemHeight: 120, // z itemHeight: 120, // z
autoItemHeight: 0, // 使>0 itemHeight 使 autoItemHeight * value autoItemHeight: 0, // 使>0 itemHeight 使 autoItemHeight * value
opacity: 0.6, // opacity: 0.6, //
@ -46,15 +43,11 @@ const props = defineProps({
}, },
}); });
//
const emit = defineEmits(['click']); const emit = defineEmits(['click']);
// DOM
const chartRef = ref(null); const chartRef = ref(null);
// 使 useEcharts ECharts
const { setOptions, getInstance } = useEcharts(chartRef); const { setOptions, getInstance } = useEcharts(chartRef);
// ECharts
const chartOption = ref({}); const chartOption = ref({});
/** /**
@ -69,8 +62,7 @@ const chartOption = ref({});
* @return {Object} parametric 曲面方程 * @return {Object} parametric 曲面方程
*/ */
function getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h, offsetZ = 0) { function getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h, offsetZ = 0) {
console.log('getParametricEquation params :>> ', startRatio, endRatio, isSelected, isHovered, k, h, offsetZ); // console.log('getParametricEquation params :>> ', startRatio, endRatio, isSelected, isHovered, k, h, offsetZ);
//
const midRatio = (startRatio + endRatio) / 2; const midRatio = (startRatio + endRatio) / 2;
const startRadian = startRatio * Math.PI * 2; const startRadian = startRatio * Math.PI * 2;
const endRadian = endRatio * Math.PI * 2; const endRadian = endRatio * Math.PI * 2;
@ -89,7 +81,6 @@ function getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h
// 1 // 1
const hoverRate = isHovered ? 1.05 : 1; const hoverRate = isHovered ? 1.05 : 1;
// parametric
return { return {
u: { u: {
// u -π 3π // u -π 3π
@ -155,10 +146,6 @@ function getPie3D(pieData, internalDiameterRatio) {
const k = typeof internalDiameterRatio !== 'undefined' ? (1 - internalDiameterRatio) / (1 + internalDiameterRatio) : 1 / 3; const k = typeof internalDiameterRatio !== 'undefined' ? (1 - internalDiameterRatio) / (1 + internalDiameterRatio) : 1 / 3;
//
// pieData.forEach((item) => {
// sumValue += item.value;
// });
// series // series
for (let i = 0; i < pieData.length; i += 1) { for (let i = 0; i < pieData.length; i += 1) {
sumValue += pieData[i].value; sumValue += pieData[i].value;
@ -169,16 +156,19 @@ function getPie3D(pieData, internalDiameterRatio) {
parametric: true, parametric: true,
wireframe: { show: false }, wireframe: { show: false },
pieData: pieData[i], pieData: pieData[i],
// itemStyle: {
// opacity: props.option.opacity,
// borderRadius: 300,
// borderColor: '#fff',
// }
pieStatus: { pieStatus: {
selected: true, selected: true,
hovered: false, hovered: false,
k, k,
}, },
label: {
show: true,
formatter: () => `${pieData[i].value}`, // value
position: 'outside', //
distance: 10, //
color: '#fff', //
fontSize: 14,
},
}; };
if (typeof pieData[i].itemStyle !== 'undefined') { if (typeof pieData[i].itemStyle !== 'undefined') {
const { itemStyle } = pieData[i]; const { itemStyle } = pieData[i];
@ -191,7 +181,7 @@ function getPie3D(pieData, internalDiameterRatio) {
} }
// 使 sumValue getParametricEquation // 使 sumValue getParametricEquation
// series-surface series-surface.parametricEquation // series-surface series-surface.parametricEquation
console.log(series); // console.log(series);
for (let i = 0; i < series.length; i += 1) { for (let i = 0; i < series.length; i += 1) {
endValue = startValue + series[i].pieData.value; endValue = startValue + series[i].pieData.value;
@ -301,7 +291,7 @@ function getPie3D(pieData, internalDiameterRatio) {
// mouseover // mouseover
function handleMouseover(params) { function handleMouseover(params) {
console.log('mouseover'); // console.log('mouseover');
const idx = params.seriesIndex; const idx = params.seriesIndex;
const series = chartOption.value.series; const series = chartOption.value.series;
@ -418,19 +408,10 @@ function handleClick(params) {
series[idx].parametricEquation = getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h); series[idx].parametricEquation = getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h);
series[idx].pieStatus.selected = isSelected; series[idx].pieStatus.selected = isSelected;
//
selectedIndex = isSelected ? idx : null; selectedIndex = isSelected ? idx : null;
//
setOptions(optionVal); setOptions(optionVal);
// click 使
emit('click', params); emit('click', params);
} }
//
window.debugZValues = {
current: null,
history: [],
};
// //
onMounted(() => { onMounted(() => {

View File

@ -42,16 +42,46 @@ const state = reactive({
icon: 'rect', icon: 'rect',
left: 'center', left: 'center',
textStyle: { textStyle: {
color: '#fff', // color: '#fff',
fontSize: 14, fontSize: 16,
},
itemStyle: {
display: 'float',
top: '120px',
backgroundColor: 'rgba(255, 255, 255, 0.2)',
}, },
formatter: (name) => name, formatter: (name) => name,
}, },
// series: [
// {
// type: 'pie3D',
// center: ['50%', '50%'],
// radius: ['40%', '60%'],
// avoidLabelOverlap: false,
// label: {
// normal: {
// formatter: (params) => {
// return params.value + '%';
// },
// padding: [0, -100, 25, -100],
// rich: {
// icon: {
// fontSize: 16,
// },
// name: {
// fontSize: 14,
// padding: [0, 10, 0, 4],
// color: '#666666',
// },
// value: {
// fontSize: 18,
// fontWeight: 'bold',
// color: '#333333',
// },
// },
// },
// },
// labelLine: {
// show: false,
// },
// data: [],
// },
// ],
}, },
data: [ data: [
{ value: 76, name: '产业运营平台' }, { value: 76, name: '产业运营平台' },