Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Commit f9b78b4

Browse files
committed
refactor: improve article sorting in charts section
- Implemented sorting of articles by count in descending order, limiting the display to the top 5 articles. - Adjusted the x-axis domain to reflect the updated article titles without reversing the order. These changes enhance the clarity and relevance of the data presented in the charts section. Signed-off-by: Innei <tukon479@gmail.com>
1 parent 20eea4e commit f9b78b4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/views/analyze/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ const ChartsSection = defineComponent({
303303
})
304304
charts.articles = chart
305305

306-
const data = articles.map((item, index) => ({
306+
const sortedArticles = [...articles]
307+
.sort((a, b) => b.count - a.count)
308+
.slice(0, 5)
309+
310+
const data = sortedArticles.map((item, index) => ({
307311
title: item.ref?.title || '未知标题',
308312
count: item.count,
309313
rank: index + 1,
@@ -315,7 +319,7 @@ const ChartsSection = defineComponent({
315319
encode: { x: 'title', y: 'count', color: 'rank' },
316320
coordinate: { transform: [{ type: 'transpose' }] },
317321
scale: {
318-
x: { domain: data.map((d) => d.title).reverse() },
322+
x: { domain: data.map((d) => d.title) },
319323
color: {
320324
range: ['#f59e0b', '#fbbf24', '#fcd34d', '#a3a3a3', '#d4d4d4'],
321325
},

0 commit comments

Comments
 (0)