svelte-plots-basic 2.5.2 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Utils.js +9 -2
package/package.json
CHANGED
package/src/Utils.js
CHANGED
|
@@ -28,7 +28,11 @@ export function getTickLabels(ticks) {
|
|
|
28
28
|
|
|
29
29
|
if (Math.abs(max(ticks)) < 1) {
|
|
30
30
|
// tick values between 0 and 1 (absolute) and step is below 1
|
|
31
|
-
let decNum =
|
|
31
|
+
let decNum = -Math.log10(step);
|
|
32
|
+
|
|
33
|
+
// adjust the decNum value in case if small decimals are present
|
|
34
|
+
decNum = Math.ceil(Math.round(decNum * 100)/100);
|
|
35
|
+
|
|
32
36
|
if (decNum <= 2) {
|
|
33
37
|
return [0, Array.from(ticks).map(v => v.toFixed(decNum))];
|
|
34
38
|
}
|
|
@@ -38,7 +42,10 @@ export function getTickLabels(ticks) {
|
|
|
38
42
|
} else {
|
|
39
43
|
// tick values above 1 (absolute) and step is below 1
|
|
40
44
|
let decNum = -Math.log10(step);
|
|
41
|
-
|
|
45
|
+
|
|
46
|
+
// adjust the decNum value in case if small decimals are present
|
|
47
|
+
decNum = Math.ceil(Math.round(decNum * 100)/100);
|
|
48
|
+
|
|
42
49
|
if (decNum <= 2) {
|
|
43
50
|
return [0, Array.from(ticks).map(v => v.toFixed(decNum))];
|
|
44
51
|
}
|