@pie-lib/plot 2.10.0 → 2.12.0

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/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [2.10.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.10.0) (2025-07-31)
6
+ # [2.12.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.12.0) (2025-07-31)
7
7
 
8
8
  **Note:** Version bump only for package @pie-lib/plot
9
9
 
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
11
 
12
12
 
13
13
 
14
- # [2.9.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.9.0) (2025-07-31)
14
+ # [2.11.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.11.0) (2025-07-31)
15
15
 
16
16
  **Note:** Version bump only for package @pie-lib/plot
17
17
 
@@ -19,7 +19,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
19
19
 
20
20
 
21
21
 
22
- # [2.8.0-beta.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.8) (2025-07-25)
22
+ # [2.10.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.10.0) (2025-07-31)
23
23
 
24
24
  **Note:** Version bump only for package @pie-lib/plot
25
25
 
@@ -27,7 +27,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
27
27
 
28
28
 
29
29
 
30
- # [2.8.0-beta.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.7) (2025-07-25)
30
+ # [2.11.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.11.0) (2025-07-31)
31
31
 
32
32
  **Note:** Version bump only for package @pie-lib/plot
33
33
 
@@ -35,7 +35,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
35
35
 
36
36
 
37
37
 
38
- # [2.8.0-beta.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.7) (2025-07-25)
38
+ # [2.10.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.10.0) (2025-07-31)
39
39
 
40
40
  **Note:** Version bump only for package @pie-lib/plot
41
41
 
@@ -43,7 +43,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
43
43
 
44
44
 
45
45
 
46
- # [2.8.0-beta.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.6) (2025-07-25)
46
+ # [2.9.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.9.0) (2025-07-31)
47
47
 
48
48
  **Note:** Version bump only for package @pie-lib/plot
49
49
 
@@ -51,118 +51,90 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
51
51
 
52
52
 
53
53
 
54
- # [2.8.0-beta.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.6) (2025-07-25)
54
+ # [2.9.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.9.0) (2025-07-31)
55
55
 
56
56
  **Note:** Version bump only for package @pie-lib/plot
57
57
 
58
+ # [2.10.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.10.0) (2025-07-31)
58
59
 
60
+ **Note:** Version bump only for package @pie-lib/plot
59
61
 
60
-
61
-
62
- # [2.8.0-beta.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.5) (2025-07-25)
62
+ # [2.9.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.9.0) (2025-07-31)
63
63
 
64
64
  **Note:** Version bump only for package @pie-lib/plot
65
65
 
66
+ # [2.8.0-beta.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.8) (2025-07-25)
66
67
 
68
+ **Note:** Version bump only for package @pie-lib/plot
67
69
 
70
+ # [2.8.0-beta.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.7) (2025-07-25)
68
71
 
72
+ **Note:** Version bump only for package @pie-lib/plot
69
73
 
70
- # [2.8.0-beta.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.5) (2025-07-25)
74
+ # [2.8.0-beta.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.7) (2025-07-25)
71
75
 
72
76
  **Note:** Version bump only for package @pie-lib/plot
73
77
 
78
+ # [2.8.0-beta.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.6) (2025-07-25)
74
79
 
80
+ **Note:** Version bump only for package @pie-lib/plot
75
81
 
82
+ # [2.8.0-beta.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.6) (2025-07-25)
76
83
 
84
+ **Note:** Version bump only for package @pie-lib/plot
77
85
 
78
- # [2.8.0-beta.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.4) (2025-07-25)
86
+ # [2.8.0-beta.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.5) (2025-07-25)
79
87
 
80
88
  **Note:** Version bump only for package @pie-lib/plot
81
89
 
90
+ # [2.8.0-beta.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.5) (2025-07-25)
82
91
 
92
+ **Note:** Version bump only for package @pie-lib/plot
83
93
 
94
+ # [2.8.0-beta.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.4) (2025-07-25)
84
95
 
96
+ **Note:** Version bump only for package @pie-lib/plot
85
97
 
86
98
  # [2.8.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.3) (2025-07-25)
87
99
 
88
100
  **Note:** Version bump only for package @pie-lib/plot
89
101
 
90
-
91
-
92
-
93
-
94
102
  # [2.8.0-beta.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.4) (2025-07-23)
95
103
 
96
104
  **Note:** Version bump only for package @pie-lib/plot
97
105
 
98
-
99
-
100
-
101
-
102
106
  # [2.8.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.3) (2025-07-23)
103
107
 
104
108
  **Note:** Version bump only for package @pie-lib/plot
105
109
 
106
-
107
-
108
-
109
-
110
110
  # [2.8.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.3) (2025-07-20)
111
111
 
112
112
  **Note:** Version bump only for package @pie-lib/plot
113
113
 
114
-
115
-
116
-
117
-
118
114
  # [2.8.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.2) (2025-07-20)
119
115
 
120
116
  **Note:** Version bump only for package @pie-lib/plot
121
117
 
122
-
123
-
124
-
125
-
126
118
  # [2.8.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.1) (2025-07-20)
127
119
 
128
120
  **Note:** Version bump only for package @pie-lib/plot
129
121
 
130
-
131
-
132
-
133
-
134
122
  # [2.8.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.2) (2025-07-20)
135
123
 
136
124
  **Note:** Version bump only for package @pie-lib/plot
137
125
 
138
-
139
-
140
-
141
-
142
126
  # [2.8.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.1) (2025-07-20)
143
127
 
144
128
  **Note:** Version bump only for package @pie-lib/plot
145
129
 
146
-
147
-
148
-
149
-
150
130
  # [2.8.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.1) (2025-07-20)
151
131
 
152
132
  **Note:** Version bump only for package @pie-lib/plot
153
133
 
154
-
155
-
156
-
157
-
158
134
  # [2.8.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.8.0-beta.0) (2025-07-20)
159
135
 
160
136
  **Note:** Version bump only for package @pie-lib/plot
161
137
 
162
-
163
-
164
-
165
-
166
138
  # [2.9.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.7.3...@pie-lib/plot@2.9.0-beta.0) (2025-07-15)
167
139
 
168
140
  **Note:** Version bump only for package @pie-lib/plot
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.10.0",
6
+ "version": "2.12.0",
7
7
  "description": "Some underlying components for building charts/graphs",
8
8
  "keywords": [
9
9
  "react",
@@ -18,8 +18,8 @@
18
18
  "dependencies": {
19
19
  "@mapbox/point-geometry": "^0.1.0",
20
20
  "@material-ui/core": "^3.8.3",
21
- "@pie-lib/editable-html": "beta",
22
- "@pie-lib/render-ui": "beta",
21
+ "@pie-lib/editable-html": "^11.6.0",
22
+ "@pie-lib/render-ui": "^4.20.0",
23
23
  "@vx/axis": "^0.0.183",
24
24
  "@vx/event": "^0.0.182",
25
25
  "@vx/grid": "^0.0.183",
@@ -41,6 +41,6 @@
41
41
  "peerDependencies": {
42
42
  "react": "^16.8.1"
43
43
  },
44
- "gitHead": "ecb1ca31aa1c24d23af00d5ad04ce73ed8871057",
44
+ "gitHead": "889a13bfea2c768b8a3a6eabfc6fe7b7725aa832",
45
45
  "scripts": {}
46
46
  }
package/lib/draggable.js DELETED
@@ -1,65 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- Object.defineProperty(exports, "DraggableCore", {
11
- enumerable: true,
12
- get: function get() {
13
- return _reactDraggable.DraggableCore;
14
- }
15
- });
16
- exports["default"] = void 0;
17
-
18
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
-
20
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
-
22
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
23
-
24
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
-
26
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
27
-
28
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
29
-
30
- var _reactDraggable = _interopRequireWildcard(require("react-draggable"));
31
-
32
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
-
34
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
-
36
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
37
-
38
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
39
-
40
- var LocalDraggable = /*#__PURE__*/function (_Draggable) {
41
- (0, _inherits2["default"])(LocalDraggable, _Draggable);
42
-
43
- var _super = _createSuper(LocalDraggable);
44
-
45
- function LocalDraggable() {
46
- (0, _classCallCheck2["default"])(this, LocalDraggable);
47
- return _super.apply(this, arguments);
48
- }
49
-
50
- (0, _createClass2["default"])(LocalDraggable, [{
51
- key: "componentWillReceiveProps",
52
- value: function componentWillReceiveProps(next) {
53
- (0, _get2["default"])((0, _getPrototypeOf2["default"])(LocalDraggable.prototype), "componentWillReceiveProps", this).call(this, next); //Remove the x/y state as these values have now been updated and will come through as props.
54
-
55
- this.setState({
56
- x: 0,
57
- y: 0
58
- });
59
- }
60
- }]);
61
- return LocalDraggable;
62
- }(_reactDraggable["default"]);
63
-
64
- exports["default"] = LocalDraggable;
65
- //# sourceMappingURL=draggable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/draggable.jsx"],"names":["LocalDraggable","next","setState","x","y","Draggable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;IAEqBA,c;;;;;;;;;;;;WACnB,mCAA0BC,IAA1B,EAAgC;AAC9B,sIAAgCA,IAAhC,EAD8B,CAE9B;;AACA,WAAKC,QAAL,CAAc;AAAEC,QAAAA,CAAC,EAAE,CAAL;AAAQC,QAAAA,CAAC,EAAE;AAAX,OAAd;AACD;;;EALyCC,0B","sourcesContent":["import Draggable, { DraggableCore } from 'react-draggable';\n\nexport default class LocalDraggable extends Draggable {\n componentWillReceiveProps(next) {\n super.componentWillReceiveProps(next);\n //Remove the x/y state as these values have now been updated and will come through as props.\n this.setState({ x: 0, y: 0 });\n }\n}\n\nexport { DraggableCore };\n"],"file":"draggable.js"}
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.create = void 0;
9
-
10
- var _invariant = _interopRequireDefault(require("invariant"));
11
-
12
- var _utils = require("./utils");
13
-
14
- var _d3Scale = require("d3-scale");
15
-
16
- var createSnapMinAndMax = function createSnapMinAndMax(_ref) {
17
- var min = _ref.min,
18
- max = _ref.max,
19
- step = _ref.step;
20
- // for graphing, if step is a value with decimals, we have to calculate the min & max for the grid taking in consideration that 0 has to be exactly in the middle
21
- // for example, if min: -5 & max: 5 & step: 0.75, in order to keep 0 in the middle we have to set min: -4.5 & max: 4.5
22
- return {
23
- step: step,
24
- min: parseInt(min / step) * step,
25
- max: parseInt(max / step) * step
26
- };
27
- };
28
-
29
- var create = function create(domain, range, size, getRootNode) {
30
- (0, _invariant["default"])(domain.min < domain.max, 'domain: min must be less than max');
31
- (0, _invariant["default"])(range.min < range.max, 'range: min must be less than max');
32
- var domainMinMax = createSnapMinAndMax(domain);
33
- var rangeMinMax = createSnapMinAndMax(range);
34
- var scale = {
35
- x: (0, _d3Scale.scaleLinear)().domain([domain.min, domain.max]).range([0, size.width]),
36
- y: (0, _d3Scale.scaleLinear)().domain([range.max, range.min]).range([0, size.height])
37
- };
38
- var snap = {
39
- x: _utils.snapTo.bind(null, domainMinMax.min, domainMinMax.max, domainMinMax.step),
40
- y: _utils.snapTo.bind(null, rangeMinMax.min, rangeMinMax.max, rangeMinMax.step)
41
- };
42
- return {
43
- scale: scale,
44
- snap: snap,
45
- domain: domain,
46
- range: range,
47
- size: size,
48
- getRootNode: getRootNode
49
- };
50
- };
51
-
52
- exports.create = create;
53
- //# sourceMappingURL=graph-props.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graph-props.js"],"names":["createSnapMinAndMax","min","max","step","parseInt","create","domain","range","size","getRootNode","domainMinMax","rangeMinMax","scale","x","width","y","height","snap","snapTo","bind"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA,IAAMA,mBAAmB,GAAG,SAAtBA,mBAAsB,OAAwB;AAAA,MAArBC,GAAqB,QAArBA,GAAqB;AAAA,MAAhBC,GAAgB,QAAhBA,GAAgB;AAAA,MAAXC,IAAW,QAAXA,IAAW;AAClD;AACA;AAEA,SAAO;AACLA,IAAAA,IAAI,EAAJA,IADK;AAELF,IAAAA,GAAG,EAAEG,QAAQ,CAACH,GAAG,GAAGE,IAAP,CAAR,GAAuBA,IAFvB;AAGLD,IAAAA,GAAG,EAAEE,QAAQ,CAACF,GAAG,GAAGC,IAAP,CAAR,GAAuBA;AAHvB,GAAP;AAKD,CATD;;AAWO,IAAME,MAAM,GAAG,SAATA,MAAS,CAACC,MAAD,EAASC,KAAT,EAAgBC,IAAhB,EAAsBC,WAAtB,EAAsC;AAC1D,6BAAUH,MAAM,CAACL,GAAP,GAAaK,MAAM,CAACJ,GAA9B,EAAmC,mCAAnC;AACA,6BAAUK,KAAK,CAACN,GAAN,GAAYM,KAAK,CAACL,GAA5B,EAAiC,kCAAjC;AAEA,MAAMQ,YAAY,GAAGV,mBAAmB,CAACM,MAAD,CAAxC;AACA,MAAMK,WAAW,GAAGX,mBAAmB,CAACO,KAAD,CAAvC;AAEA,MAAMK,KAAK,GAAG;AACZC,IAAAA,CAAC,EAAE,4BACAP,MADA,CACO,CAACA,MAAM,CAACL,GAAR,EAAaK,MAAM,CAACJ,GAApB,CADP,EAEAK,KAFA,CAEM,CAAC,CAAD,EAAIC,IAAI,CAACM,KAAT,CAFN,CADS;AAIZC,IAAAA,CAAC,EAAE,4BACAT,MADA,CACO,CAACC,KAAK,CAACL,GAAP,EAAYK,KAAK,CAACN,GAAlB,CADP,EAEAM,KAFA,CAEM,CAAC,CAAD,EAAIC,IAAI,CAACQ,MAAT,CAFN;AAJS,GAAd;AASA,MAAMC,IAAI,GAAG;AACXJ,IAAAA,CAAC,EAAEK,cAAOC,IAAP,CAAY,IAAZ,EAAkBT,YAAY,CAACT,GAA/B,EAAoCS,YAAY,CAACR,GAAjD,EAAsDQ,YAAY,CAACP,IAAnE,CADQ;AAEXY,IAAAA,CAAC,EAAEG,cAAOC,IAAP,CAAY,IAAZ,EAAkBR,WAAW,CAACV,GAA9B,EAAmCU,WAAW,CAACT,GAA/C,EAAoDS,WAAW,CAACR,IAAhE;AAFQ,GAAb;AAKA,SAAO;AAAES,IAAAA,KAAK,EAALA,KAAF;AAASK,IAAAA,IAAI,EAAJA,IAAT;AAAeX,IAAAA,MAAM,EAANA,MAAf;AAAuBC,IAAAA,KAAK,EAALA,KAAvB;AAA8BC,IAAAA,IAAI,EAAJA,IAA9B;AAAoCC,IAAAA,WAAW,EAAXA;AAApC,GAAP;AACD,CAtBM","sourcesContent":["import invariant from 'invariant';\nimport { snapTo } from './utils';\nimport { scaleLinear } from 'd3-scale';\n\nconst createSnapMinAndMax = ({ min, max, step }) => {\n // for graphing, if step is a value with decimals, we have to calculate the min & max for the grid taking in consideration that 0 has to be exactly in the middle\n // for example, if min: -5 & max: 5 & step: 0.75, in order to keep 0 in the middle we have to set min: -4.5 & max: 4.5\n\n return {\n step,\n min: parseInt(min / step) * step,\n max: parseInt(max / step) * step,\n };\n};\n\nexport const create = (domain, range, size, getRootNode) => {\n invariant(domain.min < domain.max, 'domain: min must be less than max');\n invariant(range.min < range.max, 'range: min must be less than max');\n\n const domainMinMax = createSnapMinAndMax(domain);\n const rangeMinMax = createSnapMinAndMax(range);\n\n const scale = {\n x: scaleLinear()\n .domain([domain.min, domain.max])\n .range([0, size.width]),\n y: scaleLinear()\n .domain([range.max, range.min])\n .range([0, size.height]),\n };\n\n const snap = {\n x: snapTo.bind(null, domainMinMax.min, domainMinMax.max, domainMinMax.step),\n y: snapTo.bind(null, rangeMinMax.min, rangeMinMax.max, rangeMinMax.step),\n };\n\n return { scale, snap, domain, range, size, getRootNode };\n};\n"],"file":"graph-props.js"}