vega-scale
Advanced tools
Comparing version 2.1.1 to 2.2.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-scale'), require('vega-util'), require('d3-scale-chromatic'), require('d3-interpolate'), require('d3-time')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-array', 'd3-scale', 'vega-util', 'd3-scale-chromatic', 'd3-interpolate', 'd3-time'], factory) : | ||
(factory((global.vega = global.vega || {}),global.d3,global.d3,global.vega,global.d3,global.d3,global.d3)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-scale'), require('vega-util'), require('d3-scale-chromatic'), require('d3-interpolate'), require('d3-time')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-array', 'd3-scale', 'vega-util', 'd3-scale-chromatic', 'd3-interpolate', 'd3-time'], factory) : | ||
(factory((global.vega = {}),global.d3,global.d3,global.vega,global.d3,global.d3,global.d3)); | ||
}(this, (function (exports,d3Array,$,vegaUtil,_,$$1,d3Time) { 'use strict'; | ||
var invertRange = function(scale) { | ||
return function(_$$1) { | ||
var lo = _$$1[0], | ||
hi = _$$1[1], | ||
t; | ||
function invertRange(scale) { | ||
return function(_$$1) { | ||
var lo = _$$1[0], | ||
hi = _$$1[1], | ||
t; | ||
if (hi < lo) { | ||
t = lo; | ||
lo = hi; | ||
hi = t; | ||
if (hi < lo) { | ||
t = lo; | ||
lo = hi; | ||
hi = t; | ||
} | ||
return [ | ||
scale.invert(lo), | ||
scale.invert(hi) | ||
]; | ||
} | ||
return [ | ||
scale.invert(lo), | ||
scale.invert(hi) | ||
]; | ||
} | ||
}; | ||
var invertRangeExtent = function(scale) { | ||
return function(_$$1) { | ||
var range$$1 = scale.range(), | ||
lo = _$$1[0], | ||
hi = _$$1[1], | ||
min = -1, max, t, i, n; | ||
function invertRangeExtent(scale) { | ||
return function(_$$1) { | ||
var range = scale.range(), | ||
lo = _$$1[0], | ||
hi = _$$1[1], | ||
min = -1, max, t, i, n; | ||
if (hi < lo) { | ||
t = lo; | ||
lo = hi; | ||
hi = t; | ||
} | ||
if (hi < lo) { | ||
t = lo; | ||
lo = hi; | ||
hi = t; | ||
} | ||
for (i=0, n=range$$1.length; i<n; ++i) { | ||
if (range$$1[i] >= lo && range$$1[i] <= hi) { | ||
if (min < 0) min = i; | ||
max = i; | ||
for (i=0, n=range.length; i<n; ++i) { | ||
if (range[i] >= lo && range[i] <= hi) { | ||
if (min < 0) min = i; | ||
max = i; | ||
} | ||
} | ||
} | ||
if (min < 0) return undefined; | ||
if (min < 0) return undefined; | ||
lo = scale.invertExtent(range$$1[min]); | ||
hi = scale.invertExtent(range$$1[max]); | ||
lo = scale.invertExtent(range[min]); | ||
hi = scale.invertExtent(range[max]); | ||
return [ | ||
lo[0] === undefined ? lo[1] : lo[0], | ||
hi[1] === undefined ? hi[0] : hi[1] | ||
]; | ||
return [ | ||
lo[0] === undefined ? lo[1] : lo[0], | ||
hi[1] === undefined ? hi[0] : hi[1] | ||
]; | ||
} | ||
} | ||
}; | ||
var bandSpace = function(count, paddingInner, paddingOuter) { | ||
var space = count - paddingInner + paddingOuter * 2; | ||
return count ? (space > 0 ? space : 1) : 0; | ||
}; | ||
function bandSpace(count, paddingInner, paddingOuter) { | ||
var space = count - paddingInner + paddingOuter * 2; | ||
return count ? (space > 0 ? space : 1) : 0; | ||
} | ||
function band() { | ||
var scale = $.scaleOrdinal().unknown(undefined), | ||
domain = scale.domain, | ||
ordinalRange = scale.range, | ||
range$$1 = [0, 1], | ||
step, | ||
bandwidth, | ||
round = false, | ||
paddingInner = 0, | ||
paddingOuter = 0, | ||
align = 0.5; | ||
function band() { | ||
var scale = $.scaleOrdinal().unknown(undefined), | ||
domain = scale.domain, | ||
ordinalRange = scale.range, | ||
range = [0, 1], | ||
step, | ||
bandwidth, | ||
round = false, | ||
paddingInner = 0, | ||
paddingOuter = 0, | ||
align = 0.5; | ||
delete scale.unknown; | ||
delete scale.unknown; | ||
function rescale() { | ||
var n = domain().length, | ||
reverse = range$$1[1] < range$$1[0], | ||
start = range$$1[reverse - 0], | ||
stop = range$$1[1 - reverse], | ||
space = bandSpace(n, paddingInner, paddingOuter); | ||
function rescale() { | ||
var n = domain().length, | ||
reverse = range[1] < range[0], | ||
start = range[reverse - 0], | ||
stop = range[1 - reverse], | ||
space = bandSpace(n, paddingInner, paddingOuter); | ||
step = (stop - start) / (space || 1); | ||
if (round) { | ||
step = Math.floor(step); | ||
step = (stop - start) / (space || 1); | ||
if (round) { | ||
step = Math.floor(step); | ||
} | ||
start += (stop - start - step * (n - paddingInner)) * align; | ||
bandwidth = step * (1 - paddingInner); | ||
if (round) { | ||
start = Math.round(start); | ||
bandwidth = Math.round(bandwidth); | ||
} | ||
var values = d3Array.range(n).map(function(i) { return start + step * i; }); | ||
return ordinalRange(reverse ? values.reverse() : values); | ||
} | ||
start += (stop - start - step * (n - paddingInner)) * align; | ||
bandwidth = step * (1 - paddingInner); | ||
if (round) { | ||
start = Math.round(start); | ||
bandwidth = Math.round(bandwidth); | ||
} | ||
var values = d3Array.range(n).map(function(i) { return start + step * i; }); | ||
return ordinalRange(reverse ? values.reverse() : values); | ||
} | ||
scale.domain = function(_$$1) { | ||
if (arguments.length) { | ||
domain(_$$1); | ||
return rescale(); | ||
} else { | ||
return domain(); | ||
} | ||
}; | ||
scale.domain = function(_$$1) { | ||
if (arguments.length) { | ||
domain(_$$1); | ||
return rescale(); | ||
} else { | ||
return domain(); | ||
} | ||
}; | ||
scale.range = function(_$$1) { | ||
if (arguments.length) { | ||
range$$1 = [+_$$1[0], +_$$1[1]]; | ||
return rescale(); | ||
} else { | ||
return range$$1.slice(); | ||
} | ||
}; | ||
scale.range = function(_$$1) { | ||
if (arguments.length) { | ||
range = [+_$$1[0], +_$$1[1]]; | ||
return rescale(); | ||
} else { | ||
return range.slice(); | ||
} | ||
}; | ||
scale.rangeRound = function(_$$1) { | ||
range$$1 = [+_$$1[0], +_$$1[1]]; | ||
round = true; | ||
return rescale(); | ||
}; | ||
scale.bandwidth = function() { | ||
return bandwidth; | ||
}; | ||
scale.step = function() { | ||
return step; | ||
}; | ||
scale.round = function(_$$1) { | ||
if (arguments.length) { | ||
round = !!_$$1; | ||
scale.rangeRound = function(_$$1) { | ||
range = [+_$$1[0], +_$$1[1]]; | ||
round = true; | ||
return rescale(); | ||
} else { | ||
return round; | ||
} | ||
}; | ||
}; | ||
scale.padding = function(_$$1) { | ||
if (arguments.length) { | ||
paddingOuter = Math.max(0, Math.min(1, _$$1)); | ||
paddingInner = paddingOuter; | ||
return rescale(); | ||
} else { | ||
return paddingInner; | ||
} | ||
}; | ||
scale.bandwidth = function() { | ||
return bandwidth; | ||
}; | ||
scale.paddingInner = function(_$$1) { | ||
if (arguments.length) { | ||
paddingInner = Math.max(0, Math.min(1, _$$1)); | ||
return rescale(); | ||
} else { | ||
return paddingInner; | ||
} | ||
}; | ||
scale.step = function() { | ||
return step; | ||
}; | ||
scale.paddingOuter = function(_$$1) { | ||
if (arguments.length) { | ||
paddingOuter = Math.max(0, Math.min(1, _$$1)); | ||
return rescale(); | ||
} else { | ||
return paddingOuter; | ||
} | ||
}; | ||
scale.round = function(_$$1) { | ||
if (arguments.length) { | ||
round = !!_$$1; | ||
return rescale(); | ||
} else { | ||
return round; | ||
} | ||
}; | ||
scale.align = function(_$$1) { | ||
if (arguments.length) { | ||
align = Math.max(0, Math.min(1, _$$1)); | ||
return rescale(); | ||
} else { | ||
return align; | ||
} | ||
}; | ||
scale.padding = function(_$$1) { | ||
if (arguments.length) { | ||
paddingOuter = Math.max(0, Math.min(1, _$$1)); | ||
paddingInner = paddingOuter; | ||
return rescale(); | ||
} else { | ||
return paddingInner; | ||
} | ||
}; | ||
scale.invertRange = function(_$$1) { | ||
// bail if range has null or undefined values | ||
if (_$$1[0] == null || _$$1[1] == null) return; | ||
scale.paddingInner = function(_$$1) { | ||
if (arguments.length) { | ||
paddingInner = Math.max(0, Math.min(1, _$$1)); | ||
return rescale(); | ||
} else { | ||
return paddingInner; | ||
} | ||
}; | ||
var lo = +_$$1[0], | ||
hi = +_$$1[1], | ||
reverse = range$$1[1] < range$$1[0], | ||
values = reverse ? ordinalRange().reverse() : ordinalRange(), | ||
n = values.length - 1, a, b, t; | ||
scale.paddingOuter = function(_$$1) { | ||
if (arguments.length) { | ||
paddingOuter = Math.max(0, Math.min(1, _$$1)); | ||
return rescale(); | ||
} else { | ||
return paddingOuter; | ||
} | ||
}; | ||
// bail if either range endpoint is invalid | ||
if (lo !== lo || hi !== hi) return; | ||
scale.align = function(_$$1) { | ||
if (arguments.length) { | ||
align = Math.max(0, Math.min(1, _$$1)); | ||
return rescale(); | ||
} else { | ||
return align; | ||
} | ||
}; | ||
// order range inputs, bail if outside of scale range | ||
if (hi < lo) { | ||
t = lo; | ||
lo = hi; | ||
hi = t; | ||
} | ||
if (hi < values[0] || lo > range$$1[1-reverse]) return; | ||
scale.invertRange = function(_$$1) { | ||
// bail if range has null or undefined values | ||
if (_$$1[0] == null || _$$1[1] == null) return; | ||
// binary search to index into scale range | ||
a = Math.max(0, d3Array.bisectRight(values, lo) - 1); | ||
b = lo===hi ? a : d3Array.bisectRight(values, hi) - 1; | ||
var lo = +_$$1[0], | ||
hi = +_$$1[1], | ||
reverse = range[1] < range[0], | ||
values = reverse ? ordinalRange().reverse() : ordinalRange(), | ||
n = values.length - 1, a, b, t; | ||
// increment index a if lo is within padding gap | ||
if (lo - values[a] > bandwidth + 1e-10) ++a; | ||
// bail if either range endpoint is invalid | ||
if (lo !== lo || hi !== hi) return; | ||
if (reverse) { | ||
// map + swap | ||
t = a; | ||
a = n - b; | ||
b = n - t; | ||
} | ||
return (a > b) ? undefined : domain().slice(a, b+1); | ||
}; | ||
// order range inputs, bail if outside of scale range | ||
if (hi < lo) { | ||
t = lo; | ||
lo = hi; | ||
hi = t; | ||
} | ||
if (hi < values[0] || lo > range[1-reverse]) return; | ||
scale.invert = function(_$$1) { | ||
var value = scale.invertRange([_$$1, _$$1]); | ||
return value ? value[0] : value; | ||
}; | ||
// binary search to index into scale range | ||
a = Math.max(0, d3Array.bisectRight(values, lo) - 1); | ||
b = lo===hi ? a : d3Array.bisectRight(values, hi) - 1; | ||
scale.copy = function() { | ||
return band() | ||
.domain(domain()) | ||
.range(range$$1) | ||
.round(round) | ||
.paddingInner(paddingInner) | ||
.paddingOuter(paddingOuter) | ||
.align(align); | ||
}; | ||
// increment index a if lo is within padding gap | ||
if (lo - values[a] > bandwidth + 1e-10) ++a; | ||
return rescale(); | ||
} | ||
if (reverse) { | ||
// map + swap | ||
t = a; | ||
a = n - b; | ||
b = n - t; | ||
} | ||
return (a > b) ? undefined : domain().slice(a, b+1); | ||
}; | ||
function pointish(scale) { | ||
var copy = scale.copy; | ||
scale.invert = function(_$$1) { | ||
var value = scale.invertRange([_$$1, _$$1]); | ||
return value ? value[0] : value; | ||
}; | ||
scale.padding = scale.paddingOuter; | ||
delete scale.paddingInner; | ||
scale.copy = function() { | ||
return band() | ||
.domain(domain()) | ||
.range(range) | ||
.round(round) | ||
.paddingInner(paddingInner) | ||
.paddingOuter(paddingOuter) | ||
.align(align); | ||
}; | ||
scale.copy = function() { | ||
return pointish(copy()); | ||
}; | ||
return rescale(); | ||
} | ||
return scale; | ||
} | ||
function pointish(scale) { | ||
var copy = scale.copy; | ||
function point() { | ||
return pointish(band().paddingInner(1)); | ||
} | ||
scale.padding = scale.paddingOuter; | ||
delete scale.paddingInner; | ||
var map = Array.prototype.map; | ||
var slice = Array.prototype.slice; | ||
scale.copy = function() { | ||
return pointish(copy()); | ||
}; | ||
function numbers(_$$1) { | ||
return map.call(_$$1, function(x) { return +x; }); | ||
} | ||
return scale; | ||
} | ||
function binLinear() { | ||
var linear = $.scaleLinear(), | ||
domain = []; | ||
function scale(x) { | ||
return linear(x); | ||
function point() { | ||
return pointish(band().paddingInner(1)); | ||
} | ||
function setDomain(_$$1) { | ||
domain = numbers(_$$1); | ||
linear.domain([domain[0], vegaUtil.peek(domain)]); | ||
var map = Array.prototype.map, | ||
slice = Array.prototype.slice; | ||
function numbers(_$$1) { | ||
return map.call(_$$1, function(x) { return +x; }); | ||
} | ||
scale.domain = function(_$$1) { | ||
return arguments.length ? (setDomain(_$$1), scale) : domain.slice(); | ||
}; | ||
function binLinear() { | ||
var linear = $.scaleLinear(), | ||
domain = []; | ||
scale.range = function(_$$1) { | ||
return arguments.length ? (linear.range(_$$1), scale) : linear.range(); | ||
}; | ||
function scale(x) { | ||
return linear(x); | ||
} | ||
scale.rangeRound = function(_$$1) { | ||
return arguments.length ? (linear.rangeRound(_$$1), scale) : linear.rangeRound(); | ||
}; | ||
function setDomain(_$$1) { | ||
domain = numbers(_$$1); | ||
linear.domain([domain[0], vegaUtil.peek(domain)]); | ||
} | ||
scale.interpolate = function(_$$1) { | ||
return arguments.length ? (linear.interpolate(_$$1), scale) : linear.interpolate(); | ||
}; | ||
scale.domain = function(_$$1) { | ||
return arguments.length ? (setDomain(_$$1), scale) : domain.slice(); | ||
}; | ||
scale.invert = function(_$$1) { | ||
return linear.invert(_$$1); | ||
}; | ||
scale.range = function(_$$1) { | ||
return arguments.length ? (linear.range(_$$1), scale) : linear.range(); | ||
}; | ||
scale.ticks = function(count) { | ||
var n = domain.length, | ||
stride = ~~(n / (count || n)); | ||
scale.rangeRound = function(_$$1) { | ||
return arguments.length ? (linear.rangeRound(_$$1), scale) : linear.rangeRound(); | ||
}; | ||
return stride < 2 | ||
? scale.domain() | ||
: domain.filter(function(x, i) { return !(i % stride); }); | ||
}; | ||
scale.interpolate = function(_$$1) { | ||
return arguments.length ? (linear.interpolate(_$$1), scale) : linear.interpolate(); | ||
}; | ||
scale.tickFormat = function() { | ||
return linear.tickFormat.apply(linear, arguments); | ||
}; | ||
scale.invert = function(_$$1) { | ||
return linear.invert(_$$1); | ||
}; | ||
scale.copy = function() { | ||
return binLinear().domain(scale.domain()).range(scale.range()); | ||
}; | ||
scale.ticks = function(count) { | ||
var n = domain.length, | ||
stride = ~~(n / (count || n)); | ||
return scale; | ||
} | ||
return stride < 2 | ||
? scale.domain() | ||
: domain.filter(function(x, i) { return !(i % stride); }); | ||
}; | ||
function binOrdinal() { | ||
var domain = [], | ||
range$$1 = []; | ||
scale.tickFormat = function() { | ||
return linear.tickFormat.apply(linear, arguments); | ||
}; | ||
function scale(x) { | ||
return x == null || x !== x | ||
? undefined | ||
: range$$1[(d3Array.bisect(domain, x) - 1) % range$$1.length]; | ||
scale.copy = function() { | ||
return binLinear().domain(scale.domain()).range(scale.range()); | ||
}; | ||
return scale; | ||
} | ||
scale.domain = function(_$$1) { | ||
if (arguments.length) { | ||
domain = numbers(_$$1); | ||
return scale; | ||
} else { | ||
return domain.slice(); | ||
} | ||
}; | ||
function binOrdinal() { | ||
var domain = [], | ||
range = []; | ||
scale.range = function(_$$1) { | ||
if (arguments.length) { | ||
range$$1 = slice.call(_$$1); | ||
return scale; | ||
} else { | ||
return range$$1.slice(); | ||
function scale(x) { | ||
return x == null || x !== x | ||
? undefined | ||
: range[(d3Array.bisect(domain, x) - 1) % range.length]; | ||
} | ||
}; | ||
scale.copy = function() { | ||
return binOrdinal().domain(scale.domain()).range(scale.range()); | ||
}; | ||
scale.domain = function(_$$1) { | ||
if (arguments.length) { | ||
domain = numbers(_$$1); | ||
return scale; | ||
} else { | ||
return domain.slice(); | ||
} | ||
}; | ||
return scale; | ||
} | ||
scale.range = function(_$$1) { | ||
if (arguments.length) { | ||
range = slice.call(_$$1); | ||
return scale; | ||
} else { | ||
return range.slice(); | ||
} | ||
}; | ||
function sequential(interpolator) { | ||
var linear = $.scaleLinear(), | ||
x0 = 0, | ||
dx = 1, | ||
clamp = false; | ||
scale.copy = function() { | ||
return binOrdinal().domain(scale.domain()).range(scale.range()); | ||
}; | ||
function update() { | ||
var domain = linear.domain(); | ||
x0 = domain[0]; | ||
dx = vegaUtil.peek(domain) - x0; | ||
return scale; | ||
} | ||
function scale(x) { | ||
var t = (x - x0) / dx; | ||
return interpolator(clamp ? Math.max(0, Math.min(1, t)) : t); | ||
} | ||
function sequential(interpolator) { | ||
var linear = $.scaleLinear(), | ||
x0 = 0, | ||
dx = 1, | ||
clamp = false; | ||
scale.clamp = function(_$$1) { | ||
if (arguments.length) { | ||
clamp = !!_$$1; | ||
return scale; | ||
} else { | ||
return clamp; | ||
function update() { | ||
var domain = linear.domain(); | ||
x0 = domain[0]; | ||
dx = vegaUtil.peek(domain) - x0; | ||
} | ||
}; | ||
scale.domain = function(_$$1) { | ||
return arguments.length ? (linear.domain(_$$1), update(), scale) : linear.domain(); | ||
}; | ||
scale.interpolator = function(_$$1) { | ||
if (arguments.length) { | ||
interpolator = _$$1; | ||
return scale; | ||
} else { | ||
return interpolator; | ||
function scale(x) { | ||
var t = (x - x0) / dx; | ||
return interpolator(clamp ? Math.max(0, Math.min(1, t)) : t); | ||
} | ||
}; | ||
scale.copy = function() { | ||
return sequential().domain(linear.domain()).clamp(clamp).interpolator(interpolator); | ||
}; | ||
scale.clamp = function(_$$1) { | ||
if (arguments.length) { | ||
clamp = !!_$$1; | ||
return scale; | ||
} else { | ||
return clamp; | ||
} | ||
}; | ||
scale.ticks = function(count) { | ||
return linear.ticks(count); | ||
}; | ||
scale.domain = function(_$$1) { | ||
return arguments.length ? (linear.domain(_$$1), update(), scale) : linear.domain(); | ||
}; | ||
scale.tickFormat = function(count, specifier) { | ||
return linear.tickFormat(count, specifier); | ||
}; | ||
scale.interpolator = function(_$$1) { | ||
if (arguments.length) { | ||
interpolator = _$$1; | ||
return scale; | ||
} else { | ||
return interpolator; | ||
} | ||
}; | ||
scale.nice = function(count) { | ||
return linear.nice(count), update(), scale; | ||
}; | ||
scale.copy = function() { | ||
return sequential().domain(linear.domain()).clamp(clamp).interpolator(interpolator); | ||
}; | ||
return scale; | ||
} | ||
scale.ticks = function(count) { | ||
return linear.ticks(count); | ||
}; | ||
/** | ||
* Augment scales with their type and needed inverse methods. | ||
*/ | ||
function create(type, constructor) { | ||
return function scale() { | ||
var s = constructor(); | ||
scale.tickFormat = function(count, specifier) { | ||
return linear.tickFormat(count, specifier); | ||
}; | ||
if (!s.invertRange) { | ||
s.invertRange = s.invert ? invertRange(s) | ||
: s.invertExtent ? invertRangeExtent(s) | ||
: undefined; | ||
scale.nice = function(count) { | ||
return linear.nice(count), update(), scale; | ||
}; | ||
return scale; | ||
} | ||
/** | ||
* Augment scales with their type and needed inverse methods. | ||
*/ | ||
function create(type, constructor) { | ||
return function scale() { | ||
var s = constructor(); | ||
if (!s.invertRange) { | ||
s.invertRange = s.invert ? invertRange(s) | ||
: s.invertExtent ? invertRangeExtent(s) | ||
: undefined; | ||
} | ||
s.type = type; | ||
return s; | ||
}; | ||
} | ||
function scale(type, scale) { | ||
if (arguments.length > 1) { | ||
scales[type] = create(type, scale); | ||
return this; | ||
} else { | ||
return scales.hasOwnProperty(type) ? scales[type] : undefined; | ||
} | ||
} | ||
s.type = type; | ||
return s; | ||
var scales = { | ||
// base scale types | ||
identity: $.scaleIdentity, | ||
linear: $.scaleLinear, | ||
log: $.scaleLog, | ||
ordinal: $.scaleOrdinal, | ||
pow: $.scalePow, | ||
sqrt: $.scaleSqrt, | ||
quantile: $.scaleQuantile, | ||
quantize: $.scaleQuantize, | ||
threshold: $.scaleThreshold, | ||
time: $.scaleTime, | ||
utc: $.scaleUtc, | ||
// extended scale types | ||
band: band, | ||
point: point, | ||
sequential: sequential, | ||
'bin-linear': binLinear, | ||
'bin-ordinal': binOrdinal | ||
}; | ||
} | ||
function scale(type, scale) { | ||
if (arguments.length > 1) { | ||
scales[type] = create(type, scale); | ||
return this; | ||
} else { | ||
return scales.hasOwnProperty(type) ? scales[type] : undefined; | ||
for (var key in scales) { | ||
scale(key, scales[key]); | ||
} | ||
} | ||
var scales = { | ||
// base scale types | ||
identity: $.scaleIdentity, | ||
linear: $.scaleLinear, | ||
log: $.scaleLog, | ||
ordinal: $.scaleOrdinal, | ||
pow: $.scalePow, | ||
sqrt: $.scaleSqrt, | ||
quantile: $.scaleQuantile, | ||
quantize: $.scaleQuantize, | ||
threshold: $.scaleThreshold, | ||
time: $.scaleTime, | ||
utc: $.scaleUtc, | ||
function colors(specifier) { | ||
var n = specifier.length / 6 | 0, colors = new Array(n), i = 0; | ||
while (i < n) colors[i] = "#" + specifier.slice(i * 6, ++i * 6); | ||
return colors; | ||
} | ||
// extended scale types | ||
band: band, | ||
point: point, | ||
sequential: sequential, | ||
'bin-linear': binLinear, | ||
'bin-ordinal': binOrdinal | ||
}; | ||
var category20 = colors( | ||
'1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5' | ||
); | ||
for (var key in scales) { | ||
scale(key, scales[key]); | ||
} | ||
var category20b = colors( | ||
'393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6' | ||
); | ||
function colors(specifier) { | ||
var n = specifier.length / 6 | 0, colors = new Array(n), i = 0; | ||
while (i < n) colors[i] = "#" + specifier.slice(i * 6, ++i * 6); | ||
return colors; | ||
} | ||
var category20c = colors( | ||
'3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9' | ||
); | ||
var category20 = colors( | ||
'1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5' | ||
); | ||
var tableau10 = colors( | ||
'4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac' | ||
); | ||
var category20b = colors( | ||
'393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6' | ||
); | ||
var tableau20 = colors( | ||
'4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5' | ||
); | ||
var category20c = colors( | ||
'3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9' | ||
); | ||
var blueOrange = new Array(3).concat( | ||
"67a9cff7f7f7f1a340", | ||
"0571b092c5defdb863e66101", | ||
"0571b092c5def7f7f7fdb863e66101", | ||
"2166ac67a9cfd1e5f0fee0b6f1a340b35806", | ||
"2166ac67a9cfd1e5f0f7f7f7fee0b6f1a340b35806", | ||
"2166ac4393c392c5ded1e5f0fee0b6fdb863e08214b35806", | ||
"2166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b35806", | ||
"0530612166ac4393c392c5ded1e5f0fee0b6fdb863e08214b358067f3b08", | ||
"0530612166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b358067f3b08" | ||
).map(colors); | ||
var tableau10 = colors( | ||
'4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac' | ||
); | ||
var discrete = { | ||
blueorange: blueOrange | ||
}; | ||
var tableau20 = colors( | ||
'4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5' | ||
); | ||
var schemes = { | ||
// d3 categorical palettes | ||
category10: _.schemeCategory10, | ||
accent: _.schemeAccent, | ||
dark2: _.schemeDark2, | ||
paired: _.schemePaired, | ||
pastel1: _.schemePastel1, | ||
pastel2: _.schemePastel2, | ||
set1: _.schemeSet1, | ||
set2: _.schemeSet2, | ||
set3: _.schemeSet3, | ||
var blueOrange = new Array(3).concat( | ||
"67a9cff7f7f7f1a340", | ||
"0571b092c5defdb863e66101", | ||
"0571b092c5def7f7f7fdb863e66101", | ||
"2166ac67a9cfd1e5f0fee0b6f1a340b35806", | ||
"2166ac67a9cfd1e5f0f7f7f7fee0b6f1a340b35806", | ||
"2166ac4393c392c5ded1e5f0fee0b6fdb863e08214b35806", | ||
"2166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b35806", | ||
"0530612166ac4393c392c5ded1e5f0fee0b6fdb863e08214b358067f3b08", | ||
"0530612166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b358067f3b08" | ||
).map(colors); | ||
// additional categorical palettes | ||
category20: category20, | ||
category20b: category20b, | ||
category20c: category20c, | ||
tableau10: tableau10, | ||
tableau20: tableau20, | ||
var discrete = { | ||
blueorange: blueOrange | ||
}; | ||
// sequential multi-hue interpolators | ||
viridis: _.interpolateViridis, | ||
magma: _.interpolateMagma, | ||
inferno: _.interpolateInferno, | ||
plasma: _.interpolatePlasma, | ||
var schemes = { | ||
// d3 categorical palettes | ||
category10: _.schemeCategory10, | ||
accent: _.schemeAccent, | ||
dark2: _.schemeDark2, | ||
paired: _.schemePaired, | ||
pastel1: _.schemePastel1, | ||
pastel2: _.schemePastel2, | ||
set1: _.schemeSet1, | ||
set2: _.schemeSet2, | ||
set3: _.schemeSet3, | ||
// cyclic interpolators | ||
rainbow: _.interpolateRainbow, | ||
sinebow: _.interpolateSinebow, | ||
// additional categorical palettes | ||
category20: category20, | ||
category20b: category20b, | ||
category20c: category20c, | ||
tableau10: tableau10, | ||
tableau20: tableau20, | ||
// extended interpolators | ||
blueorange: $$1.interpolateRgbBasis(vegaUtil.peek(blueOrange)) | ||
}; | ||
// sequential multi-hue interpolators | ||
viridis: _.interpolateViridis, | ||
magma: _.interpolateMagma, | ||
inferno: _.interpolateInferno, | ||
plasma: _.interpolatePlasma, | ||
function add(name, suffix) { | ||
schemes[name] = _['interpolate' + suffix]; | ||
discrete[name] = _['scheme' + suffix]; | ||
} | ||
// extended interpolators | ||
blueorange: $$1.interpolateRgbBasis(vegaUtil.peek(blueOrange)) | ||
}; | ||
// sequential single-hue | ||
add('blues', 'Blues'); | ||
add('greens', 'Greens'); | ||
add('greys', 'Greys'); | ||
add('purples', 'Purples'); | ||
add('reds', 'Reds'); | ||
add('oranges', 'Oranges'); | ||
function add(name, suffix) { | ||
schemes[name] = _['interpolate' + suffix]; | ||
discrete[name] = _['scheme' + suffix]; | ||
} | ||
// diverging | ||
add('brownbluegreen', 'BrBG'); | ||
add('purplegreen', 'PRGn'); | ||
add('pinkyellowgreen', 'PiYG'); | ||
add('purpleorange', 'PuOr'); | ||
add('redblue', 'RdBu'); | ||
add('redgrey', 'RdGy'); | ||
add('redyellowblue', 'RdYlBu'); | ||
add('redyellowgreen', 'RdYlGn'); | ||
add('spectral', 'Spectral'); | ||
// sequential single-hue | ||
add('blues', 'Blues'); | ||
add('greens', 'Greens'); | ||
add('greys', 'Greys'); | ||
add('purples', 'Purples'); | ||
add('reds', 'Reds'); | ||
add('oranges', 'Oranges'); | ||
// sequential multi-hue | ||
add('bluegreen', 'BuGn'); | ||
add('bluepurple', 'BuPu'); | ||
add('greenblue', 'GnBu'); | ||
add('orangered', 'OrRd'); | ||
add('purplebluegreen', 'PuBuGn'); | ||
add('purpleblue', 'PuBu'); | ||
add('purplered', 'PuRd'); | ||
add('redpurple', 'RdPu'); | ||
add('yellowgreenblue', 'YlGnBu'); | ||
add('yellowgreen', 'YlGn'); | ||
add('yelloworangebrown', 'YlOrBr'); | ||
add('yelloworangered', 'YlOrRd'); | ||
// diverging | ||
add('brownbluegreen', 'BrBG'); | ||
add('purplegreen', 'PRGn'); | ||
add('pinkyellowgreen', 'PiYG'); | ||
add('purpleorange', 'PuOr'); | ||
add('redblue', 'RdBu'); | ||
add('redgrey', 'RdGy'); | ||
add('redyellowblue', 'RdYlBu'); | ||
add('redyellowgreen', 'RdYlGn'); | ||
add('spectral', 'Spectral'); | ||
function schemes$1(name, scheme) { | ||
if (arguments.length > 1) { | ||
schemes[name] = scheme; | ||
return this; | ||
} | ||
// sequential multi-hue | ||
add('bluegreen', 'BuGn'); | ||
add('bluepurple', 'BuPu'); | ||
add('greenblue', 'GnBu'); | ||
add('orangered', 'OrRd'); | ||
add('purplebluegreen', 'PuBuGn'); | ||
add('purpleblue', 'PuBu'); | ||
add('purplered', 'PuRd'); | ||
add('redpurple', 'RdPu'); | ||
add('yellowgreenblue', 'YlGnBu'); | ||
add('yellowgreen', 'YlGn'); | ||
add('yelloworangebrown', 'YlOrBr'); | ||
add('yelloworangered', 'YlOrRd'); | ||
var part = name.split('-'); | ||
name = part[0]; | ||
part = +part[1] + 1; | ||
var schemes$1 = function(name, scheme) { | ||
if (arguments.length > 1) { | ||
schemes[name] = scheme; | ||
return this; | ||
return part && discrete.hasOwnProperty(name) ? discrete[name][part-1] | ||
: !part && schemes.hasOwnProperty(name) ? schemes[name] | ||
: undefined; | ||
} | ||
var part = name.split('-'); | ||
name = part[0]; | ||
part = +part[1] + 1; | ||
function interpolateRange(interpolator, range) { | ||
var start = range[0], | ||
span = vegaUtil.peek(range) - start; | ||
return function(i) { return interpolator(start + i * span); }; | ||
} | ||
return part && discrete.hasOwnProperty(name) ? discrete[name][part-1] | ||
: !part && schemes.hasOwnProperty(name) ? schemes[name] | ||
: undefined; | ||
}; | ||
function scaleFraction(scale, min, max) { | ||
var delta = max - min; | ||
return !delta ? vegaUtil.constant(0) | ||
: scale.type === 'linear' || scale.type === 'sequential' | ||
? function(_$$1) { return (_$$1 - min) / delta; } | ||
: scale.copy().domain([min, max]).range([0, 1]).interpolate(lerp); | ||
} | ||
function interpolateRange(interpolator, range$$1) { | ||
var start = range$$1[0], | ||
span = vegaUtil.peek(range$$1) - start; | ||
return function(i) { return interpolator(start + i * span); }; | ||
} | ||
function lerp(a, b) { | ||
var span = b - a; | ||
return function(i) { return a + i * span; } | ||
} | ||
function scaleFraction(scale, min, max) { | ||
var delta = max - min; | ||
return !delta ? vegaUtil.constant(0) | ||
: scale.type === 'linear' || scale.type === 'sequential' | ||
? function(_$$1) { return (_$$1 - min) / delta; } | ||
: scale.copy().domain([min, max]).range([0, 1]).interpolate(lerp); | ||
} | ||
function interpolate(type, gamma) { | ||
var interp = $$1[method(type)]; | ||
return (gamma != null && interp && interp.gamma) | ||
? interp.gamma(gamma) | ||
: interp; | ||
} | ||
function lerp(a, b) { | ||
var span = b - a; | ||
return function(i) { return a + i * span; } | ||
} | ||
function method(type) { | ||
return 'interpolate' + type.toLowerCase() | ||
.split('-') | ||
.map(function(s) { return s[0].toUpperCase() + s.slice(1); }) | ||
.join(''); | ||
} | ||
function interpolate(type, gamma) { | ||
var interp = $$1[method(type)]; | ||
return (gamma != null && interp && interp.gamma) | ||
? interp.gamma(gamma) | ||
: interp; | ||
} | ||
var time = { | ||
millisecond: d3Time.timeMillisecond, | ||
second: d3Time.timeSecond, | ||
minute: d3Time.timeMinute, | ||
hour: d3Time.timeHour, | ||
day: d3Time.timeDay, | ||
week: d3Time.timeWeek, | ||
month: d3Time.timeMonth, | ||
year: d3Time.timeYear | ||
}; | ||
function method(type) { | ||
return 'interpolate' + type.toLowerCase() | ||
.split('-') | ||
.map(function(s) { return s[0].toUpperCase() + s.slice(1); }) | ||
.join(''); | ||
} | ||
var utc = { | ||
millisecond: d3Time.utcMillisecond, | ||
second: d3Time.utcSecond, | ||
minute: d3Time.utcMinute, | ||
hour: d3Time.utcHour, | ||
day: d3Time.utcDay, | ||
week: d3Time.utcWeek, | ||
month: d3Time.utcMonth, | ||
year: d3Time.utcYear | ||
}; | ||
var time = { | ||
millisecond: d3Time.timeMillisecond, | ||
second: d3Time.timeSecond, | ||
minute: d3Time.timeMinute, | ||
hour: d3Time.timeHour, | ||
day: d3Time.timeDay, | ||
week: d3Time.timeWeek, | ||
month: d3Time.timeMonth, | ||
year: d3Time.timeYear | ||
}; | ||
function timeInterval(name) { | ||
return time.hasOwnProperty(name) && time[name]; | ||
} | ||
var utc = { | ||
millisecond: d3Time.utcMillisecond, | ||
second: d3Time.utcSecond, | ||
minute: d3Time.utcMinute, | ||
hour: d3Time.utcHour, | ||
day: d3Time.utcDay, | ||
week: d3Time.utcWeek, | ||
month: d3Time.utcMonth, | ||
year: d3Time.utcYear | ||
}; | ||
function utcInterval(name) { | ||
return utc.hasOwnProperty(name) && utc[name]; | ||
} | ||
function timeInterval(name) { | ||
return time.hasOwnProperty(name) && time[name]; | ||
} | ||
exports.scale = scale; | ||
exports.scheme = schemes$1; | ||
exports.bandSpace = bandSpace; | ||
exports.interpolate = interpolate; | ||
exports.interpolateRange = interpolateRange; | ||
exports.scaleFraction = scaleFraction; | ||
exports.timeInterval = timeInterval; | ||
exports.utcInterval = utcInterval; | ||
function utcInterval(name) { | ||
return utc.hasOwnProperty(name) && utc[name]; | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.scale = scale; | ||
exports.scheme = schemes$1; | ||
exports.bandSpace = bandSpace; | ||
exports.interpolate = interpolate; | ||
exports.interpolateRange = interpolateRange; | ||
exports.scaleFraction = scaleFraction; | ||
exports.timeInterval = timeInterval; | ||
exports.utcInterval = utcInterval; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-array"),require("d3-scale"),require("vega-util"),require("d3-scale-chromatic"),require("d3-interpolate"),require("d3-time")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-scale","vega-util","d3-scale-chromatic","d3-interpolate","d3-time"],n):n(e.vega=e.vega||{},e.d3,e.d3,e.vega,e.d3,e.d3,e.d3)}(this,function(e,n,r,t,a,i,c){"use strict";var u=function(e){return function(n){var r,t=n[0],a=n[1];return a<t&&(r=t,t=a,a=r),[e.invert(t),e.invert(a)]}},o=function(e){return function(n){var r,t,a,i,c=e.range(),u=n[0],o=n[1],d=-1;for(o<u&&(t=u,u=o,o=t),a=0,i=c.length;a<i;++a)c[a]>=u&&c[a]<=o&&(d<0&&(d=a),r=a);if(!(d<0))return u=e.invertExtent(c[d]),o=e.invertExtent(c[r]),[void 0===u[0]?u[1]:u[0],void 0===o[1]?o[0]:o[1]]}},d=function(e,n,r){var t=e-n+2*r;return e?t>0?t:1:0};function l(){var e,t,a=r.scaleOrdinal().unknown(void 0),i=a.domain,c=a.range,u=[0,1],o=!1,f=0,b=0,s=.5;function g(){var r=i().length,a=u[1]<u[0],l=u[a-0],g=u[1-a],p=d(r,f,b);e=(g-l)/(p||1),o&&(e=Math.floor(e)),l+=(g-l-e*(r-f))*s,t=e*(1-f),o&&(l=Math.round(l),t=Math.round(t));var m=n.range(r).map(function(n){return l+e*n});return c(a?m.reverse():m)}return delete a.unknown,a.domain=function(e){return arguments.length?(i(e),g()):i()},a.range=function(e){return arguments.length?(u=[+e[0],+e[1]],g()):u.slice()},a.rangeRound=function(e){return u=[+e[0],+e[1]],o=!0,g()},a.bandwidth=function(){return t},a.step=function(){return e},a.round=function(e){return arguments.length?(o=!!e,g()):o},a.padding=function(e){return arguments.length?(b=Math.max(0,Math.min(1,e)),f=b,g()):f},a.paddingInner=function(e){return arguments.length?(f=Math.max(0,Math.min(1,e)),g()):f},a.paddingOuter=function(e){return arguments.length?(b=Math.max(0,Math.min(1,e)),g()):b},a.align=function(e){return arguments.length?(s=Math.max(0,Math.min(1,e)),g()):s},a.invertRange=function(e){if(null!=e[0]&&null!=e[1]){var r,a,o,d=+e[0],l=+e[1],f=u[1]<u[0],b=f?c().reverse():c(),s=b.length-1;if(d==d&&l==l&&(l<d&&(o=d,d=l,l=o),!(l<b[0]||d>u[1-f])))return r=Math.max(0,n.bisectRight(b,d)-1),a=d===l?r:n.bisectRight(b,l)-1,d-b[r]>t+1e-10&&++r,f&&(o=r,r=s-a,a=s-o),r>a?void 0:i().slice(r,a+1)}},a.invert=function(e){var n=a.invertRange([e,e]);return n?n[0]:n},a.copy=function(){return l().domain(i()).range(u).round(o).paddingInner(f).paddingOuter(b).align(s)},g()}var f=Array.prototype.map,b=Array.prototype.slice;function s(e){return f.call(e,function(e){return+e})}function g(e,n){return arguments.length>1?(p[e]=(r=e,t=n,function(){var e=t();return e.invertRange||(e.invertRange=e.invert?u(e):e.invertExtent?o(e):void 0),e.type=r,e}),this):p.hasOwnProperty(e)?p[e]:void 0;var r,t}var p={identity:r.scaleIdentity,linear:r.scaleLinear,log:r.scaleLog,ordinal:r.scaleOrdinal,pow:r.scalePow,sqrt:r.scaleSqrt,quantile:r.scaleQuantile,quantize:r.scaleQuantize,threshold:r.scaleThreshold,time:r.scaleTime,utc:r.scaleUtc,band:l,point:function(){return function e(n){var r=n.copy;return n.padding=n.paddingOuter,delete n.paddingInner,n.copy=function(){return e(r())},n}(l().paddingInner(1))},sequential:function e(n){var a=r.scaleLinear(),i=0,c=1,u=!1;function o(){var e=a.domain();i=e[0],c=t.peek(e)-i}function d(e){var r=(e-i)/c;return n(u?Math.max(0,Math.min(1,r)):r)}return d.clamp=function(e){return arguments.length?(u=!!e,d):u},d.domain=function(e){return arguments.length?(a.domain(e),o(),d):a.domain()},d.interpolator=function(e){return arguments.length?(n=e,d):n},d.copy=function(){return e().domain(a.domain()).clamp(u).interpolator(n)},d.ticks=function(e){return a.ticks(e)},d.tickFormat=function(e,n){return a.tickFormat(e,n)},d.nice=function(e){return a.nice(e),o(),d},d},"bin-linear":function e(){var n=r.scaleLinear(),a=[];function i(e){return n(e)}return i.domain=function(e){return arguments.length?(a=s(e),n.domain([a[0],t.peek(a)]),i):a.slice()},i.range=function(e){return arguments.length?(n.range(e),i):n.range()},i.rangeRound=function(e){return arguments.length?(n.rangeRound(e),i):n.rangeRound()},i.interpolate=function(e){return arguments.length?(n.interpolate(e),i):n.interpolate()},i.invert=function(e){return n.invert(e)},i.ticks=function(e){var n=a.length,r=~~(n/(e||n));return r<2?i.domain():a.filter(function(e,n){return!(n%r)})},i.tickFormat=function(){return n.tickFormat.apply(n,arguments)},i.copy=function(){return e().domain(i.domain()).range(i.range())},i},"bin-ordinal":function e(){var r=[],t=[];function a(e){return null==e||e!=e?void 0:t[(n.bisect(r,e)-1)%t.length]}return a.domain=function(e){return arguments.length?(r=s(e),a):r.slice()},a.range=function(e){return arguments.length?(t=b.call(e),a):t.slice()},a.copy=function(){return e().domain(a.domain()).range(a.range())},a}};for(var m in p)g(m,p[m]);function h(e){for(var n=e.length/6|0,r=new Array(n),t=0;t<n;)r[t]="#"+e.slice(6*t,6*++t);return r}var v=h("1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5"),y=h("393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6"),w=h("3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9"),M=h("4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac"),R=h("4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5"),k=new Array(3).concat("67a9cff7f7f7f1a340","0571b092c5defdb863e66101","0571b092c5def7f7f7fdb863e66101","2166ac67a9cfd1e5f0fee0b6f1a340b35806","2166ac67a9cfd1e5f0f7f7f7fee0b6f1a340b35806","2166ac4393c392c5ded1e5f0fee0b6fdb863e08214b35806","2166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b35806","0530612166ac4393c392c5ded1e5f0fee0b6fdb863e08214b358067f3b08","0530612166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b358067f3b08").map(h),P={blueorange:k},O={category10:a.schemeCategory10,accent:a.schemeAccent,dark2:a.schemeDark2,paired:a.schemePaired,pastel1:a.schemePastel1,pastel2:a.schemePastel2,set1:a.schemeSet1,set2:a.schemeSet2,set3:a.schemeSet3,category20:v,category20b:y,category20c:w,tableau10:M,tableau20:R,viridis:a.interpolateViridis,magma:a.interpolateMagma,inferno:a.interpolateInferno,plasma:a.interpolatePlasma,blueorange:i.interpolateRgbBasis(t.peek(k))};function B(e,n){O[e]=a["interpolate"+n],P[e]=a["scheme"+n]}B("blues","Blues"),B("greens","Greens"),B("greys","Greys"),B("purples","Purples"),B("reds","Reds"),B("oranges","Oranges"),B("brownbluegreen","BrBG"),B("purplegreen","PRGn"),B("pinkyellowgreen","PiYG"),B("purpleorange","PuOr"),B("redblue","RdBu"),B("redgrey","RdGy"),B("redyellowblue","RdYlBu"),B("redyellowgreen","RdYlGn"),B("spectral","Spectral"),B("bluegreen","BuGn"),B("bluepurple","BuPu"),B("greenblue","GnBu"),B("orangered","OrRd"),B("purplebluegreen","PuBuGn"),B("purpleblue","PuBu"),B("purplered","PuRd"),B("redpurple","RdPu"),B("yellowgreenblue","YlGnBu"),B("yellowgreen","YlGn"),B("yelloworangebrown","YlOrBr"),B("yelloworangered","YlOrRd");function q(e,n){var r=n-e;return function(n){return e+n*r}}var x={millisecond:c.timeMillisecond,second:c.timeSecond,minute:c.timeMinute,hour:c.timeHour,day:c.timeDay,week:c.timeWeek,month:c.timeMonth,year:c.timeYear},G={millisecond:c.utcMillisecond,second:c.utcSecond,minute:c.utcMinute,hour:c.utcHour,day:c.utcDay,week:c.utcWeek,month:c.utcMonth,year:c.utcYear};e.scale=g,e.scheme=function(e,n){if(arguments.length>1)return O[e]=n,this;var r=e.split("-");return e=r[0],(r=+r[1]+1)&&P.hasOwnProperty(e)?P[e][r-1]:!r&&O.hasOwnProperty(e)?O[e]:void 0},e.bandSpace=d,e.interpolate=function(e,n){var r,t=i[(r=e,"interpolate"+r.toLowerCase().split("-").map(function(e){return e[0].toUpperCase()+e.slice(1)}).join(""))];return null!=n&&t&&t.gamma?t.gamma(n):t},e.interpolateRange=function(e,n){var r=n[0],a=t.peek(n)-r;return function(n){return e(r+n*a)}},e.scaleFraction=function(e,n,r){var a=r-n;return a?"linear"===e.type||"sequential"===e.type?function(e){return(e-n)/a}:e.copy().domain([n,r]).range([0,1]).interpolate(q):t.constant(0)},e.timeInterval=function(e){return x.hasOwnProperty(e)&&x[e]},e.utcInterval=function(e){return G.hasOwnProperty(e)&&G[e]},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-array"),require("d3-scale"),require("vega-util"),require("d3-scale-chromatic"),require("d3-interpolate"),require("d3-time")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-scale","vega-util","d3-scale-chromatic","d3-interpolate","d3-time"],n):n(e.vega={},e.d3,e.d3,e.vega,e.d3,e.d3,e.d3)}(this,function(e,g,m,o,r,a,n){"use strict";function h(e,n,r){var t=e-n+2*r;return e?0<t?t:1:0}function t(){var c,d,r=m.scaleOrdinal().unknown(void 0),l=r.domain,f=r.range,b=[0,1],u=!1,o=0,s=0,p=.5;function n(){var e=l().length,n=b[1]<b[0],r=b[n-0],t=b[1-n],a=h(e,o,s);c=(t-r)/(a||1),u&&(c=Math.floor(c)),r+=(t-r-c*(e-o))*p,d=c*(1-o),u&&(r=Math.round(r),d=Math.round(d));var i=g.range(e).map(function(e){return r+c*e});return f(n?i.reverse():i)}return delete r.unknown,r.domain=function(e){return arguments.length?(l(e),n()):l()},r.range=function(e){return arguments.length?(b=[+e[0],+e[1]],n()):b.slice()},r.rangeRound=function(e){return b=[+e[0],+e[1]],u=!0,n()},r.bandwidth=function(){return d},r.step=function(){return c},r.round=function(e){return arguments.length?(u=!!e,n()):u},r.padding=function(e){return arguments.length?(s=Math.max(0,Math.min(1,e)),o=s,n()):o},r.paddingInner=function(e){return arguments.length?(o=Math.max(0,Math.min(1,e)),n()):o},r.paddingOuter=function(e){return arguments.length?(s=Math.max(0,Math.min(1,e)),n()):s},r.align=function(e){return arguments.length?(p=Math.max(0,Math.min(1,e)),n()):p},r.invertRange=function(e){if(null!=e[0]&&null!=e[1]){var n,r,t,a=+e[0],i=+e[1],c=b[1]<b[0],u=c?f().reverse():f(),o=u.length-1;if(a==a&&i==i&&(i<a&&(t=a,a=i,i=t),!(i<u[0]||a>b[1-c])))return n=Math.max(0,g.bisectRight(u,a)-1),r=a===i?n:g.bisectRight(u,i)-1,a-u[n]>d+1e-10&&++n,c&&(t=n,n=o-r,r=o-t),r<n?void 0:l().slice(n,r+1)}},r.invert=function(e){var n=r.invertRange([e,e]);return n?n[0]:n},r.copy=function(){return t().domain(l()).range(b).round(u).paddingInner(o).paddingOuter(s).align(p)},n()}var i=Array.prototype.map,c=Array.prototype.slice;function u(e){return i.call(e,function(e){return+e})}function d(e,n){return 1<arguments.length?(l[e]=(r=e,t=n,function(){var d,a,e=t();return e.invertRange||(e.invertRange=e.invert?(a=e,function(e){var n,r=e[0],t=e[1];return t<r&&(n=r,r=t,t=n),[a.invert(r),a.invert(t)]}):e.invertExtent?(d=e,function(e){var n,r,t,a,i=d.range(),c=e[0],u=e[1],o=-1;for(u<c&&(r=c,c=u,u=r),t=0,a=i.length;t<a;++t)i[t]>=c&&i[t]<=u&&(o<0&&(o=t),n=t);if(!(o<0))return c=d.invertExtent(i[o]),u=d.invertExtent(i[n]),[void 0===c[0]?c[1]:c[0],void 0===u[1]?u[0]:u[1]]}):void 0),e.type=r,e}),this):l.hasOwnProperty(e)?l[e]:void 0;var r,t}var l={identity:m.scaleIdentity,linear:m.scaleLinear,log:m.scaleLog,ordinal:m.scaleOrdinal,pow:m.scalePow,sqrt:m.scaleSqrt,quantile:m.scaleQuantile,quantize:m.scaleQuantize,threshold:m.scaleThreshold,time:m.scaleTime,utc:m.scaleUtc,band:t,point:function(){return function e(n){var r=n.copy;return n.padding=n.paddingOuter,delete n.paddingInner,n.copy=function(){return e(r())},n}(t().paddingInner(1))},sequential:function e(r){var t=m.scaleLinear(),a=0,i=1,c=!1;function n(){var e=t.domain();a=e[0],i=o.peek(e)-a}function u(e){var n=(e-a)/i;return r(c?Math.max(0,Math.min(1,n)):n)}return u.clamp=function(e){return arguments.length?(c=!!e,u):c},u.domain=function(e){return arguments.length?(t.domain(e),n(),u):t.domain()},u.interpolator=function(e){return arguments.length?(r=e,u):r},u.copy=function(){return e().domain(t.domain()).clamp(c).interpolator(r)},u.ticks=function(e){return t.ticks(e)},u.tickFormat=function(e,n){return t.tickFormat(e,n)},u.nice=function(e){return t.nice(e),n(),u},u},"bin-linear":function e(){var n=m.scaleLinear(),t=[];function a(e){return n(e)}return a.domain=function(e){return arguments.length?(t=u(e),n.domain([t[0],o.peek(t)]),a):t.slice()},a.range=function(e){return arguments.length?(n.range(e),a):n.range()},a.rangeRound=function(e){return arguments.length?(n.rangeRound(e),a):n.rangeRound()},a.interpolate=function(e){return arguments.length?(n.interpolate(e),a):n.interpolate()},a.invert=function(e){return n.invert(e)},a.ticks=function(e){var n=t.length,r=~~(n/(e||n));return r<2?a.domain():t.filter(function(e,n){return!(n%r)})},a.tickFormat=function(){return n.tickFormat.apply(n,arguments)},a.copy=function(){return e().domain(a.domain()).range(a.range())},a},"bin-ordinal":function e(){var n=[],r=[];function t(e){return null==e||e!=e?void 0:r[(g.bisect(n,e)-1)%r.length]}return t.domain=function(e){return arguments.length?(n=u(e),t):n.slice()},t.range=function(e){return arguments.length?(r=c.call(e),t):r.slice()},t.copy=function(){return e().domain(t.domain()).range(t.range())},t}};for(var f in l)d(f,l[f]);function b(e){for(var n=e.length/6|0,r=new Array(n),t=0;t<n;)r[t]="#"+e.slice(6*t,6*++t);return r}var s=b("1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5"),p=b("393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6"),v=b("3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9"),y=b("4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac"),w=b("4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5"),R=new Array(3).concat("67a9cff7f7f7f1a340","0571b092c5defdb863e66101","0571b092c5def7f7f7fdb863e66101","2166ac67a9cfd1e5f0fee0b6f1a340b35806","2166ac67a9cfd1e5f0f7f7f7fee0b6f1a340b35806","2166ac4393c392c5ded1e5f0fee0b6fdb863e08214b35806","2166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b35806","0530612166ac4393c392c5ded1e5f0fee0b6fdb863e08214b358067f3b08","0530612166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b358067f3b08").map(b),M={blueorange:R},k={category10:r.schemeCategory10,accent:r.schemeAccent,dark2:r.schemeDark2,paired:r.schemePaired,pastel1:r.schemePastel1,pastel2:r.schemePastel2,set1:r.schemeSet1,set2:r.schemeSet2,set3:r.schemeSet3,category20:s,category20b:p,category20c:v,tableau10:y,tableau20:w,viridis:r.interpolateViridis,magma:r.interpolateMagma,inferno:r.interpolateInferno,plasma:r.interpolatePlasma,rainbow:r.interpolateRainbow,sinebow:r.interpolateSinebow,blueorange:a.interpolateRgbBasis(o.peek(R))};function P(e,n){k[e]=r["interpolate"+n],M[e]=r["scheme"+n]}function O(n,e){var r=e-n;return function(e){return n+e*r}}P("blues","Blues"),P("greens","Greens"),P("greys","Greys"),P("purples","Purples"),P("reds","Reds"),P("oranges","Oranges"),P("brownbluegreen","BrBG"),P("purplegreen","PRGn"),P("pinkyellowgreen","PiYG"),P("purpleorange","PuOr"),P("redblue","RdBu"),P("redgrey","RdGy"),P("redyellowblue","RdYlBu"),P("redyellowgreen","RdYlGn"),P("spectral","Spectral"),P("bluegreen","BuGn"),P("bluepurple","BuPu"),P("greenblue","GnBu"),P("orangered","OrRd"),P("purplebluegreen","PuBuGn"),P("purpleblue","PuBu"),P("purplered","PuRd"),P("redpurple","RdPu"),P("yellowgreenblue","YlGnBu"),P("yellowgreen","YlGn"),P("yelloworangebrown","YlOrBr"),P("yelloworangered","YlOrRd");var B={millisecond:n.timeMillisecond,second:n.timeSecond,minute:n.timeMinute,hour:n.timeHour,day:n.timeDay,week:n.timeWeek,month:n.timeMonth,year:n.timeYear},q={millisecond:n.utcMillisecond,second:n.utcSecond,minute:n.utcMinute,hour:n.utcHour,day:n.utcDay,week:n.utcWeek,month:n.utcMonth,year:n.utcYear};e.scale=d,e.scheme=function(e,n){if(1<arguments.length)return k[e]=n,this;var r=e.split("-");return e=r[0],(r=+r[1]+1)&&M.hasOwnProperty(e)?M[e][r-1]:!r&&k.hasOwnProperty(e)?k[e]:void 0},e.bandSpace=h,e.interpolate=function(e,n){var r,t=a[(r=e,"interpolate"+r.toLowerCase().split("-").map(function(e){return e[0].toUpperCase()+e.slice(1)}).join(""))];return null!=n&&t&&t.gamma?t.gamma(n):t},e.interpolateRange=function(n,e){var r=e[0],t=o.peek(e)-r;return function(e){return n(r+e*t)}},e.scaleFraction=function(e,n,r){var t=r-n;return t?"linear"===e.type||"sequential"===e.type?function(e){return(e-n)/t}:e.copy().domain([n,r]).range([0,1]).interpolate(O):o.constant(0)},e.timeInterval=function(e){return B.hasOwnProperty(e)&&B[e]},e.utcInterval=function(e){return q.hasOwnProperty(e)&&q[e]},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-scale", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Scales and color schemes for visual encoding.", | ||
@@ -27,16 +27,16 @@ "keywords": [ | ||
"test": "tape 'test/**/*-test.js' && eslint index.js src test", | ||
"prepublish": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"postpublish": "git push && git push --tags && zip -j build/vega-scale.zip -- LICENSE README.md build/vega-scale.js build/vega-scale.min.js" | ||
}, | ||
"dependencies": { | ||
"d3-array": "1", | ||
"d3-interpolate": "1", | ||
"d3-scale": "2", | ||
"d3-scale-chromatic": "^1.2", | ||
"d3-time": "1", | ||
"vega-util": "1" | ||
"d3-array": "^1.2.1", | ||
"d3-interpolate": "^1.2.0", | ||
"d3-scale": "^2.0.0", | ||
"d3-scale-chromatic": "^1.3.0", | ||
"d3-time": "^1.0.8", | ||
"vega-util": "^1.7.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "4", | ||
"rollup": "0.43", | ||
"rollup": "0.59.3", | ||
"tape": "4", | ||
@@ -43,0 +43,0 @@ "uglify-js": "3" |
@@ -8,3 +8,3 @@ # vega-scale | ||
scheme registries include all scale types and color schemes provided | ||
by the D3 4.0 [d3-scale](https://github.com/d3/d3-scale) and | ||
by the [d3-scale](https://github.com/d3/d3-scale) and | ||
[d3-scale-chromatic](https://github.com/d3/d3-scale-chromatic) modules. | ||
@@ -78,3 +78,3 @@ | ||
By default, the scheme registry includes entries for all scheme types | ||
provided by D3 4.0's [d3-scale](https://github.com/d3/d3-scale) and | ||
provided by the | ||
[d3-scale-chromatic](https://github.com/d3/d3-scale-chromatic) module. | ||
@@ -81,0 +81,0 @@ Valid schemes are either arrays of color values (e.g., applicable to |
@@ -39,2 +39,6 @@ import { | ||
// cyclic interpolators | ||
rainbow: _.interpolateRainbow, | ||
sinebow: _.interpolateSinebow, | ||
// extended interpolators | ||
@@ -41,0 +45,0 @@ blueorange: interpolateRgbBasis(peek(blueOrange)) |
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
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
50029
19
1122
Updatedd3-array@^1.2.1
Updatedd3-interpolate@^1.2.0
Updatedd3-scale@^2.0.0
Updatedd3-scale-chromatic@^1.3.0
Updatedd3-time@^1.0.8
Updatedvega-util@^1.7.0