Edit dashboard appearance

This commit is contained in:
2026-09-21 17:55:05 +03:30
parent d7d82102af
commit 1adc217375
9 changed files with 169 additions and 130 deletions
@@ -8,23 +8,16 @@ const props = defineProps<{
sources: HomeDashboardSourceDto[];
}>();
const demoSources: HomeDashboardSourceDto[] = [
{ label: 'معرفی دوستان', count: 44, percent: 34 },
{ label: 'وب‌سایت', count: 33, percent: 26 },
{ label: 'شبکه‌های اجتماعی', count: 23, percent: 18 },
{ label: 'تبلیغات', count: 18, percent: 14 },
{ label: 'سایر', count: 10, percent: 8 },
];
const colors = ['#2563eb', '#14b8a6', '#22c55e', '#fb923c', '#94a3b8'];
const rows = computed(() => (props.sources.length ? props.sources : demoSources));
const rows = computed(() => props.sources);
const total = computed(() => rows.value.reduce((a, s) => a + s.count, 0));
const option = computed<UiChartOption>(() => ({
animationDuration: 400,
color: colors,
tooltip: {
show: total.value > 0,
trigger: 'item',
textStyle: { fontFamily: 'IRANSans, Tahoma, sans-serif' },
formatter: (p) => {
@@ -37,10 +30,14 @@ const option = computed<UiChartOption>(() => ({
type: 'pie',
radius: ['58%', '82%'],
center: ['50%', '50%'],
silent: total.value === 0,
avoidLabelOverlap: true,
label: { show: false },
labelLine: { show: false },
data: rows.value.map((s) => ({ name: s.label, value: s.count })),
data:
total.value > 0
? rows.value.map((s) => ({ name: s.label, value: s.count }))
: [{ name: '', value: 1, itemStyle: { color: '#e2e8f0' } }],
},
],
}));
@@ -61,7 +58,8 @@ const option = computed<UiChartOption>(() => ({
</div>
</div>
<ul class="donut-legend">
<p v-if="!total" class="legend-empty">منبعی ثبت نشده</p>
<ul v-else class="donut-legend">
<li v-for="(row, i) in rows" :key="row.label">
<span class="dot" :style="{ background: colors[i % colors.length] }" />
<span class="lbl">{{ row.label }}</span>
@@ -80,6 +78,9 @@ const option = computed<UiChartOption>(() => ({
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
border: 1px solid var(--line);
min-width: 0;
height: 100%;
display: flex;
flex-direction: column;
}
.panel-head {
@@ -145,6 +146,12 @@ h2 {
color: #475569;
}
.legend-empty {
margin: 0;
color: #94a3b8;
font-size: 0.8rem;
}
em {
font-style: normal;
color: #94a3b8;