From 2506540ec06044543f397bfbd003c4f6aa1e4333 Mon Sep 17 00:00:00 2001 From: Caedman Ziwen Lan Date: Fri, 2 Feb 2024 17:54:40 +0800 Subject: [PATCH] Fix/fix summary (#6) * fix: fix style * fix: fix issue * fix: fix issue --- package.json | 2 +- src/summary.tsx | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 5ba7c48..32fc5d2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.2.8", + "version": "1.8.0", "description": "my apitable widget chart", "engines": { "node": ">=8.x" diff --git a/src/summary.tsx b/src/summary.tsx index 4341f6a..f0ac8b0 100644 --- a/src/summary.tsx +++ b/src/summary.tsx @@ -113,7 +113,8 @@ const Summary = ({ openSetting, formData }) => { let targetText: string = `${targetValue} `; const resizeObserverRef = useResize(resizeHandler, [note, targetValue, targetText, currentValue.text]); - const showPercent = isNumeric(targetValue) && isNumeric(currentValue.value); + let v = Number(currentValue.value.toString().replaceAll(",", "")) + const showPercent = isNumeric(targetValue) && isNumeric(v); if (showPercent) { const percent = ((parseFloat(currentValue.value + '') / parseFloat(targetValue)) * 100).toFixed(2); targetText += `( ${percent} %)`; @@ -148,7 +149,7 @@ const useGetDefaultFormData = () => { metricsType: METRICS_TYPES[0], metrics: { fieldId: fields[0]?.id, - statType: fields[0]?.statTypeList[1], // The first of each field is the display and the second is the total. + statType: fields[0]?.statTypeList[1], // The first of each field is the display and the second is the total. }, }, chartStyle: { @@ -166,7 +167,7 @@ const WidgetSummaryBase: React.FC = () => { const views = useViewsMeta(); const viewEnum = views.map(view => view.id); const viewEnumNames = views.map(view => view.name); - + const defaultFormData = useGetDefaultFormData(); const [formData, setFormData, editable] = useCloudStorage('FormData', defaultFormData); @@ -295,7 +296,7 @@ const WidgetSummaryBase: React.FC = () => { const onFormChange = (data: any) => { const nextFormData = data.formData; // console.log({ nextFormData }); - // When switching fields, the statistical type of the previous field, + // When switching fields, the statistical type of the previous field, // may not exist in the statistical type of the next field, and the default value needs to be adjusted. try { if (