@deck.gl/carto 8.7.0-alpha.3 → 8.7.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/dist.dev.js +2385 -2436
  2. package/dist/es5/api/index.js +9 -9
  3. package/dist/es5/api/layer-map.js +82 -71
  4. package/dist/es5/api/layer-map.js.map +1 -1
  5. package/dist/es5/api/maps-api-common.js +13 -9
  6. package/dist/es5/api/maps-api-common.js.map +1 -1
  7. package/dist/es5/api/maps-client.js +157 -98
  8. package/dist/es5/api/maps-client.js.map +1 -1
  9. package/dist/es5/api/maps-v3-client.js +528 -312
  10. package/dist/es5/api/maps-v3-client.js.map +1 -1
  11. package/dist/es5/api/parseMap.js +88 -92
  12. package/dist/es5/api/parseMap.js.map +1 -1
  13. package/dist/es5/basemap.js +1 -1
  14. package/dist/es5/basemap.js.map +1 -1
  15. package/dist/es5/config.js +25 -18
  16. package/dist/es5/config.js.map +1 -1
  17. package/dist/es5/index.js +15 -15
  18. package/dist/es5/layers/carto-layer.js +207 -129
  19. package/dist/es5/layers/carto-layer.js.map +1 -1
  20. package/dist/es5/style/color-bins-style.js +15 -12
  21. package/dist/es5/style/color-bins-style.js.map +1 -1
  22. package/dist/es5/style/color-categories-style.js +43 -16
  23. package/dist/es5/style/color-categories-style.js.map +1 -1
  24. package/dist/es5/style/color-continuous-style.js +15 -12
  25. package/dist/es5/style/color-continuous-style.js.map +1 -1
  26. package/dist/es5/style/palette.js +23 -13
  27. package/dist/es5/style/palette.js.map +1 -1
  28. package/dist/es5/style/utils.js +13 -6
  29. package/dist/es5/style/utils.js.map +1 -1
  30. package/dist/esm/style/color-bins-style.js +1 -1
  31. package/dist/esm/style/color-bins-style.js.map +1 -1
  32. package/dist/esm/style/color-continuous-style.js +1 -1
  33. package/dist/esm/style/color-continuous-style.js.map +1 -1
  34. package/dist.min.js +4 -4
  35. package/package.json +7 -7
  36. package/src/style/color-bins-style.js +1 -1
  37. package/src/style/color-continuous-style.js +1 -1
@@ -1,35 +1,62 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
3
7
  Object.defineProperty(exports, "__esModule", {
4
8
  value: true
5
9
  });
6
10
  exports.default = colorCategories;
7
11
 
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
8
14
  var _palette = _interopRequireWildcard(require("./palette"));
9
15
 
10
16
  var _utils = require("./utils");
11
17
 
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ 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); }
13
19
 
14
- 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; }
20
+ 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; }
15
21
 
16
- function colorCategories({
17
- attr,
18
- domain,
19
- colors = _palette.DEFAULT_PALETTE,
20
- nullColor = _palette.NULL_COLOR,
21
- othersColor = _palette.OTHERS_COLOR
22
- }) {
23
- (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers or strings');
24
- const colorsByCategory = {};
25
- const palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length) : colors;
22
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, 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; } } }; }
26
23
 
27
- for (const [i, c] of domain.entries()) {
28
- colorsByCategory[c] = palette[i];
24
+ 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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
+
26
+ 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; }
27
+
28
+ function colorCategories(_ref) {
29
+ var attr = _ref.attr,
30
+ domain = _ref.domain,
31
+ _ref$colors = _ref.colors,
32
+ colors = _ref$colors === void 0 ? _palette.DEFAULT_PALETTE : _ref$colors,
33
+ _ref$nullColor = _ref.nullColor,
34
+ nullColor = _ref$nullColor === void 0 ? _palette.NULL_COLOR : _ref$nullColor,
35
+ _ref$othersColor = _ref.othersColor,
36
+ othersColor = _ref$othersColor === void 0 ? _palette.OTHERS_COLOR : _ref$othersColor;
37
+ (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers or strings');
38
+ var colorsByCategory = {};
39
+ var palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length) : colors;
40
+
41
+ var _iterator = _createForOfIteratorHelper(domain.entries()),
42
+ _step;
43
+
44
+ try {
45
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
46
+ var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
47
+ i = _step$value[0],
48
+ c = _step$value[1];
49
+
50
+ colorsByCategory[c] = palette[i];
51
+ }
52
+ } catch (err) {
53
+ _iterator.e(err);
54
+ } finally {
55
+ _iterator.f();
29
56
  }
30
57
 
31
- return d => {
32
- const value = (0, _utils.getAttrValue)(attr, d);
58
+ return function (d) {
59
+ var value = (0, _utils.getAttrValue)(attr, d);
33
60
  return Number.isFinite(value) || typeof value === 'string' ? colorsByCategory[value] || othersColor : nullColor;
34
61
  };
35
62
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-categories-style.js"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","i","c","entries","d","value","Number","isFinite"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEe,SAASA,eAAT,CAAyB;AACtCC,EAAAA,IADsC;AAEtCC,EAAAA,MAFsC;AAGtCC,EAAAA,MAAM,GAAGC,wBAH6B;AAItCC,EAAAA,SAAS,GAAGC,mBAJ0B;AAKtCC,EAAAA,WAAW,GAAGC;AALwB,CAAzB,EAMZ;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,QAAMS,gBAAgB,GAAG,EAAzB;AACA,QAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAEA,OAAK,MAAM,CAACW,CAAD,EAAIC,CAAJ,CAAX,IAAqBb,MAAM,CAACc,OAAP,EAArB,EAAuC;AACrCL,IAAAA,gBAAgB,CAACI,CAAD,CAAhB,GAAsBH,OAAO,CAACE,CAAD,CAA7B;AACD;;AAED,SAAOG,CAAC,IAAI;AACV,UAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,KAA0B,OAAOA,KAAP,KAAiB,QAA3C,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import getPalette, {DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorCategories({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-categories-style.js"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","entries","i","c","d","value","Number","isFinite"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;;;;;;;;;;;AAEe,SAASA,eAAT,OAMZ;AAAA,MALDC,IAKC,QALDA,IAKC;AAAA,MAJDC,MAIC,QAJDA,MAIC;AAAA,yBAHDC,MAGC;AAAA,MAHDA,MAGC,4BAHQC,wBAGR;AAAA,4BAFDC,SAEC;AAAA,MAFDA,SAEC,+BAFWC,mBAEX;AAAA,8BADDC,WACC;AAAA,MADDA,WACC,iCADaC,qBACb;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,MAAMS,gBAAgB,GAAG,EAAzB;AACA,MAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAJC,6CAMoBD,MAAM,CAACY,OAAP,EANpB;AAAA;;AAAA;AAMD,wDAAuC;AAAA;AAAA,UAA3BC,CAA2B;AAAA,UAAxBC,CAAwB;;AACrCL,MAAAA,gBAAgB,CAACK,CAAD,CAAhB,GAAsBJ,OAAO,CAACG,CAAD,CAA7B;AACD;AARA;AAAA;AAAA;AAAA;AAAA;;AAUD,SAAO,UAAAE,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,KAA0B,OAAOA,KAAP,KAAiB,QAA3C,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import getPalette, {DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorCategories({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -11,21 +13,22 @@ var _palette = _interopRequireWildcard(require("./palette"));
11
13
 
12
14
  var _utils = require("./utils");
13
15
 
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
+ 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); }
15
17
 
16
- 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; }
18
+ 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; }
17
19
 
18
- function colorContinuous({
19
- attr,
20
- domain,
21
- colors = _palette.DEFAULT_PALETTE,
22
- nullColor = _palette.NULL_COLOR
23
- }) {
20
+ function colorContinuous(_ref) {
21
+ var attr = _ref.attr,
22
+ domain = _ref.domain,
23
+ _ref$colors = _ref.colors,
24
+ colors = _ref$colors === void 0 ? _palette.DEFAULT_PALETTE : _ref$colors,
25
+ _ref$nullColor = _ref.nullColor,
26
+ nullColor = _ref$nullColor === void 0 ? _palette.NULL_COLOR : _ref$nullColor;
24
27
  (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
25
- const palette = typeof colors === 'string' ? (0, _palette.default)(colors) : colors;
26
- const color = (0, _d3Scale.scaleLinear)().domain(domain).range(palette);
27
- return d => {
28
- const value = (0, _utils.getAttrValue)(attr, d);
28
+ var palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length) : colors;
29
+ var color = (0, _d3Scale.scaleLinear)().domain(domain).range(palette);
30
+ return function (d) {
31
+ var value = (0, _utils.getAttrValue)(attr, d);
29
32
  return Number.isFinite(value) ? color(value) : nullColor;
30
33
  };
31
34
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-continuous-style.js"],"names":["colorContinuous","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,eAAT,CAAyB;AACtCC,EAAAA,IADsC;AAEtCC,EAAAA,MAFsC;AAGtCC,EAAAA,MAAM,GAAGC,wBAH6B;AAItCC,EAAAA,SAAS,GAAGC;AAJ0B,CAAzB,EAKZ;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,QAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,CAA7B,GAAkDA,MAAlE;AACA,QAAMO,KAAK,GAAG,4BAAcR,MAAd,CAAqBA,MAArB,EAA6BS,KAA7B,CAAmCF,OAAnC,CAAd;AAEA,SAAOG,CAAC,IAAI;AACV,UAAMC,KAAK,GAAG,yBAAaZ,IAAb,EAAmBW,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCR,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors) : colors;\n const color = scaleLinear().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-continuous-style.js"],"names":["colorContinuous","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,eAAT,OAKZ;AAAA,MAJDC,IAIC,QAJDA,IAIC;AAAA,MAHDC,MAGC,QAHDA,MAGC;AAAA,yBAFDC,MAEC;AAAA,MAFDA,MAEC,4BAFQC,wBAER;AAAA,4BADDC,SACC;AAAA,MADDA,SACC,+BADWC,mBACX;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACQ,MAA1B,CAA7B,GAAiEP,MAAjF;AACA,MAAMQ,KAAK,GAAG,4BAAcT,MAAd,CAAqBA,MAArB,EAA6BU,KAA7B,CAAmCH,OAAnC,CAAd;AAEA,SAAO,UAAAI,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAab,IAAb,EAAmBY,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCT,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n const color = scaleLinear().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
3
7
  Object.defineProperty(exports, "__esModule", {
4
8
  value: true
5
9
  });
@@ -7,28 +11,32 @@ exports.default = getPalette;
7
11
  exports.hexToRgb = hexToRgb;
8
12
  exports.OTHERS_COLOR = exports.NULL_COLOR = exports.DEFAULT_PALETTE = void 0;
9
13
 
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
10
16
  var cartoColors = _interopRequireWildcard(require("cartocolor"));
11
17
 
12
18
  var _utils = require("./utils");
13
19
 
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
+ 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); }
15
21
 
16
- 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; }
22
+ 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; }
17
23
 
18
- const DEFAULT_PALETTE = 'PurpOr';
24
+ var DEFAULT_PALETTE = 'PurpOr';
19
25
  exports.DEFAULT_PALETTE = DEFAULT_PALETTE;
20
- const NULL_COLOR = [204, 204, 204];
26
+ var NULL_COLOR = [204, 204, 204];
21
27
  exports.NULL_COLOR = NULL_COLOR;
22
- const OTHERS_COLOR = [119, 119, 119];
28
+ var OTHERS_COLOR = [119, 119, 119];
23
29
  exports.OTHERS_COLOR = OTHERS_COLOR;
24
30
 
25
31
  function getPalette(name, numCategories) {
26
- const palette = cartoColors[name];
27
- let paletteIndex = numCategories;
32
+ var palette = cartoColors[name];
33
+ var paletteIndex = numCategories;
28
34
  (0, _utils.assert)(palette, "Palette \"".concat(name, "\" not found. Expected a CARTOColors string"));
29
- const palettesColorVariants = Object.keys(palette).filter(p => p !== 'tags').map(Number);
30
- const longestPaletteIndex = Math.max(...palettesColorVariants);
31
- const smallestPaletteIndex = Math.min(...palettesColorVariants);
35
+ var palettesColorVariants = Object.keys(palette).filter(function (p) {
36
+ return p !== 'tags';
37
+ }).map(Number);
38
+ var longestPaletteIndex = Math.max.apply(Math, (0, _toConsumableArray2.default)(palettesColorVariants));
39
+ var smallestPaletteIndex = Math.min.apply(Math, (0, _toConsumableArray2.default)(palettesColorVariants));
32
40
 
33
41
  if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {
34
42
  paletteIndex = longestPaletteIndex;
@@ -36,17 +44,19 @@ function getPalette(name, numCategories) {
36
44
  paletteIndex = smallestPaletteIndex;
37
45
  }
38
46
 
39
- let colors = palette[paletteIndex];
47
+ var colors = palette[paletteIndex];
40
48
 
41
49
  if (palette.tags && palette.tags.includes('qualitative')) {
42
50
  colors = colors.slice(0, -1);
43
51
  }
44
52
 
45
- return colors.map(c => hexToRgb(c));
53
+ return colors.map(function (c) {
54
+ return hexToRgb(c);
55
+ });
46
56
  }
47
57
 
48
58
  function hexToRgb(hex) {
49
- let result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})$/i.exec(hex);
59
+ var result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})$/i.exec(hex);
50
60
 
51
61
  if (result) {
52
62
  return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16), 255];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/palette.js"],"names":["DEFAULT_PALETTE","NULL_COLOR","OTHERS_COLOR","getPalette","name","numCategories","palette","cartoColors","paletteIndex","palettesColorVariants","Object","keys","filter","p","map","Number","longestPaletteIndex","Math","max","smallestPaletteIndex","min","isInteger","colors","tags","includes","slice","c","hexToRgb","hex","result","exec","parseInt"],"mappings":";;;;;;;;;AAAA;;AACA;;;;;;AAEO,MAAMA,eAAe,GAAG,QAAxB;;AACA,MAAMC,UAAU,GAA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AAG,wDAAwDC,IAAxD,CAA6DF,GAA7D,CAAT;;AAEA,MAAIC,MAAJ,EAAY;AACV,WAAO,CACLE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CADH,EAELE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAFH,EAGLE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAHH,EAILE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAJH,CAAP;AAMD;;AAED,qBAAOA,MAAP,gCAAqCD,GAArC;AAEA,SAAO3B,UAAP;AACD","sourcesContent":["import * as cartoColors from 'cartocolor';\nimport {assert} from './utils';\n\nexport const DEFAULT_PALETTE = 'PurpOr';\nexport const NULL_COLOR = [204, 204, 204];\nexport const OTHERS_COLOR = [119, 119, 119];\n\nexport default function getPalette(name, numCategories) {\n const palette = cartoColors[name];\n let paletteIndex = numCategories;\n\n assert(palette, `Palette \"${name}\" not found. Expected a CARTOColors string`);\n\n const palettesColorVariants = Object.keys(palette)\n .filter(p => p !== 'tags')\n .map(Number);\n\n const longestPaletteIndex = Math.max(...palettesColorVariants);\n const smallestPaletteIndex = Math.min(...palettesColorVariants);\n\n if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {\n paletteIndex = longestPaletteIndex;\n } else if (numCategories < smallestPaletteIndex) {\n paletteIndex = smallestPaletteIndex;\n }\n\n let colors = palette[paletteIndex];\n\n if (palette.tags && palette.tags.includes('qualitative')) {\n colors = colors.slice(0, -1);\n }\n\n return colors.map(c => hexToRgb(c));\n}\n\nexport function hexToRgb(hex) {\n // Evaluate #ABC\n let result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n 255\n ];\n }\n\n // Evaluate #ABCD\n result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n parseInt(result[4] + result[4], 16)\n ];\n }\n\n // Evaluate #ABCDEF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];\n }\n\n // Evaluate #ABCDEFAF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1], 16),\n parseInt(result[2], 16),\n parseInt(result[3], 16),\n parseInt(result[4], 16)\n ];\n }\n\n assert(result, `Hexadecimal color \"${hex}\" was not parsed correctly`);\n\n return NULL_COLOR;\n}\n"],"file":"palette.js"}
1
+ {"version":3,"sources":["../../../src/style/palette.js"],"names":["DEFAULT_PALETTE","NULL_COLOR","OTHERS_COLOR","getPalette","name","numCategories","palette","cartoColors","paletteIndex","palettesColorVariants","Object","keys","filter","p","map","Number","longestPaletteIndex","Math","max","smallestPaletteIndex","min","isInteger","colors","tags","includes","slice","c","hexToRgb","hex","result","exec","parseInt"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEO,IAAMA,eAAe,GAAG,QAAxB;;AACA,IAAMC,UAAU,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAnB;;AACA,IAAMC,YAAY,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAArB;;;AAEQ,SAASC,UAAT,CAAoBC,IAApB,EAA0BC,aAA1B,EAAyC;AACtD,MAAMC,OAAO,GAAGC,WAAW,CAACH,IAAD,CAA3B;AACA,MAAII,YAAY,GAAGH,aAAnB;AAEA,qBAAOC,OAAP,sBAA4BF,IAA5B;AAEA,MAAMK,qBAAqB,G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EAAY,EAAZ,CAHH,EAILE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAJH,CAAP;AAMD;;AAED,qBAAOA,MAAP,gCAAqCD,GAArC;AAEA,SAAO3B,UAAP;AACD","sourcesContent":["import * as cartoColors from 'cartocolor';\nimport {assert} from './utils';\n\nexport const DEFAULT_PALETTE = 'PurpOr';\nexport const NULL_COLOR = [204, 204, 204];\nexport const OTHERS_COLOR = [119, 119, 119];\n\nexport default function getPalette(name, numCategories) {\n const palette = cartoColors[name];\n let paletteIndex = numCategories;\n\n assert(palette, `Palette \"${name}\" not found. Expected a CARTOColors string`);\n\n const palettesColorVariants = Object.keys(palette)\n .filter(p => p !== 'tags')\n .map(Number);\n\n const longestPaletteIndex = Math.max(...palettesColorVariants);\n const smallestPaletteIndex = Math.min(...palettesColorVariants);\n\n if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {\n paletteIndex = longestPaletteIndex;\n } else if (numCategories < smallestPaletteIndex) {\n paletteIndex = smallestPaletteIndex;\n }\n\n let colors = palette[paletteIndex];\n\n if (palette.tags && palette.tags.includes('qualitative')) {\n colors = colors.slice(0, -1);\n }\n\n return colors.map(c => hexToRgb(c));\n}\n\nexport function hexToRgb(hex) {\n // Evaluate #ABC\n let result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n 255\n ];\n }\n\n // Evaluate #ABCD\n result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n parseInt(result[4] + result[4], 16)\n ];\n }\n\n // Evaluate #ABCDEF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];\n }\n\n // Evaluate #ABCDEFAF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1], 16),\n parseInt(result[2], 16),\n parseInt(result[3], 16),\n parseInt(result[4], 16)\n ];\n }\n\n assert(result, `Hexadecimal color \"${hex}\" was not parsed correctly`);\n\n return NULL_COLOR;\n}\n"],"file":"palette.js"}
@@ -1,28 +1,35 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.getAttrValue = getAttrValue;
7
9
  exports.assert = assert;
8
- const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
10
+
11
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
+
13
+ var ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
9
14
 
10
15
  function getAttrValue(attr, d) {
11
- assert(typeof d === 'object', 'Expected "data" to be an object');
12
- assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected "attr" to be a function or string');
16
+ assert((0, _typeof2.default)(d) === 'object', 'Expected "data" to be an object');
17
+ assert(ALLOWED_ATTR_TYPES.includes((0, _typeof2.default)(attr)), 'Expected "attr" to be a function or string');
13
18
 
14
- if (typeof attr === ALLOWED_ATTR_TYPES[0]) {
19
+ if ((0, _typeof2.default)(attr) === ALLOWED_ATTR_TYPES[0]) {
15
20
  return attr(d);
16
21
  }
17
22
 
18
- if (typeof attr === ALLOWED_ATTR_TYPES[1]) {
23
+ if ((0, _typeof2.default)(attr) === ALLOWED_ATTR_TYPES[1]) {
19
24
  return d.properties[attr];
20
25
  }
21
26
 
22
27
  return {};
23
28
  }
24
29
 
25
- function assert(condition, message = '') {
30
+ function assert(condition) {
31
+ var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
32
+
26
33
  if (!condition) {
27
34
  throw new Error("CARTO style error: ".concat(message));
28
35
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/utils.js"],"names":["ALLOWED_ATTR_TYPES","Object","freeze","getAttrValue","attr","d","assert","includes","properties","condition","message","Error"],"mappings":";;;;;;;AAAA,MAAMA,kBAAkB,GAAGC,MAAM,CAACC,MAAP,CAAc,CAAC,UAAD,EAAa,QAAb,CAAd,CAA3B;;AAEO,SAASC,YAAT,CAAsBC,IAAtB,EAA4BC,CAA5B,EAA+B;AACpCC,EAAAA,MAAM,CAAC,OAAOD,CAAP,KAAa,QAAd,EAAwB,iCAAxB,CAAN;AACAC,EAAAA,MAAM,CAACN,kBAAkB,CAACO,QAAnB,CAA4B,OAAOH,IAAnC,CAAD,EAA2C,4CAA3C,CAAN;;AAGA,MAAI,OAAOA,IAAP,KAAgBJ,kBAAkB,CAAC,CAAD,CAAtC,EAA2C;AACzC,WAAOI,IAAI,CAACC,CAAD,CAAX;AACD;;AAGD,MAAI,OAAOD,IAAP,KAAgBJ,kBAAkB,CAAC,CAAD,CAAtC,EAA2C;AACzC,WAAOK,CAAC,CAACG,UAAF,CAAaJ,IAAb,CAAP;AACD;;AAED,SAAO,EAAP;AACD;;AAEM,SAASE,MAAT,CAAgBG,SAAhB,EAA2BC,OAAO,GAAG,EAArC,EAAyC;AAC9C,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,8BAAgCD,OAAhC,EAAN;AACD;AACF","sourcesContent":["const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);\n\nexport function getAttrValue(attr, d) {\n assert(typeof d === 'object', 'Expected \"data\" to be an object');\n assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected \"attr\" to be a function or string');\n\n // Is function\n if (typeof attr === ALLOWED_ATTR_TYPES[0]) {\n return attr(d);\n }\n\n // Is string\n if (typeof attr === ALLOWED_ATTR_TYPES[1]) {\n return d.properties[attr];\n }\n\n return {};\n}\n\nexport function assert(condition, message = '') {\n if (!condition) {\n throw new Error(`CARTO style error: ${message}`);\n }\n}\n"],"file":"utils.js"}
1
+ {"version":3,"sources":["../../../src/style/utils.js"],"names":["ALLOWED_ATTR_TYPES","Object","freeze","getAttrValue","attr","d","assert","includes","properties","condition","message","Error"],"mappings":";;;;;;;;;;;;AAAA,IAAMA,kBAAkB,GAAGC,MAAM,CAACC,MAAP,CAAc,CAAC,UAAD,EAAa,QAAb,CAAd,CAA3B;;AAEO,SAASC,YAAT,CAAsBC,IAAtB,EAA4BC,CAA5B,EAA+B;AACpCC,EAAAA,MAAM,CAAC,sBAAOD,CAAP,MAAa,QAAd,EAAwB,iCAAxB,CAAN;AACAC,EAAAA,MAAM,CAACN,kBAAkB,CAACO,QAAnB,uBAAmCH,IAAnC,EAAD,EAA2C,4CAA3C,CAAN;;AAGA,MAAI,sBAAOA,IAAP,MAAgBJ,kBAAkB,CAAC,CAAD,CAAtC,EAA2C;AACzC,WAAOI,IAAI,CAACC,CAAD,CAAX;AACD;;AAGD,MAAI,sBAAOD,IAAP,MAAgBJ,kBAAkB,CAAC,CAAD,CAAtC,EAA2C;AACzC,WAAOK,CAAC,CAACG,UAAF,CAAaJ,IAAb,CAAP;AACD;;AAED,SAAO,EAAP;AACD;;AAEM,SAASE,MAAT,CAAgBG,SAAhB,EAAyC;AAAA,MAAdC,OAAc,uEAAJ,EAAI;;AAC9C,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,8BAAgCD,OAAhC,EAAN;AACD;AACF","sourcesContent":["const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);\n\nexport function getAttrValue(attr, d) {\n assert(typeof d === 'object', 'Expected \"data\" to be an object');\n assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected \"attr\" to be a function or string');\n\n // Is function\n if (typeof attr === ALLOWED_ATTR_TYPES[0]) {\n return attr(d);\n }\n\n // Is string\n if (typeof attr === ALLOWED_ATTR_TYPES[1]) {\n return d.properties[attr];\n }\n\n return {};\n}\n\nexport function assert(condition, message = '') {\n if (!condition) {\n throw new Error(`CARTO style error: ${message}`);\n }\n}\n"],"file":"utils.js"}
@@ -8,7 +8,7 @@ export default function colorBins({
8
8
  nullColor = NULL_COLOR
9
9
  }) {
10
10
  assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
11
- const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;
11
+ const palette = typeof colors === 'string' ? getPalette(colors, domain.length + 1) : colors;
12
12
  const color = scaleThreshold().domain(domain).range(palette);
13
13
  return d => {
14
14
  const value = getAttrValue(attr, d);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-bins-style.js"],"names":["scaleThreshold","getPalette","DEFAULT_PALETTE","NULL_COLOR","assert","getAttrValue","colorBins","attr","domain","colors","nullColor","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":"AAAA,SAAQA,cAAR,QAA6B,UAA7B;AACA,OAAOC,UAAP,IAAoBC,eAApB,EAAqCC,UAArC,QAAsD,WAAtD;AACA,SAAQC,MAAR,EAAgBC,YAAhB,QAAmC,SAAnC;AAEA,eAAe,SAASC,SAAT,CAAmB;AAChCC,EAAAA,IADgC;AAEhCC,EAAAA,MAFgC;AAGhCC,EAAAA,MAAM,GAAGP,eAHuB;AAIhCQ,EAAAA,SAAS,GAAGP;AAJoB,CAAnB,EAKZ;AACDC,EAAAA,MAAM,CAACO,KAAK,CAACC,OAAN,CAAcJ,MAAd,CAAD,EAAwB,6CAAxB,CAAN;AAEA,QAAMK,OAAO,GAAG,OAAOJ,MAAP,KAAkB,QAAlB,GAA6BR,UAAU,CAACQ,MAAD,EAASD,MAAM,CAACM,MAAhB,CAAvC,GAAiEL,MAAjF;AAEA,QAAMM,KAAK,GAAGf,cAAc,GAAGQ,MAAjB,CAAwBA,MAAxB,EAAgCQ,KAAhC,CAAsCH,OAAtC,CAAd;AAEA,SAAOI,CAAC,IAAI;AACV,UAAMC,KAAK,GAAGb,YAAY,CAACE,IAAD,EAAOU,CAAP,CAA1B;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCR,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleThreshold} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorBins({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n const color = scaleThreshold().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-bins-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-bins-style.js"],"names":["scaleThreshold","getPalette","DEFAULT_PALETTE","NULL_COLOR","assert","getAttrValue","colorBins","attr","domain","colors","nullColor","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":"AAAA,SAAQA,cAAR,QAA6B,UAA7B;AACA,OAAOC,UAAP,IAAoBC,eAApB,EAAqCC,UAArC,QAAsD,WAAtD;AACA,SAAQC,MAAR,EAAgBC,YAAhB,QAAmC,SAAnC;AAEA,eAAe,SAASC,SAAT,CAAmB;AAChCC,EAAAA,IADgC;AAEhCC,EAAAA,MAFgC;AAGhCC,EAAAA,MAAM,GAAGP,eAHuB;AAIhCQ,EAAAA,SAAS,GAAGP;AAJoB,CAAnB,EAKZ;AACDC,EAAAA,MAAM,CAACO,KAAK,CAACC,OAAN,CAAcJ,MAAd,CAAD,EAAwB,6CAAxB,CAAN;AAEA,QAAMK,OAAO,GAAG,OAAOJ,MAAP,KAAkB,QAAlB,GAA6BR,UAAU,CAACQ,MAAD,EAASD,MAAM,CAACM,MAAP,GAAgB,CAAzB,CAAvC,GAAqEL,MAArF;AAEA,QAAMM,KAAK,GAAGf,cAAc,GAAGQ,MAAjB,CAAwBA,MAAxB,EAAgCQ,KAAhC,CAAsCH,OAAtC,CAAd;AAEA,SAAOI,CAAC,IAAI;AACV,UAAMC,KAAK,GAAGb,YAAY,CAACE,IAAD,EAAOU,CAAP,CAA1B;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCR,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleThreshold} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorBins({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length + 1) : colors;\n\n const color = scaleThreshold().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-bins-style.js"}
@@ -8,7 +8,7 @@ export default function colorContinuous({
8
8
  nullColor = NULL_COLOR
9
9
  }) {
10
10
  assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
11
- const palette = typeof colors === 'string' ? getPalette(colors) : colors;
11
+ const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;
12
12
  const color = scaleLinear().domain(domain).range(palette);
13
13
  return d => {
14
14
  const value = getAttrValue(attr, d);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-continuous-style.js"],"names":["scaleLinear","getPalette","DEFAULT_PALETTE","NULL_COLOR","assert","getAttrValue","colorContinuous","attr","domain","colors","nullColor","Array","isArray","palette","color","range","d","value","Number","isFinite"],"mappings":"AAAA,SAAQA,WAAR,QAA0B,UAA1B;AACA,OAAOC,UAAP,IAAoBC,eAApB,EAAqCC,UAArC,QAAsD,WAAtD;AACA,SAAQC,MAAR,EAAgBC,YAAhB,QAAmC,SAAnC;AAEA,eAAe,SAASC,eAAT,CAAyB;AACtCC,EAAAA,IADsC;AAEtCC,EAAAA,MAFsC;AAGtCC,EAAAA,MAAM,GAAGP,eAH6B;AAItCQ,EAAAA,SAAS,GAAGP;AAJ0B,CAAzB,EAKZ;AACDC,EAAAA,MAAM,CAACO,KAAK,CAACC,OAAN,CAAcJ,MAAd,CAAD,EAAwB,6CAAxB,CAAN;AAEA,QAAMK,OAAO,GAAG,OAAOJ,MAAP,KAAkB,QAAlB,GAA6BR,UAAU,CAACQ,MAAD,CAAvC,GAAkDA,MAAlE;AACA,QAAMK,KAAK,GAAGd,WAAW,GAAGQ,MAAd,CAAqBA,MAArB,EAA6BO,KAA7B,CAAmCF,OAAnC,CAAd;AAEA,SAAOG,CAAC,IAAI;AACV,UAAMC,KAAK,GAAGZ,YAAY,CAACE,IAAD,EAAOS,CAAP,CAA1B;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCP,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors) : colors;\n const color = scaleLinear().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-continuous-style.js"],"names":["scaleLinear","getPalette","DEFAULT_PALETTE","NULL_COLOR","assert","getAttrValue","colorContinuous","attr","domain","colors","nullColor","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":"AAAA,SAAQA,WAAR,QAA0B,UAA1B;AACA,OAAOC,UAAP,IAAoBC,eAApB,EAAqCC,UAArC,QAAsD,WAAtD;AACA,SAAQC,MAAR,EAAgBC,YAAhB,QAAmC,SAAnC;AAEA,eAAe,SAASC,eAAT,CAAyB;AACtCC,EAAAA,IADsC;AAEtCC,EAAAA,MAFsC;AAGtCC,EAAAA,MAAM,GAAGP,eAH6B;AAItCQ,EAAAA,SAAS,GAAGP;AAJ0B,CAAzB,EAKZ;AACDC,EAAAA,MAAM,CAACO,KAAK,CAACC,OAAN,CAAcJ,MAAd,CAAD,EAAwB,6CAAxB,CAAN;AAEA,QAAMK,OAAO,GAAG,OAAOJ,MAAP,KAAkB,QAAlB,GAA6BR,UAAU,CAACQ,MAAD,EAASD,MAAM,CAACM,MAAhB,CAAvC,GAAiEL,MAAjF;AACA,QAAMM,KAAK,GAAGf,WAAW,GAAGQ,MAAd,CAAqBA,MAArB,EAA6BQ,KAA7B,CAAmCH,OAAnC,CAAd;AAEA,SAAOI,CAAC,IAAI;AACV,UAAMC,KAAK,GAAGb,YAAY,CAACE,IAAD,EAAOU,CAAP,CAA1B;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCR,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n const color = scaleLinear().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}