Skip to content

Commit f549b68

Browse files
auto: apply newest APITable commit
1 parent 76d760e commit f549b68

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.8.0",
2+
"version": "1.8.5",
33
"description": "my apitable widget chart",
44
"engines": {
55
"node": ">=8.x"

src/summary.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ function isNumeric(value) {
2828
!isNaN(parseFloat(value));
2929
}
3030

31+
function formatNumberWithCommas(value: number | string): string {
32+
if (value == null || value === '') {
33+
return '';
34+
}
35+
const num = typeof value === 'string' ? parseFloat(value) : value;
36+
if (isNaN(num)) {
37+
return value.toString();
38+
}
39+
return num.toLocaleString();
40+
}
41+
3142
const METRICS_TYPES = ['COUNT_RECORDS', 'AGGREGATION_BY_FIELD'];
3243
const METRICS_TYPES_NAMES = [t(Strings.count_records), t(Strings.select_y_axis_field)];
3344

@@ -111,7 +122,7 @@ const Summary = ({ openSetting, formData }) => {
111122
const { targetValue, note } = formData?.chartStyle || {};
112123
// When the statistical value and the target value can be calculated, the scale is displayed.
113124

114-
let targetText: string = `${targetValue} `;
125+
let targetText: string = `${formatNumberWithCommas(targetValue)} `;
115126
const resizeObserverRef = useResize(resizeHandler, [note, targetValue, targetText, currentValue.text]);
116127
let v = Number(currentValue.value.toString().replaceAll(",", ""))
117128
const showPercent = isNumeric(targetValue) && isNumeric(v);
@@ -127,7 +138,7 @@ const Summary = ({ openSetting, formData }) => {
127138
<CurrentValueWrapper color={color}>
128139
{currentValue.text}
129140
</CurrentValueWrapper>
130-
<Typography variant="body1">
141+
<Typography variant="h3">
131142
{targetValue && targetText}
132143
</Typography>
133144
</div>

0 commit comments

Comments
 (0)