style: format large number for chart label
This commit is contained in:
@@ -4,6 +4,22 @@ const chartColorMap = {
|
|||||||
axislabelColor: 'rgba(0, 0, 0, 0.4)'
|
axislabelColor: 'rgba(0, 0, 0, 0.4)'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatLargeNumber = (value: number) => {
|
||||||
|
if (typeof value !== 'number' || isNaN(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value >= 1e9) {
|
||||||
|
return (value / 1e9).toFixed(1).replace(/\.0$/, '') + 'B';
|
||||||
|
} else if (value >= 1e6) {
|
||||||
|
return (value / 1e6).toFixed(1).replace(/\.0$/, '') + 'M';
|
||||||
|
} else if (value >= 1e3) {
|
||||||
|
return (value / 1e3).toFixed(1).replace(/\.0$/, '') + 'K';
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const tooltip = {
|
export const tooltip = {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
// axisPointer: {
|
// axisPointer: {
|
||||||
@@ -70,7 +86,8 @@ export const yAxis = {
|
|||||||
},
|
},
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
color: chartColorMap.axislabelColor,
|
color: chartColorMap.axislabelColor,
|
||||||
fontSize: 12
|
fontSize: 12,
|
||||||
|
formatter: formatLargeNumber
|
||||||
},
|
},
|
||||||
axisTick: {
|
axisTick: {
|
||||||
show: false
|
show: false
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ const ContentItem: React.FC<MessageItemProps> = ({
|
|||||||
<IconFont
|
<IconFont
|
||||||
type="icon-assistant-filled"
|
type="icon-assistant-filled"
|
||||||
className="font-size-16 m-r-5"
|
className="font-size-16 m-r-5"
|
||||||
style={{ color: 'var(--ant-blue-4)' }}
|
style={{ color: 'var(--ant-blue-5)' }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,10 +169,10 @@ export const extractErrorMessage = (result: any) => {
|
|||||||
result?.data?.error ||
|
result?.data?.error ||
|
||||||
result?.data?.detail ||
|
result?.data?.detail ||
|
||||||
result?.data?.message ||
|
result?.data?.message ||
|
||||||
|
result?.error?.message ||
|
||||||
result?.error ||
|
result?.error ||
|
||||||
result?.detail ||
|
result?.detail ||
|
||||||
result?.message ||
|
result?.message ||
|
||||||
result?.error?.message ||
|
|
||||||
result?.data;
|
result?.data;
|
||||||
if (errorMsg) {
|
if (errorMsg) {
|
||||||
return typeof errorMsg === 'string' ? errorMsg : JSON.stringify(errorMsg);
|
return typeof errorMsg === 'string' ? errorMsg : JSON.stringify(errorMsg);
|
||||||
|
|||||||
Reference in New Issue
Block a user