@d3fc/d3fc-extent
Advanced tools
Comparing version 3.1.5 to 3.1.6
@@ -7,203 +7,202 @@ (function (global, factory) { | ||
var toConsumableArray = function (arr) { | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
} | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
} | ||
function linearExtent () { | ||
var accessors = [function (d) { | ||
return d; | ||
}]; | ||
var pad = [0, 0]; | ||
var padUnit = 'percent'; | ||
var symmetricalAbout = null; | ||
var include = []; | ||
var accessors = [function (d) { | ||
return d; | ||
}]; | ||
var pad = [0, 0]; | ||
var padUnit = 'percent'; | ||
var symmetricalAbout = null; | ||
var include = []; | ||
var instance = function instance(data) { | ||
var values = new Array(data.length); | ||
var instance = function instance(data) { | ||
var values = new Array(data.length); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (var _i = 0, _accessors = accessors; _i < _accessors.length; _i++) { | ||
var accessor = _accessors[_i]; | ||
try { | ||
for (var _iterator = accessors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var accessor = _step.value; | ||
for (var i = 0; i < data.length; i++) { | ||
var value = accessor(data[i], i); | ||
for (var i = 0; i < data.length; i++) { | ||
var value = accessor(data[i], i); | ||
if (Array.isArray(value)) { | ||
values.push.apply(values, toConsumableArray(value)); | ||
} else { | ||
values.push(value); | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
if (Array.isArray(value)) { | ||
values.push.apply(values, _toConsumableArray(value)); | ||
} else { | ||
values.push(value); | ||
} | ||
} | ||
} | ||
var extent = [d3Array.min(values), d3Array.max(values)]; | ||
var extent = [d3Array.min(values), d3Array.max(values)]; | ||
extent[0] = extent[0] == null ? d3Array.min(include) : d3Array.min([extent[0]].concat(_toConsumableArray(include))); | ||
extent[1] = extent[1] == null ? d3Array.max(include) : d3Array.max([extent[1]].concat(_toConsumableArray(include))); | ||
extent[0] = extent[0] == null ? d3Array.min(include) : d3Array.min([extent[0]].concat(toConsumableArray(include))); | ||
extent[1] = extent[1] == null ? d3Array.max(include) : d3Array.max([extent[1]].concat(toConsumableArray(include))); | ||
if (symmetricalAbout != null) { | ||
var halfRange = Math.max(Math.abs(extent[1] - symmetricalAbout), Math.abs(extent[0] - symmetricalAbout)); | ||
extent[0] = symmetricalAbout - halfRange; | ||
extent[1] = symmetricalAbout + halfRange; | ||
} | ||
if (symmetricalAbout != null) { | ||
var halfRange = Math.max(Math.abs(extent[1] - symmetricalAbout), Math.abs(extent[0] - symmetricalAbout)); | ||
extent[0] = symmetricalAbout - halfRange; | ||
extent[1] = symmetricalAbout + halfRange; | ||
switch (padUnit) { | ||
case 'domain': | ||
{ | ||
extent[0] -= pad[0]; | ||
extent[1] += pad[1]; | ||
break; | ||
} | ||
switch (padUnit) { | ||
case 'domain': | ||
{ | ||
extent[0] -= pad[0]; | ||
extent[1] += pad[1]; | ||
break; | ||
} | ||
case 'percent': | ||
{ | ||
var delta = extent[1] - extent[0]; | ||
extent[0] -= pad[0] * delta; | ||
extent[1] += pad[1] * delta; | ||
break; | ||
} | ||
default: | ||
throw new Error('Unknown padUnit: ' + padUnit); | ||
case 'percent': | ||
{ | ||
var delta = extent[1] - extent[0]; | ||
extent[0] -= pad[0] * delta; | ||
extent[1] += pad[1] * delta; | ||
break; | ||
} | ||
return extent; | ||
}; | ||
default: | ||
throw new Error("Unknown padUnit: ".concat(padUnit)); | ||
} | ||
instance.accessors = function () { | ||
if (!arguments.length) { | ||
return accessors; | ||
} | ||
accessors = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
return extent; | ||
}; | ||
instance.pad = function () { | ||
if (!arguments.length) { | ||
return pad; | ||
} | ||
pad = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.accessors = function () { | ||
if (!arguments.length) { | ||
return accessors; | ||
} | ||
instance.padUnit = function () { | ||
if (!arguments.length) { | ||
return padUnit; | ||
} | ||
padUnit = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
accessors = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.include = function () { | ||
if (!arguments.length) { | ||
return include; | ||
} | ||
include = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.pad = function () { | ||
if (!arguments.length) { | ||
return pad; | ||
} | ||
instance.symmetricalAbout = function () { | ||
if (!arguments.length) { | ||
return symmetricalAbout; | ||
} | ||
symmetricalAbout = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
pad = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.padUnit = function () { | ||
if (!arguments.length) { | ||
return padUnit; | ||
} | ||
padUnit = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.include = function () { | ||
if (!arguments.length) { | ||
return include; | ||
} | ||
include = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.symmetricalAbout = function () { | ||
if (!arguments.length) { | ||
return symmetricalAbout; | ||
} | ||
symmetricalAbout = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
return instance; | ||
} | ||
function time () { | ||
var accessors = []; | ||
var pad = [0, 0]; | ||
var padUnit = 'percent'; | ||
var symmetricalAbout = null; | ||
var include = []; | ||
var extent = linearExtent(); | ||
var accessors = []; | ||
var pad = [0, 0]; | ||
var padUnit = 'percent'; | ||
var symmetricalAbout = null; | ||
var include = []; | ||
var valueOf = function valueOf(date) { | ||
return date != null ? date.valueOf() : null; | ||
}; | ||
var extent = linearExtent(); | ||
var instance = function instance(data) { | ||
var adaptedAccessors = accessors.map(function (accessor) { | ||
return function () { | ||
var value = accessor.apply(void 0, arguments); | ||
return Array.isArray(value) ? value.map(valueOf) : valueOf(value); | ||
}; | ||
}); | ||
extent.accessors(adaptedAccessors).pad(pad).padUnit(padUnit).symmetricalAbout(symmetricalAbout != null ? symmetricalAbout.valueOf() : null).include(include.map(function (date) { | ||
return date.valueOf(); | ||
})); | ||
return extent(data).map(function (value) { | ||
return new Date(value); | ||
}); | ||
}; | ||
var valueOf = function valueOf(date) { | ||
return date != null ? date.valueOf() : null; | ||
}; | ||
instance.accessors = function () { | ||
if (!arguments.length) { | ||
return accessors; | ||
} | ||
var instance = function instance(data) { | ||
var adaptedAccessors = accessors.map(function (accessor) { | ||
return function () { | ||
var value = accessor.apply(undefined, arguments); | ||
return Array.isArray(value) ? value.map(valueOf) : valueOf(value); | ||
}; | ||
}); | ||
accessors = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
extent.accessors(adaptedAccessors).pad(pad).padUnit(padUnit).symmetricalAbout(symmetricalAbout != null ? symmetricalAbout.valueOf() : null).include(include.map(function (date) { | ||
return date.valueOf(); | ||
})); | ||
instance.pad = function () { | ||
if (!arguments.length) { | ||
return pad; | ||
} | ||
return extent(data).map(function (value) { | ||
return new Date(value); | ||
}); | ||
}; | ||
pad = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.accessors = function () { | ||
if (!arguments.length) { | ||
return accessors; | ||
} | ||
accessors = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.padUnit = function () { | ||
if (!arguments.length) { | ||
return padUnit; | ||
} | ||
instance.pad = function () { | ||
if (!arguments.length) { | ||
return pad; | ||
} | ||
pad = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
padUnit = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.padUnit = function () { | ||
if (!arguments.length) { | ||
return padUnit; | ||
} | ||
padUnit = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.include = function () { | ||
if (!arguments.length) { | ||
return include; | ||
} | ||
instance.include = function () { | ||
if (!arguments.length) { | ||
return include; | ||
} | ||
include = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
include = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.symmetricalAbout = function () { | ||
if (!arguments.length) { | ||
return symmetricalAbout; | ||
} | ||
symmetricalAbout = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.symmetricalAbout = function () { | ||
if (!arguments.length) { | ||
return symmetricalAbout; | ||
} | ||
symmetricalAbout = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
return instance; | ||
} | ||
@@ -210,0 +209,0 @@ |
@@ -6,2 +6,10 @@ # Change Log | ||
## [3.1.6](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-extent@3.1.5...@d3fc/d3fc-extent@3.1.6) (2019-09-04) | ||
**Note:** Version bump only for package @d3fc/d3fc-extent | ||
<a name="3.1.5"></a> | ||
@@ -8,0 +16,0 @@ ## [3.1.5](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-extent@3.1.4...@d3fc/d3fc-extent@3.1.5) (2019-08-12) |
{ | ||
"name": "@d3fc/d3fc-extent", | ||
"version": "3.1.5", | ||
"version": "3.1.6", | ||
"description": "Extends the d3 extent functionality to allow multiple accessors, padding and date support", | ||
@@ -34,3 +34,4 @@ "license": "MIT", | ||
"access": "public" | ||
} | ||
}, | ||
"gitHead": "d216bebca76b9bde7456f1c06e768bc67814dd2e" | ||
} |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
39895
16
1