source: node_modules/d3-scale/src/symlog.js@ a762898

Last change on this file since a762898 was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 848 bytes
Line 
1import {linearish} from "./linear.js";
2import {copy, transformer} from "./continuous.js";
3import {initRange} from "./init.js";
4
5function transformSymlog(c) {
6 return function(x) {
7 return Math.sign(x) * Math.log1p(Math.abs(x / c));
8 };
9}
10
11function transformSymexp(c) {
12 return function(x) {
13 return Math.sign(x) * Math.expm1(Math.abs(x)) * c;
14 };
15}
16
17export function symlogish(transform) {
18 var c = 1, scale = transform(transformSymlog(c), transformSymexp(c));
19
20 scale.constant = function(_) {
21 return arguments.length ? transform(transformSymlog(c = +_), transformSymexp(c)) : c;
22 };
23
24 return linearish(scale);
25}
26
27export default function symlog() {
28 var scale = symlogish(transformer());
29
30 scale.copy = function() {
31 return copy(scale, symlog()).constant(scale.constant());
32 };
33
34 return initRange.apply(scale, arguments);
35}
Note: See TracBrowser for help on using the repository browser.