@antv/scale 0.4.11 → 0.4.13

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 (41) hide show
  1. package/README.md +14 -14
  2. package/{README.en-US.md → README.zh-CN.md} +14 -14
  3. package/dist/scale.min.js +1 -1
  4. package/esm/scales/band.js +4 -4
  5. package/esm/scales/band.js.map +1 -1
  6. package/esm/scales/diverging.js.map +1 -1
  7. package/esm/scales/ordinal.d.ts +1 -1
  8. package/esm/scales/ordinal.js +4 -4
  9. package/esm/scales/ordinal.js.map +1 -1
  10. package/esm/scales/sequential.js.map +1 -1
  11. package/esm/scales/threshold.js +3 -3
  12. package/esm/scales/threshold.js.map +1 -1
  13. package/esm/tick-methods/d3-log.js +2 -1
  14. package/esm/tick-methods/d3-log.js.map +1 -1
  15. package/esm/types.d.ts +29 -29
  16. package/esm/utils/find-tick-interval.d.ts +1 -1
  17. package/esm/utils/log.js +7 -1
  18. package/esm/utils/log.js.map +1 -1
  19. package/esm/utils/pretty-number.js +1 -1
  20. package/esm/utils/time-interval.d.ts +6 -6
  21. package/lib/scales/band.js +4 -4
  22. package/lib/scales/band.js.map +1 -1
  23. package/lib/scales/diverging.js.map +1 -1
  24. package/lib/scales/ordinal.d.ts +1 -1
  25. package/lib/scales/ordinal.js +4 -4
  26. package/lib/scales/ordinal.js.map +1 -1
  27. package/lib/scales/sequential.js.map +1 -1
  28. package/lib/scales/threshold.js +3 -3
  29. package/lib/scales/threshold.js.map +1 -1
  30. package/lib/tick-methods/d3-log.js +2 -1
  31. package/lib/tick-methods/d3-log.js.map +1 -1
  32. package/lib/types.d.ts +29 -29
  33. package/lib/utils/find-tick-interval.d.ts +1 -1
  34. package/lib/utils/log.js +7 -1
  35. package/lib/utils/log.js.map +1 -1
  36. package/lib/utils/pretty-number.js +1 -1
  37. package/lib/utils/time-interval.d.ts +6 -6
  38. package/package.json +4 -3
  39. package/src/tick-methods/d3-log.ts +2 -1
  40. package/src/utils/log.ts +8 -1
  41. package/src/utils/pretty-number.ts +1 -1
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@antv/scale",
3
- "version": "0.4.11",
3
+ "version": "0.4.13",
4
4
  "description": "Toolkit for mapping abstract data into visual representation.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "module": "esm/index.js",
8
8
  "unpkg": "dist/scale.min.js",
9
9
  "types": "lib/index.d.ts",
10
+ "sideEffects": false,
10
11
  "files": [
11
12
  "src",
12
13
  "lib",
@@ -96,10 +97,10 @@
96
97
  },
97
98
  "repository": {
98
99
  "type": "git",
99
- "url": "https://github.com/antvis/template"
100
+ "url": "https://github.com/antvis/scale"
100
101
  },
101
102
  "bugs": {
102
- "url": "https://github.com/antvis/template/issues"
103
+ "url": "https://github.com/antvis/scale/issues"
103
104
  },
104
105
  "dependencies": {
105
106
  "@antv/util": "^2.0.13",
@@ -39,7 +39,8 @@ export const d3Log: TickMethod = (a, b, n, base = 10) => {
39
39
  }
40
40
  if (ticks.length * 2 < n) ticks = d3Ticks(min, max, n);
41
41
  } else {
42
- ticks = d3Ticks(i, j, Math.min(j - i, n)).map(pow);
42
+ const count = n === -1 ? j - i : Math.min(j - i, n);
43
+ ticks = d3Ticks(i, j, count).map(pow);
43
44
  }
44
45
 
45
46
  return r ? ticks.reverse() : ticks;
package/src/utils/log.ts CHANGED
@@ -4,7 +4,14 @@ const reflect = (f: Function) => {
4
4
 
5
5
  export const logs = (base: number, shouldReflect: boolean) => {
6
6
  const baseCache = Math.log(base);
7
- const log = base === Math.E ? Math.log : (x: number) => Math.log(x) / baseCache;
7
+ const log =
8
+ base === Math.E
9
+ ? Math.log
10
+ : base === 10
11
+ ? Math.log10
12
+ : base === 2
13
+ ? Math.log2
14
+ : (x: number) => Math.log(x) / baseCache;
8
15
  return shouldReflect ? reflect(log) : log;
9
16
  };
10
17
 
@@ -1,4 +1,4 @@
1
1
  // 为了解决 js 运算的精度问题
2
2
  export function prettyNumber(n: number) {
3
- return Math.abs(n) < 1e-15 ? n : parseFloat(n.toFixed(15));
3
+ return Math.abs(n) < 1e-14 ? n : parseFloat(n.toFixed(14));
4
4
  }