Skip to content

Commit

Permalink
perf: gh-135 field distribution chart only show top 10 fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
riccox committed Oct 14, 2024
1 parent aad00fc commit a05f970
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/locales/en/index.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"fieldDistribution": {
"label": "Field Distribution",
"tip": "Only the first 10 fields are shown, sorted by distribution",
"subtitle": "Click me to go for official docs about “Field Distribution”"
},
"count": "Count",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh/index.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"fieldDistribution": {
"label": "字段分布",
"tip": "仅展示前十个字段,按分布排序",
"subtitle": "点我转到有关 Field Distribution 的官方文档"
},
"count": "文档计数",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Page = () => {
<ReactECharts
option={{
title: {
text: t('fieldDistribution.label'),
text: `${t('fieldDistribution.label')} (${t('fieldDistribution.tip')})`,
textStyle: { fontSize: '1rem', color: 'black' },
subtext: t('fieldDistribution.subtitle'),
sublink: 'https://www.meilisearch.com/docs/reference/api/stats',
Expand Down Expand Up @@ -75,7 +75,10 @@ const Page = () => {
},
},
},
data: Object.entries(fieldDistribution).map(([k, v]) => ({ name: k, value: v })),
data: Object.entries(fieldDistribution)
.map(([k, v]) => ({ name: k, value: v }))
.sort((a, b) => b.value - a.value)
.slice(0, 10),
},
],
}}
Expand Down

0 comments on commit a05f970

Please sign in to comment.