Skip to content

Commit

Permalink
Fix/fix summary (#6)
Browse files Browse the repository at this point in the history
* fix: fix style

* fix: fix issue

* fix: fix issue
  • Loading branch information
ranglang committed Feb 2, 2024
1 parent de3269c commit 2506540
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.2.8",
"version": "1.8.0",
"description": "my apitable widget chart",
"engines": {
"node": ">=8.x"
Expand Down
9 changes: 5 additions & 4 deletions src/summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} %)`;
Expand Down Expand Up @@ -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: {
Expand All @@ -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);

Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 2506540

Please sign in to comment.