Replace Math.trunc integer check with Number.isInteger

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 14:20:22 +08:00
parent 57214586a8
commit 9a3d19f53c

View File

@@ -42,7 +42,7 @@ const composeFreqTypeText = (baseText, dataLayerOption, optionValue) => {
? baseText + (optionValue * 100).toFixed(2) + "%"
: baseText + optionValue.toFixed(2);
// Check if the value is an integer; if not, round to 2 decimal places.
text = Math.trunc(optionValue) === optionValue ? textInt : textFloat;
text = Number.isInteger(optionValue) ? textInt : textFloat;
return text;
};
@@ -148,7 +148,7 @@ export default function cytoscapeMap(
// Check if the value is an integer; if not, round to 2 decimal places.
textTimeLabel =
Math.trunc(optionValue) === optionValue
Number.isInteger(optionValue)
? timeLabelInt
: timeLabelFloat;
@@ -223,7 +223,7 @@ export default function cytoscapeMap(
// Check if the value is an integer; if not, round to 2 decimal places.
result =
Math.trunc(optionValue) === optionValue ? edgeInt : edgeFloat;
Number.isInteger(optionValue) ? edgeInt : edgeFloat;
break;
case "duration": // Duration: Relative is percentage %, others need time unit conversion.
@@ -233,7 +233,7 @@ export default function cytoscapeMap(
timeLabelInt = getTimeLabel(optionValue);
timeLabelFloat = getTimeLabel(optionValue.toFixed(2));
edgeTimeLabel =
Math.trunc(optionValue) === optionValue
Number.isInteger(optionValue)
? timeLabelInt
: timeLabelFloat;