We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 53ab10a commit 806ec8aCopy full SHA for 806ec8a
1 file changed
src/scale/Log.ts
@@ -42,14 +42,17 @@ const mathLog = Math.log;
42
* symmetric log, allowing negative values for logarithmic scales
43
*/
44
45
-const C = mathLog(10)
+function symMathLog(x: number, linthresh: number = 0.03): number {
46
+ if (x >= -linthresh && x <= linthresh) {
47
+ const mul = (2 + mathLog(linthresh)) / linthresh
48
+ return x * mul
49
+ }
50
-function symMathLog(x: number): number {
- if (x >= 0) {
- return mathLog(1 + x / C);
51
+ if (x > 0) {
52
+ return 2 + mathLog(x)
53
}
54
- return -mathLog(1 - x / C);
55
+ return - 2 - mathLog(-x)
56
57
58
/**
0 commit comments