版本资源综合比例
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
import {
|
import {
|
||||||
getHotKeywords,
|
getHotKeywords,
|
||||||
@@ -15,6 +15,10 @@ import type { FacetItem, YearStat } from '@/api/search'
|
|||||||
const overview = ref<AnalysisOverview | null>(null)
|
const overview = ref<AnalysisOverview | null>(null)
|
||||||
const hotKeywords = ref<FacetItem[]>([])
|
const hotKeywords = ref<FacetItem[]>([])
|
||||||
const recent = ref<YearStat[]>([])
|
const recent = ref<YearStat[]>([])
|
||||||
|
const resourceRatio = ref<FacetItem[]>([])
|
||||||
|
const libraryContribution = ref<FacetItem[]>([])
|
||||||
|
const ratioTotal = computed(() => resourceRatio.value.reduce((s, r) => s + r.value, 0))
|
||||||
|
const contribTotal = computed(() => libraryContribution.value.reduce((s, r) => s + r.value, 0))
|
||||||
|
|
||||||
const ratioRef = ref<HTMLElement>()
|
const ratioRef = ref<HTMLElement>()
|
||||||
const yearRef = ref<HTMLElement>()
|
const yearRef = ref<HTMLElement>()
|
||||||
@@ -49,15 +53,17 @@ async function loadAll() {
|
|||||||
const tip = { textStyle: { fontFamily: 'PingFang SC, Microsoft YaHei, sans-serif', color: paper } }
|
const tip = { textStyle: { fontFamily: 'PingFang SC, Microsoft YaHei, sans-serif', color: paper } }
|
||||||
|
|
||||||
const ratio = await getResourceRatio()
|
const ratio = await getResourceRatio()
|
||||||
|
resourceRatio.value = ratio
|
||||||
initChart(ratioRef.value)?.setOption({
|
initChart(ratioRef.value)?.setOption({
|
||||||
color: [ink, gold, leaf, goldDeep, mist, cssVar('--brand-light', '#eaf4ed')],
|
color: [ink, gold, leaf, goldDeep, mist, cssVar('--brand-light', '#eaf4ed')],
|
||||||
tooltip: { trigger: 'item', ...tip },
|
tooltip: { trigger: 'item', formatter: '{b}<br/>数量:{c} ({d}%)', ...tip },
|
||||||
legend: { bottom: 0, textStyle: { color: paper } },
|
legend: { bottom: 0, textStyle: { color: paper } },
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: '资源比例',
|
name: '资源比例',
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
radius: ['40%', '65%'],
|
radius: ['40%', '65%'],
|
||||||
|
label: { color: paper, formatter: '{b}\n{c} ({d}%)' },
|
||||||
data: ratio.map((r) => ({ name: r.name, value: r.value }))
|
data: ratio.map((r) => ({ name: r.name, value: r.value }))
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -90,6 +96,7 @@ async function loadAll() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const contrib = await getLibraryContribution()
|
const contrib = await getLibraryContribution()
|
||||||
|
libraryContribution.value = contrib
|
||||||
initChart(contribRef.value)?.setOption({
|
initChart(contribRef.value)?.setOption({
|
||||||
tooltip: { trigger: 'axis', ...tip },
|
tooltip: { trigger: 'axis', ...tip },
|
||||||
grid: { left: 45, right: 20, top: 30, bottom: 60 },
|
grid: { left: 45, right: 20, top: 30, bottom: 60 },
|
||||||
@@ -188,14 +195,34 @@ onBeforeUnmount(() => {
|
|||||||
<el-row :gutter="16" class="mb-16">
|
<el-row :gutter="16" class="mb-16">
|
||||||
<el-col :xs="24" :md="12">
|
<el-col :xs="24" :md="12">
|
||||||
<div class="page-card">
|
<div class="page-card">
|
||||||
<h3 class="page-title">版本资源综合比例</h3>
|
<h3 class="page-title">版本资源综合比例(纸质 / 电子)</h3>
|
||||||
<div ref="ratioRef" class="chart-sm"></div>
|
<div ref="ratioRef" class="chart-sm"></div>
|
||||||
|
<el-table :data="resourceRatio" size="small" class="pct-table" :border="false">
|
||||||
|
<el-table-column prop="name" label="资源类型" />
|
||||||
|
<el-table-column prop="value" label="数量" align="right" />
|
||||||
|
<el-table-column label="所占比例" align="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ ratioTotal ? ((row.value / ratioTotal) * 100).toFixed(1) : '0.0' }}%
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="pct-total">合计:{{ ratioTotal.toLocaleString() }} 条</div>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :md="12">
|
<el-col :xs="24" :md="12">
|
||||||
<div class="page-card">
|
<div class="page-card">
|
||||||
<h3 class="page-title">来源单位贡献量</h3>
|
<h3 class="page-title">各馆版本资源数量及占比</h3>
|
||||||
<div ref="contribRef" class="chart-sm"></div>
|
<div ref="contribRef" class="chart-sm"></div>
|
||||||
|
<el-table :data="libraryContribution" size="small" class="pct-table" max-height="240" :border="false">
|
||||||
|
<el-table-column prop="name" label="来源馆 / 院校" />
|
||||||
|
<el-table-column prop="value" label="数量(条)" align="right" />
|
||||||
|
<el-table-column label="占比" align="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ contribTotal ? ((row.value / contribTotal) * 100).toFixed(1) : '0.0' }}%
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="pct-total">合计:{{ contribTotal.toLocaleString() }} 条</div>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -251,4 +278,21 @@ onBeforeUnmount(() => {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 280px;
|
height: 280px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pct-table {
|
||||||
|
margin-top: 8px;
|
||||||
|
|
||||||
|
:deep(.el-table__header th),
|
||||||
|
:deep(.el-table__cell) {
|
||||||
|
background: transparent;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pct-total {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user