UNPKG

@actinc/dls

Version:

Design Language System (DLS) for ACT & Encoura front-end projects.

94 lines 3.11 kB
/** * Copyright (c) ACT, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import { range } from 'd3-array'; import { scaleQuantile } from 'd3-scale'; export var defaultData = [ { CONVERSION_QUANTITY: 0, QUANTITY: 80, STATE_CODE: 'TN', STATE_NAME: 'Tennessee', }, { CONVERSION_QUANTITY: 0, QUANTITY: 130, STATE_CODE: 'MD', STATE_NAME: 'Maryland', }, { CONVERSION_QUANTITY: 0, QUANTITY: 185, STATE_CODE: 'KY', STATE_NAME: 'Kentucky', }, { CONVERSION_QUANTITY: 0, QUANTITY: 200, STATE_CODE: 'AL', STATE_NAME: 'Alabama', }, { CONVERSION_QUANTITY: 0, QUANTITY: 30, STATE_CODE: 'SC', STATE_NAME: 'South Carolina', }, { CONVERSION_QUANTITY: 0, QUANTITY: 800, STATE_CODE: 'FL', STATE_NAME: 'Florida', }, { CONVERSION_QUANTITY: 0, QUANTITY: 500, STATE_CODE: 'TX', STATE_NAME: 'Texas', }, ]; export var defaultProcessDataFn = function (featureCollection, data) { var features = featureCollection.features; var scale = scaleQuantile() .domain(data.map(function (item) { return item.QUANTITY; })) .range(range(10)); var mappedFeatures = data.reduce(function (acc, _a) { var QUANTITY = _a.QUANTITY, STATE_NAME = _a.STATE_NAME, STATE_CODE = _a.STATE_CODE; acc[STATE_NAME] = { quantity: QUANTITY, stateCode: STATE_CODE, }; return acc; }, {}); return { features: features.map(function (f) { var _a, _b, _c; if (((_a = f.properties) === null || _a === void 0 ? void 0 : _a.name) && mappedFeatures[f.properties.name]) { var quantity = ((_b = f.properties) === null || _b === void 0 ? void 0 : _b.name) && mappedFeatures[f.properties.name] ? scale(mappedFeatures[f.properties.name].quantity) : 0; var properties = __assign(__assign({}, f.properties), { quantity: quantity, stateCode: mappedFeatures[f.properties.name].stateCode, value: ((_c = f.properties) === null || _c === void 0 ? void 0 : _c.name) && mappedFeatures[f.properties.name] ? mappedFeatures[f.properties.name].quantity : 0 }); return __assign(__assign({}, f), { properties: properties }); } return __assign({}, f); }), type: 'FeatureCollection', }; }; //# sourceMappingURL=mocks.js.map