From 390d12368127ad57c936bd50a46ae4eac9b745b2 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 25 Aug 2022 11:08:44 +0800 Subject: [PATCH] improve axis label --- .../components/dashboard/DashboardPriceChart2.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/views/components/dashboard/DashboardPriceChart2.vue b/src/views/components/dashboard/DashboardPriceChart2.vue index 11874e02..5aba19f8 100644 --- a/src/views/components/dashboard/DashboardPriceChart2.vue +++ b/src/views/components/dashboard/DashboardPriceChart2.vue @@ -314,12 +314,21 @@ export default { }, formatter(val) { if (val > 999999999) { - return `${(val / 1000000000).toFixed(1)}b` + return `${(val / 1000000000).toFixed()}b` } if (val > 999999) { - return `${(val / 1000000).toFixed(1)}m` + return `${(val / 1000000).toFixed()}m` } - return val > 999 ? `${(val / 1000).toFixed(1)}k` : val.toFixed(2) + if (val > 999) { + return `${(val / 1000).toFixed()}k` + } + if (val > 1) { + return val.toFixed(1) + } + if (val > 0.001) { + return parseFloat(val.toFixed(4)).toString() + } + return parseFloat(val.toFixed(6)).toString() }, }, },