feat: show yearly AC rate chart on problem info page
This commit is contained in:
@@ -14,6 +14,8 @@ import {
|
|||||||
Colors,
|
Colors,
|
||||||
} from "chart.js"
|
} from "chart.js"
|
||||||
import { getProblemBeatRate } from "oj/api"
|
import { getProblemBeatRate } from "oj/api"
|
||||||
|
import { getProblemYearlyAC, type YearlyACData } from "oj/api"
|
||||||
|
import ProblemYearlyChart from "./ProblemYearlyChart.vue"
|
||||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||||
|
|
||||||
// 仅注册饼图所需的 Chart.js 组件
|
// 仅注册饼图所需的 Chart.js 组件
|
||||||
@@ -25,6 +27,7 @@ const { problem } = storeToRefs(problemStore)
|
|||||||
const { isDesktop } = useBreakpoints()
|
const { isDesktop } = useBreakpoints()
|
||||||
|
|
||||||
const beatRate = ref("0")
|
const beatRate = ref("0")
|
||||||
|
const yearlyACData = ref<YearlyACData[]>([])
|
||||||
|
|
||||||
const data = computed(() => {
|
const data = computed(() => {
|
||||||
const status = problem.value!.statistic_info
|
const status = problem.value!.statistic_info
|
||||||
@@ -90,7 +93,15 @@ async function getBeatRate() {
|
|||||||
beatRate.value = res.data
|
beatRate.value = res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(getBeatRate)
|
async function getYearlyAC() {
|
||||||
|
const res = await getProblemYearlyAC(problem.value!._id)
|
||||||
|
yearlyACData.value = res.data
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getBeatRate()
|
||||||
|
getYearlyAC()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -142,6 +153,7 @@ onMounted(getBeatRate)
|
|||||||
<div class="pie" v-if="problem && problem.submission_number > 0">
|
<div class="pie" v-if="problem && problem.submission_number > 0">
|
||||||
<Pie :data="data" :options="options" />
|
<Pie :data="data" :options="options" />
|
||||||
</div>
|
</div>
|
||||||
|
<ProblemYearlyChart :data="yearlyACData" />
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.cards {
|
.cards {
|
||||||
|
|||||||
Reference in New Issue
Block a user