fix
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 3m13s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s

This commit is contained in:
SunCheng
2026-02-19 11:04:05 +08:00
parent 6ca00c1478
commit 3402ffaae2
9 changed files with 233 additions and 34 deletions

View File

@@ -134,6 +134,8 @@ const chartData = computed(() => {
label: '支出',
data: expenseData,
borderColor: '#ff6b6b',
yAxisID: 'yExpense',
order: 2,
backgroundColor: (context) => {
const chart = context.chart
const { ctx, chartArea } = chart
@@ -150,13 +152,15 @@ const chartData = computed(() => {
label: '收入',
data: incomeData,
borderColor: '#4ade80',
yAxisID: 'yIncome',
order: 1,
backgroundColor: (context) => {
const chart = context.chart
const { ctx, chartArea } = chart
if (!chartArea) {return 'rgba(74, 222, 128, 0.1)'}
return createGradient(ctx, chartArea, '#4ade80')
},
fill: true,
fill: false,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
@@ -168,12 +172,40 @@ const chartData = computed(() => {
// Chart.js 配置
const chartOptions = computed(() => {
const { chartData: rawData } = prepareChartData()
const { chartData: rawData, expenseData, incomeData } = prepareChartData()
const maxExpense = Math.max(...expenseData, 0)
const maxIncome = Math.max(...incomeData, 0)
return getChartOptions({
scales: {
x: { display: false },
y: { display: false }
x: {
display: false,
grid: { display: false, drawBorder: false },
ticks: { display: false },
border: { display: false }
},
y: {
display: false,
grid: { display: false, drawBorder: false },
ticks: { display: false },
border: { display: false }
},
yIncome: {
display: false,
beginAtZero: true,
suggestedMax: maxIncome ? maxIncome * 1.1 : undefined,
grid: { display: false, drawBorder: false },
ticks: { display: false },
border: { display: false }
},
yExpense: {
display: false,
beginAtZero: true,
suggestedMax: maxExpense ? maxExpense * 1.1 : undefined,
grid: { display: false, drawBorder: false },
ticks: { display: false },
border: { display: false }
}
},
plugins: {
legend: { display: false },
@@ -202,7 +234,7 @@ const chartOptions = computed(() => {
},
label: (context) => {
if (context.parsed.y === 0) {return null}
return `${context.dataset.label}: ¥${context.parsed.y.toFixed(2)}`
return `${context.dataset.label}: ¥${context.parsed.y.toFixed(1)}`
}
}
}