Ovilia commented on code in PR #21107:
URL: https://github.com/apache/echarts/pull/21107#discussion_r2209766473
##########
src/scale/Log.ts:
##########
@@ -64,8 +64,43 @@ class LogScale extends IntervalScale {
return zrUtil.map(ticks, function (tick) {
const val = tick.value;
- let powVal = fixRound(mathPow(base, val));
+ const rawVal = mathPow(base, val);
let roundingCriterion = null;
+ // Fix #21099
+ function calculatePrecision(value: number): number {
+ if (!isFinite(value) || value === 0) {
+ return 0;
+ }
+
+ const str = value.toString();
+
+ // Decimals using scientific notation
+ if (str.includes('e')) {
+ const [coefficient, exponent] = str.split('e');
+ const coefficientDecimals = coefficient.includes('.')
+ ? coefficient.split('.')[1].length
+ : 0;
+ const exp = parseInt(exponent, 10);
+ return exp < 0 ? Math.abs(exp) + coefficientDecimals :
coefficientDecimals;
+ }
+ // Normal decimals
+ const decimalPart = str.split('.')[1];
+ return decimalPart ? decimalPart.length : 0;
+ }
Review Comment:
Calling `numberUtil.getPrecision` instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]