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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Utils.js +9 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "svelte-plots-basic",
3
3
  "description": "Svelte components for creating simple plots",
4
- "version": "2.5.2",
4
+ "version": "2.5.3",
5
5
  "author": "Sergey Kucheryavskiy",
6
6
  "license": "MIT",
7
7
  "private": false,
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 = Math.ceil(-Math.log10(step));
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
- decNum = Math.ceil(Math.round(decNum * 10)/100);
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
  }