@@ -1,9 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-card title="前10名题目通过时间" v-if="hasData">
|
<div class="chart" v-if="showChart">
|
||||||
<div class="chart">
|
<Line :data="chartData" :options="chartOptions" />
|
||||||
<Line :data="chartData" :options="chartOptions" />
|
</div>
|
||||||
</div>
|
|
||||||
</n-card>
|
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Line } from "vue-chartjs"
|
import { Line } from "vue-chartjs"
|
||||||
@@ -31,14 +29,15 @@ ChartJS.register(
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
ranks: ContestRank[]
|
ranks: ContestRank[]
|
||||||
problems?: Array<{ id: number; title: string }>
|
problems: Array<{ id: number; title: string }>
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
// 判断是否有数据
|
const showChart = computed(() => {
|
||||||
const hasData = computed(() => {
|
const hasRanks = props.ranks.length > 0
|
||||||
return props.ranks && props.ranks.length > 0
|
const hasProblems = props.problems.length >= 3
|
||||||
|
return hasProblems && hasRanks
|
||||||
})
|
})
|
||||||
|
|
||||||
// 预定义的颜色方案 - 更现代和可访问的颜色
|
// 预定义的颜色方案 - 更现代和可访问的颜色
|
||||||
@@ -227,5 +226,6 @@ const chartOptions = computed(() => ({
|
|||||||
.chart {
|
.chart {
|
||||||
height: 500px;
|
height: 500px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user