gridviz 2.1.15 → 2.1.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridviz",
3
- "version": "2.1.15",
3
+ "version": "2.1.17",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
@@ -2,8 +2,12 @@
2
2
  'use strict'
3
3
 
4
4
 
5
+ /**
6
+ * Some function [0,1]->[0,1] to stretch range of values.
7
+ * @see https://github.com/eurostat/gridviz/blob/master/docs/reference.md#stretching
8
+ * @see https://observablehq.com/@jgaffuri/stretching
9
+ */
5
10
 
6
- //stretching functions [0,1]=>[0,1]
7
11
 
8
12
  export const powerScale = (exponent = 3) => t => Math.pow(t, exponent)
9
13
  export const powerInverseScale = (exponent = 3) => t => 1 - Math.pow(1 - t, 1 / exponent)
@@ -17,14 +21,28 @@ export const logarithmicScale = (base = 3) => {
17
21
  return t => 1 - (1 / base) * Math.log(Math.exp(base) * (1 - t) + t)
18
22
  }
19
23
 
24
+ export const circularScale = (alpha = 0.8) => {
25
+ if (alpha == 0) return t => t
26
+ if (alpha == 1) return t => Math.sqrt(t * (2 - t))
27
+ else {
28
+ const a = alpha / (1 - alpha)
29
+ return t => Math.sqrt(1 / (a * a) + t * (2 / a + 2 - t)) - 1 / a
30
+ }
31
+ }
32
+ export const circularInverseScale = (alpha = 0.8) => {
33
+ const f = circularScale(alpha)
34
+ return t => 1 - f(1 - t)
35
+ }
20
36
 
21
37
 
22
38
 
23
- /**
24
- * Some function [0,1]->[0,1] to stretch range of values.
25
- * @see https://github.com/eurostat/gridviz/blob/master/docs/reference.md#stretching
26
- * @see https://observablehq.com/@jgaffuri/stretching
27
- */
39
+
40
+
41
+
42
+
43
+
44
+ // deprecated
45
+
28
46
 
29
47
  /**
30
48
  * Function [0,1]->[0,1] to stretch range of values.