@pie-element/number-line 11.3.4-next.0 → 12.0.0-beta.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.
Files changed (79) hide show
  1. package/configure/lib/arrows.js +68 -103
  2. package/configure/lib/arrows.js.map +1 -1
  3. package/configure/lib/card-bar.js +41 -62
  4. package/configure/lib/card-bar.js.map +1 -1
  5. package/configure/lib/defaults.js +5 -7
  6. package/configure/lib/defaults.js.map +1 -1
  7. package/configure/lib/domain.js +60 -116
  8. package/configure/lib/domain.js.map +1 -1
  9. package/configure/lib/index.js +124 -194
  10. package/configure/lib/index.js.map +1 -1
  11. package/configure/lib/main.js +585 -721
  12. package/configure/lib/main.js.map +1 -1
  13. package/configure/lib/number-text-field.js +15 -86
  14. package/configure/lib/number-text-field.js.map +1 -1
  15. package/configure/lib/point-config.js +69 -129
  16. package/configure/lib/point-config.js.map +1 -1
  17. package/configure/lib/size.js +43 -77
  18. package/configure/lib/size.js.map +1 -1
  19. package/configure/lib/ticks.js +89 -151
  20. package/configure/lib/ticks.js.map +1 -1
  21. package/configure/lib/utils.js +2 -4
  22. package/configure/lib/utils.js.map +1 -1
  23. package/configure/package.json +10 -7
  24. package/controller/lib/defaults.js +5 -6
  25. package/controller/lib/defaults.js.map +1 -1
  26. package/controller/lib/index.js +171 -286
  27. package/controller/lib/index.js.map +1 -1
  28. package/controller/lib/tickUtils.js +96 -169
  29. package/controller/lib/tickUtils.js.map +1 -1
  30. package/controller/lib/utils.js +55 -88
  31. package/controller/lib/utils.js.map +1 -1
  32. package/controller/package.json +3 -3
  33. package/lib/data-converter.js +19 -23
  34. package/lib/data-converter.js.map +1 -1
  35. package/lib/draggable/index.js +104 -43
  36. package/lib/draggable/index.js.map +1 -1
  37. package/lib/index.js +118 -205
  38. package/lib/index.js.map +1 -1
  39. package/lib/number-line/colors.js +3 -13
  40. package/lib/number-line/colors.js.map +1 -1
  41. package/lib/number-line/feedback.js +53 -69
  42. package/lib/number-line/feedback.js.map +1 -1
  43. package/lib/number-line/graph/arrow.js +19 -38
  44. package/lib/number-line/graph/arrow.js.map +1 -1
  45. package/lib/number-line/graph/elements/base.js +7 -13
  46. package/lib/number-line/graph/elements/base.js.map +1 -1
  47. package/lib/number-line/graph/elements/builder.js +6 -7
  48. package/lib/number-line/graph/elements/builder.js.map +1 -1
  49. package/lib/number-line/graph/elements/line.js +209 -265
  50. package/lib/number-line/graph/elements/line.js.map +1 -1
  51. package/lib/number-line/graph/elements/point.js +170 -201
  52. package/lib/number-line/graph/elements/point.js.map +1 -1
  53. package/lib/number-line/graph/elements/ray.js +147 -185
  54. package/lib/number-line/graph/elements/ray.js.map +1 -1
  55. package/lib/number-line/graph/index.js +217 -283
  56. package/lib/number-line/graph/index.js.map +1 -1
  57. package/lib/number-line/graph/line.js +12 -22
  58. package/lib/number-line/graph/line.js.map +1 -1
  59. package/lib/number-line/graph/stacks.js +31 -54
  60. package/lib/number-line/graph/stacks.js.map +1 -1
  61. package/lib/number-line/graph/tick-utils.js +120 -209
  62. package/lib/number-line/graph/tick-utils.js.map +1 -1
  63. package/lib/number-line/graph/ticks.js +144 -225
  64. package/lib/number-line/graph/ticks.js.map +1 -1
  65. package/lib/number-line/index.js +331 -395
  66. package/lib/number-line/index.js.map +1 -1
  67. package/lib/number-line/point-chooser/button.js +33 -58
  68. package/lib/number-line/point-chooser/button.js.map +1 -1
  69. package/lib/number-line/point-chooser/img.js +2 -3
  70. package/lib/number-line/point-chooser/img.js.map +1 -1
  71. package/lib/number-line/point-chooser/index.js +152 -148
  72. package/lib/number-line/point-chooser/index.js.map +1 -1
  73. package/lib/number-line/point-chooser/styles.js +29 -52
  74. package/lib/number-line/point-chooser/styles.js.map +1 -1
  75. package/lib/number-line/transitions/fade.js +69 -48
  76. package/lib/number-line/transitions/fade.js.map +1 -1
  77. package/lib/number-line/transitions/index.js +2 -4
  78. package/lib/number-line/transitions/index.js.map +1 -1
  79. package/package.json +14 -11
@@ -1,45 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
4
  Object.defineProperty(exports, "__esModule", {
8
5
  value: true
9
6
  });
10
7
  exports.zeroBasedRange = exports.zbrErrorMessage = exports.snapTo = exports.snapElements = exports.simpleRange = exports.normalizeTicks = exports.labelMultiplier = exports.isMultiple = exports.getMinorLimits = exports.generateMinorValues = exports.generateMajorValuesForMinor = exports.fractionTickValues = exports.fractionSnapTo = exports.fractionRange = exports.fraction = exports.decimalTickValues = exports.closeTo = exports.buildTickDataAsFractions = exports.buildTickData = void 0;
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
8
  var math = _interopRequireWildcard(require("mathjs"));
15
-
16
9
  var _uniqWith = _interopRequireDefault(require("lodash/uniqWith"));
17
-
18
10
  var _isObject = _interopRequireDefault(require("lodash/isObject"));
19
-
20
11
  var _isNumber = _interopRequireDefault(require("lodash/isNumber"));
21
-
22
- 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); }
23
-
24
- 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; }
25
-
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
30
13
  // All these functions are duplicated in controller/src/tickUtils
31
14
 
32
15
  /*This will store the possible decimal tick values*/
33
- var decimalTickValues = [0.001, 0.01, 0.02, 0.04, 0.05, 0.1, 0.125, 0.2, 0.25, 0.5];
16
+ const decimalTickValues = exports.decimalTickValues = [0.001, 0.01, 0.02, 0.04, 0.05, 0.1, 0.125, 0.2, 0.25, 0.5];
17
+
34
18
  /*This will store the possible fraction tick values*/
19
+ const fractionTickValues = exports.fractionTickValues = ['1/1000', '1/100', '1/64', '1/50', '1/32', '1/25', '1/20', '1/16', '1/15', '1/12', '1/10', '1/9', '1/8', '1/7', '1/6', '1/5', '1/4', '1/3', '1/2'];
35
20
 
36
- exports.decimalTickValues = decimalTickValues;
37
- var fractionTickValues = ['1/1000', '1/100', '1/64', '1/50', '1/32', '1/25', '1/20', '1/16', '1/15', '1/12', '1/10', '1/9', '1/8', '1/7', '1/6', '1/5', '1/4', '1/3', '1/2'];
38
21
  /*This const will store possible multiplier for label interval that needs to be multiplied
39
22
  with tick interval with denominator represented with object key.*/
40
-
41
- exports.fractionTickValues = fractionTickValues;
42
- var labelMultiplier = {
23
+ const labelMultiplier = exports.labelMultiplier = {
43
24
  1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
44
25
  2: [1, 2, 4, 6, 8, 10],
45
26
  3: [1, 3, 6, 9],
@@ -61,89 +42,71 @@ var labelMultiplier = {
61
42
  100: [1, 2, 4, 5, 10],
62
43
  1000: [1, 2, 4, 5, 8, 10]
63
44
  };
64
- exports.labelMultiplier = labelMultiplier;
65
-
66
- var fractionRange = function fractionRange(start, end, interval) {
67
- var m = math.mod(math.abs(start), math.abs(interval));
68
-
45
+ const fractionRange = (start, end, interval) => {
46
+ const m = math.mod(math.abs(start), math.abs(interval));
69
47
  if (!math.equal(m, 0)) {
70
48
  throw new Error('start point must be divisible by interval');
71
49
  }
72
-
73
50
  if (math.equal(start, end)) {
74
51
  return [];
75
52
  }
76
-
77
- var e = math.subtract(end, math.mod(end, math.abs(interval)));
78
- var direction = math.larger(interval, 0) ? 'positive' : 'negative';
79
-
53
+ const e = math.subtract(end, math.mod(end, math.abs(interval)));
54
+ const direction = math.larger(interval, 0) ? 'positive' : 'negative';
80
55
  if (direction === 'negative' && math.largerEq(end, start)) {
81
56
  throw new Error('start must be > than end when doing a negative decrement');
82
57
  }
83
-
84
58
  if (direction === 'positive' && math.smallerEq(end, start)) {
85
59
  throw new Error('start must be < end when doing increments');
86
60
  }
87
-
88
- var compareFn = direction === 'positive' ? math.smallerEq : math.equal(e, end) ? math.largerEq : math.larger;
89
- var out = [];
90
- var next = start;
91
-
61
+ let compareFn;
62
+ if (direction === 'positive') {
63
+ compareFn = math.smallerEq;
64
+ } else if (math.equal(e, end)) {
65
+ compareFn = math.largerEq;
66
+ } else {
67
+ compareFn = math.larger;
68
+ }
69
+ const out = [];
70
+ let next = start;
92
71
  while (compareFn(next, e)) {
93
72
  out.push(next);
94
73
  next = math.add(next, interval);
95
74
  }
96
-
97
75
  return out;
98
76
  };
99
-
100
77
  exports.fractionRange = fractionRange;
101
-
102
- var zbrErrorMessage = function zbrErrorMessage(start, end) {
103
- return "Can only do a positive or negative range, but got: start: ".concat(start, " and end:").concat(end);
104
- };
105
-
78
+ const zbrErrorMessage = (start, end) => `Can only do a positive or negative range, but got: start: ${start} and end:${end}`;
106
79
  exports.zbrErrorMessage = zbrErrorMessage;
107
-
108
- var zeroBasedRange = function zeroBasedRange(start, end, interval) {
80
+ const zeroBasedRange = (start, end, interval) => {
109
81
  start = math.fraction(start);
110
82
  end = math.fraction(end);
111
83
  interval = math.fraction(interval);
112
- var length = math.abs(math.subtract(end, start));
113
-
84
+ const length = math.abs(math.subtract(end, start));
114
85
  if (math.larger(length, math.abs(end))) {
115
86
  throw new Error(zbrErrorMessage(start, end));
116
87
  }
117
-
118
- var a = {
88
+ const a = {
119
89
  start: math.abs(start),
120
90
  end: math.abs(end),
121
91
  interval: math.abs(interval),
122
92
  multiplier: math.smaller(interval, 0) ? -1 : 1
123
93
  };
124
- var m = math.mod(a.start, a.interval);
125
- var s = math.larger(m, 0) ? math.add(math.subtract(a.start, m), a.interval) : a.start;
126
- var r = fractionRange(s, a.end, a.interval);
127
- var out = a.multiplier === -1 ? r.map(function (v) {
128
- return math.multiply(v, -1);
129
- }) : r;
130
-
94
+ const m = math.mod(a.start, a.interval);
95
+ const s = math.larger(m, 0) ? math.add(math.subtract(a.start, m), a.interval) : a.start;
96
+ const r = fractionRange(s, a.end, a.interval);
97
+ const out = a.multiplier === -1 ? r.map(v => math.multiply(v, -1)) : r;
131
98
  if (math.smaller(interval, 0)) {
132
99
  out.reverse();
133
100
  }
134
-
135
101
  return out;
136
102
  };
137
-
138
103
  exports.zeroBasedRange = zeroBasedRange;
139
-
140
- var fmin = function fmin(a, b) {
104
+ const fmin = (a, b) => {
141
105
  a = math.fraction(a);
142
106
  b = math.fraction(b);
143
107
  return math.smaller(a, b) ? a : b;
144
108
  };
145
-
146
- var fmax = function fmax(a, b) {
109
+ const fmax = (a, b) => {
147
110
  a = math.fraction(a);
148
111
  b = math.fraction(b);
149
112
  return math.larger(a, b) ? a : b;
@@ -153,160 +116,136 @@ var fmax = function fmax(a, b) {
153
116
  * such that it was hard to round the numbers.
154
117
  * This is a more simplistic version but makes rounding work.
155
118
  */
156
-
157
-
158
- var simpleRange = function simpleRange(start, end, interval) {
119
+ const simpleRange = (start, end, interval) => {
159
120
  start = math.fraction(start);
160
121
  end = math.fraction(end);
161
122
  interval = math.fraction(interval);
162
- var positiveRange = math.larger(end, 0) ? zeroBasedRange(fmax(0, start), end, interval) : [];
163
- var negativeRange = math.smaller(start, 0) ? zeroBasedRange(fmin(0, end), start, math.multiply(interval, -1)) : [];
164
- var together = negativeRange.concat(positiveRange);
165
- var out = (0, _uniqWith["default"])(together, math.equal);
123
+ const positiveRange = math.larger(end, 0) ? zeroBasedRange(fmax(0, start), end, interval) : [];
124
+ const negativeRange = math.smaller(start, 0) ? zeroBasedRange(fmin(0, end), start, math.multiply(interval, -1)) : [];
125
+ let together = negativeRange.concat(positiveRange);
126
+ const out = (0, _uniqWith.default)(together, math.equal);
166
127
  return out;
167
128
  };
168
-
169
129
  exports.simpleRange = simpleRange;
170
-
171
- var closeTo = function closeTo(a, b, precision) {
130
+ const closeTo = (a, b, precision) => {
172
131
  precision = precision || 2;
173
- var expectedDiff = Math.pow(10, -precision) / 2;
174
- var receivedDiff = Math.abs(a - b);
132
+ const expectedDiff = Math.pow(10, -precision) / 2;
133
+ const receivedDiff = Math.abs(a - b);
175
134
  return receivedDiff < expectedDiff;
176
135
  };
177
-
178
136
  exports.closeTo = closeTo;
179
-
180
- var limit = function limit(v, min, max) {
137
+ const limit = (v, min, max) => {
181
138
  if (math.smaller(fraction(v), fraction(min))) {
182
139
  return min;
183
140
  }
184
-
185
141
  if (math.larger(fraction(v), fraction(max))) {
186
142
  return max;
187
143
  }
188
-
189
144
  return v;
190
145
  };
146
+
191
147
  /*
192
148
  * Function to get tick interval limits based on min, max and width entered by the user.
193
149
  * @param domain object containing max and min value.
194
150
  * @param width number represents width of number line.
195
151
  * */
196
-
197
-
198
- var getMinorLimits = function getMinorLimits(domain, width) {
199
- var end = domain.max - domain.min;
200
- var min = math.number(math.multiply(10, math.divide(math.fraction(end), width)));
201
- var max = math.number(math.multiply(20, min));
152
+ const getMinorLimits = (domain, width) => {
153
+ const end = domain.max - domain.min;
154
+ const min = math.number(math.multiply(10, math.divide(math.fraction(end), width)));
155
+ const max = math.number(math.multiply(20, min));
202
156
  return {
203
157
  min: min,
204
158
  max: max
205
159
  };
206
160
  };
207
-
208
161
  exports.getMinorLimits = getMinorLimits;
209
-
210
- var isMultiple = function isMultiple(multiple, src) {
211
- var mod = math.mod(multiple, src);
162
+ const isMultiple = (multiple, src) => {
163
+ const mod = math.mod(multiple, src);
212
164
  return math.equal(mod, 0);
213
165
  };
166
+
214
167
  /**
215
168
  * Accepts a fraction object {n,d,s} or number.
216
169
  * @param {*} v
217
170
  * @return mathjs.fraction
218
171
  */
219
-
220
-
221
172
  exports.isMultiple = isMultiple;
222
-
223
- var fraction = function fraction(v) {
224
- if ((0, _isObject["default"])(v)) {
173
+ const fraction = v => {
174
+ if ((0, _isObject.default)(v)) {
225
175
  return math.fraction(v.n * v.s, v.d);
226
- } else if ((0, _isNumber["default"])(v)) {
176
+ } else if ((0, _isNumber.default)(v)) {
227
177
  return math.fraction(v);
228
178
  }
229
179
  };
230
-
231
180
  exports.fraction = fraction;
232
-
233
- var normalizeTicks = function normalizeTicks(domain, width, ticks, opts) {
234
- var useLimit = opts ? opts.limit !== false : true;
235
- var minorLimits = getMinorLimits(domain, width);
236
- var minor = useLimit ? limit(fraction(ticks.minor), minorLimits.min, minorLimits.max) : fraction(ticks.minor);
237
- var major = useLimit ? limit(fraction(ticks.major), minor, math.multiply(minor, 20)) : fraction(ticks.major);
238
- var isMajorMultiple = isMultiple(major, minor);
239
-
181
+ const normalizeTicks = (domain, width, ticks, opts) => {
182
+ const useLimit = opts ? opts.limit !== false : true;
183
+ const minorLimits = getMinorLimits(domain, width);
184
+ const minor = useLimit ? limit(fraction(ticks.minor), minorLimits.min, minorLimits.max) : fraction(ticks.minor);
185
+ const major = useLimit ? limit(fraction(ticks.major), minor, math.multiply(minor, 20)) : fraction(ticks.major);
186
+ const isMajorMultiple = isMultiple(major, minor);
240
187
  if (!isMajorMultiple) {
241
- var multiplier = math.divide(major, minor);
242
- var multiplyBy = multiplier <= 2 ? 2 : Math.round(multiplier); // major must be a multiple of minor
188
+ const multiplier = math.divide(major, minor);
189
+ const multiplyBy = multiplier <= 2 ? 2 : Math.round(multiplier);
243
190
 
191
+ // major must be a multiple of minor
244
192
  return {
245
- minor: minor,
193
+ minor,
246
194
  major: math.multiply(minor, multiplyBy)
247
195
  };
248
196
  }
249
-
250
197
  return {
251
- major: major,
252
- minor: minor
198
+ major,
199
+ minor
253
200
  };
254
201
  };
202
+
255
203
  /**
256
204
  * Build ticks as an array of mathjs Fractions
257
205
  */
258
-
259
-
260
206
  exports.normalizeTicks = normalizeTicks;
261
-
262
- var buildTickDataAsFractions = function buildTickDataAsFractions(domain, width, ticks, opts) {
207
+ const buildTickDataAsFractions = (domain, width, ticks, opts) => {
263
208
  ticks = normalizeTicks(domain, width, ticks, opts);
264
- var rng = simpleRange(domain.min, domain.max, ticks.minor);
265
- var o = rng.filter(function (x) {
266
- return math.smallerEq(x, math.fraction(domain.max));
267
- }).map(function (x) {
268
- var type = 'minor';
269
- var modulo = math.mod(x, ticks.major);
270
-
209
+ const rng = simpleRange(domain.min, domain.max, ticks.minor);
210
+ const o = rng.filter(x => math.smallerEq(x, math.fraction(domain.max))).map(x => {
211
+ let type = 'minor';
212
+ const modulo = math.mod(x, ticks.major);
271
213
  if (closeTo(math.number(modulo), 0)) {
272
214
  type = 'major';
273
215
  }
274
-
275
216
  return {
276
- x: x,
277
- type: type
217
+ x,
218
+ type
278
219
  };
279
220
  });
280
221
  return o;
281
222
  };
223
+
282
224
  /*
283
225
  * This function will generate tick interval values based on min and max limits of ticks.
284
226
  * @param minorLimits object containing min and max values
285
227
  * @return out object containing three arrays 1. fraction values, 2. decimal values,
286
228
  * */
287
-
288
-
289
229
  exports.buildTickDataAsFractions = buildTickDataAsFractions;
290
-
291
- var generateMinorValues = function generateMinorValues(minorLimits) {
292
- var out = {
230
+ const generateMinorValues = minorLimits => {
231
+ let out = {
293
232
  fraction: [],
294
233
  decimal: []
295
234
  };
296
- decimalTickValues.forEach(function (value) {
235
+ decimalTickValues.forEach(value => {
297
236
  if (value >= minorLimits.min && value <= minorLimits.max) {
298
237
  out.decimal.push(value);
299
238
  }
300
239
  });
301
- fractionTickValues.forEach(function (value) {
302
- var decimalValue = math.number(math.fraction(value));
303
-
240
+ fractionTickValues.forEach(value => {
241
+ let decimalValue = math.number(math.fraction(value));
304
242
  if (decimalValue >= minorLimits.min && decimalValue <= minorLimits.max) {
305
243
  out.fraction.push(value);
306
244
  }
307
245
  });
308
246
  return out;
309
247
  };
248
+
310
249
  /*
311
250
  * This function will generate label interval values for provided tick interval value.
312
251
  * @param minor number representing tick interval value.
@@ -314,126 +253,98 @@ var generateMinorValues = function generateMinorValues(minorLimits) {
314
253
  * @param width number representing width of number line.
315
254
  * @return out object containing three arrays 1. fraction values, 2. decimal values,
316
255
  * */
317
-
318
-
319
256
  exports.generateMinorValues = generateMinorValues;
320
-
321
- var generateMajorValuesForMinor = function generateMajorValuesForMinor(minor, domain, width) {
322
- var out = {
257
+ const generateMajorValuesForMinor = (minor, domain, width) => {
258
+ let out = {
323
259
  decimal: [],
324
260
  fraction: []
325
261
  };
326
- var fraction = math.fraction(math.number(math.number(minor)));
327
- var n = fraction.n;
328
- var d = fraction.d;
329
-
262
+ let fraction = math.fraction(math.number(math.number(minor)));
263
+ let n = fraction.n;
264
+ let d = fraction.d;
330
265
  if (n >= 1 && d === 1) {
331
- for (var i = 1; i <= 10; i++) {
332
- var num = math.number(math.multiply(n, i)); //Here we check if this major value can plot at least 2 points on number line.
333
-
334
- var ticksData = {
266
+ for (let i = 1; i <= 10; i++) {
267
+ let num = math.number(math.multiply(n, i));
268
+ //Here we check if this major value can plot at least 2 points on number line.
269
+ let ticksData = {
335
270
  minor: minor,
336
271
  major: num
337
272
  };
338
- var output = buildTickData(domain, width, ticksData, {
273
+ let output = buildTickData(domain, width, ticksData, {
339
274
  fraction: undefined
340
275
  });
341
-
342
- if (output.filter(function (x) {
343
- return x.type === 'major';
344
- }).length > 1) {
276
+ if (output.filter(x => x.type === 'major').length > 1) {
345
277
  out.fraction.push(num.toString());
346
278
  out.decimal.push(num);
347
279
  }
348
280
  }
349
281
  } else {
350
- for (var multiplierKey in labelMultiplier[d]) {
351
- var _num = math.multiply(math.fraction(n, d), labelMultiplier[d][multiplierKey]); //Here we check if this major value can plot at least 2 points on number line.
352
-
353
-
354
- var _ticksData = {
282
+ for (const multiplierKey in labelMultiplier[d]) {
283
+ let num = math.multiply(math.fraction(n, d), labelMultiplier[d][multiplierKey]);
284
+ //Here we check if this major value can plot at least 2 points on number line.
285
+ let ticksData = {
355
286
  minor: minor,
356
- major: math.number(_num)
287
+ major: math.number(num)
357
288
  };
358
-
359
- var _output = buildTickData(domain, width, _ticksData, {
289
+ let output = buildTickData(domain, width, ticksData, {
360
290
  fraction: undefined
361
291
  });
362
-
363
- if (_output.filter(function (x) {
364
- return x.type === 'major';
365
- }).length > 1) {
366
- if (_num.d !== 1) {
367
- out.fraction.push(_num.n + '/' + _num.d);
292
+ if (output.filter(x => x.type === 'major').length > 1) {
293
+ if (num.d !== 1) {
294
+ out.fraction.push(num.n + '/' + num.d);
368
295
  } else {
369
- out.fraction.push(_num.n.toString());
296
+ out.fraction.push(num.n.toString());
370
297
  }
371
-
372
- out.decimal.push(math.number(_num));
298
+ out.decimal.push(math.number(num));
373
299
  }
374
300
  }
375
301
  }
376
-
377
302
  return out;
378
303
  };
379
-
380
304
  exports.generateMajorValuesForMinor = generateMajorValuesForMinor;
381
-
382
- var buildTickData = function buildTickData(domain, width, ticks, opts) {
383
- var result = buildTickDataAsFractions(domain, width, ticks, opts);
384
- var out = result.map(function (o) {
385
- return opts.fraction ? o : _objectSpread(_objectSpread({}, o), {}, {
386
- x: math.number(o.x) || 0
387
- });
305
+ const buildTickData = (domain, width, ticks, opts) => {
306
+ const result = buildTickDataAsFractions(domain, width, ticks, opts);
307
+ const out = result.map(o => opts.fraction ? o : {
308
+ ...o,
309
+ x: math.number(o.x) || 0
388
310
  });
389
311
  return out;
390
312
  };
391
-
392
313
  exports.buildTickData = buildTickData;
393
-
394
- var fractionSnapTo = function fractionSnapTo(min, max, interval, value) {
314
+ const fractionSnapTo = (min, max, interval, value) => {
395
315
  value = fmax(fmin(value, max), min);
396
- var mod = value.mod(interval);
397
- var v;
398
- var half = interval.div(2);
399
-
316
+ const mod = value.mod(interval);
317
+ let v;
318
+ const half = interval.div(2);
400
319
  if (math.largerEq(math.abs(mod), half)) {
401
- var d = interval.sub(math.abs(mod));
402
- var fn = math.largerEq(value, 0) ? 'add' : 'sub';
320
+ const d = interval.sub(math.abs(mod));
321
+ const fn = math.largerEq(value, 0) ? 'add' : 'sub';
403
322
  v = value[fn](d);
404
323
  } else {
405
- var fn2 = math.largerEq(value, 0) ? 'sub' : 'add';
324
+ const fn2 = math.largerEq(value, 0) ? 'sub' : 'add';
406
325
  v = value[fn2](math.abs(mod));
407
326
  }
408
-
409
327
  return v;
410
328
  };
411
-
412
329
  exports.fractionSnapTo = fractionSnapTo;
413
-
414
- var snapTo = function snapTo(min, max, interval, value) {
415
- var out = fractionSnapTo(math.fraction(min), math.fraction(max), math.fraction(interval), math.fraction(value));
330
+ const snapTo = (min, max, interval, value) => {
331
+ const out = fractionSnapTo(math.fraction(min), math.fraction(max), math.fraction(interval), math.fraction(value));
416
332
  return math.number(out);
417
333
  };
418
-
419
334
  exports.snapTo = snapTo;
420
-
421
- var snapElements = function snapElements(domain, ticks, elements) {
422
- return elements.map(function (e) {
423
- var size = Number.isFinite(e.size) ? snapTo(0, e.size, ticks.minor, e.size) : undefined;
424
- var domainPosition = snapTo(domain.min, domain.max, ticks.minor, e.domainPosition);
425
-
426
- var out = _objectSpread(_objectSpread({}, e), {}, {
427
- domainPosition: domainPosition
428
- });
429
-
335
+ const snapElements = (domain, ticks, elements) => {
336
+ return elements.map(e => {
337
+ const size = Number.isFinite(e.size) ? snapTo(0, e.size, ticks.minor, e.size) : undefined;
338
+ const domainPosition = snapTo(domain.min, domain.max, ticks.minor, e.domainPosition);
339
+ const out = {
340
+ ...e,
341
+ domainPosition
342
+ };
430
343
  if (Number.isFinite(size)) {
431
344
  out.size = size;
432
345
  }
433
-
434
346
  return out;
435
347
  });
436
348
  };
437
-
438
349
  exports.snapElements = snapElements;
439
350
  //# sourceMappingURL=tick-utils.js.map