首页优化

This commit is contained in:
bb_pan 2026-02-03 09:27:41 +08:00
parent f1fc46c340
commit f52bfb1025
2 changed files with 47 additions and 32 deletions

View File

@ -55,7 +55,50 @@ export default {
const myChart = echarts.init(chartDom)
const xData = this.chartData.map((item) => item.name)
const yData = this.chartData.map((item) => item.value)
const BAR_COLOR_MAP = [
{
bottom: '#51ABF7',
top: '#78C5FF',
},
{
bottom: '#5EDDCA',
top: '#32E1C6',
},
{
bottom: '#FFB644',
top: '#FFC468',
},
{
bottom: '#FFAB6F',
top: '#F8AC86',
},
]
const seriesData = this.chartData.map((item, index) => {
const color = BAR_COLOR_MAP[index] || BAR_COLOR_MAP[0]
return {
value: item.value,
//
itemStyle: {
borderRadius: [50, 50, 0, 0],
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
{ offset: 0, color: color.bottom },
{ offset: 1, color: color.top },
]),
},
// label
label: {
show: true,
position: 'top',
fontSize: 16,
fontWeight: 'bold',
color: color.top,
formatter: `${item.value}/${item.proportion}%`,
},
}
})
const option = {
title: [
@ -137,37 +180,10 @@ export default {
series: [
{
type: 'bar',
barWidth: 28, // 👉 = 28px
barWidth: 20, // 👉 = 28px
barMinHeight: 6,
z: 10,
itemStyle: {
borderRadius: [5, 5, 0, 0], // 👉 5px 5px 0 0
color: {
type: 'linear',
x: 0,
y: 1,
x2: 0,
y2: 0, // 👉 0deg =
colorStops: [
{ offset: 0, color: '#31B5C4' }, //
{ offset: 1, color: '#5DDAE2' }, //
],
},
},
label: {
show: true,
position: 'top',
fontSize: 16,
fontWeight: 'bold',
color: '#333',
formatter: (params) => {
const proportion = this.chartData[params.dataIndex].proportion
return `${params.value}/${proportion}%`
},
},
data: yData,
data: seriesData,
},
],
}

View File

@ -146,6 +146,5 @@ export default {
.table-sty ::v-deep .el-table__cell {
padding: 7px 0;
border: 0.5px solid #333;
}
</style>