@visx/scale
Advanced tools
Comparing version 2.2.2 to 2.17.0-alpha.0
@@ -0,1 +1,4 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable no-redeclare */ | ||
import createLinearScale from './scales/linear'; | ||
@@ -13,3 +16,5 @@ import createLogScale from './scales/log'; | ||
import createPointScale from './scales/point'; | ||
import createBandScale from './scales/band'; // Overload function for more strict typing, e.g., | ||
import createBandScale from './scales/band'; | ||
// Overload function for more strict typing, e.g., | ||
// If the config is a linear config then a ScaleLinear will be returned | ||
@@ -19,2 +24,3 @@ // instead of a union type of all scales. | ||
// Actual implementation | ||
function createScale(config) { | ||
@@ -25,47 +31,33 @@ if (typeof config !== 'undefined' && 'type' in config) { | ||
return createLinearScale(config); | ||
case 'log': | ||
return createLogScale(config); | ||
case 'pow': | ||
return createPowScale(config); | ||
case 'sqrt': | ||
return createSqrtScale(config); | ||
case 'symlog': | ||
return createSymlogScale(config); | ||
case 'time': | ||
return createTimeScale(config); | ||
case 'utc': | ||
return createUtcScale(config); | ||
case 'quantile': | ||
return createQuantileScale(config); | ||
case 'quantize': | ||
return createQuantizeScale(config); | ||
case 'threshold': | ||
return createThresholdScale(config); | ||
case 'ordinal': | ||
return createOrdinalScale(config); | ||
case 'point': | ||
return createPointScale(config); | ||
case 'band': | ||
return createBandScale(config); | ||
default: | ||
} | ||
} // If type is not specified, fallback to linear scale | ||
} | ||
// If type is not specified, fallback to linear scale | ||
return createLinearScale(config); | ||
} | ||
export default createScale; |
@@ -21,4 +21,5 @@ export { default as scaleBand } from './scales/band'; | ||
export { default as toString } from './utils/toString'; | ||
export { default as scaleCanBeZeroed } from './utils/scaleCanBeZeroed'; // export types | ||
export { default as scaleCanBeZeroed } from './utils/scaleCanBeZeroed'; | ||
// export types | ||
export * from './types/Base'; | ||
@@ -25,0 +26,0 @@ export * from './types/Nice'; |
@@ -24,3 +24,2 @@ import { timeSecond, timeMinute, timeHour, timeDay, timeYear, timeMonth, timeWeek, utcSecond, utcMinute, utcHour, utcDay, utcWeek, utcMonth, utcYear } from 'd3-time'; | ||
var nice = config.nice; | ||
if (typeof nice === 'boolean') { | ||
@@ -35,3 +34,2 @@ if (nice) { | ||
var isUtc = isUtcScale(timeScale); | ||
if (typeof nice === 'string') { | ||
@@ -41,5 +39,4 @@ timeScale.nice(isUtc ? utcIntervals[nice] : localTimeIntervals[nice]); | ||
var interval = nice.interval, | ||
step = nice.step; | ||
step = nice.step; | ||
var parsedInterval = (isUtc ? utcIntervals[interval] : localTimeIntervals[interval]).every(step); | ||
if (parsedInterval != null) { | ||
@@ -46,0 +43,0 @@ timeScale.nice(parsedInterval); |
@@ -5,7 +5,5 @@ export default function applyPadding(scale, config) { | ||
} | ||
if ('paddingInner' in scale && 'paddingInner' in config && typeof config.paddingInner !== 'undefined') { | ||
scale.paddingInner(config.paddingInner); | ||
} | ||
if ('paddingOuter' in scale && 'paddingOuter' in config && typeof config.paddingOuter !== 'undefined') { | ||
@@ -12,0 +10,0 @@ scale.paddingOuter(config.paddingOuter); |
export default function applyReverse(scale, config) { | ||
if (config.reverse) { | ||
var reversedRange = scale.range().slice().reverse(); | ||
if ('padding' in scale) { | ||
@@ -6,0 +5,0 @@ // point and band scales |
@@ -15,10 +15,14 @@ import domain from './domain'; | ||
import zero from './zero'; | ||
/** | ||
* List of all operators, in order of execution | ||
*/ | ||
export var ALL_OPERATORS = [// domain => nice => zero | ||
'domain', 'nice', 'zero', // interpolate before round | ||
'interpolate', 'round', // set range then reverse | ||
'range', 'reverse', // Order does not matter for these operators | ||
export var ALL_OPERATORS = [ | ||
// domain => nice => zero | ||
'domain', 'nice', 'zero', | ||
// interpolate before round | ||
'interpolate', 'round', | ||
// set range then reverse | ||
'range', 'reverse', | ||
// Order does not matter for these operators | ||
'align', 'base', 'clamp', 'constant', 'exponent', 'padding', 'unknown']; | ||
@@ -46,3 +50,2 @@ // Use Record to enforce that all keys in OperatorType must exist. | ||
} | ||
var selection = new Set(ops); | ||
@@ -58,5 +61,4 @@ var selectedOps = ALL_OPERATORS.filter(function (o) { | ||
} | ||
return scale; | ||
}; | ||
} |
@@ -5,9 +5,7 @@ export default function applyZero(scale, config) { | ||
var a = domain[0], | ||
b = domain[1]; | ||
b = domain[1]; | ||
var isDescending = b < a; | ||
var _ref = isDescending ? [b, a] : [a, b], | ||
min = _ref[0], | ||
max = _ref[1]; | ||
min = _ref[0], | ||
max = _ref[1]; | ||
var domainWithZero = [Math.min(0, min), Math.max(0, max)]; | ||
@@ -14,0 +12,0 @@ scale.domain(isDescending ? domainWithZero.reverse() : domainWithZero); |
@@ -0,10 +1,15 @@ | ||
/* eslint-disable no-redeclare */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import scaleOperator, { ALL_OPERATORS } from './operators/scaleOperator'; | ||
var applyAllOperators = scaleOperator.apply(void 0, ALL_OPERATORS); // Overload function signature for more strict typing, e.g., | ||
var applyAllOperators = scaleOperator.apply(void 0, ALL_OPERATORS); | ||
// Overload function signature for more strict typing, e.g., | ||
// If the scale is a ScaleLinear, the config is a linear config. | ||
// Actual implementation | ||
function updateScale(scale, config) { | ||
return applyAllOperators(scale.copy(), config); | ||
} | ||
export default updateScale; |
@@ -6,4 +6,3 @@ export default function coerceNumber(val) { | ||
} | ||
return val; | ||
} |
@@ -23,10 +23,8 @@ import { interpolateRgb, interpolateLab, interpolateHcl, interpolateHclLong, interpolateHsl, interpolateHslLong, interpolateCubehelix, interpolateCubehelixLong } from 'd3-interpolate'; | ||
return interpolatorMap[interpolate]; | ||
default: | ||
} | ||
var type = interpolate.type, | ||
gamma = interpolate.gamma; | ||
gamma = interpolate.gamma; | ||
var interpolator = interpolatorMap[type]; | ||
return typeof gamma === 'undefined' ? interpolator : interpolator.gamma(gamma); | ||
} |
@@ -7,7 +7,5 @@ export default function getTicks(scale, numTicks) { | ||
var s = scale; | ||
if ('ticks' in s) { | ||
return s.ticks(numTicks); | ||
} | ||
return s.domain().filter(function (_, index, arr) { | ||
@@ -14,0 +12,0 @@ return numTicks == null || arr.length <= numTicks || index % Math.round((arr.length - 1) / numTicks) === 0; |
import isUtcScale from './isUtcScale'; | ||
export default function inferScaleType(scale) { | ||
// Try a sequence of typeguards to figure out the scale type | ||
if ('paddingInner' in scale) { | ||
return 'band'; | ||
} | ||
if ('padding' in scale) { | ||
return 'point'; | ||
} | ||
if ('quantiles' in scale) { | ||
return 'quantile'; | ||
} | ||
if ('base' in scale) { | ||
return 'log'; | ||
} | ||
if ('exponent' in scale) { | ||
return scale.exponent() === 0.5 ? 'sqrt' : 'pow'; | ||
} | ||
if ('constant' in scale) { | ||
return 'symlog'; | ||
} | ||
if ('clamp' in scale) { | ||
@@ -33,15 +28,11 @@ // Linear, Time or Utc scales | ||
} | ||
return 'linear'; | ||
} | ||
if ('nice' in scale) { | ||
return 'quantize'; | ||
} | ||
if ('invertExtent' in scale) { | ||
return 'threshold'; | ||
} | ||
return 'ordinal'; | ||
} |
var TEST_TIME = new Date(Date.UTC(2020, 1, 2, 3, 4, 5)); | ||
var TEST_FORMAT = '%Y-%m-%d %H:%M'; | ||
/** | ||
@@ -8,3 +9,2 @@ * Check if the scale is UTC or Time scale | ||
*/ | ||
export default function isUtcScale(scale) { | ||
@@ -11,0 +11,0 @@ // The only difference between time and utc scale is |
@@ -5,32 +5,21 @@ "use strict"; | ||
exports.default = void 0; | ||
var _linear = _interopRequireDefault(require("./scales/linear")); | ||
var _log = _interopRequireDefault(require("./scales/log")); | ||
var _power = _interopRequireDefault(require("./scales/power")); | ||
var _squareRoot = _interopRequireDefault(require("./scales/squareRoot")); | ||
var _symlog = _interopRequireDefault(require("./scales/symlog")); | ||
var _time = _interopRequireDefault(require("./scales/time")); | ||
var _utc = _interopRequireDefault(require("./scales/utc")); | ||
var _quantile = _interopRequireDefault(require("./scales/quantile")); | ||
var _quantize = _interopRequireDefault(require("./scales/quantize")); | ||
var _threshold = _interopRequireDefault(require("./scales/threshold")); | ||
var _ordinal = _interopRequireDefault(require("./scales/ordinal")); | ||
var _point = _interopRequireDefault(require("./scales/point")); | ||
var _band = _interopRequireDefault(require("./scales/band")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable no-redeclare */ | ||
// Actual implementation | ||
function createScale(config) { | ||
@@ -41,48 +30,34 @@ if (typeof config !== 'undefined' && 'type' in config) { | ||
return (0, _linear.default)(config); | ||
case 'log': | ||
return (0, _log.default)(config); | ||
case 'pow': | ||
return (0, _power.default)(config); | ||
case 'sqrt': | ||
return (0, _squareRoot.default)(config); | ||
case 'symlog': | ||
return (0, _symlog.default)(config); | ||
case 'time': | ||
return (0, _time.default)(config); | ||
case 'utc': | ||
return (0, _utc.default)(config); | ||
case 'quantile': | ||
return (0, _quantile.default)(config); | ||
case 'quantize': | ||
return (0, _quantize.default)(config); | ||
case 'threshold': | ||
return (0, _threshold.default)(config); | ||
case 'ordinal': | ||
return (0, _ordinal.default)(config); | ||
case 'point': | ||
return (0, _point.default)(config); | ||
case 'band': | ||
return (0, _band.default)(config); | ||
default: | ||
} | ||
} // If type is not specified, fallback to linear scale | ||
} | ||
// If type is not specified, fallback to linear scale | ||
return (0, _linear.default)(config); | ||
} | ||
var _default = createScale; | ||
exports.default = _default; |
@@ -27,90 +27,46 @@ "use strict"; | ||
}; | ||
exports.scaleCanBeZeroed = exports.toString = exports.getTicks = exports.coerceNumber = exports.inferScaleType = exports.updateScale = exports.createScale = exports.scaleSqrt = exports.scaleThreshold = exports.scaleSymlog = exports.scaleQuantile = exports.scaleQuantize = exports.scaleOrdinal = exports.scalePower = exports.scaleLog = exports.scaleUtc = exports.scaleTime = exports.scaleRadial = exports.scaleLinear = exports.scalePoint = exports.scaleBand = void 0; | ||
exports.updateScale = exports.toString = exports.scaleUtc = exports.scaleTime = exports.scaleThreshold = exports.scaleSymlog = exports.scaleSqrt = exports.scaleRadial = exports.scaleQuantize = exports.scaleQuantile = exports.scalePower = exports.scalePoint = exports.scaleOrdinal = exports.scaleLog = exports.scaleLinear = exports.scaleCanBeZeroed = exports.scaleBand = exports.inferScaleType = exports.getTicks = exports.createScale = exports.coerceNumber = void 0; | ||
var _band = _interopRequireDefault(require("./scales/band")); | ||
exports.scaleBand = _band.default; | ||
var _point = _interopRequireDefault(require("./scales/point")); | ||
exports.scalePoint = _point.default; | ||
var _linear = _interopRequireDefault(require("./scales/linear")); | ||
exports.scaleLinear = _linear.default; | ||
var _radial = _interopRequireDefault(require("./scales/radial")); | ||
exports.scaleRadial = _radial.default; | ||
var _time = _interopRequireDefault(require("./scales/time")); | ||
exports.scaleTime = _time.default; | ||
var _utc = _interopRequireDefault(require("./scales/utc")); | ||
exports.scaleUtc = _utc.default; | ||
var _log = _interopRequireDefault(require("./scales/log")); | ||
exports.scaleLog = _log.default; | ||
var _power = _interopRequireDefault(require("./scales/power")); | ||
exports.scalePower = _power.default; | ||
var _ordinal = _interopRequireDefault(require("./scales/ordinal")); | ||
exports.scaleOrdinal = _ordinal.default; | ||
var _quantize = _interopRequireDefault(require("./scales/quantize")); | ||
exports.scaleQuantize = _quantize.default; | ||
var _quantile = _interopRequireDefault(require("./scales/quantile")); | ||
exports.scaleQuantile = _quantile.default; | ||
var _symlog = _interopRequireDefault(require("./scales/symlog")); | ||
exports.scaleSymlog = _symlog.default; | ||
var _threshold = _interopRequireDefault(require("./scales/threshold")); | ||
exports.scaleThreshold = _threshold.default; | ||
var _squareRoot = _interopRequireDefault(require("./scales/squareRoot")); | ||
exports.scaleSqrt = _squareRoot.default; | ||
var _createScale = _interopRequireDefault(require("./createScale")); | ||
exports.createScale = _createScale.default; | ||
var _updateScale = _interopRequireDefault(require("./updateScale")); | ||
exports.updateScale = _updateScale.default; | ||
var _inferScaleType = _interopRequireDefault(require("./utils/inferScaleType")); | ||
exports.inferScaleType = _inferScaleType.default; | ||
var _coerceNumber = _interopRequireDefault(require("./utils/coerceNumber")); | ||
exports.coerceNumber = _coerceNumber.default; | ||
var _getTicks = _interopRequireDefault(require("./utils/getTicks")); | ||
exports.getTicks = _getTicks.default; | ||
var _toString = _interopRequireDefault(require("./utils/toString")); | ||
exports.toString = _toString.default; | ||
var _scaleCanBeZeroed = _interopRequireDefault(require("./utils/scaleCanBeZeroed")); | ||
exports.scaleCanBeZeroed = _scaleCanBeZeroed.default; | ||
var _Base = require("./types/Base"); | ||
Object.keys(_Base).forEach(function (key) { | ||
@@ -122,5 +78,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _Nice = require("./types/Nice"); | ||
Object.keys(_Nice).forEach(function (key) { | ||
@@ -132,5 +86,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _Scale = require("./types/Scale"); | ||
Object.keys(_Scale).forEach(function (key) { | ||
@@ -142,5 +94,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _ScaleConfig = require("./types/ScaleConfig"); | ||
Object.keys(_ScaleConfig).forEach(function (key) { | ||
@@ -152,5 +102,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _ScaleInterpolate = require("./types/ScaleInterpolate"); | ||
Object.keys(_ScaleInterpolate).forEach(function (key) { | ||
@@ -162,3 +110,2 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyAlign; | ||
function applyAlign(scale, config) { | ||
@@ -8,0 +7,0 @@ if ('align' in scale && 'align' in config && typeof config.align !== 'undefined') { |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyBase; | ||
function applyBase(scale, config) { | ||
@@ -8,0 +7,0 @@ if ('base' in scale && 'base' in config && typeof config.base !== 'undefined') { |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyClamp; | ||
function applyClamp(scale, config) { | ||
@@ -8,0 +7,0 @@ if ('clamp' in scale && 'clamp' in config && typeof config.clamp !== 'undefined') { |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyConstant; | ||
function applyConstant(scale, config) { | ||
@@ -8,0 +7,0 @@ if ('constant' in scale && 'constant' in config && typeof config.constant !== 'undefined') { |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyDomain; | ||
function applyDomain(scale, config) { | ||
@@ -8,0 +7,0 @@ if (config.domain) { |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyExponent; | ||
function applyExponent(scale, config) { | ||
@@ -8,0 +7,0 @@ if ('exponent' in scale && 'exponent' in config && typeof config.exponent !== 'undefined') { |
@@ -5,7 +5,4 @@ "use strict"; | ||
exports.default = applyInterpolate; | ||
var _createColorInterpolator = _interopRequireDefault(require("../utils/createColorInterpolator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function applyInterpolate(scale, config) { | ||
@@ -12,0 +9,0 @@ if ('interpolate' in config && 'interpolate' in scale && typeof config.interpolate !== 'undefined') { |
@@ -5,9 +5,5 @@ "use strict"; | ||
exports.default = applyNice; | ||
var _d3Time = require("d3-time"); | ||
var _isUtcScale = _interopRequireDefault(require("../utils/isUtcScale")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var localTimeIntervals = { | ||
@@ -31,7 +27,5 @@ day: _d3Time.timeDay, | ||
}; | ||
function applyNice(scale, config) { | ||
if ('nice' in config && typeof config.nice !== 'undefined' && 'nice' in scale) { | ||
var nice = config.nice; | ||
if (typeof nice === 'boolean') { | ||
@@ -46,3 +40,2 @@ if (nice) { | ||
var isUtc = (0, _isUtcScale.default)(timeScale); | ||
if (typeof nice === 'string') { | ||
@@ -52,5 +45,4 @@ timeScale.nice(isUtc ? utcIntervals[nice] : localTimeIntervals[nice]); | ||
var interval = nice.interval, | ||
step = nice.step; | ||
step = nice.step; | ||
var parsedInterval = (isUtc ? utcIntervals[interval] : localTimeIntervals[interval]).every(step); | ||
if (parsedInterval != null) { | ||
@@ -57,0 +49,0 @@ timeScale.nice(parsedInterval); |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyPadding; | ||
function applyPadding(scale, config) { | ||
@@ -11,7 +10,5 @@ if ('padding' in scale && 'padding' in config && typeof config.padding !== 'undefined') { | ||
} | ||
if ('paddingInner' in scale && 'paddingInner' in config && typeof config.paddingInner !== 'undefined') { | ||
scale.paddingInner(config.paddingInner); | ||
} | ||
if ('paddingOuter' in scale && 'paddingOuter' in config && typeof config.paddingOuter !== 'undefined') { | ||
@@ -18,0 +15,0 @@ scale.paddingOuter(config.paddingOuter); |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyRange; | ||
function applyRange(scale, config) { | ||
@@ -8,0 +7,0 @@ if (config.range) { |
@@ -5,7 +5,5 @@ "use strict"; | ||
exports.default = applyReverse; | ||
function applyReverse(scale, config) { | ||
if (config.reverse) { | ||
var reversedRange = scale.range().slice().reverse(); | ||
if ('padding' in scale) { | ||
@@ -12,0 +10,0 @@ // point and band scales |
@@ -5,5 +5,3 @@ "use strict"; | ||
exports.default = applyRound; | ||
var _d3Interpolate = require("d3-interpolate"); | ||
function applyRound(scale, config) { | ||
@@ -10,0 +8,0 @@ if ('round' in config && typeof config.round !== 'undefined') { |
"use strict"; | ||
exports.__esModule = true; | ||
exports.ALL_OPERATORS = void 0; | ||
exports.default = scaleOperator; | ||
exports.ALL_OPERATORS = void 0; | ||
var _domain = _interopRequireDefault(require("./domain")); | ||
var _range = _interopRequireDefault(require("./range")); | ||
var _align = _interopRequireDefault(require("./align")); | ||
var _base = _interopRequireDefault(require("./base")); | ||
var _clamp = _interopRequireDefault(require("./clamp")); | ||
var _constant = _interopRequireDefault(require("./constant")); | ||
var _exponent = _interopRequireDefault(require("./exponent")); | ||
var _interpolate = _interopRequireDefault(require("./interpolate")); | ||
var _nice = _interopRequireDefault(require("./nice")); | ||
var _padding = _interopRequireDefault(require("./padding")); | ||
var _reverse = _interopRequireDefault(require("./reverse")); | ||
var _round = _interopRequireDefault(require("./round")); | ||
var _unknown = _interopRequireDefault(require("./unknown")); | ||
var _zero = _interopRequireDefault(require("./zero")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* List of all operators, in order of execution | ||
*/ | ||
var ALL_OPERATORS = [// domain => nice => zero | ||
'domain', 'nice', 'zero', // interpolate before round | ||
'interpolate', 'round', // set range then reverse | ||
'range', 'reverse', // Order does not matter for these operators | ||
var ALL_OPERATORS = [ | ||
// domain => nice => zero | ||
'domain', 'nice', 'zero', | ||
// interpolate before round | ||
'interpolate', 'round', | ||
// set range then reverse | ||
'range', 'reverse', | ||
// Order does not matter for these operators | ||
'align', 'base', 'clamp', 'constant', 'exponent', 'padding', 'unknown']; | ||
@@ -63,3 +51,2 @@ exports.ALL_OPERATORS = ALL_OPERATORS; | ||
}; | ||
function scaleOperator() { | ||
@@ -69,3 +56,2 @@ for (var _len = arguments.length, ops = new Array(_len), _key = 0; _key < _len; _key++) { | ||
} | ||
var selection = new Set(ops); | ||
@@ -81,5 +67,4 @@ var selectedOps = ALL_OPERATORS.filter(function (o) { | ||
} | ||
return scale; | ||
}; | ||
} |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyUnknown; | ||
function applyUnknown(scale, config) { | ||
@@ -8,0 +7,0 @@ if ('unknown' in scale && 'unknown' in config && typeof config.unknown !== 'undefined') { |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = applyZero; | ||
function applyZero(scale, config) { | ||
@@ -11,9 +10,7 @@ if ('zero' in config && config.zero === true) { | ||
var a = domain[0], | ||
b = domain[1]; | ||
b = domain[1]; | ||
var isDescending = b < a; | ||
var _ref = isDescending ? [b, a] : [a, b], | ||
min = _ref[0], | ||
max = _ref[1]; | ||
min = _ref[0], | ||
max = _ref[1]; | ||
var domainWithZero = [Math.min(0, min), Math.max(0, max)]; | ||
@@ -20,0 +17,0 @@ scale.domain(isDescending ? domainWithZero.reverse() : domainWithZero); |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateBandScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateBandScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'align', 'padding', 'round'); | ||
exports.updateBandScale = updateBandScale; | ||
function createBandScale(config) { | ||
return updateBandScale((0, _d3Scale.scaleBand)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateLinearScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateLinearScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'clamp', 'interpolate', 'nice', 'round', 'zero'); | ||
exports.updateLinearScale = updateLinearScale; | ||
function createLinearScale(config) { | ||
return updateLinearScale((0, _d3Scale.scaleLinear)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateLogScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateLogScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'base', 'clamp', 'interpolate', 'nice', 'round'); | ||
exports.updateLogScale = updateLogScale; | ||
function createLogScale(config) { | ||
return updateLogScale((0, _d3Scale.scaleLog)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateOrdinalScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateOrdinalScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'unknown'); | ||
exports.updateOrdinalScale = updateOrdinalScale; | ||
function createOrdinalScale(config) { | ||
return updateOrdinalScale((0, _d3Scale.scaleOrdinal)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updatePointScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updatePointScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'align', 'padding', 'round'); | ||
exports.updatePointScale = updatePointScale; | ||
function createPointScale(config) { | ||
return updatePointScale((0, _d3Scale.scalePoint)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updatePowScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updatePowScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'clamp', 'exponent', 'interpolate', 'nice', 'round', 'zero'); | ||
exports.updatePowScale = updatePowScale; | ||
function createPowScale(config) { | ||
return updatePowScale((0, _d3Scale.scalePow)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateQuantileScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateQuantileScale = (0, _scaleOperator.default)('domain', 'range', 'reverse'); | ||
exports.updateQuantileScale = updateQuantileScale; | ||
function createQuantileScale(config) { | ||
return updateQuantileScale((0, _d3Scale.scaleQuantile)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateQuantizeScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateQuantizeScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'nice', 'zero'); | ||
exports.updateQuantizeScale = updateQuantizeScale; | ||
function createQuantizeScale(config) { | ||
return updateQuantizeScale((0, _d3Scale.scaleQuantize)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateRadialScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateRadialScale = (0, _scaleOperator.default)('domain', 'range', 'clamp', 'nice', 'round', 'unknown'); | ||
exports.updateRadialScale = updateRadialScale; | ||
function createRadialScale(config) { | ||
return updateRadialScale((0, _d3Scale.scaleRadial)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateSqrtScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateSqrtScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'clamp', 'interpolate', 'nice', 'round', 'zero'); | ||
exports.updateSqrtScale = updateSqrtScale; | ||
function createSqrtScale(config) { | ||
return updateSqrtScale((0, _d3Scale.scaleSqrt)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateSymlogScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateSymlogScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'clamp', 'constant', 'nice', 'zero', 'round'); | ||
exports.updateSymlogScale = updateSymlogScale; | ||
function createSymlogScale(config) { | ||
return updateSymlogScale((0, _d3Scale.scaleSymlog)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateThresholdScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateThresholdScale = (0, _scaleOperator.default)('domain', 'range', 'reverse'); | ||
exports.updateThresholdScale = updateThresholdScale; | ||
function createThresholdScale(config) { | ||
return updateThresholdScale((0, _d3Scale.scaleThreshold)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateTimeScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateTimeScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'clamp', 'interpolate', 'nice', 'round'); | ||
exports.updateTimeScale = updateTimeScale; | ||
function createTimeScale(config) { | ||
return updateTimeScale((0, _d3Scale.scaleTime)(), config); | ||
} |
@@ -6,14 +6,9 @@ "use strict"; | ||
exports.updateUtcScale = void 0; | ||
var _d3Scale = require("d3-scale"); | ||
var _scaleOperator = _interopRequireDefault(require("../operators/scaleOperator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var updateUtcScale = (0, _scaleOperator.default)('domain', 'range', 'reverse', 'clamp', 'interpolate', 'nice', 'round'); | ||
exports.updateUtcScale = updateUtcScale; | ||
function createUtcScale(config) { | ||
return updateUtcScale((0, _d3Scale.scaleUtc)(), config); | ||
} |
@@ -5,19 +5,19 @@ "use strict"; | ||
exports.default = void 0; | ||
var _scaleOperator = _interopRequireWildcard(require("./operators/scaleOperator")); | ||
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); } | ||
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; } | ||
/* eslint-disable no-redeclare */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
var applyAllOperators = _scaleOperator.default.apply(void 0, _scaleOperator.ALL_OPERATORS); // Overload function signature for more strict typing, e.g., | ||
var applyAllOperators = _scaleOperator.default.apply(void 0, _scaleOperator.ALL_OPERATORS); | ||
// Overload function signature for more strict typing, e.g., | ||
// If the scale is a ScaleLinear, the config is a linear config. | ||
// Actual implementation | ||
// Actual implementation | ||
function updateScale(scale, config) { | ||
return applyAllOperators(scale.copy(), config); | ||
} | ||
var _default = updateScale; | ||
exports.default = _default; |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = coerceNumber; | ||
function coerceNumber(val) { | ||
@@ -12,4 +11,3 @@ if ((typeof val === 'function' || typeof val === 'object' && !!val) && 'valueOf' in val) { | ||
} | ||
return val; | ||
} |
@@ -5,5 +5,3 @@ "use strict"; | ||
exports.default = createColorInterpolator; | ||
var _d3Interpolate = require("d3-interpolate"); | ||
var interpolatorMap = { | ||
@@ -19,3 +17,2 @@ lab: _d3Interpolate.interpolateLab, | ||
}; | ||
function createColorInterpolator(interpolate) { | ||
@@ -32,10 +29,8 @@ switch (interpolate) { | ||
return interpolatorMap[interpolate]; | ||
default: | ||
} | ||
var type = interpolate.type, | ||
gamma = interpolate.gamma; | ||
gamma = interpolate.gamma; | ||
var interpolator = interpolatorMap[type]; | ||
return typeof gamma === 'undefined' ? interpolator : interpolator.gamma(gamma); | ||
} |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.default = getTicks; | ||
function getTicks(scale, numTicks) { | ||
@@ -13,7 +12,5 @@ // Because `Scale` is generic type which maybe a subset of AnyD3Scale | ||
var s = scale; | ||
if ('ticks' in s) { | ||
return s.ticks(numTicks); | ||
} | ||
return s.domain().filter(function (_, index, arr) { | ||
@@ -20,0 +17,0 @@ return numTicks == null || arr.length <= numTicks || index % Math.round((arr.length - 1) / numTicks) === 0; |
@@ -5,33 +5,25 @@ "use strict"; | ||
exports.default = inferScaleType; | ||
var _isUtcScale = _interopRequireDefault(require("./isUtcScale")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function inferScaleType(scale) { | ||
// Try a sequence of typeguards to figure out the scale type | ||
if ('paddingInner' in scale) { | ||
return 'band'; | ||
} | ||
if ('padding' in scale) { | ||
return 'point'; | ||
} | ||
if ('quantiles' in scale) { | ||
return 'quantile'; | ||
} | ||
if ('base' in scale) { | ||
return 'log'; | ||
} | ||
if ('exponent' in scale) { | ||
return scale.exponent() === 0.5 ? 'sqrt' : 'pow'; | ||
} | ||
if ('constant' in scale) { | ||
return 'symlog'; | ||
} | ||
if ('clamp' in scale) { | ||
@@ -42,15 +34,11 @@ // Linear, Time or Utc scales | ||
} | ||
return 'linear'; | ||
} | ||
if ('nice' in scale) { | ||
return 'quantize'; | ||
} | ||
if ('invertExtent' in scale) { | ||
return 'threshold'; | ||
} | ||
return 'ordinal'; | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
var TEST_FORMAT = '%Y-%m-%d %H:%M'; | ||
/** | ||
@@ -13,3 +14,2 @@ * Check if the scale is UTC or Time scale | ||
*/ | ||
function isUtcScale(scale) { | ||
@@ -16,0 +16,0 @@ // The only difference between time and utc scale is |
@@ -6,5 +6,4 @@ "use strict"; | ||
var zeroableScaleTypes = new Set(['linear', 'pow', 'quantize', 'sqrt', 'symlog']); | ||
function scaleCanBeZeroed(scaleConfig) { | ||
return zeroableScaleTypes.has(scaleConfig.type); | ||
} |
@@ -5,5 +5,4 @@ "use strict"; | ||
exports.default = toString; | ||
function toString(x) { | ||
return x == null ? void 0 : x.toString(); | ||
} |
{ | ||
"name": "@visx/scale", | ||
"version": "2.2.2", | ||
"version": "2.17.0-alpha.0", | ||
"description": "visx scale", | ||
@@ -44,3 +44,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "488a0e570b86f00386e24de72705b312d3f10048" | ||
"gitHead": "77292e262dfe082b554b64839eb3ee141439a95f" | ||
} |
@@ -113,3 +113,4 @@ # @visx/scale | ||
**Important note:** As log(0) = -∞, a log scale domain must be strictly-positive or strictly-negative; the domain must not include or cross zero. | ||
**Important note:** As log(0) = -∞, a log scale domain must be strictly-positive or | ||
strictly-negative; the domain must not include or cross zero. | ||
@@ -116,0 +117,0 @@ ### Radial scale |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141803
1718
272
1