Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nivo/colors

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nivo/colors - npm Package Compare versions

Comparing version 0.62.0 to 0.63.0

dist/nivo-colors.cjs.js.map

180

dist/nivo-colors.cjs.js

@@ -16,4 +16,45 @@ 'use strict';

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(Object(source)); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
var categoricalColorSchemes = {

@@ -74,3 +115,3 @@ nivo: ['#e8c1a0', '#f47560', '#f1e15b', '#e8a838', '#61cdbb', '#97e3d5'],

};
var colorSchemes = _objectSpread({}, categoricalColorSchemes, divergingColorSchemes, sequentialColorSchemes);
var colorSchemes = _objectSpread2(_objectSpread2(_objectSpread2({}, categoricalColorSchemes), divergingColorSchemes), sequentialColorSchemes);
var colorSchemeIds = Object.keys(colorSchemes);

@@ -180,6 +221,106 @@ var colorInterpolators = {

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _createForOfIteratorHelper(o) {
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
var i = 0;
var F = function F() {};
return {
s: F,
n: function n() {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function e(_e) {
throw _e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var it,
normalCompletion = true,
didErr = false,
err;
return {
s: function s() {
it = o[Symbol.iterator]();
},
n: function n() {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function e(_e2) {
didErr = true;
err = _e2;
},
f: function f() {
try {
if (!normalCompletion && it["return"] != null) it["return"]();
} finally {
if (didErr) throw err;
}
}
};
}
var getInheritedColorGenerator = function getInheritedColorGenerator(inheritedColor, theme) {

@@ -208,5 +349,4 @@ if (typeof inheritedColor === 'function') return function (node) {

var modifiers = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
var _iterator = _createForOfIteratorHelper(inheritedColor.modifiers),
_step;
try {

@@ -235,18 +375,9 @@ var _loop = function _loop() {

};
for (var _iterator = inheritedColor.modifiers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
_iterator.e(err);
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
_iterator.f();
}

@@ -288,4 +419,2 @@ if (modifiers.length === 0) return getColor;

function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(Object(source)); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } return target; }
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var interpolateColor = function interpolateColor(color, springConfig) {

@@ -300,3 +429,3 @@ var colorComponents = d3Color.rgb(color);

}
var configWithPrecision = _objectSpread$1({}, springConfig, {
var configWithPrecision = _objectSpread2(_objectSpread2({}, springConfig), {}, {
precision: 1

@@ -339,1 +468,2 @@ });

exports.useOrdinalColorScale = useOrdinalColorScale;
//# sourceMappingURL=nivo-colors.cjs.js.map

724

dist/nivo-colors.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-scale-chromatic'), require('react'), require('lodash.get'), require('lodash.isplainobject'), require('d3-scale'), require('d3-color'), require('prop-types'), require('react-motion')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-scale-chromatic', 'react', 'lodash.get', 'lodash.isplainobject', 'd3-scale', 'd3-color', 'prop-types', 'react-motion'], factory) :
(global = global || self, factory(global.nivo = global.nivo || {}, global.d3, global.React, global.lodash.get, global.lodash.isplainobject, global.d3, global.d3, global.PropTypes, global.ReactMotion));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-scale-chromatic'), require('react'), require('lodash.get'), require('lodash.isplainobject'), require('d3-scale'), require('d3-color'), require('prop-types'), require('react-motion')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-scale-chromatic', 'react', 'lodash.get', 'lodash.isplainobject', 'd3-scale', 'd3-color', 'prop-types', 'react-motion'], factory) :
(global = global || self, factory(global.nivo = global.nivo || {}, global.d3, global.React, global.lodash.get, global.lodash.isplainobject, global.d3, global.d3, global.PropTypes, global.ReactMotion));
}(this, (function (exports, d3ScaleChromatic, react, get, isPlainObject, d3Scale, d3Color, PropTypes, reactMotion) { 'use strict';
get = get && get.hasOwnProperty('default') ? get['default'] : get;
isPlainObject = isPlainObject && isPlainObject.hasOwnProperty('default') ? isPlainObject['default'] : isPlainObject;
PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes;
get = get && Object.prototype.hasOwnProperty.call(get, 'default') ? get['default'] : get;
isPlainObject = isPlainObject && Object.prototype.hasOwnProperty.call(isPlainObject, 'default') ? isPlainObject['default'] : isPlainObject;
PropTypes = PropTypes && Object.prototype.hasOwnProperty.call(PropTypes, 'default') ? PropTypes['default'] : PropTypes;
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(Object(source)); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var categoricalColorSchemes = {
nivo: ['#e8c1a0', '#f47560', '#f1e15b', '#e8a838', '#61cdbb', '#97e3d5'],
category10: d3ScaleChromatic.schemeCategory10,
accent: d3ScaleChromatic.schemeAccent,
dark2: d3ScaleChromatic.schemeDark2,
paired: d3ScaleChromatic.schemePaired,
pastel1: d3ScaleChromatic.schemePastel1,
pastel2: d3ScaleChromatic.schemePastel2,
set1: d3ScaleChromatic.schemeSet1,
set2: d3ScaleChromatic.schemeSet2,
set3: d3ScaleChromatic.schemeSet3
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
var categoricalColorSchemes = {
nivo: ['#e8c1a0', '#f47560', '#f1e15b', '#e8a838', '#61cdbb', '#97e3d5'],
category10: d3ScaleChromatic.schemeCategory10,
accent: d3ScaleChromatic.schemeAccent,
dark2: d3ScaleChromatic.schemeDark2,
paired: d3ScaleChromatic.schemePaired,
pastel1: d3ScaleChromatic.schemePastel1,
pastel2: d3ScaleChromatic.schemePastel2,
set1: d3ScaleChromatic.schemeSet1,
set2: d3ScaleChromatic.schemeSet2,
set3: d3ScaleChromatic.schemeSet3
};
var categoricalColorSchemeIds = Object.keys(categoricalColorSchemes);
var isCategoricalColorScheme = function isCategoricalColorScheme(scheme) {
return categoricalColorSchemeIds.includes(scheme);
};
var divergingColorSchemes = {
brown_blueGreen: d3ScaleChromatic.schemeBrBG,
purpleRed_green: d3ScaleChromatic.schemePRGn,
pink_yellowGreen: d3ScaleChromatic.schemePiYG,
purple_orange: d3ScaleChromatic.schemePuOr,
red_blue: d3ScaleChromatic.schemeRdBu,
red_grey: d3ScaleChromatic.schemeRdGy,
red_yellow_blue: d3ScaleChromatic.schemeRdYlBu,
red_yellow_green: d3ScaleChromatic.schemeRdYlGn,
spectral: d3ScaleChromatic.schemeSpectral
};
var divergingColorSchemeIds = Object.keys(divergingColorSchemes);
var isDivergingColorScheme = function isDivergingColorScheme(scheme) {
return divergingColorSchemeIds.includes(scheme);
};
var sequentialColorSchemes = {
blues: d3ScaleChromatic.schemeBlues,
greens: d3ScaleChromatic.schemeGreens,
greys: d3ScaleChromatic.schemeGreys,
oranges: d3ScaleChromatic.schemeOranges,
purples: d3ScaleChromatic.schemePurples,
reds: d3ScaleChromatic.schemeReds,
blue_green: d3ScaleChromatic.schemeBuGn,
blue_purple: d3ScaleChromatic.schemeBuPu,
green_blue: d3ScaleChromatic.schemeGnBu,
orange_red: d3ScaleChromatic.schemeOrRd,
purple_blue_green: d3ScaleChromatic.schemePuBuGn,
purple_blue: d3ScaleChromatic.schemePuBu,
purple_red: d3ScaleChromatic.schemePuRd,
red_purple: d3ScaleChromatic.schemeRdPu,
yellow_green_blue: d3ScaleChromatic.schemeYlGnBu,
yellow_green: d3ScaleChromatic.schemeYlGn,
yellow_orange_brown: d3ScaleChromatic.schemeYlOrBr,
yellow_orange_red: d3ScaleChromatic.schemeYlOrRd
};
var sequentialColorSchemeIds = Object.keys(sequentialColorSchemes);
var isSequentialColorScheme = function isSequentialColorScheme(scheme) {
return sequentialColorSchemeIds.includes(scheme);
};
var colorSchemes = _objectSpread2(_objectSpread2(_objectSpread2({}, categoricalColorSchemes), divergingColorSchemes), sequentialColorSchemes);
var colorSchemeIds = Object.keys(colorSchemes);
var colorInterpolators = {
brown_blueGreen: d3ScaleChromatic.interpolateBrBG,
purpleRed_green: d3ScaleChromatic.interpolatePRGn,
pink_yellowGreen: d3ScaleChromatic.interpolatePiYG,
purple_orange: d3ScaleChromatic.interpolatePuOr,
red_blue: d3ScaleChromatic.interpolateRdBu,
red_grey: d3ScaleChromatic.interpolateRdGy,
red_yellow_blue: d3ScaleChromatic.interpolateRdYlBu,
red_yellow_green: d3ScaleChromatic.interpolateRdYlGn,
spectral: d3ScaleChromatic.interpolateSpectral,
blues: d3ScaleChromatic.interpolateBlues,
greens: d3ScaleChromatic.interpolateGreens,
greys: d3ScaleChromatic.interpolateGreys,
oranges: d3ScaleChromatic.interpolateOranges,
purples: d3ScaleChromatic.interpolatePurples,
reds: d3ScaleChromatic.interpolateReds,
viridis: d3ScaleChromatic.interpolateViridis,
inferno: d3ScaleChromatic.interpolateInferno,
magma: d3ScaleChromatic.interpolateMagma,
plasma: d3ScaleChromatic.interpolatePlasma,
warm: d3ScaleChromatic.interpolateWarm,
cool: d3ScaleChromatic.interpolateCool,
cubehelixDefault: d3ScaleChromatic.interpolateCubehelixDefault,
blue_green: d3ScaleChromatic.interpolateBuGn,
blue_purple: d3ScaleChromatic.interpolateBuPu,
green_blue: d3ScaleChromatic.interpolateGnBu,
orange_red: d3ScaleChromatic.interpolateOrRd,
purple_blue_green: d3ScaleChromatic.interpolatePuBuGn,
purple_blue: d3ScaleChromatic.interpolatePuBu,
purple_red: d3ScaleChromatic.interpolatePuRd,
red_purple: d3ScaleChromatic.interpolateRdPu,
yellow_green_blue: d3ScaleChromatic.interpolateYlGnBu,
yellow_green: d3ScaleChromatic.interpolateYlGn,
yellow_orange_brown: d3ScaleChromatic.interpolateYlOrBr,
yellow_orange_red: d3ScaleChromatic.interpolateYlOrRd,
rainbow: d3ScaleChromatic.interpolateRainbow,
sinebow: d3ScaleChromatic.interpolateSinebow
};
var colorInterpolatorIds = Object.keys(colorInterpolators);
var getOrdinalColorScale = function getOrdinalColorScale(instruction, identity) {
if (typeof instruction === 'function') return instruction;
var getIdentity = typeof identity === 'function' ? identity : function (d) {
return get(d, identity);
};
var categoricalColorSchemeIds = Object.keys(categoricalColorSchemes);
var isCategoricalColorScheme = function isCategoricalColorScheme(scheme) {
return categoricalColorSchemeIds.includes(scheme);
};
var divergingColorSchemes = {
brown_blueGreen: d3ScaleChromatic.schemeBrBG,
purpleRed_green: d3ScaleChromatic.schemePRGn,
pink_yellowGreen: d3ScaleChromatic.schemePiYG,
purple_orange: d3ScaleChromatic.schemePuOr,
red_blue: d3ScaleChromatic.schemeRdBu,
red_grey: d3ScaleChromatic.schemeRdGy,
red_yellow_blue: d3ScaleChromatic.schemeRdYlBu,
red_yellow_green: d3ScaleChromatic.schemeRdYlGn,
spectral: d3ScaleChromatic.schemeSpectral
};
var divergingColorSchemeIds = Object.keys(divergingColorSchemes);
var isDivergingColorScheme = function isDivergingColorScheme(scheme) {
return divergingColorSchemeIds.includes(scheme);
};
var sequentialColorSchemes = {
blues: d3ScaleChromatic.schemeBlues,
greens: d3ScaleChromatic.schemeGreens,
greys: d3ScaleChromatic.schemeGreys,
oranges: d3ScaleChromatic.schemeOranges,
purples: d3ScaleChromatic.schemePurples,
reds: d3ScaleChromatic.schemeReds,
blue_green: d3ScaleChromatic.schemeBuGn,
blue_purple: d3ScaleChromatic.schemeBuPu,
green_blue: d3ScaleChromatic.schemeGnBu,
orange_red: d3ScaleChromatic.schemeOrRd,
purple_blue_green: d3ScaleChromatic.schemePuBuGn,
purple_blue: d3ScaleChromatic.schemePuBu,
purple_red: d3ScaleChromatic.schemePuRd,
red_purple: d3ScaleChromatic.schemeRdPu,
yellow_green_blue: d3ScaleChromatic.schemeYlGnBu,
yellow_green: d3ScaleChromatic.schemeYlGn,
yellow_orange_brown: d3ScaleChromatic.schemeYlOrBr,
yellow_orange_red: d3ScaleChromatic.schemeYlOrRd
};
var sequentialColorSchemeIds = Object.keys(sequentialColorSchemes);
var isSequentialColorScheme = function isSequentialColorScheme(scheme) {
return sequentialColorSchemeIds.includes(scheme);
};
var colorSchemes = _objectSpread({}, categoricalColorSchemes, divergingColorSchemes, sequentialColorSchemes);
var colorSchemeIds = Object.keys(colorSchemes);
var colorInterpolators = {
brown_blueGreen: d3ScaleChromatic.interpolateBrBG,
purpleRed_green: d3ScaleChromatic.interpolatePRGn,
pink_yellowGreen: d3ScaleChromatic.interpolatePiYG,
purple_orange: d3ScaleChromatic.interpolatePuOr,
red_blue: d3ScaleChromatic.interpolateRdBu,
red_grey: d3ScaleChromatic.interpolateRdGy,
red_yellow_blue: d3ScaleChromatic.interpolateRdYlBu,
red_yellow_green: d3ScaleChromatic.interpolateRdYlGn,
spectral: d3ScaleChromatic.interpolateSpectral,
blues: d3ScaleChromatic.interpolateBlues,
greens: d3ScaleChromatic.interpolateGreens,
greys: d3ScaleChromatic.interpolateGreys,
oranges: d3ScaleChromatic.interpolateOranges,
purples: d3ScaleChromatic.interpolatePurples,
reds: d3ScaleChromatic.interpolateReds,
viridis: d3ScaleChromatic.interpolateViridis,
inferno: d3ScaleChromatic.interpolateInferno,
magma: d3ScaleChromatic.interpolateMagma,
plasma: d3ScaleChromatic.interpolatePlasma,
warm: d3ScaleChromatic.interpolateWarm,
cool: d3ScaleChromatic.interpolateCool,
cubehelixDefault: d3ScaleChromatic.interpolateCubehelixDefault,
blue_green: d3ScaleChromatic.interpolateBuGn,
blue_purple: d3ScaleChromatic.interpolateBuPu,
green_blue: d3ScaleChromatic.interpolateGnBu,
orange_red: d3ScaleChromatic.interpolateOrRd,
purple_blue_green: d3ScaleChromatic.interpolatePuBuGn,
purple_blue: d3ScaleChromatic.interpolatePuBu,
purple_red: d3ScaleChromatic.interpolatePuRd,
red_purple: d3ScaleChromatic.interpolateRdPu,
yellow_green_blue: d3ScaleChromatic.interpolateYlGnBu,
yellow_green: d3ScaleChromatic.interpolateYlGn,
yellow_orange_brown: d3ScaleChromatic.interpolateYlOrBr,
yellow_orange_red: d3ScaleChromatic.interpolateYlOrRd,
rainbow: d3ScaleChromatic.interpolateRainbow,
sinebow: d3ScaleChromatic.interpolateSinebow
};
var colorInterpolatorIds = Object.keys(colorInterpolators);
var getOrdinalColorScale = function getOrdinalColorScale(instruction, identity) {
if (typeof instruction === 'function') return instruction;
var getIdentity = typeof identity === 'function' ? identity : function (d) {
return get(d, identity);
if (Array.isArray(instruction)) {
var scale = d3Scale.scaleOrdinal(instruction);
var generator = function generator(d) {
return scale(getIdentity(d));
};
if (Array.isArray(instruction)) {
var scale = d3Scale.scaleOrdinal(instruction);
var generator = function generator(d) {
return scale(getIdentity(d));
generator.scale = scale;
return generator;
}
if (isPlainObject(instruction)) {
if (instruction.datum !== undefined) {
return function (datum) {
return get(datum, instruction.datum);
};
generator.scale = scale;
return generator;
}
if (isPlainObject(instruction)) {
if (instruction.datum !== undefined) {
return function (datum) {
return get(datum, instruction.datum);
if (instruction.scheme !== undefined) {
if (isCategoricalColorScheme(instruction.scheme)) {
var _scale = d3Scale.scaleOrdinal(colorSchemes[instruction.scheme]);
var _generator = function _generator(d) {
return _scale(getIdentity(d));
};
_generator.scale = _scale;
return _generator;
}
if (instruction.scheme !== undefined) {
if (isCategoricalColorScheme(instruction.scheme)) {
var _scale = d3Scale.scaleOrdinal(colorSchemes[instruction.scheme]);
var _generator = function _generator(d) {
return _scale(getIdentity(d));
};
_generator.scale = _scale;
return _generator;
if (isDivergingColorScheme(instruction.scheme)) {
if (instruction.size !== undefined && (instruction.size < 3 || instruction.size > 11)) {
throw new Error("Invalid size '".concat(instruction.size, "' for diverging color scheme '").concat(instruction.scheme, "', must be between 3~11"));
}
if (isDivergingColorScheme(instruction.scheme)) {
if (instruction.size !== undefined && (instruction.size < 3 || instruction.size > 11)) {
throw new Error("Invalid size '".concat(instruction.size, "' for diverging color scheme '").concat(instruction.scheme, "', must be between 3~11"));
}
var _scale2 = d3Scale.scaleOrdinal(colorSchemes[instruction.scheme][instruction.size || 11]);
var _generator2 = function _generator2(d) {
return _scale2(getIdentity(d));
};
_generator2.scale = _scale2;
return _generator2;
var _scale2 = d3Scale.scaleOrdinal(colorSchemes[instruction.scheme][instruction.size || 11]);
var _generator2 = function _generator2(d) {
return _scale2(getIdentity(d));
};
_generator2.scale = _scale2;
return _generator2;
}
if (isSequentialColorScheme(instruction.scheme)) {
if (instruction.size !== undefined && (instruction.size < 3 || instruction.size > 9)) {
throw new Error("Invalid size '".concat(instruction.size, "' for sequential color scheme '").concat(instruction.scheme, "', must be between 3~9"));
}
if (isSequentialColorScheme(instruction.scheme)) {
if (instruction.size !== undefined && (instruction.size < 3 || instruction.size > 9)) {
throw new Error("Invalid size '".concat(instruction.size, "' for sequential color scheme '").concat(instruction.scheme, "', must be between 3~9"));
}
var _scale3 = d3Scale.scaleOrdinal(colorSchemes[instruction.scheme][instruction.size || 9]);
var _generator3 = function _generator3(d) {
return _scale3(getIdentity(d));
var _scale3 = d3Scale.scaleOrdinal(colorSchemes[instruction.scheme][instruction.size || 9]);
var _generator3 = function _generator3(d) {
return _scale3(getIdentity(d));
};
_generator3.scale = _scale3;
return _generator3;
}
}
throw new Error("Invalid colors, when using an object, you should either pass a 'datum' or a 'scheme' property");
}
return function () {
return instruction;
};
};
var useOrdinalColorScale = function useOrdinalColorScale(instruction, identity) {
return react.useMemo(function () {
return getOrdinalColorScale(instruction, identity);
}, [instruction, identity]);
};
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _createForOfIteratorHelper(o) {
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
var i = 0;
var F = function F() {};
return {
s: F,
n: function n() {
if (i >= o.length) return {
done: true
};
_generator3.scale = _scale3;
return _generator3;
}
return {
done: false,
value: o[i++]
};
},
e: function e(_e) {
throw _e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var it,
normalCompletion = true,
didErr = false,
err;
return {
s: function s() {
it = o[Symbol.iterator]();
},
n: function n() {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function e(_e2) {
didErr = true;
err = _e2;
},
f: function f() {
try {
if (!normalCompletion && it["return"] != null) it["return"]();
} finally {
if (didErr) throw err;
}
throw new Error("Invalid colors, when using an object, you should either pass a 'datum' or a 'scheme' property");
}
return function () {
return instruction;
};
};
var useOrdinalColorScale = function useOrdinalColorScale(instruction, identity) {
return react.useMemo(function () {
return getOrdinalColorScale(instruction, identity);
}, [instruction, identity]);
}
var getInheritedColorGenerator = function getInheritedColorGenerator(inheritedColor, theme) {
if (typeof inheritedColor === 'function') return function (node) {
return inheritedColor(node);
};
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var getInheritedColorGenerator = function getInheritedColorGenerator(inheritedColor, theme) {
if (typeof inheritedColor === 'function') return function (node) {
return inheritedColor(node);
};
if (isPlainObject(inheritedColor)) {
if (inheritedColor.theme !== undefined) {
if (theme === undefined) {
throw new Error("Unable to use color from theme as no theme was provided");
}
var themeColor = get(theme, inheritedColor.theme);
if (themeColor === undefined) {
throw new Error("Color from theme is undefined at path: '".concat(inheritedColor.theme, "'"));
}
return function () {
return themeColor;
};
if (isPlainObject(inheritedColor)) {
if (inheritedColor.theme !== undefined) {
if (theme === undefined) {
throw new Error("Unable to use color from theme as no theme was provided");
}
if (inheritedColor.from !== undefined) {
var getColor = function getColor(datum) {
return get(datum, inheritedColor.from);
};
if (Array.isArray(inheritedColor.modifiers)) {
var modifiers = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
var _loop = function _loop() {
var modifier = _step.value;
var _modifier = _slicedToArray(modifier, 2),
modifierType = _modifier[0],
amount = _modifier[1];
if (modifierType === 'brighter') {
modifiers.push(function (color) {
return color.brighter(amount);
});
} else if (modifierType === 'darker') {
modifiers.push(function (color) {
return color.darker(amount);
});
} else if (modifierType === 'opacity') {
modifiers.push(function (color) {
color.opacity = amount;
return color;
});
} else {
throw new Error("Invalid color modifier: '".concat(modifierType, "', must be one of: 'brighter', 'darker', 'opacity'"));
}
};
for (var _iterator = inheritedColor.modifiers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop();
var themeColor = get(theme, inheritedColor.theme);
if (themeColor === undefined) {
throw new Error("Color from theme is undefined at path: '".concat(inheritedColor.theme, "'"));
}
return function () {
return themeColor;
};
}
if (inheritedColor.from !== undefined) {
var getColor = function getColor(datum) {
return get(datum, inheritedColor.from);
};
if (Array.isArray(inheritedColor.modifiers)) {
var modifiers = [];
var _iterator = _createForOfIteratorHelper(inheritedColor.modifiers),
_step;
try {
var _loop = function _loop() {
var modifier = _step.value;
var _modifier = _slicedToArray(modifier, 2),
modifierType = _modifier[0],
amount = _modifier[1];
if (modifierType === 'brighter') {
modifiers.push(function (color) {
return color.brighter(amount);
});
} else if (modifierType === 'darker') {
modifiers.push(function (color) {
return color.darker(amount);
});
} else if (modifierType === 'opacity') {
modifiers.push(function (color) {
color.opacity = amount;
return color;
});
} else {
throw new Error("Invalid color modifier: '".concat(modifierType, "', must be one of: 'brighter', 'darker', 'opacity'"));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
}
if (modifiers.length === 0) return getColor;
return function (datum) {
return modifiers.reduce(function (color, modify) {
return modify(color);
}, d3Color.rgb(getColor(datum))).toString();
};
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return getColor;
if (modifiers.length === 0) return getColor;
return function (datum) {
return modifiers.reduce(function (color, modify) {
return modify(color);
}, d3Color.rgb(getColor(datum))).toString();
};
}
throw new Error("Invalid color spec, you should either specify 'theme' or 'from' when using a config object");
return getColor;
}
return function () {
return inheritedColor;
};
throw new Error("Invalid color spec, you should either specify 'theme' or 'from' when using a config object");
}
return function () {
return inheritedColor;
};
var useInheritedColor = function useInheritedColor(parentColor, theme) {
return react.useMemo(function () {
return getInheritedColorGenerator(parentColor, theme);
}, [parentColor, theme]);
};
};
var useInheritedColor = function useInheritedColor(parentColor, theme) {
return react.useMemo(function () {
return getInheritedColorGenerator(parentColor, theme);
}, [parentColor, theme]);
};
var ordinalColorsPropType = PropTypes.oneOfType([PropTypes.func, PropTypes.arrayOf(PropTypes.string), PropTypes.shape({
scheme: PropTypes.oneOf(colorSchemeIds).isRequired,
size: PropTypes.number
}), PropTypes.shape({
datum: PropTypes.string.isRequired
}), PropTypes.string]);
var colorPropertyAccessorPropType = PropTypes.oneOfType([PropTypes.func, PropTypes.string]);
var inheritedColorPropType = PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.shape({
theme: PropTypes.string.isRequired
}), PropTypes.shape({
from: PropTypes.string.isRequired,
modifiers: PropTypes.arrayOf(PropTypes.array)
})]);
var ordinalColorsPropType = PropTypes.oneOfType([PropTypes.func, PropTypes.arrayOf(PropTypes.string), PropTypes.shape({
scheme: PropTypes.oneOf(colorSchemeIds).isRequired,
size: PropTypes.number
}), PropTypes.shape({
datum: PropTypes.string.isRequired
}), PropTypes.string]);
var colorPropertyAccessorPropType = PropTypes.oneOfType([PropTypes.func, PropTypes.string]);
var inheritedColorPropType = PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.shape({
theme: PropTypes.string.isRequired
}), PropTypes.shape({
from: PropTypes.string.isRequired,
modifiers: PropTypes.arrayOf(PropTypes.array)
})]);
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(Object(source)); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } return target; }
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var interpolateColor = function interpolateColor(color, springConfig) {
var colorComponents = d3Color.rgb(color);
if (!springConfig) {
return {
colorR: colorComponents.r,
colorG: colorComponents.g,
colorB: colorComponents.b
};
}
var configWithPrecision = _objectSpread$1({}, springConfig, {
precision: 1
});
var interpolateColor = function interpolateColor(color, springConfig) {
var colorComponents = d3Color.rgb(color);
if (!springConfig) {
return {
colorR: reactMotion.spring(colorComponents.r, configWithPrecision),
colorG: reactMotion.spring(colorComponents.g, configWithPrecision),
colorB: reactMotion.spring(colorComponents.b, configWithPrecision)
colorR: colorComponents.r,
colorG: colorComponents.g,
colorB: colorComponents.b
};
}
var configWithPrecision = _objectSpread2(_objectSpread2({}, springConfig), {}, {
precision: 1
});
return {
colorR: reactMotion.spring(colorComponents.r, configWithPrecision),
colorG: reactMotion.spring(colorComponents.g, configWithPrecision),
colorB: reactMotion.spring(colorComponents.b, configWithPrecision)
};
var getInterpolatedColor = function getInterpolatedColor(_ref) {
var colorR = _ref.colorR,
colorG = _ref.colorG,
colorB = _ref.colorB;
return "rgb(".concat(Math.round(Math.max(colorR, 0)), ",").concat(Math.round(Math.max(colorG, 0)), ",").concat(Math.round(Math.max(colorB, 0)), ")");
};
};
var getInterpolatedColor = function getInterpolatedColor(_ref) {
var colorR = _ref.colorR,
colorG = _ref.colorG,
colorB = _ref.colorB;
return "rgb(".concat(Math.round(Math.max(colorR, 0)), ",").concat(Math.round(Math.max(colorG, 0)), ",").concat(Math.round(Math.max(colorB, 0)), ")");
};
exports.categoricalColorSchemeIds = categoricalColorSchemeIds;
exports.categoricalColorSchemes = categoricalColorSchemes;
exports.colorInterpolatorIds = colorInterpolatorIds;
exports.colorInterpolators = colorInterpolators;
exports.colorPropertyAccessorPropType = colorPropertyAccessorPropType;
exports.colorSchemeIds = colorSchemeIds;
exports.colorSchemes = colorSchemes;
exports.divergingColorSchemeIds = divergingColorSchemeIds;
exports.divergingColorSchemes = divergingColorSchemes;
exports.getInheritedColorGenerator = getInheritedColorGenerator;
exports.getInterpolatedColor = getInterpolatedColor;
exports.getOrdinalColorScale = getOrdinalColorScale;
exports.inheritedColorPropType = inheritedColorPropType;
exports.interpolateColor = interpolateColor;
exports.isCategoricalColorScheme = isCategoricalColorScheme;
exports.isDivergingColorScheme = isDivergingColorScheme;
exports.isSequentialColorScheme = isSequentialColorScheme;
exports.ordinalColorsPropType = ordinalColorsPropType;
exports.sequentialColorSchemeIds = sequentialColorSchemeIds;
exports.sequentialColorSchemes = sequentialColorSchemes;
exports.useInheritedColor = useInheritedColor;
exports.useOrdinalColorScale = useOrdinalColorScale;
exports.categoricalColorSchemeIds = categoricalColorSchemeIds;
exports.categoricalColorSchemes = categoricalColorSchemes;
exports.colorInterpolatorIds = colorInterpolatorIds;
exports.colorInterpolators = colorInterpolators;
exports.colorPropertyAccessorPropType = colorPropertyAccessorPropType;
exports.colorSchemeIds = colorSchemeIds;
exports.colorSchemes = colorSchemes;
exports.divergingColorSchemeIds = divergingColorSchemeIds;
exports.divergingColorSchemes = divergingColorSchemes;
exports.getInheritedColorGenerator = getInheritedColorGenerator;
exports.getInterpolatedColor = getInterpolatedColor;
exports.getOrdinalColorScale = getOrdinalColorScale;
exports.inheritedColorPropType = inheritedColorPropType;
exports.interpolateColor = interpolateColor;
exports.isCategoricalColorScheme = isCategoricalColorScheme;
exports.isDivergingColorScheme = isDivergingColorScheme;
exports.isSequentialColorScheme = isSequentialColorScheme;
exports.ordinalColorsPropType = ordinalColorsPropType;
exports.sequentialColorSchemeIds = sequentialColorSchemeIds;
exports.sequentialColorSchemes = sequentialColorSchemes;
exports.useInheritedColor = useInheritedColor;
exports.useOrdinalColorScale = useOrdinalColorScale;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=nivo-colors.umd.js.map
{
"name": "@nivo/colors",
"version": "0.62.0",
"version": "0.63.0",
"license": "MIT",

@@ -10,3 +10,3 @@ "author": {

"main": "./dist/nivo-colors.cjs.js",
"module": "./dist/nivo-colors.esm.js",
"module": "./dist/nivo-colors.es.js",
"files": [

@@ -33,3 +33,3 @@ "README.md",

},
"gitHead": "a98a072c4fe5339457d26f396d032dfc302187bc"
"gitHead": "defc453433d8e6767ba3d612cce0d05c119ec5ed"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc