Skip to content

Commit

Permalink
feat: use log scale for daily usd value transfer chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakia committed Apr 3, 2024
1 parent 85d5539 commit b1b6954
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ echarts.use([
export default function LedgerUSDTransferred({ data, isLoading }) {
const span_style =
'float:right;margin-left:20px;font-size:14px;color:#666;font-weight:900'

const option = {
grid: {
containLabel: true
Expand Down Expand Up @@ -56,10 +57,25 @@ export default function LedgerUSDTransferred({ data, isLoading }) {
type: 'time'
},
yAxis: {
type: 'value',
type: 'log',
min: 1,
name: 'Nano',
axisLabel: {
formatter: (value) => `$${value}`
formatter: (value) => {
const format_value = (number, divisor, suffix) => {
const result = number / divisor
return `$${result.toFixed(result % 1 !== 0 ? 1 : 0)}${suffix}`
}
if (value >= 1000000000) {
return format_value(value, 1000000000, 'B')
} else if (value >= 1000000) {
return format_value(value, 1000000, 'M')
} else if (value >= 1000) {
return format_value(value, 1000, 'K')
} else {
return `$${value}`
}
}
}
},
series: [
Expand Down

0 comments on commit b1b6954

Please sign in to comment.